/*
///////////////////////////////////////////////////////////////////////////////////////////////////
// Description : LightDia.cpp
//
// Dialog edition the spots
//
///////////////////////////////////////////////////////////////////////////////////////////////////
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
// Creation date: 11 feb 1997                        Author: J Thénoz
///////////////////////////////////////////////////////////////////////////////////////////////////
// Modification date:			                      Author:
//
//
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
*/

#include "stdafx.h"
#include "acp_base.h"
#include "resource.h"
#include "itf.h"
#include "LightDia.hpp"
#include "LightObj.hpp"
#include "Inter.hpp"
#include "x:\cpa\main\inc\_EditId.h"
#include "tut.h"
//ROMTEAM color lights Ionut Grozea 10-08-1998
#include "ogd.h"
//ENDROMTEAM color lights Ionut Grozea 10-08-1998

//CHINA WFQ (MT) 16/02/98 {
#define LIMIT 1000
//ENDCHINA WFQ }
//ROMTEAM Color edition Ionut Grozea 1-08-1998
#define C_szLightIniFile "Light\\Light.ini"
//ENDROMTEAM Color edition Ionut Grozea 1-08-1998
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// MACROS

#define M_Enable( nID, bShow )              GetDlgItem ( (nID) ) -> EnableWindow( bShow )
#define M_Show( nID, iShow )                GetDlgItem ( (nID) ) -> ShowWindow( iShow )
#define M_ShowAndEnable( nID, bShow )\
{\
    M_Show( nID, (bShow) ? SW_SHOW : SW_HIDE );\
    M_Enable( nID, bShow );\
}

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE ( DiaLight, CFormView );

/////////////////////////////////////////////////////////////////////////////
// DiaLight dialog


DiaLight::DiaLight(CWnd* pParent /*=NULL*/)
	: CFormView(DiaLight::IDD)

{
	m_poLight=NULL;
	m_bUpdate=TRUE;

	m_bNearHasFocus=FALSE;
	m_bFarHasFocus=FALSE;
	m_bNameEditHasFocus=FALSE;
	m_bIntensityEditHasFocus=FALSE;
	m_bREditHasFocus=FALSE;
	m_bGEditHasFocus=FALSE;
	m_bBEditHasFocus=FALSE;
	m_bAEditHasFocus=FALSE;
//CHINA WFQ (MT) 16/02/98 {
    m_bMaxXHasFocus = FALSE;
	m_bMaxYHasFocus = FALSE;
	m_bMaxZHasFocus = FALSE;
	m_bMinXHasFocus = FALSE;
	m_bMinYHasFocus = FALSE;
	m_bMinZHasFocus = FALSE;
//ENDCHINA WFQ }

//ANNECY jt {
	BOOL	m_bFogNearHasFocus = FALSE;
	BOOL	m_bFogFarHasFocus = FALSE;
	BOOL	m_bFogInfiniteHasFocus = FALSE;
	BOOL	m_bFogBlendNearHasFocus = FALSE;
	BOOL	m_bFogBlendFarHasFocus = FALSE;
//ENDANNECY jt }
}

//ROMTEAM scroll job Ionut Grozea 1-08-1998
WNDPROC oldproc1 ;
BOOL CALLBACK DialogProc1(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if(uMsg == WM_KEYDOWN)
	{
		if(wParam == VK_DOWN) wParam = VK_UP;
		else if(wParam == VK_UP) wParam = VK_DOWN;
	}
	return CallWindowProc(oldproc1, hwnd, uMsg, wParam, lParam);
} 
//ROMTEAM scroll job Ionut Grozea 1-08-1998

void DiaLight::fn_vInitDialog ( Light_Interface* pInterface )
{
	m_pInterface = pInterface;


//ROMTEAM  Ionut Grozea 1-08-1998
	if (!pInterface->fn_bGetRealLight())
//ROMTEAM  Ionut Grozea 1-08-1998
	{
		GetDlgItem(IDC_BUTTON_REAL_LIGHT)->SetWindowText("Display only real Lights");
	}
	else
	{
		GetDlgItem(IDC_BUTTON_REAL_LIGHT)->SetWindowText("Display all Lights");
	}


	UpdateData (FALSE);
	m_oRSlider.SetOwner( this );

	m_oRSlider.SetRange( -100, 100, TRUE );
	m_oGSlider.SetRange( -100, 100, TRUE );
	m_oBSlider.SetRange( -100, 100, TRUE );
	m_oASlider.SetRange( -100, 100, TRUE );
	m_oNearSlider.SetRange ( 0, 1000, TRUE );
	m_oFarSlider.SetRange ( 0, 1000, TRUE );
	m_oIntensitySlider.SetRange ( 1, 10000, TRUE );
	m_fRValue=0.f;
	m_fGValue=0.f;
	m_fBValue=0.f;
	m_fAValue=0.f;
	m_oRSlider.SetPos( 0 );
	m_oGSlider.SetPos( 0 );
	m_oBSlider.SetPos( 0 );
	m_oASlider.SetPos( 0 );

	m_oTabControl.DeleteAllItems ();

	m_fNearValue = 0.f;
	m_fFarValue = 0.f;
	m_fIntensity = 0.f;

	m_bNearFarTab	 = FALSE;	// 1 Tab with Near/Far
	m_bAlphaTab		 = FALSE;	// 2 tabs with Near/Far & Alpha
	m_bInterExtraTab = FALSE;	// 3 tabs with Intern & Extern & Intensity

	UpdateData (FALSE);

	// enable the dialog
    // common controls
    fn_vDisplayCommonControls( FALSE );

    // near/far
    fn_vDisplayNearFarControls( FALSE );

    // tab
    M_ShowAndEnable (IDC_LIGHT_TAB, FALSE);

    // fog
	fn_vDisplayFogControl (FALSE);

    // icon
    fn_vDisplayCommonIcons( SW_HIDE );

	// Buttons
	((CButton *) GetDlgItem(IDC_LIGHT_OFF_RADIO))->SetIcon(LoadIcon(m_pInterface->GetDLLIdentity()->hModule, MAKEINTRESOURCE(IDI_BUTTON_ACTOROFF)));
	((CButton *) GetDlgItem(IDC_LIGHT_ON_RADIO))->SetIcon(LoadIcon(m_pInterface->GetDLLIdentity()->hModule, MAKEINTRESOURCE(IDI_BUTTON_ACTORON)));

    // Parallel Box controls
    fn_vDisplayInternalExternalControls( FALSE );

//ROMTEAM scroll job Ionut Grozea 1-08-1998
 	 oldproc1 = (WNDPROC)SetWindowLong(GetDlgItem(IDC_LIGHT_R_SLIDER)->m_hWnd, GWL_WNDPROC, (long)DialogProc1);
 	 oldproc1 = (WNDPROC)SetWindowLong(GetDlgItem(IDC_LIGHT_B_SLIDER)->m_hWnd, GWL_WNDPROC, (long)DialogProc1);
 	 oldproc1 = (WNDPROC)SetWindowLong(GetDlgItem(IDC_LIGHT_FAR_SLIDER)->m_hWnd, GWL_WNDPROC, (long)DialogProc1);
 	 oldproc1 = (WNDPROC)SetWindowLong(GetDlgItem(IDC_LIGHT_NEAR_SLIDER)->m_hWnd, GWL_WNDPROC, (long)DialogProc1);
 	 oldproc1 = (WNDPROC)SetWindowLong(GetDlgItem(IDC_LIGHT_G_SLIDER)->m_hWnd, GWL_WNDPROC, (long)DialogProc1);
 	 oldproc1 = (WNDPROC)SetWindowLong(GetDlgItem(IDC_LIGHT_INTENSITY_SLIDER)->m_hWnd, GWL_WNDPROC, (long)DialogProc1);
 	 oldproc1 = (WNDPROC)SetWindowLong(GetDlgItem(IDC_LIGHT_A_SLIDER)->m_hWnd, GWL_WNDPROC, (long)DialogProc1);
//ENDROMTEAM scroll job Ionut Grozea 1-08-1998





}


// to edit a new light
void DiaLight::fn_vEdit (Light* poLight)
{
	if( m_poLight )
	{
		if( !poLight )
		{
			fn_vDisplayCommonControls( FALSE );
			fn_vDisplayCommonIcons( SW_HIDE );
			fn_vDisplayNearFarControls( FALSE );
			fn_vDisplayInternalExternalControls( FALSE );
			fn_vDisplayFogControl( FALSE );
		}
		else if( m_poLight->GetSuperObject()->GetModelName() != poLight->GetSuperObject()->GetModelName() )
		{
			fn_vDisplayCommonIcons( SW_HIDE );
			fn_vDisplayNearFarControls( FALSE );
			fn_vDisplayInternalExternalControls( FALSE );
			fn_vDisplayFogControl( FALSE );
		}
	}
	else if( poLight )
	{
		fn_vDisplayCommonControls( TRUE );
		fn_vDisplayCommonIcons( SW_HIDE );
		fn_vDisplayNearFarControls( FALSE );
		fn_vDisplayInternalExternalControls( FALSE );
		fn_vDisplayFogControl( FALSE );
	}

	m_poLight = poLight;

	if ( poLight && poLight->GetSuperObject() )
	{
		GetParent()->SetWindowText ( m_poLight->GetSuperObject()->GetModelName() );
		fn_vInitEditName ();
		fn_vGetColor ();
		fn_vInitOnOff ();
		fn_vInitTabControl ();
        fn_vSwapLightTab();
        fn_vRefreshDialog ();
//ROMTEAM BlendRLI (Ionut Grozea 24/02/98)
		fn_vInitType();
//ENDROMTEAM BlendRLI (Ionut Grozea)

		// display status icon
		fn_vDisplayIcon ();
	}
	else
	{
		GetParent()->SetWindowText ( "No light to edit" );
		m_poLight=NULL;
		m_csEditName="";
	}
	GetParent()->GetParent()->RedrawWindow (NULL, NULL, RDW_INVALIDATE|RDW_FRAME);
}

void DiaLight::fn_vRefreshSectorList (void)
{
	if (!m_poLight)
		return;

	// sectors of the light
	CPA_List<CPA_SuperObject>* poSectorList = m_poLight->fn_pGetSectorList();

	m_poLight->GetInterface()->fn_vAddModifSectorList ( poSectorList );

	// empty Clist
	m_SectorList.ResetContent();

	if (!m_oDisplayAllControl.GetCheck())
	{
		POSITION xPos;
		CPA_SuperObject* poSector;
		for ( poSector=poSectorList->GetHeadElement(xPos); poSector; poSector=poSectorList->GetNextElement(xPos) )
			m_SectorList.AddString ( poSector->GetObject()->GetName() );

	}
	else
	{
		POSITION xPos;
		CPA_SuperObject* poSector;
		CPA_BaseObject* poBaseObject;

		CPA_BaseObjectList* poList = m_poLight->GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szSectorTypeName);
		Position xBaseObjectPos;


		// set all the sectors in the list
		for ( poBaseObject=poList->GetHeadElement(xBaseObjectPos); xBaseObjectPos; poBaseObject=poList->GetNextElement(xBaseObjectPos) )
		{
			m_SectorList.AddString ( poBaseObject->GetName() );
		}

		for ( poSector=poSectorList->GetHeadElement(xPos); poSector; poSector=poSectorList->GetNextElement(xPos) )
		{
			int iPos = m_SectorList.FindStringExact( 0, poSector->GetObject()->GetName() );
			if (iPos>=0) m_SectorList.SetSel( iPos );
		}
	}

	// color the sectors
	if (m_oSee.GetCheck()) m_poLight->fn_vPaintSector ();
}


