#include "T2BitImage.h" #include "T2DlgItemICheck.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif T2DlgItemICheck::T2DlgItemICheck(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) : T2DlgItem(inDoc, inImageObj, inPalette) { } /*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 inValue) { T2DlgItem::SetValue(inValue); if (mValue == 0) SetPattern(0); else if (mValue == 1) SetPattern(100); } #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(UINT, CPoint) { SetCapture(); m74 = true; SetValue(!mValue); Notify(mValue ? 2 : 3, NULL); } /*virtual*/ void T2DlgItemICheck::OnT2DlgItemLButtonUp(UINT, CPoint) { ReleaseCapture(); m74 = false; } /*virtual*/ void T2DlgItemICheck::OnT2DlgItemMouseMove(UINT, CPoint) { }