/*=========================================================================
*
* CPAdlang.cpp :  CPA_DialogLanguage - Implementation file
*
*
* Version			1.0
* Creation date
* Revision date
*
* Xavier Billault
*=======================================================================*/

#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"

#include "itf/CPAdLang.hpp"
#include "itf/CPAInter.hpp"

//#################################################################################
// CPA_DialogLanguage dialog
//#################################################################################

/*----------------------------------------
----------------------------------------*/
CPA_DialogLanguage::CPA_DialogLanguage(CPA_Interface *pclInterface,CStringList *pcslList,CWnd* pParent /*=NULL*/)
	: CDialog(CPA_DialogLanguage::IDD, pParent)
{
	m_pclInterface=pclInterface;
	m_pcslLanguageList=pcslList;
	//{{AFX_DATA_INIT(CPA_DialogLanguage)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


/*----------------------------------------
----------------------------------------*/
void CPA_DialogLanguage::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPA_DialogLanguage)
	//}}AFX_DATA_MAP
}


/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogLanguage, CDialog)
	//{{AFX_MSG_MAP(CPA_DialogLanguage)
	ON_BN_CLICKED(ID_LANG_SAVE, OnSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


//#################################################################################
// CPA_DialogLanguage message handlers
//#################################################################################

/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogLanguage::OnInitDialog ()
{
	// Create the dialog
	CDialog::OnInitDialog();

	// init combo
	CComboBox	*pclCombo=(CComboBox *)GetDlgItem(IDC_LANG_COMBO);
	
	pclCombo->ResetContent();

	POSITION	pos=m_pcslLanguageList->GetHeadPosition();
	while(pos!=NULL)
	{
		pclCombo->AddString(m_pcslLanguageList->GetNext(pos));
	}

	pclCombo->SetCurSel(0);

	return TRUE;
}


/*----------------------------------------
----------------------------------------*/
void CPA_DialogLanguage::OnOK()
{
	// set the current selection
	CComboBox	*pclCombo=(CComboBox *)GetDlgItem(IDC_LANG_COMBO);

	pclCombo->GetLBText(pclCombo->GetCurSel(),m_csLanguage);

	CDialog::OnOK();
}

/*----------------------------------------
----------------------------------------*/
void CPA_DialogLanguage::OnSave ()
{
	CComboBox	*pclCombo=(CComboBox *)GetDlgItem(IDC_LANG_COMBO);

	pclCombo->GetLBText(pclCombo->GetCurSel(),m_csLanguage);

	m_pclInterface->fn_vSaveLanguage(m_csLanguage);
}

#endif // ACTIVE_EDITOR
