summaryrefslogtreecommitdiff
path: root/redo
diff options
context:
space:
mode:
Diffstat (limited to 'redo')
-rw-r--r--redo/common_windows.c37
-rw-r--r--redo/winapi_windows.h1
-rw-r--r--redo/zz_test.go13
3 files changed, 47 insertions, 4 deletions
diff --git a/redo/common_windows.c b/redo/common_windows.c
index 50be912..6b6f08f 100644
--- a/redo/common_windows.c
+++ b/redo/common_windows.c
@@ -89,10 +89,13 @@ BOOL sharedWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *
*lResult = forwardNotify(hwnd, uMsg, wParam, lParam);
return TRUE;
case WM_CTLCOLORSTATIC:
+ case WM_CTLCOLORBTN:
exstyle = (DWORD) GetWindowLongPtrW((HWND) lParam, GWL_EXSTYLE);
- if ((exstyle & WS_EX_TRANSPARENT) != 0) {
+ // TODO clean this up
+{// if ((exstyle & WS_EX_TRANSPARENT) != 0) {
if (SetBkMode((HDC) wParam, TRANSPARENT) == 0)
xpanic("error setting transparent background mode to Labels", GetLastError());
+ paintControlBackground((HWND) lParam, (HDC) wParam);
*lResult = (LRESULT) hollowBrush;
return TRUE;
}
@@ -100,3 +103,35 @@ BOOL sharedWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *
}
return FALSE;
}
+
+void paintControlBackground(HWND hwnd, HDC dc)
+{
+ HWND parent;
+ RECT r;
+ POINT p;
+ int saved;
+
+ // TODO traverse deeper if a groupbox
+ // TODO implement WM_PRINTCLIENT in window_windows.c
+ parent = GetParent(hwnd);
+ if (parent == NULL)
+ xpanic("error getting parent container of control in paintControlBackground()", GetLastError());
+ parent = GetParent(parent);
+ if (parent == NULL)
+ xpanic("error getting parent control of control in paintControlBackground()", GetLastError());
+ if (GetWindowRect(hwnd, &r) == 0)
+ xpanic("error getting control's window rect in paintControlBackground()", GetLastError());
+ // the above is a window rect; convert to client rect
+ p.x = r.left;
+ p.y = r.top;
+ if (ScreenToClient(parent, &p) == 0)
+ xpanic("error getting client origin of control in paintControlBackground()", GetLastError());
+ saved = SaveDC(dc);
+ if (saved == 0)
+ xpanic("error saving DC info in paintControlBackground()", GetLastError());
+ if (SetWindowOrgEx(dc, p.x, p.y, NULL) == 0)
+ xpanic("error moving window origin in paintControlBackground()", GetLastError());
+ SendMessageW(parent, WM_PRINTCLIENT, (WPARAM) dc, PRF_CLIENT);
+ if (RestoreDC(dc, saved) == 0)
+ xpanic("error restoring DC info in paintControlBackground()", GetLastError());
+}
diff --git a/redo/winapi_windows.h b/redo/winapi_windows.h
index 743c819..83f7822 100644
--- a/redo/winapi_windows.h
+++ b/redo/winapi_windows.h
@@ -100,6 +100,7 @@ extern void setWindowText(HWND, LPWSTR);
extern void updateWindow(HWND);
extern void *getWindowData(HWND, UINT, WPARAM, LPARAM, LRESULT *, void (*)(void *, HWND));
extern BOOL sharedWndProc(HWND, UINT, WPARAM, LPARAM, LRESULT *);
+extern void paintControlBackground(HWND, HDC);
// tab_windows.go
extern LPWSTR xWC_TABCONTROL;
diff --git a/redo/zz_test.go b/redo/zz_test.go
index 0afd7d7..dbf68bc 100644
--- a/redo/zz_test.go
+++ b/redo/zz_test.go
@@ -116,13 +116,20 @@ func (tw *testwin) addfe() {
OpenFile(tw.w, tw.openFile)
})
tw.fnlabel = NewStandaloneLabel("<no file selected>")
- tw.festack = NewVerticalStack(tw.festart, tw.felabel, tw.festop,
+ tw.festack = NewVerticalStack(tw.festart,
+ tw.felabel,
+ tw.festop,
+ NewCheckbox("This is a checkbox test"),
Space(),
tw.vedit,
Space(),
+ NewCheckbox("This is a checkbox test"),
tw.openbtn, tw.fnlabel)
- tw.festack.SetStretchy(3)
- tw.festack.SetStretchy(5)
+ tw.festack.SetStretchy(4)
+ tw.festack.SetStretchy(6)
+ tw.festack = NewHorizontalStack(tw.festack, Space())
+ tw.festack.SetStretchy(0)
+ tw.festack.SetStretchy(1)
tw.t.Append("Foreign Events", tw.festack)
}