// EdIRCsNB.hpp : implementation file
//

#include "stdafx.h"

#include "Defines.hpp"

#ifdef D_ED_IR_ACTIVE

#include "EdIRCsNB.hpp"

#include "EdIRStrg.hpp"

#include "ITF/FrmGest.hpp"

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

/////////////////////////////////////////////////////////////////////////////
// class CPA_EdIR_NewConstantDialog dialog
/////////////////////////////////////////////////////////////////////////////

BEGIN_MESSAGE_MAP(CPA_EdIR_NewConstantDialog, CDialog)
	//{{AFX_MSG_MAP(CPA_EdIR_NewConstantDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/**********************************************************************************/
CPA_EdIR_NewConstantDialog::CPA_EdIR_NewConstantDialog(CString csType,CString csName,CString csValue,CWnd* pParent /*=NULL*/)
	: CDialog(CPA_EdIR_NewConstantDialog::IDD, &g_oBaseFrame)
{
	//{{AFX_DATA_INIT(CPA_EdIR_NewConstantDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_csType=csType;
	m_csName=csName;
	m_csValue=csValue;
}

/**********************************************************************************/
void CPA_EdIR_NewConstantDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPA_EdIR_NewConstantDialog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

/////////////////////////////////////////////////////////////////////////////
// CPA_EdIR_NewConstantDialog message handlers

/**********************************************************************************/
BOOL CPA_EdIR_NewConstantDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();

	((CComboBox *)GetDlgItem(IDC_COMBO_TYPE))->AddString(g_c_csInteger);
	((CComboBox *)GetDlgItem(IDC_COMBO_TYPE))->AddString(g_c_csDecimal);

	if(m_csType!="")
	{
		int	iCurSel=((CComboBox *)GetDlgItem(IDC_COMBO_TYPE))->FindStringExact(0,m_csType);
		if(iCurSel!=CB_ERR)
		{
			((CComboBox *)GetDlgItem(IDC_COMBO_TYPE))->SetCurSel(iCurSel);

			GetDlgItem(IDC_COMBO_TYPE)->EnableWindow(FALSE);
		}
		else
		{
			AfxMessageBox("CPA_EdIR_NewConstantDialog::OnInitDialog : Unkonwn type "+m_csType);

			ASSERT(FALSE);
		}
	}

	if(m_csName!="")
	{
		GetDlgItem(IDC_EDIT_CONSTNAME)->SetWindowText(m_csName);

		GetDlgItem(IDC_EDIT_CONSTNAME)->EnableWindow(FALSE);
	}

	if(m_csValue!="")
		GetDlgItem(IDC_EDIT_VALUE)->SetWindowText(m_csValue);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

/**********************************************************************************/
void CPA_EdIR_NewConstantDialog::OnOK() 
{
	BOOL	bError=FALSE;

	GetDlgItem(IDC_COMBO_TYPE)->GetWindowText(m_csType);
	if(m_csType=="")
	{
		AfxMessageBox("You must enter a type");
		bError=TRUE;
	}

	GetDlgItem(IDC_EDIT_CONSTNAME)->GetWindowText(m_csName);
	if(m_csName=="")
	{
		AfxMessageBox("You must enter a name");
		bError=TRUE;
	}

	GetDlgItem(IDC_EDIT_VALUE)->GetWindowText(m_csValue);
	if(m_csValue=="")
	{
		AfxMessageBox("You must enter a valid value");
		bError=TRUE;
	}

	if(bError==FALSE)
		CDialog::OnOK();
}

#endif //D_ED_IR_ACTIVE
