// Rlidia.cpp : implementation file
//

//#include "resource.h"
//#include "stdafx.h"
//#include "..\res\spot.h"



#include "stdafx.h"
#include "acp_base.h"
#include "resource.h"
#include "itf.h"
#include "lightObj.hpp"
#include "inter.hpp"


#include "Rlidia.hpp"

/////////////////////////////////////////////////////////////////////////////
// RliDia dialog


RliDia::RliDia(Light_Interface* poInterface, CWnd* pParent /*=NULL*/)
	: CDialog(RliDia::IDD, pParent)
{
	m_poInterface = poInterface;

	//{{AFX_DATA_INIT(RliDia)
	m_fColorScale = 1.0f;
	//}}AFX_DATA_INIT
}


void RliDia::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(RliDia)
	DDX_Control(pDX, IDC_LIGHT_SLIDER, m_oColorScaleSlider);
	DDX_Control(pDX, IDC_COMMAND_BUTTON, m_oCommandButton);
	DDX_Text(pDX, IDC_LIGHT_COLOR_SCALE_EDIT, m_fColorScale);
	DDV_MinMaxFloat(pDX, m_fColorScale, 0.f, 10.f);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(RliDia, CDialog)
	//{{AFX_MSG_MAP(RliDia)
	ON_BN_CLICKED(IDC_COMMAND_BUTTON, OnCommandButton)
	ON_WM_HSCROLL()
	ON_EN_KILLFOCUS(IDC_LIGHT_COLOR_SCALE_EDIT, OnKillfocusLightColorScaleEdit)
	ON_BN_CLICKED(IDC_COMMAND_ALL_BUTTON, OnCommandAllButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// RliDia message handlers

BOOL RliDia::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_oColorScaleSlider.SetRange( 0, 1000, TRUE );
	m_oColorScaleSlider.SetPos( 100 );
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void RliDia::OnCommandButton() 
{
//	m_poInterface->fn_vComputeRLI (TRUE, m_fColorScale);
	EndDialog (0);
}



void RliDia::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if (pScrollBar==(void*)&m_oColorScaleSlider) 
	{
		m_fColorScale = ((float)m_oColorScaleSlider.GetPos()/100.f);
		UpdateData (FALSE);
	}

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


void RliDia::OnKillfocusLightColorScaleEdit() 
{
	UpdateData (TRUE);
	m_fColorScale = (float) min ( m_fColorScale, 10. );
	m_fColorScale = (float) max ( m_fColorScale, 0. );
	m_oColorScaleSlider.SetPos((int)(m_fColorScale*100));
	UpdateData (FALSE);
}

BOOL RliDia::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	if (wParam==1)
	{
		OnKillfocusLightColorScaleEdit ();
		return TRUE;
	}

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

void RliDia::OnCommandAllButton() 
{
//	m_poInterface->fn_vComputeRLI (FALSE, m_fColorScale);
	EndDialog (0);
}
