From 37e364b2c6cc7487a1c888d256a73e5337bb7189 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Jun 2023 00:50:34 +0100 Subject: initial commit --- src/T2DLL/CToggleButtonDisabled.cpp | 86 +++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/T2DLL/CToggleButtonDisabled.cpp (limited to 'src/T2DLL/CToggleButtonDisabled.cpp') diff --git a/src/T2DLL/CToggleButtonDisabled.cpp b/src/T2DLL/CToggleButtonDisabled.cpp new file mode 100644 index 0000000..e31ae08 --- /dev/null +++ b/src/T2DLL/CToggleButtonDisabled.cpp @@ -0,0 +1,86 @@ +#include "CToggleButtonDisabled.h" +#include "T2BitImage.h" + +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, -1, 0, 0, 255)) { + 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 clientRect; + GetClientRect(clientRect); + + int savedDC = dc->SaveDC(); + + dc->SelectPalette(mPalette, false); + dc->RealizePalette(); + + CPen pen; + CBrush brush; + + CString text; + GetWindowText(text); + + RECT imageRect; + T2BitImage *image = GetObjectImage(imageRect, text, GetPattern(), 0, 0, 255); + if (image) + image->CopyImage(dc, imageRect, clientRect, 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) { +} -- cgit v1.2.3