summaryrefslogtreecommitdiff
path: root/src/T2DLL/CToggleButtonDisabled.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/T2DLL/CToggleButtonDisabled.cpp86
1 files changed, 86 insertions, 0 deletions
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) {
+}