void DiaLight::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(DiaLight)
	DDX_Control(pDX, IDC_MIN_Z, m_cMin_Z);
	DDX_Control(pDX, IDC_MIN_Y, m_cMin_Y);
	DDX_Control(pDX, IDC_MIN_X, m_cMin_X);
	DDX_Control(pDX, IDC_MAX_Z, m_cMax_Z);
	DDX_Control(pDX, IDC_MAX_Y, m_cMax_Y);
	DDX_Control(pDX, IDC_MAX_X, m_cMax_X);
    DDX_Control(pDX, IDC_LIGHT_A_SLIDER, m_oASlider);
	DDX_Control(pDX, IDC_LIGHT_INTENSITY_SLIDER, m_oIntensitySlider);
	DDX_Control(pDX, IDC_NEAR_STATIC, m_oNearStatic);
	DDX_Control(pDX, IDC_FAR_STATIC, m_oFarStatic);
	DDX_Control(pDX, IDC_LIGHT_TAB, m_oTabControl);
	DDX_Control(pDX, IDC_LIGHT_FAR_SLIDER, m_oFarSlider);
	DDX_Control(pDX, IDC_LIGHT_NEAR_SLIDER, m_oNearSlider);
	DDX_Control(pDX, IDC_LIGHT_SEE, m_oSee);
	DDX_Control(pDX, IDC_LIGHT_DISPLAY_ALL, m_oDisplayAllControl);
	DDX_Control(pDX, IDC_LIGHT_SECTOR_LIST, m_SectorList);
	DDX_Control(pDX, IDC_LIGHT_B_SLIDER, m_oBSlider);
	DDX_Control(pDX, IDC_LIGHT_R_SLIDER, m_oRSlider);
	DDX_Control(pDX, IDC_LIGHT_G_SLIDER, m_oGSlider);
	DDX_Text(pDX, IDC_LIGHT_B_EDIT, m_fBValue);
	DDX_Text(pDX, IDC_LIGHT_G_EDIT, m_fGValue);
	DDX_Text(pDX, IDC_LIGHT_R_EDIT, m_fRValue);
	DDX_Text(pDX, IDC_LIGHT_NAME_EDIT, m_csEditName);
	DDV_MaxChars(pDX, m_csEditName, 100);
	DDX_Text(pDX, IDC_LIGHT_FAR_EDIT, m_fFarValue);
	DDX_Text(pDX, IDC_LIGHT_NEAR_EDIT, m_fNearValue);
	DDX_Text(pDX, IDC_LIGHT_INTENSITY_EDIT, m_fIntensity);
	DDX_Text(pDX, IDC_LIGHT_A_EDIT, m_fAValue);
	DDX_Text(pDX, IDC_MAX_X_EDIT, m_Max_X);
	DDX_Text(pDX, IDC_MAX_Z_EDIT, m_Max_Z);
	DDX_Text(pDX, IDC_MAX_Y_EDIT, m_Max_Y);
	DDX_Text(pDX, IDC_MIN_X_EDIT, m_Min_X);
	DDX_Text(pDX, IDC_MIN_Y_EDIT, m_Min_Y);
	DDX_Text(pDX, IDC_MIN_Z_EDIT, m_Min_Z);
	DDX_Text(pDX, IDC_FOG_BLEND_FAR_EDIT, m_fFogBlendFar);
	DDX_Text(pDX, IDC_FOG_BLEND_NEAR_EDIT, m_fFogBlendNear);
	DDX_Text(pDX, IDC_FOG_FAR_EDIT, m_fFogFar);
	DDX_Text(pDX, IDC_FOG_INFINITE_EDIT, m_fFogInfinite);
	DDX_Text(pDX, IDC_FOG_NEAR_EDIT, m_fFogNear);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(DiaLight, CFormView)
	//{{AFX_MSG_MAP(DiaLight)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_DRAWITEM()
	ON_WM_QUERYDRAGICON()
	ON_EN_KILLFOCUS(IDC_LIGHT_B_EDIT, OnKillfocusLightBEdit)
	ON_EN_KILLFOCUS(IDC_LIGHT_G_EDIT, OnKillfocusLightGEdit)
	ON_EN_KILLFOCUS(IDC_LIGHT_R_EDIT, OnKillfocusLightREdit)
	ON_WM_HSCROLL()
	ON_BN_CLICKED(IDC_LIGHT_COLOR_DEFINITION, OnLightColorDefinition)
	ON_BN_CLICKED(IDC_LIGHT_AMBIENT_BUTTON, OnLightAmbientButton)
	ON_BN_CLICKED(IDC_LIGHT_DISPLAY_ALL, OnLightDisplayAll)
	ON_BN_CLICKED(IDC_LIGHT_AFFECT_ALL, OnLightAffectAll)
	ON_LBN_SELCHANGE(IDC_LIGHT_SECTOR_LIST, OnSelchangeLightSectorList)
	ON_BN_CLICKED(IDC_LIGHT_SEE, OnLightSEE)
	ON_BN_CLICKED(IDC_LIGHT_DEFAULT, OnLightDefault)
	ON_EN_KILLFOCUS(IDC_LIGHT_NAME_EDIT, OnKillfocusLightNameEdit)
	ON_EN_KILLFOCUS(IDC_LIGHT_FAR_EDIT, OnKillfocusLightFarEdit)
	ON_EN_KILLFOCUS(IDC_LIGHT_NEAR_EDIT, OnKillfocusLightNearEdit)
	ON_EN_SETFOCUS(IDC_LIGHT_FAR_EDIT, OnSetfocusLightFarEdit)
	ON_EN_SETFOCUS(IDC_LIGHT_NEAR_EDIT, OnSetfocusLightNearEdit)
	ON_NOTIFY(TCN_SELCHANGE, IDC_LIGHT_TAB, OnSelchangeLightTab)
	ON_EN_SETFOCUS(IDC_LIGHT_NAME_EDIT, OnSetfocusLightNameEdit)
	ON_BN_CLICKED(IDC_LIGHT_ON_RADIO, OnLightOnRadio)
	ON_BN_CLICKED(IDC_LIGHT_OFF_RADIO, OnLightOffRadio)
	ON_EN_KILLFOCUS(IDC_LIGHT_INTENSITY_EDIT, OnKillfocusLightIntensityEdit)
	ON_EN_SETFOCUS(IDC_LIGHT_INTENSITY_EDIT, OnSetfocusLightIntensityEdit)
	ON_EN_KILLFOCUS(IDC_LIGHT_A_EDIT, OnKillfocusLightAEdit)
	ON_BN_CLICKED(IDC_LIGHT_ACTIVE_OFF_RADIO, OnLightActiveOffRadio)
	ON_BN_CLICKED(IDC_LIGHT_ACTIVE_ON_RADIO, OnLightActiveOnRadio)
	ON_EN_SETFOCUS(IDC_LIGHT_A_EDIT, OnSetfocusLightAEdit)
	ON_EN_SETFOCUS(IDC_LIGHT_B_EDIT, OnSetfocusLightBEdit)
	ON_EN_SETFOCUS(IDC_LIGHT_G_EDIT, OnSetfocusLightGEdit)
	ON_EN_SETFOCUS(IDC_LIGHT_R_EDIT, OnSetfocusLightREdit)
	ON_BN_CLICKED(IDC_MAP_OFF_RADIO, OnMapOffRadio)
	ON_BN_CLICKED(IDC_MAP_ON_RADIO, OnMapOnRadio)
	ON_EN_SETFOCUS(IDC_MAX_X_EDIT, OnSetfocusMaxXEdit)
	ON_EN_SETFOCUS(IDC_MAX_Y_EDIT, OnSetfocusMaxYEdit)
	ON_EN_SETFOCUS(IDC_MAX_Z_EDIT, OnSetfocusMaxZEdit)
	ON_EN_SETFOCUS(IDC_MIN_X_EDIT, OnSetfocusMinXEdit)
	ON_EN_SETFOCUS(IDC_MIN_Y_EDIT, OnSetfocusMinYEdit)
	ON_EN_SETFOCUS(IDC_MIN_Z_EDIT, OnSetfocusMinZEdit)
	ON_EN_KILLFOCUS(IDC_MIN_Z_EDIT, OnKillfocusMinZEdit)
	ON_EN_KILLFOCUS(IDC_MIN_Y_EDIT, OnKillfocusMinYEdit)
	ON_EN_KILLFOCUS(IDC_MIN_X_EDIT, OnKillfocusMinXEdit)
	ON_EN_KILLFOCUS(IDC_MAX_Z_EDIT, OnKillfocusMaxZEdit)
	ON_EN_KILLFOCUS(IDC_MAX_Y_EDIT, OnKillfocusMaxYEdit)
	ON_EN_KILLFOCUS(IDC_MAX_X_EDIT, OnKillfocusMaxXEdit)
	ON_BN_CLICKED(IDC_BUTTON_NORMAL, OnButtonNormal)
	ON_BN_CLICKED(IDC_BUTTON_PAINT, OnButtonPaint)
	ON_BN_CLICKED(IDC_BUTTON_BACK, OnButtonBack)
	ON_BN_CLICKED(IDC_BUTTON_REAL_LIGHT, OnButtonRealLight)
	ON_EN_KILLFOCUS(IDC_FOG_BLEND_FAR_EDIT, OnKillfocusBlendFarEdit)
	ON_EN_SETFOCUS(IDC_FOG_BLEND_FAR_EDIT, OnSetfocusBlendFarEdit)
	ON_EN_KILLFOCUS(IDC_FOG_BLEND_NEAR_EDIT, OnKillfocusBlendNearEdit)
	ON_EN_SETFOCUS(IDC_FOG_BLEND_NEAR_EDIT, OnSetfocusBlendNearEdit)
	ON_EN_KILLFOCUS(IDC_FOG_FAR_EDIT, OnKillfocusFarEdit)
	ON_EN_SETFOCUS(IDC_FOG_FAR_EDIT, OnSetfocusFarEdit)
	ON_EN_KILLFOCUS(IDC_FOG_INFINITE_EDIT, OnKillfocusInfiniteEdit)
	ON_EN_SETFOCUS(IDC_FOG_INFINITE_EDIT, OnSetfocusInfiniteEdit)
	ON_EN_KILLFOCUS(IDC_FOG_NEAR_EDIT, OnKillfocusNearEdit)
	ON_EN_SETFOCUS(IDC_FOG_NEAR_EDIT, OnSetfocusNearEdit)
	ON_BN_CLICKED(IDC_BUTTON_COMPUTE_ALL, OnButtonComputeAll)
    ON_WM_DESTROY()
//ROMTEAM color lights Ionut Grozea 10-08-1998
	ON_BN_CLICKED(IDC_BUTTON_MODE, OnButtonMode)
//ENDROMTEAM color lights Ionut Grozea 10-08-1998

	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// DiaLight message handlers

/////////////////////////////////////////////////////////////////////////////
// DiaNetWP message handlers


void DiaLight::fn_vRefreshDialog (void)
{
	fn_vRefreshSectorList ();
	UpdateData (FALSE);
}


void DiaLight::OnSysCommand(UINT nID, LPARAM lParam)
{
		CFormView::OnSysCommand(nID, lParam);
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void DiaLight::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CFormView::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR DiaLight::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}



//--------------------------------------------------------------------------
// Management color edit/slider
//--------------------------------------------------------------------------
void DiaLight::fn_vInitSlider (void)
{
	m_oRSlider.SetPos((int)(m_fRValue*100.f));
	m_oGSlider.SetPos((int)(m_fGValue*100.f));
	m_oBSlider.SetPos((int)(m_fBValue*100.f));
	m_oASlider.SetPos((int)(m_fAValue*100.f));
	m_oIntensitySlider.SetPos((int)(m_poLight->fn_fGetIntensity()*100.f));
}

BOOL DiaLight::OnCommand(WPARAM wParam, LPARAM lParam)
{
	m_pInterface->fn_vClearStatus();
	if (wParam==1)
	{
		if (m_bNearHasFocus)
		{
			OnKillfocusLightNearEdit();
			m_bNearHasFocus=TRUE;
		}
		else if (m_bFarHasFocus)
		{
			OnKillfocusLightFarEdit();
			m_bFarHasFocus=TRUE;
		}
		else if (m_bNameEditHasFocus)
		{
			OnKillfocusLightNameEdit();
			m_bNameEditHasFocus=TRUE;
		}
		else if (m_bIntensityEditHasFocus)
		{
			OnKillfocusLightIntensityEdit();
			m_bIntensityEditHasFocus=TRUE;
		}
		else if(m_bREditHasFocus)
		{
			OnKillfocusLightREdit();
			m_bREditHasFocus=TRUE;
		}
		else if (m_bGEditHasFocus)
		{
			OnKillfocusLightGEdit();
			m_bGEditHasFocus=TRUE;
		}
		else if (m_bBEditHasFocus)
		{
			OnKillfocusLightBEdit();
			m_bBEditHasFocus=TRUE;
		}
		else if (m_bAEditHasFocus)
		{
			OnKillfocusLightAEdit();
			m_bAEditHasFocus=TRUE;
		}
//CHINA WFQ (MT) 16/02/98 {
		else if (m_bMaxXHasFocus==TRUE)
		{
			OnKillfocusMaxXEdit();
			//m_bMaxXHasFocus=TRUE;
		}
		else if (m_bMaxYHasFocus==TRUE)
		{
			OnKillfocusMaxYEdit();
			//m_bMaxYHasFocus=TRUE;
		}
		else if (m_bMaxZHasFocus==TRUE)
		{
			OnKillfocusMaxZEdit();
			//m_bMaxZHasFocus=TRUE;
		}
		else if (m_bMinXHasFocus==TRUE)
		{
			OnKillfocusMinXEdit();
			//m_bMinXHasFocus=TRUE;
		}
		else if (m_bMinYHasFocus==TRUE)
		{
			OnKillfocusMinYEdit();
			//m_bMinYHasFocus=TRUE;
		}
		else if (m_bMinZHasFocus==TRUE)
		{
			OnKillfocusMinZEdit();
			//m_bMinZHasFocus=TRUE;
		}
//ENDCHINA WFQ }

//ANNECY jt {
		else if (m_bFogNearHasFocus)
		{
			OnKillfocusNearEdit();
			m_bFogNearHasFocus=TRUE;
		}
		else if (m_bFogFarHasFocus)
		{
			OnKillfocusFarEdit();
			m_bFogFarHasFocus=TRUE;
		}
		else if (m_bFogInfiniteHasFocus)
		{
			OnKillfocusInfiniteEdit();
			m_bFogInfiniteHasFocus=TRUE;
		}
		else if (m_bFogBlendNearHasFocus)
		{
			OnKillfocusBlendNearEdit();
			m_bFogBlendNearHasFocus=TRUE;
		}
		else if (m_bFogBlendFarHasFocus)
		{
			OnKillfocusBlendFarEdit();
			m_bFogBlendFarHasFocus=TRUE;
		}
//ENDANNECY jt }

		return TRUE;
	}

	return CFormView::OnCommand(wParam, lParam);
}


void DiaLight::OnSetfocusLightAEdit()
{
	m_bAEditHasFocus=TRUE;
}

void DiaLight::OnSetfocusLightBEdit()
{
	m_bBEditHasFocus=TRUE;
}

void DiaLight::OnSetfocusLightGEdit()
{
	m_bGEditHasFocus=TRUE;
}

void DiaLight::OnSetfocusLightREdit()
{
	m_bREditHasFocus=TRUE;
}

void DiaLight::OnKillfocusLightBEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;
	
	UpdateData (TRUE);
	m_fBValue = (float) min ( m_fBValue, 1. );
	m_fBValue = (float) max ( m_fBValue, -1. );
	m_oBSlider.SetPos((int)(m_fBValue*100));
	fn_vSetColor ();
	m_bBEditHasFocus=FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusLightGEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	m_fGValue = (float) min ( m_fGValue, 1. );
	m_fGValue = (float) max ( m_fGValue, -1. );
	m_oGSlider.SetPos((int)(m_fGValue*100));
	fn_vSetColor ();
	m_bGEditHasFocus=FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusLightREdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	m_fRValue = (float) min ( m_fRValue, 1. );
	m_fRValue = (float) max ( m_fRValue, -1. );
	m_oRSlider.SetPos((int)(m_fRValue*100));
	fn_vSetColor ();
	m_bREditHasFocus=FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusLightAEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	m_fAValue = (float) min ( m_fAValue, 10.f );
	m_fAValue = (float) max ( m_fAValue, -10.f );
	m_oASlider.SetPos((int)(m_fAValue*100));
	fn_vSetColor ();
	m_bAEditHasFocus=FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusLightIntensityEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	m_fIntensity = (float) max ( m_fIntensity, 0.01f );
	m_fIntensity = (float) min ( m_fIntensity, 100.f );
	m_oIntensitySlider.SetPos ((int)(m_fIntensity*100));
	fn_vSetIntensity ();
	m_bIntensityEditHasFocus=FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	// security for mouse swap 
	if (ShowCursor(TRUE) <= 0)
	{
		ShowCursor(FALSE);
		return;
	}

	if (pScrollBar==(void*)&m_oIntensitySlider)
	{
		m_fIntensity = (float)m_oIntensitySlider.GetPos()/100.f;
		fn_vSetIntensity ();
		UpdateData (FALSE);
	}
	else if (pScrollBar==(void*)&m_oRSlider)
	{
		m_fRValue = ((float)m_oRSlider.GetPos()/100.f);
		fn_vSetColor ();
		UpdateData (FALSE);
	}
	else if (pScrollBar==(void*)&m_oGSlider)
	{
		m_fGValue = ((float)m_oGSlider.GetPos()/100.f);
		fn_vSetColor ();
		UpdateData (FALSE);
	}
	else if (pScrollBar==(void*)&m_oBSlider)
	{
		m_fBValue = ((float)m_oBSlider.GetPos()/100.f);
		fn_vSetColor ();
		UpdateData (FALSE);
	}
	else if (pScrollBar==(void*)&m_oASlider)
	{
		m_fAValue = ((float)m_oASlider.GetPos()/100.f);
		fn_vSetColor ();
		UpdateData (FALSE);
	}
	else if (pScrollBar==(void*)&m_oNearSlider)
	{
		UpdateData (TRUE);
		m_fNearValue = fn_iSlider2Value ( m_oNearSlider.GetPos() );
		if (m_fNearValue>m_fFarValue)
		{
			m_fFarValue = m_fNearValue;
			m_oFarSlider.SetPos(m_oNearSlider.GetPos());
		}
		fn_vSetNearFar ();
		UpdateData (FALSE);
	}
	else if (pScrollBar==(void*)&m_oFarSlider)
	{
		UpdateData (TRUE);
		m_fFarValue = fn_iSlider2Value ( m_oFarSlider.GetPos() );
		if (m_fFarValue<m_fNearValue)
		{
			m_fNearValue = m_fFarValue;
			m_oNearSlider.SetPos(m_oFarSlider.GetPos());
		}
		fn_vSetNearFar ();
		UpdateData (FALSE);
	}

	CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
}


