summaryrefslogtreecommitdiff
path: root/wintable/new/draw.h
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-12-08 10:01:41 -0500
committerPietro Gagliardi <[email protected]>2014-12-08 10:01:41 -0500
commit2f95837155e84240b508d561372ff54ef2b836bc (patch)
tree4e14bb3fef8ab05334a2dd163dd5449399f4d1ce /wintable/new/draw.h
parent47a83a311d6f9702ab6ce87a38d77234496d09ad (diff)
Added drawing scaffolds to the new Windows Table.
Diffstat (limited to 'wintable/new/draw.h')
-rw-r--r--wintable/new/draw.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/wintable/new/draw.h b/wintable/new/draw.h
new file mode 100644
index 0000000..7cd978c
--- /dev/null
+++ b/wintable/new/draw.h
@@ -0,0 +1,40 @@
+// 8 december 2014
+
+static void draw(struct table *t, HDC dc, RECT cliprect, RECT client)
+{
+ Rectangle(dc, 20, 20, 200, 200);
+}
+
+// TODO handle WM_PRINTCLIENT flags?
+
+HANDLER(drawHandlers)
+{
+ HDC dc;
+ PAINTSTRUCT ps;
+ RECT client;
+ RECT r;
+ BOOL wmpaint;
+
+ if (uMsg != WM_PAINT && uMsg != WM_PRINTCLIENT)
+ return FALSE;
+ if (GetClientRect(t->hwnd, &client) == 0)
+ panic("error getting client rect for Table painting");
+ // let's be nice: some controls don't support WM_PRINTCLIENT but do allow you to pass a HDC as the WPARAM to WM_PAINT, so let's support that too as an option
+ // TODO find out how susch controls handle LPARAM
+ wmpaint = uMsg == WM_PAINT && ((HDC) wParam) == NULL;
+ if (wmpaint) {
+ dc = BeginPaint(t->hwnd, &ps);
+ if (dc == NULL)
+ panic("error beginning Table painting");
+ r = ps.rcPaint;
+ } else {
+ dc = (HDC) wParam;
+ r = client;
+ }
+ draw(t, dc, r, client);
+ if (wmpaint)
+ EndPaint(t->hwnd, &ps);
+ // TODO is this correct for WM_PRINTCLIENT? MSDN doesn't say
+ *lResult = 0;
+ return TRUE;
+}