// VisualCppRunDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AsCfgBuilder.h"
#include "VisualCppRunDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CVisualCppRunDlg dialog


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


void CVisualCppRunDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CVisualCppRunDlg)
	DDX_Control(pDX, IDC_CHK_RUN_TESTPROJECT, chkRunTestProject_);
	DDX_Control(pDX, IDC_TITLE, lblTitle_);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CVisualCppRunDlg, CDialog)
	//{{AFX_MSG_MAP(CVisualCppRunDlg)
	ON_BN_CLICKED(IDC_OPT1, OnOpt1)
	ON_BN_CLICKED(IDC_OPT2, OnOpt2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVisualCppRunDlg message handlers

void CVisualCppRunDlg::OnOK() 
{
	testProjectRun_ = (chkRunTestProject_.GetCheck() == TRUE);
	
	CDialog::OnOK();
}

void CVisualCppRunDlg::SetCaption(const wstring& caption)
{
	caption_ = caption;
}

void CVisualCppRunDlg::SetTitle(const wstring& title)
{
	title_ = title;
}


CVisualCppRunDlg::enVcRunMode CVisualCppRunDlg::GetRunMode() const
{
	return runMode_;
}

BOOL CVisualCppRunDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	SetWindowText(caption_.c_str());
	lblTitle_.SetWindowText(title_.c_str());

	CButton* opt;

	opt = (CButton*)GetDlgItem(IDC_OPT1);
	opt->SetCheck(TRUE);

	runMode_ = enVcRunMode_ExecuteAndCompile;

	chkRunTestProject_.EnableWindow(testProjectEnabled_);

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

void CVisualCppRunDlg::OnOpt1() 
{
	runMode_ = enVcRunMode_ExecuteAndCompile;	
}

void CVisualCppRunDlg::OnOpt2() 
{
	runMode_ = enVcRunMode_Execute;	
}

void CVisualCppRunDlg::OnRadio3() 
{
	runMode_ = enVcRunMode_None;		
}

bool CVisualCppRunDlg::GetTestProjectRun() const
{
	return testProjectRun_;
}

void CVisualCppRunDlg::SetTestProjectEnabled(bool enable)
{
	testProjectEnabled_ = enable;
}
