summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DlgItemButtonBase.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
commitc0c336500955a23e344651e5412c9d9d441ef4ee (patch)
tree790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2DlgItemButtonBase.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2DlgItemButtonBase.cpp92
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);
+ }
}