diff options
Diffstat (limited to 'src/T2DLL/T2DlgItemButtonBase.cpp')
-rw-r--r-- | src/T2DLL/T2DlgItemButtonBase.cpp | 92 |
1 files changed, 87 insertions, 5 deletions
diff --git a/src/T2DLL/T2DlgItemButtonBase.cpp b/src/T2DLL/T2DlgItemButtonBase.cpp index 24fd54c..2ef7362 100644 --- a/src/T2DLL/T2DlgItemButtonBase.cpp +++ b/src/T2DLL/T2DlgItemButtonBase.cpp @@ -1,16 +1,98 @@ #include "T2DlgItemButtonBase.h" -T2DlgItemButtonBase::T2DlgItemButtonBase(T2TowerDoc*, T2ImageObj*, CPalette*) { +T2DlgItemButtonBase::T2DlgItemButtonBase(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) + : T2DlgItem(inDoc, inImageObj, inPalette) + , mIsClicked(false) +{ } -/*virtual*/ void T2DlgItemButtonBase::OnT2DlgItemLButtonDown(unsigned int, CPoint) { +/*virtual*/ void T2DlgItemButtonBase::OnT2DlgItemLButtonDown(UINT, CPoint) { + SetCapture(); + mIsClicked = true; + m74 = true; + SetPattern(100); + Invalidate(); } -/*virtual*/ void T2DlgItemButtonBase::OnT2DlgItemLButtonUp(unsigned int, CPoint) { +/*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(unsigned int, CPoint) { +/*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*, const RECT&, int) { +/*virtual*/ void T2DlgItemButtonBase::DrawButtonBase(CDC* pDC, const RECT& inRect, BOOL flag) { + if (IsWindowEnabled() && flag) { + 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 { + 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); + } } |