// CfgEdit.cpp : implementation file
//

#include "stdafx.h"
#include "AsCfgBuilder.h"
#include "CfgEdit.h"
#include "MemDC.h"
#include "DrawUtils.h"
#include "GuiDefs.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCfgEdit

CCfgEdit::CCfgEdit()
{
}

CCfgEdit::~CCfgEdit()
{
}


BEGIN_MESSAGE_MAP(CCfgEdit, CEdit)
	//{{AFX_MSG_MAP(CCfgEdit)
	ON_WM_ERASEBKGND()
	ON_WM_NCPAINT()
	ON_WM_CTLCOLOR_REFLECT()
	ON_WM_CREATE()
//	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCfgEdit message handlers

BOOL CCfgEdit::OnEraseBkgnd(CDC* pDC) 
{
	return CEdit::OnEraseBkgnd(pDC); //return TRUE;
}


void CCfgEdit::OnNcPaint() 
{
	Default();

	/*CPaintDC dc(this); // device context for painting
	CRect rc;
	CBrush b(::GetSysColor(COLOR_WINDOW));
	cmString tmp;
	DWORD style;

	GetClientRect(rc);
	
	style = GetStyle();

	dc.FillRect(rc, &b);
	rc.InflateRect(1, 1, 0, 0);
	
	if(style & WS_VSCROLL)
		rc.InflateRect(0,0, ::GetSystemMetrics(SM_CXVSCROLL), 0);
	
	if(style & WS_HSCROLL)
		rc.InflateRect(0,0, ::GetSystemMetrics(SM_CYHSCROLL), 0);
		
	DrawUtils::DrawRect(&dc, rc, DIALOG_EDITBOX_BORDER_COLOR);

	rc.DeflateRect(1,1,0,0);
	GetWindowText(tmp);
	DrawUtils::DrawString(&dc, tmp, rc, DT_LEFT | DT_NOPREFIX, DIALOG_EDITBOX_FORE_COLOR, GetFont());
	*/
}

HBRUSH CCfgEdit::CtlColor(CDC* pDC, UINT nCtlColor) 
{
	if (brush_.GetSafeHandle() == NULL)
		brush_.CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
	
	if (nCtlColor == CTLCOLOR_EDIT) {
		pDC->SetBkColor(::GetSysColor(COLOR_WINDOW));
		pDC->SetBkMode(OPAQUE);
		pDC->SetTextColor(DIALOG_EDITBOX_FORE_COLOR);
		return brush_;
	}	
	
	return NULL;
}

int CCfgEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	
	if (CEdit::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	/*CRect rc;

	GetWindowRect(rc);
	GetParent()->ScreenToClient(rc);
	rc.DeflateRect(1,1,0,0);
	SetWindowPos(&CWnd::wndTop, rc.left, rc.top, rc.Width(), rc.Height(), 0);*/
	return 0;
}
