Added drawing scaffolds to the new Windows Table.

This commit is contained in:
Pietro Gagliardi 2014-12-08 10:01:41 -05:00
parent 47a83a311d
commit 2f95837155
2 changed files with 42 additions and 0 deletions

40
wintable/new/draw.h Normal file
View File

@ -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;
}

View File

@ -57,11 +57,13 @@ struct table {
#include "header.h" #include "header.h"
#include "children.h" #include "children.h"
#include "resize.h" #include "resize.h"
#include "draw.h"
static const handlerfunc handlers[] = { static const handlerfunc handlers[] = {
eventHandlers, eventHandlers,
childrenHandlers, childrenHandlers,
resizeHandler, resizeHandler,
drawHandlers,
NULL, NULL,
}; };