summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DlgItemTab.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/T2DlgItemTab.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2DlgItemTab.cpp158
1 files changed, 152 insertions, 6 deletions
diff --git a/src/T2DLL/T2DlgItemTab.cpp b/src/T2DLL/T2DlgItemTab.cpp
index f9989b0..fdf0d2f 100644
--- a/src/T2DLL/T2DlgItemTab.cpp
+++ b/src/T2DLL/T2DlgItemTab.cpp
@@ -1,22 +1,168 @@
+#include "CTokenizer.h"
#include "T2DlgItemTab.h"
-T2DlgItemTab::T2DlgItemTab(T2TowerDoc*, T2ImageObj*, CPalette*) {
+// oops, no name for this lad
+class CustomTabControl : public CTabCtrl {
+ DECLARE_MESSAGE_MAP()
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+
+public:
+ CPalette *mPalette;
+};
+
+T2DlgItemTab::T2DlgItemTab(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
+ : T2DlgItem(inDoc, inImageObj, inPalette)
+ , mSubItem(NULL)
+{
}
/*virtual*/ T2DlgItemTab::~T2DlgItemTab() {
+ delete mSubItem;
+}
+
+/*virtual*/ int T2DlgItemTab::OnT2DlgItemCreate(CREATESTRUCT* cs) {
+ T2DlgItem::OnT2DlgItemCreate(cs);
+ return 0;
}
-/*virtual*/ int T2DlgItemTab::OnT2DlgItemCreate(CREATESTRUCTA*) {
+/*virtual*/ void T2DlgItemTab::SetFont(HFONT inFont) {
+ T2DlgItem::SetFont(inFont);
+
+ if (mSubItem)
+ mSubItem->SetFont(CFont::FromHandle(inFont));
+}
+
+/*virtual*/ void T2DlgItemTab::CreateSubItem(void* inData) {
+ mSubItem = new CustomTabControl;
+ mSubItem->mPalette = mPalette;
+
+ CRect clientRect;
+ GetClientRect(clientRect);
+ clientRect.bottom = clientRect.top + 20;
+ mSubItem->Create(WS_VISIBLE | WS_CHILD, clientRect, this, 0);
+
+ char *buf = (char *) calloc(GetWindowTextLength() + 1, 1);
+ GetWindowText(buf, GetWindowTextLength());
+
+ if (strlen(buf) != 0 && buf[0] != '-') {
+ CTokenizer theTokenizer(buf, "|\r\n");
+ const char *itemText = theTokenizer.NextString();
+ int i = 0;
+
+ while (itemText) {
+ TCITEM item;
+ item.mask = TCIF_TEXT | TCIF_PARAM;
+ item.pszText = (LPSTR) itemText;
+ item.cchTextMax = strlen(itemText);
+ item.lParam = i;
+ mSubItem->InsertItem(i, &item);
+ i++;
+ itemText = theTokenizer.NextString();
+ }
+ }
+
+ free(buf);
}
-/*virtual*/ void T2DlgItemTab::SetFont(HFONT) {
+/*virtual*/ BOOL T2DlgItemTab::OnT2DlgItemEraseBkgnd(CDC* pDC) {
+#pragma var_order(rect, pen1, pen2, save, brush, pen3, pen4)
+ CRect rect;
+ GetClientRect(rect);
+ rect.top += 20;
+
+ 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));
+ CPen pen4;
+ pen4.CreatePen(PS_SOLID, 0, PALETTERGB(224, 224, 224));
+
+ CBrush brush;
+
+ int save = pDC->SaveDC();
+ pDC->SelectPalette(mPalette, false);
+ pDC->RealizePalette();
+
+ if (IsWindowEnabled()) {
+ pDC->SelectObject(pen3);
+
+ pDC->MoveTo(rect.right - 2, rect.top - 2);
+ pDC->LineTo(rect.right - 2, rect.top - 1);
+
+ pDC->MoveTo(rect.right - 1, rect.top - 1);
+ pDC->LineTo(rect.right - 1, rect.bottom - 1);
+ pDC->LineTo(rect.left, rect.bottom - 1);
+
+ pDC->SelectObject(pen2);
+
+ pDC->MoveTo(rect.right - 2, rect.top + 1);
+ pDC->LineTo(rect.right - 2, rect.bottom - 2);
+ pDC->LineTo(rect.left + 1, rect.bottom - 2);
+
+ pDC->SelectObject(pen1);
+
+ pDC->MoveTo(rect.left, rect.bottom - 1);
+ pDC->LineTo(rect.left, rect.top);
+
+ pDC->SelectObject(pen4);
+
+ pDC->MoveTo(rect.left + 1, rect.bottom - 2);
+ pDC->LineTo(rect.left + 1, rect.top);
+ } else {
+ brush.CreateSolidBrush(PALETTERGB(179, 179, 179));
+ pDC->FrameRect(rect, &brush);
+ }
+
+ pDC->RestoreDC(save);
+ return true;
}
-/*virtual*/ void T2DlgItemTab::CreateSubItem(void*) {
+/*virtual*/ LRESULT T2DlgItemTab::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
+ if (mSubItem) {
+ switch (message) {
+ case WM_NOTIFY: {
+ NMHDR *hdr = (NMHDR *) lParam;
+ if (hdr->code == TCN_SELCHANGE) {
+ int num = mSubItem->GetCurSel() + 1;
+ BroadcastMessage(-GetDlgCtrlID(), &num);
+ return 0;
+ }
+ break;
+ }
+
+ default:
+ return CWnd::WindowProc(message, wParam, lParam);
+ }
+ }
+
+ return CWnd::WindowProc(message, wParam, lParam);
}
-/*virtual*/ int T2DlgItemTab::OnT2DlgItemEraseBkgnd(CDC*) {
+
+
+/*virtual*/ LRESULT CustomTabControl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
+ switch (message) {
+ default:
+ return CWnd::WindowProc(message, wParam, lParam);
+ }
}
-/*virtual*/ long T2DlgItemTab::WindowProc(unsigned int, unsigned int, long) {
+BEGIN_MESSAGE_MAP(CustomTabControl, CTabCtrl)
+ ON_WM_ERASEBKGND()
+END_MESSAGE_MAP()
+
+afx_msg BOOL CustomTabControl::OnEraseBkgnd(CDC* pDC) {
+ int save = pDC->SaveDC();
+ pDC->SelectPalette(mPalette, false);
+ pDC->RealizePalette();
+
+ CRect clientRect;
+ GetClientRect(clientRect);
+ pDC->FillSolidRect(clientRect, PALETTERGB(204, 204, 204));
+
+ pDC->RestoreDC(save);
+ return true;
}