void DiaLight::fn_vSetColor (void)
{
	if (!m_poLight)
		return;

	m_poLight->fn_vSetColor ( m_fRValue*m_fIntensity, m_fGValue*m_fIntensity, m_fBValue*m_fIntensity, m_fAValue );
//ROMTEAM color lights Ionut Grozea 10-08-1998
	if(!m_poLight->GetInterface()->fn_bGetColorMode())
		m_poLight->SetMultiColor();
//ROMTEAM color lights Ionut Grozea 10-08-1998

	// update control colors
	GetDlgItem(IDC_LIGHT_COLOR_DEFINITION)->Invalidate();
}

void DiaLight::fn_vGetColor (void)
{
	if (!m_poLight)
		return;

	m_poLight->fn_vGetColor ( &m_fRValue, &m_fGValue, &m_fBValue, &m_fAValue );
	m_fIntensity = m_poLight->fn_fGetIntensity ();

	if (m_fIntensity)
	{
		m_fRValue /= m_fIntensity;
		m_fGValue /= m_fIntensity;
		m_fBValue /= m_fIntensity;
	}
	fn_vInitSlider ();
}

void DiaLight::fn_vSetIntensity (void)
{
	if (!m_poLight) return;
	m_poLight->fn_vSetLightIntensity ( m_fIntensity );
}


void DiaLight::OnLightColorDefinition()
{
	UpdateData (TRUE);
//ROMTEAM Color edition Ionut Grozea 1-08-1998
	DiaColor oColor(this);
//ROMTEAM Color edition Ionut Grozea 1-08-1998
	oColor.m_cc.rgbResult = RGB ( max(m_fRValue,0.f)*255., max(m_fGValue,0.f)*255., max(m_fBValue,0.f)*255. );
	oColor.m_cc.Flags |= CC_RGBINIT;
	oColor.RestoreDefaultColor();
	if (oColor.DoModal()==IDOK)
	{
		COLORREF clr =  oColor.GetColor();
		m_fRValue = (float)(GetRValue (clr)/255.);
		m_fGValue = (float)(GetGValue (clr)/255.);
		m_fBValue = (float)(GetBValue (clr)/255.);
		fn_vInitSlider ();
		fn_vSetColor ();
		UpdateData (FALSE);
	}
}


void DiaLight::fn_vSetOnOff (Light* poLight)
{
	if (!m_poLight)
		return;

	if (m_poLight==poLight) fn_vInitOnOff ();
}

void DiaLight::fn_vClicSector (CPA_BaseObject* poSector)
{
	// set dialog list
	if (m_oDisplayAllControl.GetCheck())
	{	// select all mode
		int iSectorIndex = m_SectorList.FindStringExact( 0, poSector->GetName() );
		m_SectorList.SetSel ( iSectorIndex, !m_SectorList.GetSel(iSectorIndex) );
		OnSelchangeLightSectorList();
	}
	else
	{	// select sector mode
		int iSectorIndex = m_SectorList.FindStringExact( 0, poSector->GetName() );
		if (iSectorIndex>=0) m_SectorList.DeleteString (iSectorIndex);
		else m_SectorList.AddString ( poSector->GetName() );

		// set list of light
		fn_vChangeSectorList ();
	}

}


//--------------------------------------------------------------------------
// On/Off radios
//--------------------------------------------------------------------------
void DiaLight::fn_vInitOnOff (void)
{
	if (!m_poLight)
		return;

	CheckRadioButton( IDC_LIGHT_ON_RADIO, IDC_LIGHT_OFF_RADIO, m_poLight->fn_bGetOnOff () ? IDC_LIGHT_ON_RADIO : IDC_LIGHT_OFF_RADIO );
	CheckRadioButton( IDC_LIGHT_ACTIVE_ON_RADIO, IDC_LIGHT_ACTIVE_OFF_RADIO, m_poLight->fn_bIsLightOn () ? IDC_LIGHT_ACTIVE_ON_RADIO : IDC_LIGHT_ACTIVE_OFF_RADIO );
	CheckRadioButton( IDC_MAP_ON_RADIO, IDC_MAP_OFF_RADIO, m_poLight->fn_bGetOnDecor () ? IDC_MAP_ON_RADIO : IDC_MAP_OFF_RADIO );
}

void DiaLight::OnLightOnRadio()
{
	m_poLight->fn_vSetOnOff (TRUE);
}

void DiaLight::OnLightOffRadio()
{
	m_poLight->fn_vSetOnOff (FALSE);
}


void DiaLight::OnLightAmbientButton()
{
	fn_vEdit (NULL);
}

void DiaLight::fn_vInitEditName (void)
{
	if (!m_poLight)
		return;

	m_csEditName = m_poLight->GetName();
}

void DiaLight::OnLightActiveOffRadio()
{
	m_poLight->GetInterface()->fn_vSwitchOnLight ( m_poLight, FALSE );
}

void DiaLight::OnLightActiveOnRadio()
{
	m_poLight->GetInterface()->fn_vSwitchOnLight ( m_poLight, TRUE );
}

void DiaLight::OnMapOffRadio()
{
	m_poLight->fn_vSetOnDecor (FALSE);
	m_poLight->fn_vNotifySave();
}

void DiaLight::OnMapOnRadio()
{
	m_poLight->fn_vSetOnDecor (TRUE);
	m_poLight->fn_vNotifySave();
}


//--------------------------------------------------------------------------
// Near/Far slider
//--------------------------------------------------------------------------
void DiaLight::OnKillfocusLightFarEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
//	m_fFarValue = max ( m_fNearValue, m_fFarValue );
	if (m_fNearValue > m_fFarValue)
	{
		m_fNearValue = m_fFarValue;
		m_oNearSlider.SetPos ( fn_lValue2Slider (m_fNearValue) );
	}
	m_oFarSlider.SetPos ( fn_lValue2Slider (m_fFarValue) );
	fn_vCheckLimit ();
	fn_vSetNearFar ();
	UpdateData (FALSE);
	m_bFarHasFocus=FALSE;
}

void DiaLight::OnKillfocusLightNearEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
//	m_fNearValue = min ( m_fNearValue, m_fFarValue );
	if (m_fFarValue < m_fNearValue)
	{
		m_fFarValue = m_fNearValue;
		m_oFarSlider.SetPos ( fn_lValue2Slider (m_fFarValue) );
	}
	m_oNearSlider.SetPos ( fn_lValue2Slider (m_fNearValue) );
	fn_vCheckLimit ();
	fn_vSetNearFar ();
	UpdateData (FALSE);
	m_bNearHasFocus=FALSE;
}


float DiaLight::fn_iSlider2Value ( int iSlider )
{
	int iIndex = m_oTabControl.GetCurSel();

	switch( iIndex )
	{
	case 0:
		ASSERT(m_bNearFarTab || m_bAlphaTab);
		return (float)(int)((exp((float)iSlider/180.f)-1.f)*1000.f+0.5)/1000.f;
	case 1:
		ASSERT(m_bAlphaTab);
		return ((float)iSlider*178.f)/1000.f + 1.f;
	default:
		return 0.0f;
	}
	/*
	if (m_bNearFarTab) return (float)(int)((exp((float)iSlider/180.f)-1.f)*1000.f+0.5)/1000.f;
	return ((float)iSlider*178.f)/1000.f + 1.f;
	*/
}


int DiaLight::fn_lValue2Slider ( float fValue )
{
	int iIndex = m_oTabControl.GetCurSel();

	switch( iIndex )
	{
	case 0:
		ASSERT(m_bNearFarTab || m_bAlphaTab);
		return (int)(180.f*(log(fValue+1.f))+0.5);
	case 1:
		ASSERT(m_bAlphaTab);
		return (int)((fValue-1.f)*1000.f/178.f+0.5);
	default:
		return 0;
	}
	/*
	if (m_bNearFarTab) return (int)(180.f*(log(fValue+1.f))+0.5);
	return (int)((fValue-1.f)*1000.f/178.f+0.5);
	*/
}

void DiaLight::fn_vCheckLimit (void)
{
	int iIndex = m_oTabControl.GetCurSel();

	switch( iIndex )
	{
	case 0:
		ASSERT(m_bNearFarTab || m_bAlphaTab);
		m_fNearValue = max ( m_fNearValue, 0. );
		break;
	case 1:
		ASSERT(m_bAlphaTab);
		m_fFarValue = min ( m_fFarValue, 179. );
		break;
	}
	/*
	if (m_bNearFarTab)
	{
		m_fNearValue = max ( m_fNearValue, 0. );
	}
	else
	{
		m_fNearValue = max ( m_fNearValue, 1. );
		m_fFarValue = min ( m_fFarValue, 179. );
	}
	*/
}


void DiaLight::fn_vSetNearFar (void)
{
	if (!m_poLight)
		return;

	int iIndex = m_oTabControl.GetCurSel();
	MTH_tdxReal xNear, xFar;
	MTH_tdxReal xLittleAlpha, xBigAlpha;

	switch( iIndex )
	{
	case 0:
		ASSERT( m_bNearFarTab || m_bAlphaTab );
		xNear = (MTH_tdxReal) m_fNearValue;
		xFar = (MTH_tdxReal) m_fFarValue;
		m_poLight->fn_vSetLightNearFar ( xNear, xFar );
		m_poLight->fn_vDrawEditObject();
		break;
	case 1:
		ASSERT( m_bAlphaTab );
		xLittleAlpha = (MTH_tdxReal)m_fNearValue * MTH_C_Pi / 180.f;
		xBigAlpha = (MTH_tdxReal)m_fFarValue * MTH_C_Pi / 180.f;
		m_poLight->fn_vSetLightAlpha ( xLittleAlpha, xBigAlpha );
		m_poLight->fn_vDrawEditObject();
		break;
	}
	/*
	if (m_bNearFarTab)
	{
		ASSERT( iIndex == 0 );
	}
	else if( m_bAlphaTab )
	{
		MTH_tdxReal xLittleAlpha, xBigAlpha;
		xLittleAlpha = (MTH_tdxReal)m_fNearValue * MTH_C_Pi / 180.f;
		xBigAlpha = (MTH_tdxReal)m_fFarValue * MTH_C_Pi / 180.f;
		m_poLight->fn_vSetLightAlpha ( xLittleAlpha, xBigAlpha );
		m_poLight->fn_vDrawEditObject();
	}
	*/
}

//CHINA WFQ (MT) 16/02/98 {
void DiaLight::fn_vInitNearFarValue (void)
{
	if (!m_poLight)
		return;

	GLI_tdxHandleToLight hLight = (GLI_tdxHandleToLight) m_poLight->GetEngineStruct ();

	MTH_tdxReal xNear, xFar;
	GLI_vGetLightNearFar ( hLight , &xNear, &xFar ) ;
	m_fFarValue = xFar;
	m_fNearValue = xNear;
	m_oNearStatic.SetWindowText ("Near");
	m_oFarStatic.SetWindowText ("Far");

	m_oFarSlider.SetPos		( fn_lValue2Slider(m_fFarValue) );
	m_oNearSlider.SetPos	( fn_lValue2Slider(m_fNearValue) );
	UpdateData (FALSE);
}

void DiaLight::fn_vInitAlphaValue (void)
{
	if (!m_poLight)
		return;

	GLI_tdxHandleToLight hLight = (GLI_tdxHandleToLight) m_poLight->GetEngineStruct ();

	MTH_tdxReal xLittleAlpha, xBigAlpha;
	GLI_vGetLightAlphas ( hLight, &xLittleAlpha, &xBigAlpha);
	m_fNearValue = xLittleAlpha * 180.f / MTH_C_Pi;
	m_fFarValue = xBigAlpha * 180.f / MTH_C_Pi;
	m_oNearStatic.SetWindowText ("Little");
	m_oFarStatic.SetWindowText ("Big");

	m_oFarSlider.SetPos		( fn_lValue2Slider(m_fFarValue) );
	m_oNearSlider.SetPos	( fn_lValue2Slider(m_fNearValue) );
	UpdateData (FALSE);
}

void DiaLight::fn_vInitInternalValue(void)
{
	if(!m_poLight)
		return;

    fn_vDisplayInternalExternalControls( TRUE );

	GLI_tdxHandleToLight hLight = (GLI_tdxHandleToLight) m_poLight->GetEngineStruct ();

	MTH3D_tdstVector xInter_Min_Pos, xInter_Max_Pos;
	GLI_vGetLight_Inter_Min_Pos (hLight, &xInter_Min_Pos);
	GLI_vGetLight_Inter_Max_Pos (hLight, &xInter_Max_Pos);

	m_Get_Min_x = m_Min_X = xInter_Min_Pos.xX;
	m_Get_Min_y = m_Min_Y = xInter_Min_Pos.xY;
	m_Get_Min_z = m_Min_Z = xInter_Min_Pos.xZ;
	m_Get_Max_x = m_Max_X = xInter_Max_Pos.xX;
	m_Get_Max_y = m_Max_Y = xInter_Max_Pos.xY;
	m_Get_Max_z = m_Max_Z = xInter_Max_Pos.xZ;

	m_cMin_X.SetWindowText ("min_x");
	m_cMin_Y.SetWindowText ("min_y");
	m_cMin_Z.SetWindowText ("min_z");
	m_cMax_X.SetWindowText ("max_x");
	m_cMax_Y.SetWindowText ("max_y");
	m_cMax_Z.SetWindowText ("max_z");

	UpdateData (FALSE);


}

