// Options.cpp : implementation file
//

#include "stdafx.h"
#include "Test.h"
#include "Options.h"
#include "TestDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COptions dialog


COptions::COptions(CWnd* pParent /*=NULL*/)
	: CDialog(COptions::IDD, pParent)
{
	//{{AFX_DATA_INIT(COptions)
	m_critery = -1;
	m_pause = FALSE;
	//}}AFX_DATA_INIT
}


void COptions::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COptions)
	DDX_Control(pDX, IDC_EDIT3, m_edStep);
	DDX_Control(pDX, IDC_EDIT2, m_edYsize);
	DDX_Control(pDX, IDC_EDIT1, m_edXsize);
	DDX_Control(pDX, IDC_SPIN3, m_sStep);
	DDX_Control(pDX, IDC_SPIN2, m_sYsize);
	DDX_Control(pDX, IDC_SPIN1, m_sXsize);
	DDX_Radio(pDX, IDC_RADIO1, m_critery);
	DDX_Check(pDX, IDC_CHECK1, m_pause);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COptions, CDialog)
	//{{AFX_MSG_MAP(COptions)
	ON_EN_UPDATE(IDC_EDIT1, OnUpdateEdit1)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COptions message handlers

void COptions::OnUpdateEdit1() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function to send the EM_SETEVENTMASK message to the control
	// with the ENM_UPDATE flag ORed into the lParam mask.
	
	// TODO: Add your control notification handler code here
	
}

BOOL COptions::OnInitDialog() 
{
	CDialog::OnInitDialog();
	

	m_sXsize.SetBuddy(&m_edXsize);
	m_sXsize.SetRange(10,100);
	m_sXsize.SetPos(pDoc->PltSizeX);
    m_sYsize.SetBuddy(&m_edYsize);
	m_sYsize.SetRange(10,100);
	m_sYsize.SetPos(pDoc->PltSizeY);
	m_sStep.SetBuddy(&m_edStep);
	m_sStep.SetRange(6,24);
	m_sStep.SetPos(pDoc->step);

 	m_critery=pDoc->Critery;
    m_pause=pDoc->Pause;

	UpdateData(false);   


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void COptions::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	/*char str[10];
	int t=m_sYsize.GetPos();
	sprintf(str,"%d",t);
    m_Xsize=str;
	UpdateData(false);
*/
	*pResult = 0;
}

void COptions::OnOK() 
{
	// TODO: Add extra validation here
	pDoc->step=m_sStep.GetPos();
	pDoc->PltSizeX=m_sXsize.GetPos();
	pDoc->PltSizeY=m_sYsize.GetPos();
	pDoc->Critery=m_critery;
	pDoc->Pause=m_pause;
	CDialog::OnOK();
}

void COptions::OnRadio1() 
{
	// TODO: Add your control notification handler code here
    m_critery=0;	
}

void COptions::OnRadio2() 
{
	// TODO: Add your control notification handler code here
    m_critery=1;	
}

void COptions::OnRadio3() 
{
	// TODO: Add your control notification handler code here
    m_critery=2; 	
}

void COptions::OnCheck1() 
{
	// TODO: Add your control notification handler code here
	m_pause=!m_pause;
}
