diff options
Diffstat (limited to 'src/T2DLL/T2DlgItemICheck.cpp')
-rw-r--r-- | src/T2DLL/T2DlgItemICheck.cpp | 78 |
1 files changed, 71 insertions, 7 deletions
diff --git a/src/T2DLL/T2DlgItemICheck.cpp b/src/T2DLL/T2DlgItemICheck.cpp index b138e73..e4c4900 100644 --- a/src/T2DLL/T2DlgItemICheck.cpp +++ b/src/T2DLL/T2DlgItemICheck.cpp @@ -1,22 +1,86 @@ +#include "T2BitImage.h" #include "T2DlgItemICheck.h" -T2DlgItemICheck::T2DlgItemICheck(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2DlgItemICheck::T2DlgItemICheck(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2DlgItem(inDoc, inImageObj, inPalette) +{ } -/*virtual*/ int T2DlgItemICheck::Create(const char*, unsigned long, const RECT&, CWnd*, unsigned int) { +/*virtual*/ BOOL T2DlgItemICheck::Create(const char* windowName, DWORD style, const RECT& inRect, CWnd* parentWnd, UINT nId) { + CRect rect = inRect; + CRect imageRect; + + if (GetObjectImage(imageRect, windowName)) { + rect.right = rect.left + imageRect.Width(); + rect.bottom = rect.top + imageRect.Height(); + } else { + rect.right = rect.left + 20; + rect.bottom = rect.top + 20; + } + + return T2DlgItem::Create(windowName, style, rect, parentWnd, nId); } -/*virtual*/ void T2DlgItemICheck::SetValue(int) { +/*virtual*/ void T2DlgItemICheck::SetValue(int inValue) { + T2DlgItem::SetValue(inValue); + + if (mValue == 0) + SetPattern(0); + else if (mValue == 1) + SetPattern(100); } -/*virtual*/ int T2DlgItemICheck::OnT2DlgItemEraseBkgnd(CDC*) { +#pragma var_order(pen, imageRect, brush, clientRect, theImage, text, save) +/*virtual*/ BOOL T2DlgItemICheck::OnT2DlgItemEraseBkgnd(CDC* pDC) { + CRect clientRect; + GetClientRect(clientRect); + + int save = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + CPen pen; + CBrush brush; + + CString text; + GetWindowText(text); + + RECT imageRect; + T2BitImage *theImage = GetObjectImage(imageRect, text, GetPattern()); + if (theImage) { + theImage->CopyImage(pDC, imageRect, clientRect); + } else { + pen.CreateStockObject(BLACK_PEN); + brush.CreateStockObject(WHITE_BRUSH); + pDC->SelectObject(&pen); + pDC->SelectObject(&brush); + + pDC->Rectangle(clientRect); + if (GetPattern() == 100) { + pDC->MoveTo(clientRect.left, clientRect.top); + pDC->LineTo(clientRect.right, clientRect.bottom); + + pDC->MoveTo(clientRect.left, clientRect.bottom - 1); + pDC->LineTo(clientRect.right, clientRect.top - 1); + } + } + + pDC->RestoreDC(save); + return true; } -/*virtual*/ void T2DlgItemICheck::OnT2DlgItemLButtonDown(unsigned int, CPoint) { +/*virtual*/ void T2DlgItemICheck::OnT2DlgItemLButtonDown(UINT, CPoint) { + SetCapture(); + m74 = true; + + SetValue(!mValue); + Notify(mValue ? 2 : 3, NULL); } -/*virtual*/ void T2DlgItemICheck::OnT2DlgItemLButtonUp(unsigned int, CPoint) { +/*virtual*/ void T2DlgItemICheck::OnT2DlgItemLButtonUp(UINT, CPoint) { + ReleaseCapture(); + m74 = false; } -/*virtual*/ void T2DlgItemICheck::OnT2DlgItemMouseMove(unsigned int, CPoint) { +/*virtual*/ void T2DlgItemICheck::OnT2DlgItemMouseMove(UINT, CPoint) { } |