void DiaLight::fn_vInitExternalValue(void)
{
	if(!m_poLight)
		return;

    fn_vDisplayInternalExternalControls( TRUE );

	GLI_tdxHandleToLight hLight = (GLI_tdxHandleToLight) m_poLight->GetEngineStruct ();

	MTH3D_tdstVector xExter_Min_Pos, xExter_Max_Pos;
	GLI_vGetLight_Exter_Min_Pos (hLight, &xExter_Min_Pos);
	GLI_vGetLight_Exter_Max_Pos (hLight, &xExter_Max_Pos);

	m_Get_Min_X = m_Min_X = xExter_Min_Pos.xX;
	m_Get_Min_Y = m_Min_Y = xExter_Min_Pos.xY;
	m_Get_Min_Z = m_Min_Z = xExter_Min_Pos.xZ;
	m_Get_Max_X = m_Max_X = xExter_Max_Pos.xX;
	m_Get_Max_Y = m_Max_Y = xExter_Max_Pos.xY;
	m_Get_Max_Z = m_Max_Z = xExter_Max_Pos.xZ;

	m_cMin_X.SetWindowText ("min_X");
	m_cMin_Y.SetWindowText ("min_Y");
	m_cMin_Z.SetWindowText ("min_Z");
	m_cMax_X.SetWindowText ("max_X");
	m_cMax_Y.SetWindowText ("max_Y");
	m_cMax_Z.SetWindowText ("max_Z");

	UpdateData (FALSE);
}

void DiaLight::fn_vInitIntensityValue(void)
{
	if(!m_poLight)
		return;

    fn_vDisplayInternalExternalControls( FALSE );
    // uses Y controls to Intensity edition
    M_ShowAndEnable(IDC_MIN_Y, TRUE);
    M_ShowAndEnable(IDC_MIN_Y_EDIT, TRUE);
    M_ShowAndEnable(IDC_MAX_Y, TRUE);
    M_ShowAndEnable(IDC_MAX_Y_EDIT, TRUE);

	GLI_tdxHandleToLight hLight = (GLI_tdxHandleToLight) m_poLight->GetEngineStruct ();

	MTH_tdxReal xMin_I;
	MTH_tdxReal xMax_I;

	GLI_vGetLight_Intensity_Min_Max ( hLight , &xMin_I, &xMax_I ) ;

	m_Get_Min_I = m_Min_Y = xMin_I;
	m_Get_Max_I = m_Max_Y = xMax_I;

	m_cMin_Y.SetWindowText ("min_I");
	m_cMax_Y.SetWindowText ("max_I");

	UpdateData (FALSE);
}

//ENDCHINA WFQ }


//ANNECY jt {
void DiaLight::fn_vInitFogValue (void)
{
	if(!m_poLight) return;
	GLI_tdxHandleToLight hLight = (GLI_tdxHandleToLight) m_poLight->GetEngineStruct ();

	MTH_tdxReal xMaxI;

	GLI_vGetLightNearFar ( hLight , &m_fFogNear, &m_fFogFar ) ;
	GLI_vGetLightAlphas ( hLight, &m_fFogInfinite, &m_fFogBlendNear);
	GLI_vGetLight_Intensity_Min_Max ( hLight , &m_fFogBlendFar, &xMaxI ) ;

	UpdateData (FALSE);
}
//ENDANNECY jt }


//--------------------------------------------------------------------------
// Tab Control
//--------------------------------------------------------------------------
void DiaLight::fn_vInitTabControl (void)
{
	if (!m_poLight)
		return;

	if( (m_poLight->GetSuperObject()->GetModelName() == csAmbientModelName) || 
		(m_poLight->GetSuperObject()->GetModelName() == csParallelModelName) )
	{
		M_ShowAndEnable( IDC_LIGHT_TAB, FALSE );
		m_oTabControl.DeleteAllItems ();
		m_bNearFarTab	 = FALSE;
		m_bAlphaTab		 = FALSE;
		m_bInterExtraTab = FALSE;
	}
	else if(( m_poLight->GetSuperObject()->GetModelName() == csSphericalModelName ) ||
			( m_poLight->GetSuperObject()->GetModelName() == csZModelName ))	
	{
		M_ShowAndEnable( IDC_LIGHT_TAB, TRUE );
		fn_vDisplayNearFarControls( TRUE );
		// update TAB
		if(m_bNearFarTab == FALSE)
		{			
			TC_ITEM stTabCtrlItemNearFar;
			m_oTabControl.DeleteAllItems ();
			stTabCtrlItemNearFar.mask = TCIF_TEXT;
			stTabCtrlItemNearFar.pszText = "Near/Far";
			m_oTabControl.InsertItem( 0, &stTabCtrlItemNearFar);
			m_oTabControl.SetCurSel ( 0 );
			m_bNearFarTab	 = TRUE;
			m_bAlphaTab		 = FALSE;
			m_bInterExtraTab = FALSE;
		}
	}
	else if( m_poLight->GetSuperObject()->GetModelName() == csSpotModelName )
	{
		M_ShowAndEnable( IDC_LIGHT_TAB, TRUE );
		fn_vDisplayNearFarControls( TRUE );
		// update TAB
		if(m_bAlphaTab == FALSE)
		{
			TC_ITEM stTabCtrlItemNearFar;
			TC_ITEM stTabCtrlItemAlpha;

			m_oTabControl.DeleteAllItems ();

			stTabCtrlItemNearFar.mask = TCIF_TEXT;
			stTabCtrlItemAlpha  .mask = TCIF_TEXT;

			stTabCtrlItemNearFar.pszText = "Near/Far";
			stTabCtrlItemAlpha  .pszText = "Alpha";

			m_oTabControl.InsertItem( 0, &stTabCtrlItemNearFar);
			m_oTabControl.InsertItem( 1, &stTabCtrlItemAlpha );
			m_oTabControl.SetCurSel ( 0 );

			m_bNearFarTab	 = FALSE;
			m_bAlphaTab		 = TRUE;
			m_bInterExtraTab = FALSE;
		}
	}
	else if( m_poLight->GetSuperObject()->GetModelName() == csParallelBoxModelName )
	{
		M_ShowAndEnable( IDC_LIGHT_TAB, TRUE );
		fn_vDisplayInternalExternalControls( TRUE );
		// update TAB
		if(m_bInterExtraTab == FALSE)
		{
			TC_ITEM stTabCtrlItemInter;
			TC_ITEM stTabCtrlItemExtra;
			TC_ITEM stTabCtrlItemIntensity;

			m_oTabControl.DeleteAllItems ();

			stTabCtrlItemInter.		mask = TCIF_TEXT;
			stTabCtrlItemExtra.		mask = TCIF_TEXT;
			stTabCtrlItemIntensity.	mask = TCIF_TEXT;

			stTabCtrlItemInter.		pszText = "In_vol";
			stTabCtrlItemExtra.		pszText = "Ex_vol";
			stTabCtrlItemIntensity.	pszText = "Inten_val";

			m_oTabControl.InsertItem( 0, &stTabCtrlItemInter);
			m_oTabControl.InsertItem( 1, &stTabCtrlItemExtra);
			m_oTabControl.InsertItem( 2, &stTabCtrlItemIntensity);

			m_oTabControl. SetCurSel( 0 );

			m_bNearFarTab		= FALSE;
			m_bAlphaTab			= FALSE;
			m_bInterExtraTab	= TRUE;
		}
	}
	else if( m_poLight->GetSuperObject()->GetModelName() == csFogModelName )
	{
		M_ShowAndEnable( IDC_LIGHT_TAB, FALSE );
		fn_vDisplayFogControl (TRUE);
		fn_vInitFogValue ();

		m_oTabControl.DeleteAllItems ();
		m_bNearFarTab	 = FALSE;
		m_bAlphaTab		 = FALSE;
		m_bInterExtraTab = FALSE;
	}
}

//CHINA WFQ (MT) 16/02/98 {
void DiaLight::OnSelchangeLightTab(NMHDR* pNMHDR, LRESULT* pResult)
{
	if (pNMHDR->idFrom==IDC_LIGHT_TAB)
	{
        fn_vSwapLightTab();
    }
	*pResult = 0;
}
//ENDCHINA WFQ }

static int iOldIndex = 0;
void DiaLight::fn_vSwapLightTab()
{
    int iIndex = m_oTabControl.GetCurSel();

	switch( iIndex )
	{
	case 0:
		if( m_bNearFarTab || m_bAlphaTab )
		{
			fn_vInitNearFarValue ();
		}
		else if( m_bInterExtraTab )
		{
			if (iOldIndex != iIndex)
			{
				m_oTabControl.SetCurSel(iOldIndex);
				if (m_bMaxXHasFocus==TRUE)
				{
					OnKillfocusMaxXEdit();
				}
				else if (m_bMaxYHasFocus==TRUE)
				{
					OnKillfocusMaxYEdit();
				}
				else if (m_bMaxZHasFocus==TRUE)
				{
					OnKillfocusMaxZEdit();
				}
				else if (m_bMinXHasFocus==TRUE)
				{
					OnKillfocusMinXEdit();
				}
				else if (m_bMinYHasFocus==TRUE)
				{
					OnKillfocusMinYEdit();
				}
				else if (m_bMinZHasFocus==TRUE)
				{
					OnKillfocusMinZEdit();
				}
				m_oTabControl.SetCurSel(iIndex);
			}
			fn_vInitInternalValue();
		}
        break;
	case 1:
		if( m_bAlphaTab )
		{
			fn_vInitAlphaValue ();
		}
		else if( m_bInterExtraTab )
		{
			if (iOldIndex != iIndex)
			{
				m_oTabControl.SetCurSel(iOldIndex);
				if (m_bMaxXHasFocus==TRUE)
				{
					OnKillfocusMaxXEdit();
				}
				else if (m_bMaxYHasFocus==TRUE)
				{
					OnKillfocusMaxYEdit();
				}
				else if (m_bMaxZHasFocus==TRUE)
				{
					OnKillfocusMaxZEdit();
				}
				else if (m_bMinXHasFocus==TRUE)
				{
					OnKillfocusMinXEdit();
				}
				else if (m_bMinYHasFocus==TRUE)
				{
					OnKillfocusMinYEdit();
				}
				else if (m_bMinZHasFocus==TRUE)
				{
					OnKillfocusMinZEdit();
				}
				m_oTabControl.SetCurSel(iIndex);
			}
			fn_vInitExternalValue();
		}
		break;
	case 2:
		if( m_bInterExtraTab )
		{
			if (iOldIndex != iIndex)
			{
				m_oTabControl.SetCurSel(iOldIndex);
				if (m_bMaxXHasFocus==TRUE)
				{
					OnKillfocusMaxXEdit();
				}
				else if (m_bMaxYHasFocus==TRUE)
				{
					OnKillfocusMaxYEdit();
				}
				else if (m_bMaxZHasFocus==TRUE)
				{
					OnKillfocusMaxZEdit();
				}
				else if (m_bMinXHasFocus==TRUE)
				{
					OnKillfocusMinXEdit();
				}
				else if (m_bMinYHasFocus==TRUE)
				{
					OnKillfocusMinYEdit();
				}
				else if (m_bMinZHasFocus==TRUE)
				{
					OnKillfocusMinZEdit();
				}
				m_oTabControl.SetCurSel(iIndex);
			}
			fn_vInitIntensityValue();
		}
		break;
	}
	iOldIndex =  iIndex;

}

//--------------------------------------------------------------------------
// Sectors management
//--------------------------------------------------------------------------
void DiaLight::OnLightDisplayAll()
{
	fn_vRefreshSectorList();
}

void DiaLight::OnLightAffectAll()
{
	if (!m_poLight)
		return;

	CPA_List<CPA_SuperObject>* poSectorList = m_poLight->fn_pGetSectorList();

	poSectorList->RemoveAll ();

	POSITION xSuperObjectPos;
	CPA_SuperObject* poSuperObject;
	CPA_List<CPA_SuperObject>* poList = m_poLight->GetInterface()->GetInterface()->GetObjectListByType	(C_szSectorTypeName);

	// set all the sectors in the list
	for ( poSuperObject=poList->GetHeadElement(xSuperObjectPos); xSuperObjectPos; poSuperObject=poList->GetNextElement(xSuperObjectPos) )
		m_poLight->fn_vAddSector (poSuperObject);
	m_poLight->GetInterface()->fn_vRefreshLight(m_poLight);
	m_poLight->fn_vNotifySave ();
	fn_vRefreshSectorList();
}


void DiaLight::OnSelchangeLightSectorList()
{
	if (!m_poLight)
		return;

	if (!m_oDisplayAllControl.GetCheck())
	{
		 m_SectorList.SelItemRange( FALSE, 0, m_SectorList.GetCount() );
		 return;
	}


	CPA_List<CPA_SuperObject>* poSectorList = m_poLight->fn_pGetSectorList();
	poSectorList->RemoveAll ();

	POSITION xSuperObjectPos;
	CPA_SuperObject* poSuperObject;
	CPA_List<CPA_SuperObject>* poList = m_poLight->GetInterface()->GetInterface()->GetObjectListByType	(C_szSectorTypeName);

	m_poLight->GetInterface()->fn_vAddModifSectorList ( poList );


	// set all the sectors in the list
	for ( poSuperObject=poList->GetHeadElement(xSuperObjectPos); xSuperObjectPos; poSuperObject=poList->GetNextElement(xSuperObjectPos) )
	{
		int iSectorPos = m_SectorList.FindStringExact ( 0, poSuperObject->GetObject()->GetName() );

		if (m_SectorList.GetSel(iSectorPos))
			if (!m_poLight->fn_vAddSector (poSuperObject))
				m_SectorList.SetSel ( iSectorPos, FALSE );

	}
	m_poLight->GetInterface()->fn_vRefreshLight(m_poLight);
	m_poLight->fn_vNotifySave ();

	// color the sectors
	if (m_oSee.GetCheck()) m_poLight->fn_vPaintSector ();

}

