#include "StdAfx.h" #include "T2DlgItemButtonBase.h" T2DlgItemButtonBase::T2DlgItemButtonBase(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) : T2DlgItem(inDoc, inImageObj, inPalette) , mIsClicked(false) { } /*virtual*/ void T2DlgItemButtonBase::OnT2DlgItemLButtonDown(UINT, CPoint) { SetCapture(); mIsClicked = true; m74 = true; SetPattern(100); Invalidate(); } /*virtual*/ void T2DlgItemButtonBase::OnT2DlgItemLButtonUp(UINT, CPoint) { if (mIsClicked) { ReleaseCapture(); mIsClicked = false; if (m74) { m74 = false; SetPattern(0); Invalidate(); Notify(GetDlgCtrlID(), 0, NULL); } } } /*virtual*/ void T2DlgItemButtonBase::OnT2DlgItemMouseMove(UINT, CPoint inPt) { if (mIsClicked) { CRect rect; GetClientRect(rect); BOOL inRect = rect.PtInRect(inPt); if (inRect != m74) { m74 = inRect; SetPattern(m74 ? 100 : 0); Invalidate(); } } } /*virtual*/ void T2DlgItemButtonBase::DrawButtonBase(CDC* pDC, const RECT& inRect, BOOL flag) { if (IsWindowEnabled() && flag) { #pragma var_order(brush, penB, save, penA) int save = pDC->SaveDC(); pDC->SelectPalette(mPalette, false); pDC->RealizePalette(); CPen penA; penA.CreatePen(PS_SOLID, 0, PALETTEINDEX(255)); CBrush brush; brush.CreateSolidBrush(PALETTERGB(179, 179, 179)); pDC->SelectObject(penA); pDC->SelectObject(brush); pDC->Rectangle(&inRect); CPen penB; penB.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133)); pDC->SelectObject(penB); pDC->MoveTo(inRect.right - 2, inRect.top + 1); pDC->LineTo(inRect.left + 1, inRect.top + 1); pDC->LineTo(inRect.left + 1, inRect.bottom - 1); pDC->RestoreDC(save); } else { #pragma var_order(brush, penB, penC, save, penA) int save = pDC->SaveDC(); pDC->SelectPalette(mPalette, false); pDC->RealizePalette(); CPen penA; penA.CreatePen(PS_SOLID, 0, PALETTEINDEX(255)); CBrush brush; brush.CreateSolidBrush(PALETTERGB(204, 204, 204)); pDC->SelectObject(penA); pDC->SelectObject(brush); pDC->Rectangle(&inRect); CPen penB; penB.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255)); CPen penC; penC.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133)); pDC->SelectObject(penB); pDC->MoveTo(inRect.right - 2, inRect.top + 1); pDC->LineTo(inRect.left + 1, inRect.top + 1); pDC->LineTo(inRect.left + 1, inRect.bottom - 1); pDC->SelectObject(penC); pDC->MoveTo(inRect.right - 2, inRect.top + 2); pDC->LineTo(inRect.right - 2, inRect.bottom - 2); pDC->LineTo(inRect.left + 1, inRect.bottom - 2); pDC->RestoreDC(save); } }