#include "CToggleButtonDisabled.h" #include "T2BitImage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CToggleButtonDisabled::CToggleButtonDisabled(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette) : T2DlgItem(towerDoc, imageObj, palette) { } /*virtual*/ BOOL CToggleButtonDisabled::Create(const char* windowName, DWORD style, const RECT& rect, CWnd* parentWnd, UINT nId) { CRect rect1 = rect; CRect rect2; if (GetObjectImage(rect2, windowName)) { rect1.right = rect1.left + rect2.Width(); rect1.bottom = rect1.top + rect2.Height(); } else { rect1.right = rect1.left + 20; rect1.bottom = rect1.top + 20; } return T2DlgItem::Create(windowName, style, rect1, parentWnd, nId); } /*virtual*/ void CToggleButtonDisabled::SetValue(int value) { T2DlgItem::SetValue(value); if (IsWindowEnabled()) { if (mValue == 0) SetPattern(0); else if (mValue == 1) SetPattern(100); } } void CToggleButtonDisabled::Enable() { EnableWindow(true); SetValue(mValue); } void CToggleButtonDisabled::Disable() { EnableWindow(false); SetPattern(200); } /*virtual*/ BOOL CToggleButtonDisabled::OnT2DlgItemEraseBkgnd(CDC* dc) { CRect theClientRect; GetClientRect(theClientRect); int savedDC = dc->SaveDC(); dc->SelectPalette(mPalette, false); dc->RealizePalette(); CPen pen; CBrush theBrush; CString text; GetWindowText(text); RECT theImageRect; T2BitImage *theImage = GetObjectImage(theImageRect, text, GetPattern()); if (theImage) theImage->CopyImage(dc, theImageRect, theClientRect, 0, NULL); dc->RestoreDC(savedDC); return true; } /*virtual*/ void CToggleButtonDisabled::OnT2DlgItemLButtonDown(UINT nFlags, CPoint pt) { SetCapture(); m74 = true; if (IsWindowEnabled()) { SetValue(!mValue); Notify(mValue ? 2 : 3, NULL); } } /*virtual*/ void CToggleButtonDisabled::OnT2DlgItemLButtonUp(UINT nFlags, CPoint pt) { ReleaseCapture(); m74 = false; } /*virtual*/ void CToggleButtonDisabled::OnT2DlgItemMouseMove(UINT nFlags, CPoint pt) { }