void DiaLight::fn_vChangeSectorList (void)
{
	if (!m_poLight)
		return;

	CPA_List<CPA_SuperObject>* poSectorList = m_poLight->fn_pGetSectorList();
	poSectorList->RemoveAll ();
	POSITION xSuperObjectPos;
	CPA_SuperObject* poSuperObject;
	CPA_List<CPA_SuperObject>* poList = m_poLight->GetInterface()->GetInterface()->GetObjectListByType	(C_szSectorTypeName);

	// set all the sectors in the list
	for ( poSuperObject=poList->GetHeadElement(xSuperObjectPos); xSuperObjectPos; poSuperObject=poList->GetNextElement(xSuperObjectPos) )
	{
		int iSectorPos = m_SectorList.FindStringExact ( 0, poSuperObject->GetObject()->GetName() );
		if (iSectorPos>=0) m_poLight->fn_vAddSector (poSuperObject);
	}

	m_poLight->GetInterface()->fn_vRefreshLight(m_poLight);
	m_poLight->fn_vNotifySave ();

	// color the sectors
	if (m_oSee.GetCheck()) m_poLight->fn_vPaintSector ();
}


void DiaLight::OnLightSEE()
{
	if (!m_poLight)
		return;

	m_poLight->fn_vPaintSector ( m_oSee.GetCheck() );
}

void DiaLight::OnLightDefault()
{
	if (!m_poLight)
		return;

	m_poLight->fn_vComputeSector ();
	m_pInterface->fn_vRefreshLight(m_poLight);
	fn_vRefreshSectorList();
}

void DiaLight::OnKillfocusLightNameEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	if (!m_poLight)
		return;

	CString pOldName = m_csEditName;
	UpdateData (TRUE);
	if (pOldName == m_csEditName) return;

	if (m_poLight->fn_eRename (m_csEditName)!=E_mc_None)
	{
		m_pInterface->fn_vGiveProgressInfo (m_csEditName+CString( " is already used."), -1);
		m_csEditName=pOldName;
		UpdateData (FALSE);
	}
	else
	{
		m_poLight->GetInterface()->fn_vRefreshHierarchyList ();
	}
	m_bNameEditHasFocus=FALSE;
}


void DiaLight::OnSetfocusLightFarEdit()
{
	m_bFarHasFocus=TRUE;
}

void DiaLight::OnSetfocusLightNearEdit()
{
	m_bNearHasFocus=TRUE;
}


void DiaLight::OnLightRealRadio()
{
	m_pInterface->fn_vSetRLIDrawMask (FALSE);
}

void DiaLight::OnLightRliRadio()
{
	m_pInterface->fn_vSetRLIDrawMask (TRUE);
}

void DiaLight::OnSetfocusLightNameEdit()
{
	m_bNameEditHasFocus=TRUE;
}


void DiaLight::OnSetfocusLightIntensityEdit()
{
	m_bIntensityEditHasFocus=TRUE;
}

