summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-11-30 21:27:32 -0500
committerPietro Gagliardi <[email protected]>2014-11-30 21:27:32 -0500
commit84d66b6b50a3956015cc8bf0e78d6373ebdb4ba4 (patch)
tree548058f746a1819d2d023d3a3c06e50084c31d77
parentc41b9b16fffb000700e64c0d652e2db58242d98d (diff)
Started splitting message handlers for the new Windows Table into their respective files.
-rw-r--r--wintable/api.h29
-rw-r--r--wintable/main.c32
2 files changed, 42 insertions, 19 deletions
diff --git a/wintable/api.h b/wintable/api.h
index a933df7..5fdf599 100644
--- a/wintable/api.h
+++ b/wintable/api.h
@@ -23,3 +23,32 @@ static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam)
// TODO resize(t)?
redrawAll(t);
}
+
+HANDLER(API)
+{
+ switch (uMsg) {
+ case WM_SETFONT:
+ t->font = (HFONT) wParam;
+ if (t->font == NULL)
+ t->font = t->defaultFont;
+ // also set the header font
+ SendMessageW(t->header, WM_SETFONT, wParam, lParam);
+ if (LOWORD(lParam) != FALSE) {
+ // the scrollbar page size will change so redraw that too
+ // also recalculate the header height
+ // TODO do that when this is FALSE too somehow
+ resize(t);
+ redrawAll(t);
+ }
+ *lResult = 0;
+ return TRUE;
+ case WM_GETFONT:
+ *lResult = (LRESULT) t->font;
+ return TRUE;
+ case tableAddColumn:
+ addColumn(t, wParam, lParam);
+ *lResult = 0;
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/wintable/main.c b/wintable/main.c
index 8933879..d8eae68 100644
--- a/wintable/main.c
+++ b/wintable/main.c
@@ -93,6 +93,7 @@ struct table {
int checkboxHeight;
};
+#define HANDLER(what) static BOOL what ## Handler(struct table *t, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
#include "util.h"
#include "hscroll.h"
#include "vscroll.h"
@@ -100,10 +101,19 @@ struct table {
#include "draw.h"
#include "api.h"
+typedef BOOL (*handlerfunc)(struct table *, UINT, WPARAM, LPARAM, LRESULT *);
+
+handlerfunc handlerfuncs[] = {
+ APIHandler,
+ NULL,
+};
+
// TODO create a system where each of the above modules provide their own window procedures
static LRESULT CALLBACK tableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
struct table *t;
+ handlerfunc *hf;
+ LRESULT lResult;
HDC dc;
PAINTSTRUCT ps;
NMHDR *nmhdr = (NMHDR *) lParam;
@@ -154,6 +164,9 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
// even if we did the above, fall through
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
+ for (hf = handlerfuncs; *hf != NULL; hf++)
+ if ((*hf)(t, uMsg, wParam, lParam, &lResult))
+ return lResult;
switch (uMsg) {
case WM_PAINT:
dc = BeginPaint(hwnd, &ps);
@@ -162,22 +175,6 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
drawItems(t, dc, ps.rcPaint);
EndPaint(hwnd, &ps);
return 0;
- case WM_SETFONT:
- t->font = (HFONT) wParam;
- if (t->font == NULL)
- t->font = t->defaultFont;
- // also set the header font
- SendMessageW(t->header, WM_SETFONT, wParam, lParam);
- if (LOWORD(lParam) != FALSE) {
- // the scrollbar page size will change so redraw that too
- // also recalculate the header height
- // TODO do that when this is FALSE too somehow
- resize(t);
- redrawAll(t);
- }
- return 0;
- case WM_GETFONT:
- return (LRESULT) t->font;
case WM_VSCROLL:
vscroll(t, wParam);
return 0;
@@ -226,9 +223,6 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
// now defer back to DefWindowProc() in case other things are needed
// TODO needed?
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
- case tableAddColumn:
- addColumn(t, wParam, lParam);
- return 0;
case WM_GETOBJECT: // accessibility
/*
if (((DWORD) lParam) == OBJID_CLIENT) {