// ScaleOpt.cpp : implementation file
//

#include "stdafx.h"
#include "pixelwhippro.h"
#include "ScaleOpt.h"

/////////////////////////////////////////////////////////////////////////////
// CScaleOpt dialog


CScaleOpt::CScaleOpt(CWnd* pParent /*=NULL*/)
	: CDialog(CScaleOpt::IDD, pParent)
{
	//{{AFX_DATA_INIT(CScaleOpt)
	m_Recurse = FALSE;
	m_SFact = 1.0f;
	//}}AFX_DATA_INIT
	ScaleAll=false;
LastFact=m_SFact;
}


void CScaleOpt::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CScaleOpt)
	DDX_Control(pDX, IDC_RECURSE, m_RBut);
	DDX_Control(pDX, IDC_SCOPE, m_ScopeBut);
	DDX_Control(pDX, IDC_SCALESPIN, m_ScaleSpin);
	DDX_Check(pDX, IDC_RECURSE, m_Recurse);
	DDX_Text(pDX, IDC_SFACT, m_SFact);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CScaleOpt, CDialog)
	//{{AFX_MSG_MAP(CScaleOpt)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SCALESPIN, OnDeltaposScalespin)
	ON_EN_CHANGE(IDC_SFACT, OnChangeSfact)
	ON_BN_CLICKED(IDC_SCOPE, OnScope)
	ON_BN_CLICKED(IDC_SELEFFECT, OnSeleffect)
	ON_BN_CLICKED(IDC_ALLEFF, OnAlleff)
	ON_EN_KILLFOCUS(IDC_SFACT, OnKillfocusSfact)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScaleOpt message handlers

void CScaleOpt::OnDeltaposScalespin(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(TRUE);
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	m_SFact*=(float)pow(2,-pNMUpDown->iDelta);
	if(m_SFact<=0.0f) 
	{
	m_SFact=0.001f;
	}
	UpdateData(FALSE);
	*pResult = 0;
}

void CScaleOpt::OnChangeSfact() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	// TODO: Add your control notification handler code here
}

BOOL CScaleOpt::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CheckDlgButton(IDC_SELEFFECT,1); 
	CheckDlgButton(IDC_TYPE_SIZE,1); 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CScaleOpt::OnScope() 
{
	
}

void CScaleOpt::OnSeleffect() 
{
	ScaleAll=false;
	CheckDlgButton(IDC_SELEFFECT,1); 
	m_RBut.EnableWindow(TRUE);
	
}

void CScaleOpt::OnAlleff() 
{
	ScaleAll=true;
	m_RBut.EnableWindow(FALSE);
}

void CScaleOpt::OnKillfocusSfact() 
{
UpdateData(TRUE);
if(m_SFact<=0.0f) 
	{
	m_SFact=LastFact;
	UpdateData(FALSE);
	}	
LastFact=m_SFact;	

	
}

void CScaleOpt::OnOK() 
{
	Brightness=IsDlgButtonChecked(IDC_BRIGHTNESS)?true:false;
	CDialog::OnOK();
}