//--------------------------------------------------------------------------
// Dialog icons
//--------------------------------------------------------------------------
void DiaLight::fn_vDisplayIcon (void)
{
    // hide all icons
    //fn_vDisplayCommonIcons( SW_HIDE );

    // show real icons
	if (!m_poLight->fn_bIs3DsMaxLight())
	{
		switch (m_poLight->fn_lGetType())
		{
        case GLI_C_lSphericalLight:
            M_Show (IDC_SPHERICAL_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lHotSpotLight :
            M_Show (IDC_SPOT_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lParallelLight :
            M_Show (IDC_PARALLEL_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lAmbientLight :
            M_Show (IDC_AMBIENT_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lParallelLight_With_Limit:
            M_Show (IDC_PARABOX_LIGHT_PICTURE,  SW_SHOW );
            break;
//ROMTEAM Z_Light Ionut Grozea 01-05-1998
/*
		case GLI_C_lZ_Light:
            M_Show (IDC_Z_LIGHT1,  SW_SHOW );
			break;
*/
//ENDROMTEAM Z_Light Ionut Grozea 01-05-1998
        case GLI_C_lFogLight :
            M_Show (IDC_FOG_PICTURE,  SW_SHOW );
            break;
		}
	}
	else
	{
		switch (m_poLight->fn_lGetType())
		{
        case GLI_C_lParallelLight_With_Limit:
            M_Show (IDC_PARABOX_IMPORT_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lSphericalLight:
            M_Show (IDC_SPHERICAL_IMPORT_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lHotSpotLight :
            M_Show (IDC_SPOT_IMPORT_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lParallelLight :
            M_Show (IDC_PARALLEL_IMPORT_LIGHT_PICTURE,  SW_SHOW );
            break;
        case GLI_C_lAmbientLight :
            M_Show (IDC_AMBIENT_IMPORT_LIGHT_PICTURE,  SW_SHOW );
            break;
		}
	}
}



BOOL DiaLight::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
	BOOL bCreate = CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
	TUT_M_vGetTutDll ();
    TUT_M_vRegisterControl   (m_hWnd ,                  "OLG_LightWindow",      TUT_e_Window);
    TUT_M_vRegisterControlID (IDC_LIGHT_R_SLIDER,       "OLG_RedSlider",        TUT_e_Slider);
    TUT_M_vRegisterControlID (IDC_LIGHT_G_SLIDER,       "OLG_GreenSlider",      TUT_e_Slider);
    TUT_M_vRegisterControlID (IDC_LIGHT_B_SLIDER,       "OLG_BlueSlider",       TUT_e_Slider);
    TUT_M_vRegisterControlID (IDC_LIGHT_A_SLIDER,       "OLG_AlphaSlider",      TUT_e_Slider);
    TUT_M_vRegisterControlID (IDC_LIGHT_R_EDIT,         "OLG_RedEdit",          TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_LIGHT_G_EDIT,         "OLG_GreenEdit",        TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_LIGHT_B_EDIT,         "OLG_BlueEdit",         TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_LIGHT_A_EDIT,         "OLG_AlphaEdit",        TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_LIGHT_ON_RADIO,       "OLG_LightOn",          TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_OFF_RADIO,      "OLG_LightOff",         TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_ACTIVE_ON_RADIO,"OLG_ActiveOn",         TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_ACTIVE_OFF_RADIO,"OLG_ActiveOff",       TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_MAP_ON_RADIO,         "OLG_MapOn",            TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_MAP_OFF_RADIO,        "OLG_MapOff",           TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_COLOR_DEFINITION,"OLG_ColorDefine",     TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_AFFECT_ALL,     "OLG_AllSectors",       TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_DEFAULT,        "OLG_DefaultSectors",   TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_SEE,            "OLG_See",              TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_DISPLAY_ALL,    "OLG_DisplayAll",       TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_LIGHT_SECTOR_LIST,    "OLG_SectorList",       TUT_e_ListBox);
    TUT_M_vRegisterControlID (IDC_LIGHT_NAME_EDIT,      "OLG_NameEdit",         TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_LIGHT_NEAR_SLIDER,    "OLG_NearSlider",       TUT_e_Slider);
    TUT_M_vRegisterControlID (IDC_LIGHT_FAR_SLIDER,     "OLG_FarSlider",        TUT_e_Slider);
    TUT_M_vRegisterControlID (IDC_LIGHT_NEAR_EDIT,      "OLG_NearEdit",         TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_LIGHT_FAR_EDIT,       "OLG_FarEdit",          TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_LIGHT_TAB,            "OLG_LightTab",         TUT_e_Window);        // <-  Onglet
    TUT_M_vRegisterControlID (IDC_LIGHT_INTENSITY_SLIDER,"OLG_IntensitySlider", TUT_e_Slider);
    TUT_M_vRegisterControlID (IDC_LIGHT_INTENSITY_EDIT, "OLG_IntensityEdit",    TUT_e_TextEdit);
//ROMTEAM BlendRLI (Ionut Grozea 24/02/98)
    TUT_M_vRegisterControlID (IDC_BUTTON_NORMAL,        "OLG_TypeNormal",       TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_BUTTON_PAINT,         "OLG_TypePaint",        TUT_e_Button);
    TUT_M_vRegisterControlID (IDC_BUTTON_BACK,          "OLG_TypeBack",        TUT_e_Button);
//ROMTEAM Ionut Grozea (Compute all 19.05.98)
    TUT_M_vRegisterControlID (IDC_BUTTON_COMPUTE_ALL,   "OLG_TypeComputeAll",        TUT_e_Button);
//ENDROMTEAM Ionut Grozea (Compute all 19.05.98)
//ENDROMTEAM BlendRLI (Ionut Grozea)
    TUT_M_vRegisterControlID (IDC_MIN_X_EDIT,           "OLG_ParaBox_MinX",     TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_MIN_Y_EDIT,           "OLG_ParaBox_MinY",     TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_MIN_Z_EDIT,           "OLG_ParaBox_MinZ",     TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_MAX_X_EDIT,           "OLG_ParaBox_MaxX",     TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_MAX_Y_EDIT,           "OLG_ParaBox_MaxY",     TUT_e_TextEdit);
    TUT_M_vRegisterControlID (IDC_MAX_Z_EDIT,           "OLG_ParaBox_MaxZ",     TUT_e_TextEdit);
	TUT_M_vRegisterControlID (IDC_BUTTON_REAL_LIGHT,	"OLG_DisplayRealOrAll",	TUT_e_Button);
	return bCreate;
}

void DiaLight::OnDestroy()
{
	CFormView::OnDestroy();
	TUT_M_vGetTutDll ();
	TUT_M_vUnregisterControl (m_hWnd);
	TUT_M_vUnregisterControlID (IDC_LIGHT_R_SLIDER);
	TUT_M_vUnregisterControlID (IDC_LIGHT_G_SLIDER);
	TUT_M_vUnregisterControlID (IDC_LIGHT_B_SLIDER);
	TUT_M_vUnregisterControlID (IDC_LIGHT_A_SLIDER);
	TUT_M_vUnregisterControlID (IDC_LIGHT_R_EDIT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_G_EDIT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_B_EDIT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_A_EDIT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_ON_RADIO);
	TUT_M_vUnregisterControlID (IDC_LIGHT_OFF_RADIO);
	TUT_M_vUnregisterControlID (IDC_LIGHT_ACTIVE_ON_RADIO);
	TUT_M_vUnregisterControlID (IDC_LIGHT_ACTIVE_OFF_RADIO);
    TUT_M_vUnregisterControlID (IDC_MAP_ON_RADIO);
    TUT_M_vUnregisterControlID (IDC_MAP_OFF_RADIO);
	TUT_M_vUnregisterControlID (IDC_LIGHT_COLOR_DEFINITION);
	TUT_M_vUnregisterControlID (IDC_LIGHT_AFFECT_ALL);
	TUT_M_vUnregisterControlID (IDC_LIGHT_DEFAULT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_SEE);
	TUT_M_vUnregisterControlID (IDC_LIGHT_DISPLAY_ALL);
	TUT_M_vUnregisterControlID (IDC_LIGHT_SECTOR_LIST);
	TUT_M_vUnregisterControlID (IDC_LIGHT_NAME_EDIT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_NEAR_SLIDER);
	TUT_M_vUnregisterControlID (IDC_LIGHT_FAR_SLIDER);
	TUT_M_vUnregisterControlID (IDC_LIGHT_NEAR_EDIT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_FAR_EDIT);
	TUT_M_vUnregisterControlID (IDC_LIGHT_TAB);
	TUT_M_vUnregisterControlID (IDC_LIGHT_INTENSITY_SLIDER);
	TUT_M_vUnregisterControlID (IDC_LIGHT_INTENSITY_EDIT);
//ROMTEAM BlendRLI (Ionut Grozea 24/02/98)
	TUT_M_vUnregisterControlID (IDC_BUTTON_NORMAL);
	TUT_M_vUnregisterControlID (IDC_BUTTON_PAINT);
	TUT_M_vUnregisterControlID (IDC_BUTTON_BACK);
//ROMTEAM Ionut Grozea (Compute all 19.05.98)
	TUT_M_vUnregisterControlID (IDC_BUTTON_COMPUTE_ALL);
//ENDROMTEAM Ionut Grozea (Compute all 19.05.98)
//ENDROMTEAM BlendRLI (Ionut Grozea)
	TUT_M_vUnregisterControlID (IDC_MIN_X_EDIT);
	TUT_M_vUnregisterControlID (IDC_MIN_Y_EDIT);
	TUT_M_vUnregisterControlID (IDC_MIN_Z_EDIT);
	TUT_M_vUnregisterControlID (IDC_MAX_X_EDIT);
	TUT_M_vUnregisterControlID (IDC_MAX_Y_EDIT);
	TUT_M_vUnregisterControlID (IDC_MAX_Z_EDIT);
	TUT_M_vUnregisterControlID (IDC_BUTTON_REAL_LIGHT);
}

//CHINA WFQ (MT) 16/02/98 {
void DiaLight::OnSetfocusMaxXEdit()
{
	// TODO: Add your control notification handler code here
	m_bMaxXHasFocus=TRUE;

}

void DiaLight::OnSetfocusMaxYEdit()
{
	// TODO: Add your control notification handler code here
	m_bMaxYHasFocus=TRUE;
}

void DiaLight::OnSetfocusMaxZEdit()
{
	// TODO: Add your control notification handler code here
	m_bMaxZHasFocus=TRUE;
}

void DiaLight::OnSetfocusMinXEdit()
{
	// TODO: Add your control notification handler code here
	m_bMinXHasFocus=TRUE;
}

void DiaLight::OnSetfocusMinYEdit()
{
	// TODO: Add your control notification handler code here
	m_bMinYHasFocus=TRUE;
}


void DiaLight::OnSetfocusMinZEdit()
{
	// TODO: Add your control notification handler code here
	m_bMinZHasFocus=TRUE;
}

void DiaLight::OnKillfocusMinZEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	// TODO: Add your control notification handler code here
	UpdateData (TRUE);
	if(m_oTabControl.GetCurSel() == 1)
	{
		m_Get_Min_Z = m_Min_Z;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Min_Z = (float)min ( m_Get_Min_Z, m_Get_Min_z );
//		m_Get_Min_Z = (float)max ( m_Get_Min_Z, -LIMIT);
		m_Get_Min_Z = (float)max ( m_Get_Min_Z, -LIMIT);

		m_Get_Min_z = (float)max ( m_Get_Min_Z, m_Get_Min_z);
		m_Get_Max_z = (float)max ( m_Get_Min_Z, m_Get_Max_z);
		m_Get_Max_Z = (float)max ( m_Get_Min_Z, m_Get_Max_Z);
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Min_Z = m_Get_Min_Z;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Max_Z = m_Get_Max_Z;
		fn_vSetxyzXYZ ();
//ROMTEAM parallel box Ionut Grozea 1-08-1998
	}
	else if(m_oTabControl.GetCurSel() == 0)
	{
		m_Get_Min_z = m_Min_Z;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Min_z = (float)min ( m_Get_Min_z, m_Get_Max_z );
//		m_Get_Min_z = (float)max ( m_Get_Min_z, m_Get_Min_Z );
		m_Get_Max_z = (float)max ( m_Get_Min_z, m_Get_Max_z );
		m_Get_Max_Z = (float)max ( m_Get_Min_z, m_Get_Max_Z );
		m_Get_Min_Z = (float)min ( m_Get_Min_z, m_Get_Min_Z );
		m_Max_Z = m_Get_Max_z;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Min_Z = m_Get_Min_z;

//ROMTEAM parallel box Ionut Grozea 1-08-1998
		fn_vSetxyzXYZ ();
//ROMTEAM parallel box Ionut Grozea 1-08-1998
	};
	m_bMinZHasFocus = FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusMinYEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	// TODO: Add your control notification handler code here
	UpdateData (TRUE);
	if(m_oTabControl.GetCurSel() == 1)
	{
		m_Get_Min_Y = m_Min_Y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Min_Y = (float)min ( m_Get_Min_Y, m_Get_Min_y );
//		m_Get_Min_Y = (float)max ( m_Get_Min_Y, -LIMIT);
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Get_Min_Y = (float)max ( m_Get_Min_Y, -LIMIT);

		m_Get_Min_y = (float)max ( m_Get_Min_Y, m_Get_Min_y);
		m_Get_Max_y = (float)max ( m_Get_Min_Y, m_Get_Max_y);
		m_Get_Max_Y = (float)max ( m_Get_Min_Y, m_Get_Max_Y);
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Min_Y = m_Get_Min_Y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Max_Y = m_Get_Max_Y;
		fn_vSetxyzXYZ ();
//ROMTEAM parallel box Ionut Grozea 1-08-1998
	}
	else if(m_oTabControl.GetCurSel() == 0)
	{
		m_Get_Min_y = m_Min_Y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Min_y = (float)min ( m_Get_Min_y, m_Get_Max_y );
//		m_Get_Min_y = (float)max ( m_Get_Min_y, m_Get_Min_Y );
		m_Get_Max_y = (float)max ( m_Get_Min_y, m_Get_Max_y );
		m_Get_Max_Y = (float)max ( m_Get_Min_y, m_Get_Max_Y );
		m_Get_Min_Y = (float)min ( m_Get_Min_y, m_Get_Min_Y );
		m_Max_Y = m_Get_Max_y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Min_Y = m_Get_Min_y;

//ROMTEAM parallel box Ionut Grozea 1-08-1998
		fn_vSetxyzXYZ ();
//ROMTEAM parallel box Ionut Grozea 1-08-1998

//		m_Min_Y = m_Get_Min_y;
//		fn_vSetMinxyz ();
	}
	else if(m_oTabControl.GetCurSel() == 2)
	{
		if (m_bMinYHasFocus)
		{
			m_Get_Min_I = m_Min_Y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
			m_Get_Min_I = (float)max ( m_Get_Min_I, 0);
			m_Get_Max_I = (float)max ( m_Get_Min_I, m_Get_Max_I);
			m_Min_Y = m_Get_Min_I;
			m_Max_Y = m_Get_Max_I;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
			fn_vSetMinMaxI ();
		}
	}
	m_bMinYHasFocus = FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusMinXEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	// TODO: Add your control notification handler code here
	UpdateData (TRUE);
	if(m_oTabControl.GetCurSel() == 1)
	{
		m_Get_Min_X = m_Min_X;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Min_X = (float)min ( m_Get_Min_X, m_Get_Min_x );
//		m_Get_Min_X = (float)max ( m_Get_Min_X, -LIMIT);
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Get_Min_X = (float)max ( m_Get_Min_Z, -LIMIT);

		m_Get_Min_x = (float)max ( m_Get_Min_X, m_Get_Min_x);
		m_Get_Max_x = (float)max ( m_Get_Min_X, m_Get_Max_x);
		m_Get_Max_X = (float)max ( m_Get_Min_X, m_Get_Max_X);
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Min_X = m_Get_Min_X;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Max_X = m_Get_Max_X;
		fn_vSetxyzXYZ ();
//ROMTEAM parallel box Ionut Grozea 1-08-1998

//		m_Min_X = m_Get_Min_X;
//		fn_vSetMinXYZ ();
	}
	else if(m_oTabControl.GetCurSel() == 0)
	{
		m_Get_Min_x = m_Min_X;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Min_x = (float)min ( m_Get_Min_x, m_Get_Max_x );
//		m_Get_Min_x = (float)max ( m_Get_Min_x, m_Get_Min_X );
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Get_Max_x= (float)max ( m_Get_Min_x, m_Get_Max_x);
		m_Get_Max_X= (float)max ( m_Get_Min_x ,m_Get_Max_X);
		m_Get_Min_X= (float)min ( m_Get_Min_x, m_Get_Min_X);
		m_Max_X= m_Get_Max_x;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Min_X= m_Get_Min_x;

//ROMTEAM parallel box Ionut Grozea 1-08-1998
		fn_vSetxyzXYZ ();
//ROMTEAM parallel box Ionut Grozea 1-08-1998

//		m_Min_X = m_Get_Min_x;
//		fn_vSetMinxyz ();
	};
	m_bMinXHasFocus = FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusMaxZEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	// TODO: Add your control notification handler code here
	UpdateData (TRUE);
	if(m_oTabControl.GetCurSel() == 1)
	{
		m_Get_Max_Z = m_Max_Z;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Max_Z = (float)max ( m_Get_Max_Z, m_Get_Max_z );
//		m_Get_Max_Z = (float)min ( m_Get_Max_Z, LIMIT);
//ROMTEAM parallel box Ionut Grozea 1-08-1998
		m_Get_Max_Z = (float)min ( m_Get_Max_Z, LIMIT);
		m_Get_Max_z = (float)min ( m_Get_Max_Z, m_Get_Max_z );
		m_Get_Min_z = (float)min ( m_Get_Max_Z, m_Get_Min_z );
		m_Get_Min_Z = (float)min ( m_Get_Max_Z, m_Get_Min_Z );

		m_Max_Z = m_Get_Max_Z;
		m_Min_Z = m_Get_Min_Z;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		fn_vSetMaxXYZ ();
		fn_vSetxyzXYZ ();
	}
	else if(m_oTabControl.GetCurSel() == 0)
	{
		m_Get_Max_z = m_Max_Z;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Max_z = (float)min ( m_Get_Max_Z, m_Get_Max_z );
//		m_Get_Max_z = (float)max ( m_Get_Min_z, m_Get_Max_z );
		m_Get_Max_Z = (float)max ( m_Get_Max_Z, m_Get_Max_z );
		m_Get_Min_z = (float)min ( m_Get_Min_z, m_Get_Max_z );
		m_Get_Min_Z = (float)min ( m_Get_Min_Z, m_Get_Max_z );


		m_Min_Z = m_Get_Min_z;
		m_Max_Z = m_Get_Max_z;
		fn_vSetxyzXYZ ();
	};
	m_bMaxZHasFocus = FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusMaxYEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	// TODO: Add your control notification handler code here
	UpdateData (TRUE);
	if(m_oTabControl.GetCurSel() == 1)
	{
		m_Get_Max_Y = m_Max_Y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Max_Y = (float)max ( m_Get_Max_Y, m_Get_Max_y );
//		m_Get_Max_Y = (float)min ( m_Get_Max_Y, LIMIT);
		m_Get_Max_Y = (float)min ( m_Get_Max_Y, LIMIT);
		m_Get_Max_y = (float)min ( m_Get_Max_Y, m_Get_Max_y );
		m_Get_Min_y = (float)min ( m_Get_Max_Y, m_Get_Min_y );
		m_Get_Min_Y = (float)min ( m_Get_Max_Y, m_Get_Min_Y );

		m_Max_Y = m_Get_Max_Y;
		m_Min_Y = m_Get_Min_Y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		fn_vSetMaxXYZ ();
		fn_vSetxyzXYZ ();
//		m_Max_Y = m_Get_Max_Y;
//		fn_vSetMaxXYZ ();
	}
	else if(m_oTabControl.GetCurSel() == 0)
	{
		m_Get_Max_y = m_Max_Y;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Max_y = (float)min ( m_Get_Max_Y, m_Get_Max_y );
//		m_Get_Max_y = (float)max ( m_Get_Min_y, m_Get_Max_y );
		m_Get_Max_Y = (float)max ( m_Get_Max_Y, m_Get_Max_y );
		m_Get_Min_y = (float)min ( m_Get_Min_y, m_Get_Max_y );
		m_Get_Min_Y = (float)min ( m_Get_Min_Y, m_Get_Max_y );


		m_Min_Y = m_Get_Min_y;
		m_Max_Y = m_Get_Max_y;
		fn_vSetxyzXYZ ();


//		m_Max_Y = m_Get_Max_y;
//		fn_vSetMaxxyz ();
	}
	else if(m_oTabControl.GetCurSel() == 2)
	{
		if (m_bMaxYHasFocus)
		{
			m_Get_Max_I = m_Max_Y;
			m_Get_Max_I = (float)min ( m_Get_Max_I, 100);
//			m_Get_Max_I = (float)max ( m_Get_Max_I, m_Get_Min_I);
//ROMTEAM parallel box Ionut Grozea 1-08-1998
			m_Get_Min_I = (float)min ( m_Get_Max_I, m_Get_Min_I);
			m_Max_Y = m_Get_Max_I;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
			m_Min_Y = m_Get_Min_I;
			fn_vSetMinMaxI();
		}

	};
	m_bMaxYHasFocus = FALSE;
	UpdateData (FALSE);
}

void DiaLight::OnKillfocusMaxXEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	// TODO: Add your control notification handler code here
	UpdateData (TRUE);
	if(m_oTabControl.GetCurSel() == 1)
	{
		m_Get_Max_X = m_Max_X;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Max_X = (float)max ( m_Get_Max_X, m_Get_Max_x );
//		m_Get_Max_X = (float)min ( m_Get_Max_X, LIMIT);
		m_Get_Max_X = (float)min ( m_Get_Max_X, LIMIT);
		m_Get_Max_x = (float)min ( m_Get_Max_X, m_Get_Max_x );
		m_Get_Min_x = (float)min ( m_Get_Max_X, m_Get_Min_x );
		m_Get_Min_X = (float)min ( m_Get_Max_X, m_Get_Min_X );

		m_Max_X = m_Get_Max_X;
		m_Min_X = m_Get_Min_X;
		fn_vSetxyzXYZ ();
//ROMTEAM parallel box Ionut Grozea 1-08-1998

//		m_Max_X = m_Get_Max_X;
//		fn_vSetMaxXYZ ();
	}
	else if(m_oTabControl.GetCurSel() == 0)
	{
		m_Get_Max_x = m_Max_X;
//ROMTEAM parallel box Ionut Grozea 1-08-1998
//		m_Get_Max_x = (float)min ( m_Get_Max_X, m_Get_Max_x );
//		m_Get_Max_x = (float)max ( m_Get_Min_x, m_Get_Max_x );
		m_Get_Max_X = (float)max ( m_Get_Max_X, m_Get_Max_x );
		m_Get_Min_x = (float)min ( m_Get_Min_x, m_Get_Max_x );
		m_Get_Min_X = (float)min ( m_Get_Min_X, m_Get_Max_x );


		m_Min_X = m_Get_Min_x;
		m_Max_X = m_Get_Max_x;
		fn_vSetxyzXYZ ();

//		m_Max_X = m_Get_Max_x;
//		fn_vSetMaxxyz ();
	};
	m_bMaxXHasFocus = FALSE;
	UpdateData (FALSE);
}

void DiaLight::fn_vSetMaxxyz (void)
{
	if (!m_poLight)
		return;

	if (m_bInterExtraTab )
	{
		MTH3D_tdstVector xInter_Max_Pos;
		MTH3D_M_vSetVectorElements (&xInter_Max_Pos, m_Get_Max_x, m_Get_Max_y, m_Get_Max_z);

		m_poLight->fn_vSetLight_Inter_Max_Pos ( xInter_Max_Pos );
		m_poLight->fn_vDrawEditObject();
	}
}

void DiaLight::fn_vSetMaxXYZ (void)
{
	if (!m_poLight)
		return;

	if (m_bInterExtraTab )
	{
		MTH3D_tdstVector xExter_Max_Pos;
		MTH3D_M_vSetVectorElements (&xExter_Max_Pos, m_Get_Max_X, m_Get_Max_Y, m_Get_Max_Z);

		m_poLight->fn_vSetLight_Exter_Max_Pos ( xExter_Max_Pos );
		m_poLight->fn_vDrawEditObject();
	}
}

void DiaLight::fn_vSetMinxyz (void)
{
	if (!m_poLight)
		return;

	if (m_bInterExtraTab )
	{
		MTH3D_tdstVector xInter_Min_Pos;
		MTH3D_M_vSetVectorElements (&xInter_Min_Pos, m_Get_Min_x, m_Get_Min_y, m_Get_Min_z);

		m_poLight->fn_vSetLight_Inter_Min_Pos ( xInter_Min_Pos );
		m_poLight->fn_vDrawEditObject();
	}
}

void DiaLight::fn_vSetMinXYZ (void)
{
	if (!m_poLight)
		return;

	if (m_bInterExtraTab )
	{
		MTH3D_tdstVector xExter_Min_Pos;
		MTH3D_M_vSetVectorElements (&xExter_Min_Pos, m_Get_Min_X, m_Get_Min_Y, m_Get_Min_Z);

		m_poLight->fn_vSetLight_Exter_Min_Pos ( xExter_Min_Pos );
		m_poLight->fn_vDrawEditObject();
	}
}
//ROMTEAM parallel box Ionut Grozea 1-08-1998
void DiaLight::fn_vSetxyzXYZ (void)
{
fn_vSetMaxxyz ();
fn_vSetMaxXYZ ();
fn_vSetMinxyz ();
fn_vSetMinXYZ ();
}
//ROMTEAM parallel box Ionut Grozea 1-08-1998
void DiaLight::fn_vSetMinMaxI (void)
{
	if (!m_poLight)
		return;

	if (m_bInterExtraTab )
	{
		MTH_tdxReal xIntensity_Min, xIntensity_Max;
		xIntensity_Min = m_Get_Min_I;
		xIntensity_Max = m_Get_Max_I;
		m_poLight->fn_vSetLight_Intensity_Min_Max( xIntensity_Min, xIntensity_Max );
		m_poLight->fn_vDrawEditObject();
	}
}

//ENDCHINA WFQ }


//ROMTEAM BlendRLI (Ionut Grozea 24/02/98)

void DiaLight::OnButtonNormal()
{
	if (!m_poLight)
		return;

	if (m_poLight->GetSuperObject()->GetModelName() == csFogModelName)
		return;


	if (m_poLight->fn_bIsNoAlphaLight())
	{
		GetDlgItem(IDC_BUTTON_NORMAL)->SetWindowText("Normal");
		GLI_vSetAlphaLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),0);
	    M_ShowAndEnable (IDC_LIGHT_A_SLIDER, TRUE);
	    M_ShowAndEnable (IDC_LIGHT_A_EDIT, TRUE);
		M_ShowAndEnable (IDC_LIGHT_A_STATIC, TRUE);
	}
	else
	{
		GetDlgItem(IDC_BUTTON_NORMAL)->SetWindowText("No Alpha");
		GLI_vSetAlphaLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),2);
	    M_ShowAndEnable (IDC_LIGHT_A_SLIDER, FALSE);
	    M_ShowAndEnable (IDC_LIGHT_A_EDIT, FALSE);
		M_ShowAndEnable (IDC_LIGHT_A_STATIC, FALSE);
	}

	m_poLight->GetInterface()->fn_vComputeRLI ();
	m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
	m_poLight->fn_vNotifySave ();
/*
		GLI_vSetPaintingLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),0);
		GLI_vSetAlphaLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),0);

		((CButton*)(GetDlgItem(IDC_BUTTON_PAINT)))->SetState(0);
		((CButton*)(GetDlgItem(IDC_BUTTON_NORMAL)))->SetState(1);
		m_poLight->fn_vSetTypeNormal();
		m_poLight->GetInterface()->fn_vComputeRLI ();
		m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
		m_poLight->fn_vNotifySave ();
*/

}

