// PropertyEditorDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AsCfgBuilder.h"
#include "PropertyEditorDlg.h"
#include "ProjectItemView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPropertyEditorDlg dialog


CPropertyEditorDlg::CPropertyEditorDlg(int idd, CWnd* pParent /*=NULL*/)
	: CBaseDialog(idd, pParent)
{
	//{{AFX_DATA_INIT(CPropertyEditorDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


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


BEGIN_MESSAGE_MAP(CPropertyEditorDlg, CBaseDialog)
	//{{AFX_MSG_MAP(CPropertyEditorDlg)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPropertyEditorDlg message handlers

BOOL CPropertyEditorDlg::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_CHAR) {
		if (pMsg->lParam == VK_RETURN || pMsg->lParam == VK_ESCAPE)
			return TRUE;
	}
	
	return CBaseDialog::PreTranslateMessage(pMsg);
}

void CPropertyEditorDlg::UpdateAllViews(enUpdateViewReason reason)
{
	CProjectDoc* doc;

	doc = GetDocument();
	if (doc)
		doc->UpdateAllViews(NULL, reason);
}

CProjectDoc* CPropertyEditorDlg::GetDocument()
{
	CWnd* parentWnd;
	CProjectItemView* parentView;

	parentWnd = GetParent();
	if (parentWnd == NULL)
		return NULL;

	parentView = dynamic_cast<CProjectItemView*>(parentWnd);
	if (parentView == NULL)
		return NULL;

	return parentView->GetDocument();
}