/******************************************************************************
**
** Authors : Edwin Chan (with help from MFC)
** Date    : 26-Nov-01
** Filename: PropDlg.cpp 
** Purpose : implementation of the CPropDlg class
**
** History:
** 26-Nov-01 Edwin Chan
**     File Created
** 02-Dec-01 Edwin Chan, Satish Hota
**     Implemented the dialog box.
******************************************************************************/

#include "stdafx.h"
#include "ConGraT.h"
#include "PropDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPropDlg property page

IMPLEMENT_DYNCREATE(CPropDlg, CPropertyPage)

CPropDlg::CPropDlg() : CPropertyPage(CPropDlg::IDD)
{
	//{{AFX_DATA_INIT(CPropDlg)
	m_strRef = _T("");
	//}}AFX_DATA_INIT
}

CPropDlg::~CPropDlg()
{
}

void CPropDlg::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPropDlg)
	DDX_Text(pDX, IDC_EDIT1, m_strRef);
	DDX_Control(pDX, IDC_LIST1, m_ListBox);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPropDlg, CPropertyPage)
	//{{AFX_MSG_MAP(CPropDlg)
	ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPropDlg message handlers

BOOL CPropDlg::OnInitDialog()
{
	CPropertyPage::OnInitDialog();
	CListBox *pLB = (CListBox *) GetDlgItem(IDC_LIST1);

	for(int i=0;i<m_vectorStrings.size();i++)
	{
		pLB->AddString(_T(m_vectorStrings[i].c_str()));
	}

	pLB->SetCurSel(m_nCursor);

	return TRUE;
}

void CPropDlg::SetTypes(std::vector<std::string> typesVector, int nCursor)
{
	m_vectorStrings = typesVector;
	m_nCursor = nCursor;
}

void CPropDlg::OnDblclkList1() 
{
	// TODO: Add your control notification handler code here
	CListBox *pLB = (CListBox *) GetDlgItem(IDC_LIST1);
	CString strSelected;
	m_nCursor = pLB->GetCurSel();

	pLB->GetText(m_nCursor, strSelected);

	m_strSelected = LPCTSTR(strSelected);
}