void DiaLight::OnButtonBack()
{
	UpdateData (TRUE);
//ROMTEAM Color editionIonut Grozea 1-08-1998
	DiaColor oColor(this);
//ROMTEAM Color editionIonut Grozea 1-08-1998
	float fRValue, fGValue, fBValue;
	GEO_tdstColor stColor;

	GLI_xGetLightBackgroundColor ( (GLI_tdxHandleToLight)m_poLight->GetEngineStruct(), &stColor );
	fRValue = stColor.xR;
	fGValue = stColor.xG;
	fBValue = stColor.xB;
	stColor.xA = 0.;

	oColor.m_cc.rgbResult = RGB ( max(fRValue,0.f)*255., max(fGValue,0.f)*255., max(fBValue,0.f)*255. );
	oColor.m_cc.Flags |= CC_RGBINIT;
	if (oColor.DoModal()==IDOK)
	{
		COLORREF clr =  oColor.GetColor();
		fRValue = (float)(GetRValue (clr)/255.);
		fGValue = (float)(GetGValue (clr)/255.);
		fBValue = (float)(GetBValue (clr)/255.);

		stColor.xR = fRValue;
		stColor.xG = fGValue;
		stColor.xB = fBValue;
		stColor.xA = 0.;

		m_poLight->fn_vNotifySave ();
		GLI_xSetLightBackgroundColor ( (GLI_tdxHandleToLight)m_poLight->GetEngineStruct(), &stColor );
		m_poLight->fn_vSetModify (TRUE);
		m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);

//		UpdateData (FALSE);
	}
	// update control colors
	GetDlgItem(IDC_BUTTON_BACK)->Invalidate();
}

void DiaLight::OnButtonPaint()
{
		if (!m_poLight)
		return;

		if (m_poLight->fn_bIsPaint())
		{
			GetDlgItem(IDC_BUTTON_PAINT)->SetWindowText("No Paint");
//			((CButton*)(GetDlgItem(IDC_BUTTON_PAINT)))->SetState(0);
			m_poLight->fn_vSetTypeNormal();
			GLI_vSetPaintingLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),0);
		}
		else
		{
			GetDlgItem(IDC_BUTTON_PAINT)->SetWindowText("Paint");
//			((CButton*)(GetDlgItem(IDC_BUTTON_PAINT)))->SetState(1);
			GLI_vSetPaintingLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),1);
			m_poLight->fn_vSetTypePaint();
		}

		m_poLight->GetInterface()->fn_vComputeRLI ();
		m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
		m_poLight->fn_vNotifySave ();

/*
		GLI_vSetPaintingLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),1);
		GLI_vSetAlphaLightFlag ((GLI_tdxHandleToLight)m_poLight->GetEngineStruct(),0);

		((CButton*)(GetDlgItem(IDC_BUTTON_PAINT)))->SetState(1);
		((CButton*)(GetDlgItem(IDC_BUTTON_NORMAL)))->SetState(0);
		m_poLight->fn_vSetTypePaint();
		m_poLight->GetInterface()->fn_vComputeRLI ();
		m_poLight->fn_vNotifySave ();
		m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
*/
}

void DiaLight::fn_vInitType()
{
	if (!m_poLight)
		return;
	
	// paint
	if (m_poLight->fn_bIsPaint())
	{
		GetDlgItem(IDC_BUTTON_PAINT)->SetWindowText("Paint");

	}
	else
	{
		GetDlgItem(IDC_BUTTON_PAINT)->SetWindowText("No Paint");
	}

	// fog
	if (m_poLight->GetSuperObject()->GetModelName() == csFogModelName)
	{
	    M_ShowAndEnable (IDC_LIGHT_A_SLIDER, (m_poLight->GetSuperObject()->GetModelName() != csFogModelName));
	    M_ShowAndEnable (IDC_LIGHT_A_EDIT, (m_poLight->GetSuperObject()->GetModelName() != csFogModelName));
		M_ShowAndEnable (IDC_LIGHT_A_STATIC, (m_poLight->GetSuperObject()->GetModelName() != csFogModelName));
		GetDlgItem(IDC_BUTTON_NORMAL)->SetWindowText("No Alpha");
		GetDlgItem(IDC_BUTTON_NORMAL)->EnableWindow(FALSE);
	}
	else
	{
		GetDlgItem(IDC_BUTTON_NORMAL)->EnableWindow(TRUE);

		// alpha
		if (m_poLight->fn_bIsNoAlphaLight())
		{
			M_ShowAndEnable (IDC_LIGHT_A_SLIDER, FALSE);
			M_ShowAndEnable (IDC_LIGHT_A_EDIT, FALSE);
			M_ShowAndEnable (IDC_LIGHT_A_STATIC, FALSE);
			GetDlgItem(IDC_BUTTON_NORMAL)->SetWindowText("No Alpha");
		}
		else
		{
			M_ShowAndEnable (IDC_LIGHT_A_SLIDER, TRUE);
			M_ShowAndEnable (IDC_LIGHT_A_EDIT, TRUE);
			M_ShowAndEnable (IDC_LIGHT_A_STATIC, TRUE);
			GetDlgItem(IDC_BUTTON_NORMAL)->SetWindowText("Normal");
		}
	}


}
//ENDROMTEAM BlendRLI (Ionut Grozea)


//ANNECY jt {


void DiaLight::OnKillfocusBlendFarEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	MTH_tdxReal xFogBlendFar, xMaxIntensity;
	xFogBlendFar = (MTH_tdxReal) m_fFogBlendFar;
	xMaxIntensity = (MTH_tdxReal) 0.f;
	m_poLight->fn_vSetLight_Intensity_Min_Max (xFogBlendFar,xMaxIntensity);
	m_bFogBlendFarHasFocus = FALSE;
}

void DiaLight::OnSetfocusBlendFarEdit()
{
	m_bFogBlendFarHasFocus = TRUE;
}

void DiaLight::OnKillfocusBlendNearEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	MTH_tdxReal xFogInfinite, xFogBlendNear;
	xFogInfinite = (MTH_tdxReal) m_fFogInfinite;
	xFogBlendNear = (MTH_tdxReal) m_fFogBlendNear;
	m_poLight->fn_vSetLightAlpha ( xFogInfinite, xFogBlendNear );
	m_bFogBlendNearHasFocus = FALSE;
}

void DiaLight::OnSetfocusBlendNearEdit()
{
	m_bFogBlendNearHasFocus = TRUE;
}

void DiaLight::OnKillfocusFarEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	MTH_tdxReal xFogNear, xFogFar;
	xFogNear = (MTH_tdxReal) m_fFogNear;
	xFogFar = (MTH_tdxReal) m_fFogFar;
	m_poLight->fn_vSetLightNearFar ( xFogNear, xFogFar );
	m_bFogBlendFarHasFocus = FALSE;
}

void DiaLight::OnSetfocusFarEdit()
{
	m_bFogBlendFarHasFocus = TRUE;
}

void DiaLight::OnKillfocusInfiniteEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	MTH_tdxReal xFogInfinite, xFogBlendNear;
	xFogInfinite = (MTH_tdxReal) m_fFogInfinite;
	xFogBlendNear = (MTH_tdxReal) m_fFogBlendNear;
	m_poLight->fn_vSetLightAlpha ( xFogInfinite, xFogBlendNear );
	m_bFogInfiniteHasFocus = FALSE;
}

void DiaLight::OnSetfocusInfiniteEdit()
{
	m_bFogInfiniteHasFocus = TRUE;
}

void DiaLight::OnKillfocusNearEdit()
{
	if (m_pInterface->fn_bRunEngine())
		return;

	UpdateData (TRUE);
	MTH_tdxReal xFogNear, xFogFar;
	xFogNear = (MTH_tdxReal) m_fFogNear;
	xFogFar = (MTH_tdxReal) m_fFogFar;
	m_poLight->fn_vSetLightNearFar ( xFogNear, xFogFar );
	m_bFogNearHasFocus = FALSE;
}

void DiaLight::OnSetfocusNearEdit()
{
	m_bFogNearHasFocus = TRUE;
}


void DiaLight::fn_vDisplayFogControl (BOOL bState)
{
    /*
	int iState = bState ? SW_SHOW : SW_HIDE;

	GetDlgItem (IDC_FOG_NEAR_EDIT)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_FAR_EDIT)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_INFINITE_EDIT)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_BLEND_NEAR_EDIT)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_BLEND_FAR_EDIT)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_NEAR_STATIC)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_FAR_STATIC)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_INFINITE_STATIC)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_BLEND_NEAR_STATIC)->ShowWindow( iState );
	GetDlgItem (IDC_FOG_BLEND_FAR_STATIC)->ShowWindow( iState );

	GetDlgItem (IDC_FOG_NEAR_EDIT)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_FAR_EDIT)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_INFINITE_EDIT)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_BLEND_NEAR_EDIT)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_BLEND_FAR_EDIT)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_NEAR_STATIC)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_FAR_STATIC)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_INFINITE_STATIC)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_BLEND_NEAR_STATIC)->EnableWindow( bState );
	GetDlgItem (IDC_FOG_BLEND_FAR_STATIC)->EnableWindow( bState );
    */
    M_ShowAndEnable(IDC_FOG_NEAR_EDIT,          bState);
    M_ShowAndEnable(IDC_FOG_FAR_EDIT,           bState);
    M_ShowAndEnable(IDC_FOG_INFINITE_EDIT,      bState);
    M_ShowAndEnable(IDC_FOG_BLEND_NEAR_EDIT,    bState);
    M_ShowAndEnable(IDC_FOG_BLEND_FAR_EDIT,     bState);
    M_ShowAndEnable(IDC_FOG_NEAR_STATIC,        bState);
    M_ShowAndEnable(IDC_FOG_FAR_STATIC,         bState);
    M_ShowAndEnable(IDC_FOG_INFINITE_STATIC,    bState);
    M_ShowAndEnable(IDC_FOG_BLEND_NEAR_STATIC,  bState);
    M_ShowAndEnable(IDC_FOG_BLEND_FAR_STATIC,   bState);
}

//ENDANNECY jt }

//ROMTEAM RealLights (Ionut Grozea 05/03/98)
void DiaLight::OnButtonRealLight()
{
//ROMTEAM  Ionut Grozea 1-08-1998
	HCURSOR     hWaitCursor;
	HCURSOR     hOldCursor;
//ROMTEAM  Ionut Grozea 1-08-1998
	if (!m_poLight->GetInterface()->fn_bGetRealLight())
	{
//ROMTEAM  Ionut Grozea 1-08-1998
		hWaitCursor = AfxGetApp()->LoadStandardCursor( IDC_WAIT );
		hOldCursor = SetCursor( hWaitCursor );
//ROMTEAM  Ionut Grozea 1-08-1998
		GetDlgItem(IDC_BUTTON_REAL_LIGHT)->SetWindowText("Display all Lights");
		m_poLight->GetInterface()->fn_bSetRealLight(TRUE);
		m_poLight->GetInterface()->RefreshOnlyRealLights();
		m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
//ROMTEAM  Ionut Grozea 1-08-1998
		SetCursor( hOldCursor );
//ROMTEAM  Ionut Grozea 1-08-1998
	}
	else
	{
//ROMTEAM  Ionut Grozea 1-08-1998
		hWaitCursor = AfxGetApp()->LoadStandardCursor( IDC_WAIT );
		hOldCursor = SetCursor( hWaitCursor );
//ROMTEAM  Ionut Grozea 1-08-1998
		((CButton*)(GetDlgItem(IDC_BUTTON_REAL_LIGHT)))->SetWindowText("Display only real Lights");
		m_poLight->GetInterface()->fn_bSetRealLight(FALSE);
		m_poLight->GetInterface()->fn_vRefreshAllLights();
		m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);
//ROMTEAM  Ionut Grozea 1-08-1998
		SetCursor( hOldCursor );
//ROMTEAM  Ionut Grozea 1-08-1998
	}
}
//ENDROMTEAM RealLights (Ionut Grozea)

void DiaLight::fn_vDisplayInternalExternalControls(BOOL _bShow )
{
    M_ShowAndEnable(IDC_MIN_X, _bShow );
    M_ShowAndEnable(IDC_MIN_Y, _bShow );
    M_ShowAndEnable(IDC_MIN_Z, _bShow );
    M_ShowAndEnable(IDC_MIN_X_EDIT, _bShow );
    M_ShowAndEnable(IDC_MIN_Y_EDIT, _bShow );
    M_ShowAndEnable(IDC_MIN_Z_EDIT, _bShow );

    M_ShowAndEnable (IDC_MAX_X, _bShow );
    M_ShowAndEnable (IDC_MAX_Y, _bShow );
    M_ShowAndEnable (IDC_MAX_Z, _bShow );
    M_ShowAndEnable (IDC_MAX_X_EDIT, _bShow );
    M_ShowAndEnable (IDC_MAX_Y_EDIT, _bShow );
    M_ShowAndEnable (IDC_MAX_Z_EDIT, _bShow );
}

