// LightListDlg.cpp : implementation file
//

#include "stdafx.h"
#include "mfc gos.h"
#include "LightListDlg.h"
#include "AmbientLightProperties.h"
#include "PointLightProps.h"
#include "SpotLightProps.h"
#include "InfiniteLightProps.h"
#include <MLR\MLRHeaders.hpp>

/////////////////////////////////////////////////////////////////////////////
// CLightListDlg dialog


CLightListDlg::CLightListDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLightListDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLightListDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CLightListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLightListDlg)
	DDX_Control(pDX, IDC_LIGHTLIST, m_LightList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLightListDlg, CDialog)
	//{{AFX_MSG_MAP(CLightListDlg)
	ON_WM_CLOSE()
	ON_LBN_DBLCLK(IDC_LIGHTLIST, OnDblclkLightlist)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLightListDlg message handlers

void CLightListDlg::OnCancel() 
{
//	CDialog::OnCancel();
}

void CLightListDlg::OnOK() 
{
//	CDialog::OnOK();
}

void CLightListDlg::OnClose() 
{
ShowWindow(SW_HIDE);	
//	CDialog::OnClose();
}

void CLightListDlg::OnDblclkLightlist() 
{
MLRLight *SelLight;
SelLight=(MLRLight *)m_LightList.GetItemDataPtr(m_LightList.GetCurSel());
gos_PushCurrentHeap(MidLevelRenderer::LightsHeap);

switch(SelLight->GetLightType())
{
case MidLevelRenderer::MLRLight::AmbientLight:
	{

	MLRAmbientLight *light=(MLRAmbientLight *)SelLight;
	CAmbientLightProperties PropDlg;
	PropDlg.SetData(light);
	if(PropDlg.DoModal()==IDOK)
		{
		*light=PropDlg.GetData();
		}
	}
	break;

case MidLevelRenderer::MLRLight::InfiniteLight:
	{
	MLRInfiniteLight *light=(MLRInfiniteLight *)SelLight;
	CInfiniteLightProps PropDlg;
	PropDlg.SetData(light);
	if(PropDlg.DoModal()==IDOK)
		{
		*light=PropDlg.GetData();
		}
	}
	break;

case MidLevelRenderer::MLRLight::PointLight:
	{
	MLRPointLight *light=(MLRPointLight *)SelLight;
	CPointLightProps PropDlg;
	PropDlg.SetData(light);
	if(PropDlg.DoModal()==IDOK)
		{
		*light=PropDlg.GetData();
		}
	}
	break;

case MidLevelRenderer::MLRLight::SpotLight:
	{
		MLRSpotLight *light=(MLRSpotLight *)SelLight;
		CSpotLightProps PropDlg;
		PropDlg.SetData(light);
		if(PropDlg.DoModal()==IDOK)
		{
			PropDlg.GetData(light);
		}
	}
	break;
case MidLevelRenderer::MLRLight::ProjectLight:
	{
		MLRProjectLight *light=(MLRProjectLight *)SelLight;
		CSpotLightProps PropDlg;

		PropDlg.SetData(light);
		if(PropDlg.DoModal()==IDOK)
		{
			PropDlg.GetData(light);
		}
	}
	break;
}
gos_PopCurrentHeap();
	
}
