#include "T2DlgItem.h" #include "T2ImageObj.h" #include "T2TowerDoc.h" #include "T2WorldDef.h" T2DlgItem::T2DlgItem() { } T2DlgItem::T2DlgItem(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette) { mTowerDoc = towerDoc; mImageObj = imageObj; mPalette = palette; mPattern = 0; m74 = 0; mFont = NULL; mValue = 0; } /*virtual*/ T2DlgItem::~T2DlgItem() { } BEGIN_MESSAGE_MAP(T2DlgItem, CWnd) ON_WM_ERASEBKGND() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_RBUTTONDOWN() ON_WM_RBUTTONUP() ON_WM_MOUSEMOVE() ON_WM_ENABLE() ON_WM_CREATE() ON_WM_SIZE() ON_WM_SETFOCUS() ON_WM_KILLFOCUS() ON_WM_TIMER() ON_WM_CLOSE() END_MESSAGE_MAP() /*virtual*/ BOOL T2DlgItem::Create(const char* inWindowName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID) { CRect crect = inRect; CString className = AfxRegisterWndClass( WS_EX_CLIENTEDGE, LoadCursor(NULL, IDC_ARROW), (HBRUSH) GetStockObject(WHITE_BRUSH), NULL); return CWnd::Create(className, inWindowName, inStyle, crect, inParentWnd, inID); } /*virtual*/ T2BitImage* T2DlgItem::GetObjectImage(RECT& outRect, const char* inName, int inPattern, int inGrade, int inSpan, int inOffset) const { T2BitImage *theImage = NULL; int index; if (mImageObj) { index = mImageObj->FindObject(inName, inPattern, inGrade, inSpan, inOffset); if (index != -1) theImage = mImageObj->GetObjectImage(index, outRect); } if (!theImage && mTowerDoc && mTowerDoc->mWorldDef) { index = mTowerDoc->mWorldDef->mImageObj->FindObject(inName, inPattern, inGrade, inSpan, inOffset); if (index != -1) theImage = mTowerDoc->mWorldDef->mImageObj->GetObjectImage(index, outRect); } return theImage; } /*virtual*/ void T2DlgItem::PostNcDestroy() { DestroySelf(); } /*virtual*/ void T2DlgItem::DestroySelf() { delete this; } /*virtual*/ BOOL T2DlgItem::OnT2DlgItemEraseBkgnd(CDC*) { return false; } /*virtual*/ void T2DlgItem::OnT2DlgItemLButtonDown(UINT nFlags, CPoint pt) { } /*virtual*/ void T2DlgItem::OnT2DlgItemLButtonUp(UINT nFlags, CPoint pt) { } /*virtual*/ void T2DlgItem::OnT2DlgItemRButtonDown(UINT nFlags, CPoint pt) { } /*virtual*/ void T2DlgItem::OnT2DlgItemRButtonUp(UINT nFlags, CPoint pt) { } /*virtual*/ void T2DlgItem::OnT2DlgItemMouseMove(UINT nFlags, CPoint pt) { } /*virtual*/ void T2DlgItem::OnT2DlgItemEnable(int) { Invalidate(); } /*virtual*/ int T2DlgItem::OnT2DlgItemCreate(CREATESTRUCT*) { return false; } BOOL T2DlgItem::OnEraseBkgnd(CDC* pDC) { return OnT2DlgItemEraseBkgnd(pDC); } void T2DlgItem::OnLButtonDown(UINT nFlags, CPoint pt) { OnT2DlgItemLButtonDown(nFlags, pt); } void T2DlgItem::OnLButtonUp(UINT nFlags, CPoint pt) { OnT2DlgItemLButtonUp(nFlags, pt); } void T2DlgItem::OnRButtonDown(UINT nFlags, CPoint pt) { OnT2DlgItemRButtonDown(nFlags, pt); } void T2DlgItem::OnRButtonUp(UINT nFlags, CPoint pt) { OnT2DlgItemRButtonUp(nFlags, pt); } void T2DlgItem::OnMouseMove(UINT nFlags, CPoint pt) { OnT2DlgItemMouseMove(nFlags, pt); } void T2DlgItem::OnEnable(int v) { CWnd::OnEnable(v); OnT2DlgItemEnable(v); } int T2DlgItem::OnCreate(CREATESTRUCT* cs) { if (CWnd::OnCreate(cs) == -1) return -1; return OnT2DlgItemCreate(cs); } /*virtual*/ void T2DlgItem::CreateSubItem(void*) { } /*virtual*/ void T2DlgItem::SetFont(HFONT font) { mFont = font; Invalidate(); } /*virtual*/ int T2DlgItem::GetValue() { return mValue; } /*virtual*/ void T2DlgItem::SetValue(int value) { mValue = value; Invalidate(); } /*virtual*/ void T2DlgItem::GetDescriptor(CString& outStr) const { GetWindowText(outStr); } /*virtual*/ void T2DlgItem::SetDescriptor(const CString& str) { SetWindowText(str); } void T2DlgItem::Notify(unsigned short msg, void* data) { Notify(GetDlgCtrlID(), msg, data); } void T2DlgItem::Notify(unsigned short id, unsigned short msg, void* data) { BroadcastMessage(id, data); GetParent()->SendMessage(WM_COMMAND, id | (msg << 16), (LPARAM) m_hWnd); } int T2DlgItem::GetPattern() const { return IsWindowEnabled() ? mPattern : 200; } void T2DlgItem::SetPattern(int pattern) { mPattern = pattern; } void T2DlgItem::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); OnT2Size(nType, cx, cy); } /*virtual*/ void T2DlgItem::OnT2Size(UINT nType, int cx, int cy) { } void T2DlgItem::OnSetFocus(CWnd* wnd) { CWnd::OnSetFocus(wnd); OnT2SetFocus(wnd); } void T2DlgItem::OnKillFocus(CWnd* wnd) { CWnd::OnKillFocus(wnd); OnT2KillFocus(wnd); } /*virtual*/ void T2DlgItem::OnT2SetFocus(CWnd* wnd) { } /*virtual*/ void T2DlgItem::OnT2KillFocus(CWnd* wnd) { } void T2DlgItem::OnTimer(UINT id) { OnT2Timer(id); CWnd::OnTimer(id); } /*virtual*/ void T2DlgItem::OnT2Timer(UINT id) { } void T2DlgItem::OnClose() { OnT2Close(); CWnd::OnClose(); } /*virtual*/ void T2DlgItem::OnT2Close() { }