/*=======================================================================================
 * Description
 *
 * Creation date    24/03/98
 * Author           Marc Trabucato
 *=====================================================================================*/
void DiaLight::fn_vDisplayNearFarControls(BOOL _bShow )
{
    M_ShowAndEnable(IDC_LIGHT_NEAR_SLIDER, _bShow );
    M_ShowAndEnable(IDC_LIGHT_FAR_SLIDER, _bShow );
    M_ShowAndEnable(IDC_LIGHT_NEAR_EDIT, _bShow );
    M_ShowAndEnable(IDC_LIGHT_FAR_EDIT, _bShow );
    M_ShowAndEnable(IDC_NEAR_STATIC, _bShow );
    M_ShowAndEnable(IDC_FAR_STATIC, _bShow );
}

/*=======================================================================================
 * Description
 *
 * Creation date    24/03/98
 * Author           Marc Trabucato
 *=====================================================================================*/
void DiaLight::fn_vDisplayCommonControls(BOOL _bShow )
{
    // Name
    M_Enable (IDC_LIGHT_NAME_EDIT, _bShow);

    // On/Off buttons
    M_Enable (IDC_LIGHT_ON_RADIO, _bShow);
    M_Enable (IDC_LIGHT_OFF_RADIO, _bShow);
    M_Enable (IDC_ON_OFF_STATIC, _bShow);
    M_Enable (IDC_LIGHT_ACTIVE_ON_RADIO, _bShow);
    M_Enable (IDC_LIGHT_ACTIVE_OFF_RADIO, _bShow);
    M_Enable (IDC_MAP_ON_RADIO, _bShow);
    M_Enable (IDC_MAP_OFF_RADIO, _bShow);

    // Paint
    M_Enable (IDC_BUTTON_PAINT, _bShow);
    M_Enable (IDC_BUTTON_NORMAL, _bShow);
    M_Enable (IDC_BUTTON_BACK, _bShow);
//ROMTEAM Ionut Grozea (Compute all 19.05.98)
    M_Enable (IDC_BUTTON_COMPUTE_ALL, _bShow);
//ENDROMTEAM Ionut Grozea (Compute all 19.05.98)

	M_Enable (IDC_BUTTON_REAL_LIGHT, TRUE);
    // color & alpha
    M_Enable (IDC_LIGHT_R_SLIDER, _bShow);
    M_Enable (IDC_LIGHT_G_SLIDER, _bShow);
    M_Enable (IDC_LIGHT_B_SLIDER, _bShow);
    M_Enable (IDC_LIGHT_A_SLIDER, _bShow);

    M_Enable (IDC_LIGHT_R_EDIT, _bShow);
    M_Enable (IDC_LIGHT_G_EDIT, _bShow);
    M_Enable (IDC_LIGHT_B_EDIT, _bShow);
    M_Enable (IDC_LIGHT_A_EDIT, _bShow);

    M_Enable (IDC_LIGHT_R_STATIC, _bShow);
    M_Enable (IDC_LIGHT_G_STATIC, _bShow);
    M_Enable (IDC_LIGHT_B_STATIC, _bShow);
    M_Enable (IDC_LIGHT_A_STATIC, _bShow);

    M_Enable (IDC_LIGHT_COLOR_DEFINITION, _bShow);

    // intensity
    M_Enable (IDC_LIGHT_INTENSITY_SLIDER, _bShow);
    M_Enable (IDC_LIGHT_INTENSITY_EDIT, _bShow);
    M_Enable (IDC_LIGHT_MIN_INTENSITY, _bShow);
    M_Enable (IDC_LIGHT_MAX_INTENSITY, _bShow);

    // effect
    M_Enable (IDC_LIGHT_AFFECT_ALL, _bShow);
    M_Enable (IDC_LIGHT_DEFAULT, _bShow);
    M_Enable (IDC_LIGHT_SEE, _bShow);
    M_Enable (IDC_LIGHT_DISPLAY_ALL, _bShow);
    M_Enable (IDC_LIGHT_SECTOR_LIST, _bShow);
    M_Enable (IDC_LIGHT_REAL_TIME_STATIC, _bShow);
}

/*=======================================================================================
 * Description
 *
 * Creation date    24/03/98
 * Author           Marc Trabucato
 *=====================================================================================*/
void DiaLight::fn_vDisplayCommonIcons(int _iState )
{
    M_Show (IDC_AMBIENT_LIGHT_PICTURE,  _iState );
    M_Show (IDC_PARALLEL_LIGHT_PICTURE,  _iState );
    M_Show (IDC_SPHERICAL_LIGHT_PICTURE,  _iState );
    M_Show (IDC_SPOT_LIGHT_PICTURE,  _iState );
    M_Show (IDC_AMBIENT_IMPORT_LIGHT_PICTURE,  _iState );
    M_Show (IDC_PARALLEL_IMPORT_LIGHT_PICTURE,  _iState );
    M_Show (IDC_SPHERICAL_IMPORT_LIGHT_PICTURE,  _iState );
    M_Show (IDC_SPOT_IMPORT_LIGHT_PICTURE,  _iState );
    M_Show (IDC_PARABOX_LIGHT_PICTURE, _iState );
    M_Show (IDC_PARABOX_IMPORT_LIGHT_PICTURE, _iState );
    M_Show (IDC_FOG_PICTURE, _iState );
    M_Show (IDC_Z_LIGHT1, _iState );
}

//ROMTEAM ComputeAll Ionut Grozea 21-04-1998
void DiaLight::OnButtonComputeAll() 
{
	if(!m_pInterface)
		return;
	
	CPA_BaseObjectList* poListOfLight = m_pInterface->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szLightTypeName);
	Position xPosLight;
	CPA_BaseObject* poBaseObject;

	if(!poListOfLight)
		return;
	m_pInterface->fn_vSetCursor (IDC_ORIENT_LIGHT_POINTER);

	for ( poBaseObject = poListOfLight->GetHeadElement(xPosLight); poBaseObject; poBaseObject = poListOfLight->GetNextElement(xPosLight) )
	{

			if (!(Light*)poBaseObject)
		return;

			((Light*)poBaseObject)->fn_vComputeSector ();
			m_pInterface->fn_vRefreshLight((Light*)poBaseObject);
			(Light*)poBaseObject;
	}
		 	fn_vRefreshSectorList();
	m_pInterface->fn_vSetCursor (IDC_POINTER);

	
}
//ENDROMTEAM ComputeAll Ionut Grozea 21-04-1998

 

//ROMTEAM  Color edition Ionut Grozea 1-08-1998
BOOL DiaColor::OnInitDialog()
{
	RECT	m_Rect,m_RectDiaLight ;

	GetWindowRect( &m_Rect);
	m_pDiaLight->GetWindowRect( &m_RectDiaLight);
	MoveWindow( m_RectDiaLight.right, 200, m_Rect.right - m_Rect.left,m_Rect.bottom - m_Rect.top);
	return CColorDialog::OnInitDialog();
}
//ROMTEAM  Color edition Ionut Grozea 1-08-1998

//ROMTEAM  Color edition Ionut Grozea 1-08-1998
void DiaColor::OnOK()
{
	CColorDialog::OnOK();
	int			iCount,jCount;
	CString		m_cString;
	CString		csFileName = M_GetMainApp()->m_csEditorDataPath + "Objects\\" + C_szLightIniFile;
	char		csDimension[255];
	static		COLORREF * m_CustomColor; 

	m_CustomColor = GetSavedCustomColors();
	for(iCount = 0;iCount<16;iCount++)
	{
		for(jCount = 0;jCount<3;jCount++)
		{
			char m_szNr[255] ;
			itoa(iCount , m_szNr,10);
			m_cString = "Color nr "+ (CString)m_szNr +(jCount==0?"Red":(jCount==1?"Green":"Blue"));

			if (jCount == 0)
			itoa(GetRValue(m_CustomColor[iCount]), csDimension,10);
			if (jCount == 1)
			itoa(GetGValue(m_CustomColor[iCount]), csDimension,10);
			if (jCount == 2)
			itoa(GetBValue(m_CustomColor[iCount]), csDimension,10);

			WritePrivateProfileString ("Default colors", m_cString,  csDimension, (char*)(LPCSTR)csFileName);
		}
	}
}
//ROMTEAM  Color edition Ionut Grozea 1-08-1998


//ROMTEAM  Color edition Ionut Grozea 1-08-1998
void DiaColor::RestoreDefaultColor()
{
	COLORREF	m_defaultColor;
	BYTE		m_color[3];
	CString		m_cString;
	int			iCount,jCount;
	char		szDimension[256];
	CString		csFileName = M_GetMainApp()->m_csEditorDataPath + "Objects\\" + C_szLightIniFile;
	char		m_szNr[255] ;


	for(iCount = 0;iCount<16;iCount++)
	{
		for(jCount = 0;jCount<3;jCount++)
		{
			itoa(iCount,m_szNr,10);
			m_cString = "Color nr "+ (CString)m_szNr +(jCount==0?"Red":(jCount==1?"Green":"Blue"));
			GetPrivateProfileString ("Default colors", m_cString, "0", szDimension, 256, (char*)(LPCSTR)csFileName);
			m_color[jCount] = atoi(szDimension);
		}
			m_defaultColor = RGB(m_color[0],m_color[1],m_color[2] );
			m_cc.lpCustColors[iCount]=m_defaultColor;			
	}

}
//ROMTEAM  Color edition Ionut Grozea 1-08-1998


//ROMTEAM color lights Ionut Grozea 10-08-1998
void DiaLight::OnButtonMode() 
{
	if(!m_pInterface)
		return;


 	HCURSOR     hWaitCursor;
	HCURSOR     hOldCursor;
 	hWaitCursor = AfxGetApp()->LoadStandardCursor( IDC_WAIT );
	hOldCursor  = SetCursor( hWaitCursor );

	


	if (m_poLight->GetInterface()->fn_bGetColorMode())
	{
		GetDlgItem(IDC_BUTTON_MODE)->SetWindowText("Display in 2 colors");
		CPA_BaseObjectList* poListOfLight = m_pInterface->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szLightTypeName);
		Position xPosLight;
		CPA_BaseObject* poBaseObject;
 
		if(!poListOfLight)
			return;
 
		for ( poBaseObject = poListOfLight->GetHeadElement(xPosLight); poBaseObject; poBaseObject = poListOfLight->GetNextElement(xPosLight) )
		{
			if (!(Light*)poBaseObject )  
				continue;
			if ( m_poLight->GetInterface()->fn_bGetRealLight() && !((Light*)poBaseObject)->fn_bGetOnOff()) 
				continue;
			((Light*)poBaseObject)->SetMultiColor();
		}
		m_poLight->GetInterface()->fn_SetColorMode(FALSE);
	}
	else
	{
		GetDlgItem(IDC_BUTTON_MODE)->SetWindowText("Display multicolors");
		CPA_BaseObjectList* poListOfLight = m_pInterface->GetMainWorld()->fn_p_oGetOriginalObjectList (C_szLightTypeName);
		Position xPosLight;
		CPA_BaseObject* poBaseObject;
 
		if(!poListOfLight)
			return;
 
		for ( poBaseObject = poListOfLight->GetHeadElement(xPosLight); poBaseObject; poBaseObject = poListOfLight->GetNextElement(xPosLight) )
		{
			if (!(Light*)poBaseObject)
				continue;
			if ( m_poLight->GetInterface()->fn_bGetRealLight() && !((Light*)poBaseObject)->fn_bGetOnOff()) 
				continue;
			((Light*)poBaseObject)->Set2Colors();
		}

		m_poLight->GetInterface()->fn_SetColorMode(TRUE);
	}

 		m_poLight->GetInterface()->GetInterface()->fn_vUpdateAll (E_mc_JustDraw);






 	SetCursor( hOldCursor );


}
//ENDROMTEAM color lights Ionut Grozea 10-08-1998


//==================================================================================================
//  Description : handle function for WM_DRAWITEM
//==================================================================================================
void DiaLight::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC			*pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	RECT		*rect = &lpDrawItemStruct->rcItem;
	COLORREF	xColor;

	switch ( nIDCtl )
	{
	default:
		CFormView::OnDrawItem(nIDCtl, lpDrawItemStruct);
		break;

	case IDC_LIGHT_COLOR_DEFINITION:
		{
			if (m_poLight)
			{
				GEO_tdstColor stColor;
				float fIntensity;

				GLI_xGetLightColor ( (GLI_tdxHandleToLight)m_poLight->GetEngineStruct(), &stColor );
				fIntensity = m_poLight->fn_fGetIntensity();
				xColor = RGB ( max(stColor.xR,0.f)/fIntensity*255., max(stColor.xG,0.f)/fIntensity*255., max(stColor.xB,0.f)/fIntensity*255. );
			}
			else
				xColor = RGB(0.0f,0.0f,0.0f);
			// draw button
			rect->bottom -=1;
			pDC->FillSolidRect(rect, RGB(250.0f, 250.0f, 250.0f));
			rect->left +=1;
			rect->top +=1;
			rect->bottom +=1;
			pDC->FillSolidRect(rect, RGB(0.0f, 0.0f, 0.0f));
			// draw color
			rect->right -=1;
			rect->bottom -=1;
			pDC->FillSolidRect( rect, xColor);
			//draw text
			pDC->SetBkMode(TRANSPARENT);
			pDC->DrawText("\nC\no\nl\no\nr", rect, DT_CENTER | DT_VCENTER);
		}
		break;

	case IDC_BUTTON_BACK:
		{
			if (m_poLight)
			{
				GEO_tdstColor stColor;

				GLI_xGetLightBackgroundColor ( (GLI_tdxHandleToLight)m_poLight->GetEngineStruct(), &stColor );
				xColor = RGB ( max(stColor.xR,0.f)*255., max(stColor.xG,0.f)*255., max(stColor.xB,0.f)*255. );
			}
			else
				xColor = RGB(0.0f,0.0f,0.0f);
			// draw button
			rect->bottom -=1;
			pDC->FillSolidRect(rect, RGB(250.0f, 250.0f, 250.0f));
			rect->left +=1;
			rect->top +=1;
			rect->bottom +=1;
			pDC->FillSolidRect(rect, RGB(0.0f, 0.0f, 0.0f));
			// draw color
			rect->right -=1;
			rect->bottom -=1;
			pDC->FillSolidRect( rect, xColor);
			//draw text
			pDC->SetBkMode(TRANSPARENT);
			pDC->DrawText("FogBack", rect, DT_CENTER | DT_VCENTER);
		}
		break;

	}
}

