summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DlgItemEdit.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/T2DlgItemEdit.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2DlgItemEdit.cpp116
1 files changed, 106 insertions, 10 deletions
diff --git a/src/T2DLL/T2DlgItemEdit.cpp b/src/T2DLL/T2DlgItemEdit.cpp
index f906c49..d614890 100644
--- a/src/T2DLL/T2DlgItemEdit.cpp
+++ b/src/T2DLL/T2DlgItemEdit.cpp
@@ -1,40 +1,136 @@
+#include "CEditWFocus.h"
#include "T2DlgItemEdit.h"
-T2DlgItemEdit::T2DlgItemEdit(T2TowerDoc*, T2ImageObj*, CPalette*) {
+T2DlgItemEdit::T2DlgItemEdit(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
+ : T2DlgItem(inDoc, inImageObj, inPalette)
+ , mSubItem(NULL)
+{
}
/*virtual*/ T2DlgItemEdit::~T2DlgItemEdit() {
+ delete mSubItem;
}
-/*virtual*/ void T2DlgItemEdit::SetFont(HFONT) {
+/*virtual*/ void T2DlgItemEdit::SetFont(HFONT inFont) {
+ T2DlgItem::SetFont(inFont);
+
+ if (mSubItem)
+ mSubItem->SetFont(CFont::FromHandle(inFont));
}
-/*virtual*/ void T2DlgItemEdit::CreateSubItem(void*) {
+/*virtual*/ void T2DlgItemEdit::CreateSubItem(void* inData) {
+ mSubItem = new CEditWFocus;
+
+ int value = *((int *) inData);
+
+ CRect rect;
+ GetClientRect(rect);
+
+ if (rect.Height() < (value + 4))
+ value = rect.Height() - 4;
+
+ rect.top += (rect.Height() - value) / 2;
+ rect.left += 2;
+ rect.bottom = rect.top + value;
+ rect.right -= 2;
+ mSubItem->Create(WS_VISIBLE | WS_CHILD, rect, this, 0);
}
-/*virtual*/ int T2DlgItemEdit::OnT2DlgItemEraseBkgnd(CDC*) {
+#pragma var_order(brush3, brush2, rect, pen1, pen2, save, pen3, brush1)
+/*virtual*/ BOOL T2DlgItemEdit::OnT2DlgItemEraseBkgnd(CDC* pDC) {
+ CRect rect;
+ GetClientRect(rect);
+
+ CPen pen1;
+ pen1.CreatePen(PS_SOLID, 0, PALETTERGB(255, 255, 255));
+
+ CPen pen2;
+ pen2.CreatePen(PS_SOLID, 0, PALETTERGB(133, 133, 133));
+
+ CPen pen3;
+ pen3.CreatePen(PS_SOLID, 0, PALETTEINDEX(255));
+
+ CBrush brush1;
+ CBrush brush2;
+ CBrush brush3;
+
+ int save = pDC->SaveDC();
+ pDC->SelectPalette(mPalette, false);
+ pDC->RealizePalette();
+
+ if (IsWindowEnabled()) {
+ pDC->SelectObject(pen2);
+ pDC->MoveTo(rect.right - 1, rect.top);
+ pDC->LineTo(rect.left, rect.top);
+ pDC->LineTo(rect.left, rect.bottom);
+
+ pDC->SelectObject(pen1);
+ pDC->MoveTo(rect.right - 1, rect.top + 1);
+ pDC->LineTo(rect.right - 1, rect.bottom - 1);
+ pDC->LineTo(rect.left, rect.bottom - 1);
+
+ rect.DeflateRect(1, 1);
+
+ brush2.CreateSolidBrush(PALETTERGB(255, 255, 255));
+ pDC->SelectObject(brush2);
+ pDC->SelectObject(pen3);
+ pDC->Rectangle(rect);
+
+ brush3.CreateSolidBrush(PALETTEINDEX(255));
+ pDC->FrameRect(rect, &brush3);
+ } else {
+ brush1.CreateSolidBrush(PALETTERGB(179, 179, 179));
+ pDC->FrameRect(rect, &brush1);
+ }
+
+ pDC->RestoreDC(save);
+ return true;
}
-/*virtual*/ void T2DlgItemEdit::GetDescriptor(CString&) const {
+/*virtual*/ void T2DlgItemEdit::GetDescriptor(CString& outStr) const {
+ if (mSubItem)
+ mSubItem->GetWindowText(outStr);
}
-/*virtual*/ void T2DlgItemEdit::SetDescriptor(const CString&) {
+/*virtual*/ void T2DlgItemEdit::SetDescriptor(const CString& inStr) {
+ if (mSubItem)
+ mSubItem->SetWindowText(inStr);
}
/*virtual*/ int T2DlgItemEdit::GetValue() {
+ int value = 0;
+ CString str;
+
+ GetDescriptor(str);
+ if (str.GetLength() > 0) {
+ value = atoi(str);
+ mValue = value;
+ }
+
+ return value;
}
-/*virtual*/ void T2DlgItemEdit::SetValue(int) {
+/*virtual*/ void T2DlgItemEdit::SetValue(int inValue) {
+ T2DlgItem::SetValue(inValue);
+
+ CString str;
+ str.Format("%d", T2DlgItem::GetValue());
+ SetDescriptor(str);
}
void T2DlgItemEdit::SelectAll() {
+ if (mSubItem)
+ mSubItem->SetSel(0, -1);
}
-/*virtual*/ void T2DlgItemEdit::OnT2SetFocus(CWnd*) {
+/*virtual*/ void T2DlgItemEdit::OnT2SetFocus(CWnd* inWnd) {
}
-/*virtual*/ void T2DlgItemEdit::OnT2KillFocus(CWnd*) {
+/*virtual*/ void T2DlgItemEdit::OnT2KillFocus(CWnd* inWnd) {
}
-/*virtual*/ void T2DlgItemEdit::OnT2DlgItemEnable(int) {
+/*virtual*/ void T2DlgItemEdit::OnT2DlgItemEnable(BOOL inEnable) {
+ if (mSubItem)
+ mSubItem->EnableWindow(inEnable);
+ T2DlgItem::OnT2DlgItemEnable(inEnable);
}