#include "T2DlgItemAllPurpose.h" T2DlgItemAllPurpose::T2DlgItemAllPurpose(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) : T2DlgItem(inDoc, inImageObj, inPalette) { #line 16 mDownPoint = DEBUG_NEW CPoint(-1, -1); mUpPoint = DEBUG_NEW CPoint(-1, -1); mButton = -1; } /*virtual*/ T2DlgItemAllPurpose::~T2DlgItemAllPurpose() { delete mDownPoint; delete mUpPoint; } /*virtual*/ BOOL T2DlgItemAllPurpose::OnT2DlgItemEraseBkgnd(CDC* pDC) { CRect rect; GetClientRect(rect); int save = pDC->SaveDC(); pDC->SelectPalette(mPalette, false); pDC->RealizePalette(); CPen whitePen; whitePen.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255)); CPen greyPen; greyPen.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133)); pDC->SelectObject(greyPen); pDC->MoveTo(rect.right - 1, rect.top); pDC->LineTo(rect.left, rect.top); pDC->LineTo(rect.left, rect.bottom); pDC->SelectObject(whitePen); pDC->MoveTo(rect.right - 1, rect.top + 1); pDC->LineTo(rect.right - 1, rect.bottom - 1); pDC->LineTo(rect.left, rect.bottom - 1); pDC->RestoreDC(save); return true; } /*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemLButtonDown(UINT, CPoint inPt) { *mDownPoint = inPt; mButton = 0; } /*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemLButtonUp(UINT, CPoint inPt) { *mUpPoint = inPt; if (mButton == 0) { mButton = 0; CSize delta = *mDownPoint - *mUpPoint; if (abs(delta.cx) < 2 && abs(delta.cy) < 2) Notify(GetDlgCtrlID(), 0, &mButton); } else { mButton = 0; } } /*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemRButtonDown(UINT, CPoint inPt) { *mDownPoint = inPt; mButton = 1; } /*virtual*/ void T2DlgItemAllPurpose::OnT2DlgItemRButtonUp(UINT, CPoint inPt) { *mUpPoint = inPt; if (mButton == 1) { mButton = 1; CSize delta = *mDownPoint - *mUpPoint; if (abs(delta.cx) < 2 && abs(delta.cy) < 2) Notify(GetDlgCtrlID(), 0, &mButton); } else { mButton = 1; } } CPoint T2DlgItemAllPurpose::GetUpPoint() { return *mUpPoint; } CPoint T2DlgItemAllPurpose::GetDownPoint() { return *mDownPoint; }