From f7daa5580f8788a8d15f46b65c2e21ca96db8523 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 5 Dec 2014 10:18:37 -0500 Subject: [PATCH] Added the new Windows Table event handling framework. --- wintable/NEWevents.h | 54 ++++++++++++++++++++++++++++++++++++++++++++ wintable/NEWutil.h | 1 + 2 files changed, 55 insertions(+) create mode 100644 wintable/NEWevents.h diff --git a/wintable/NEWevents.h b/wintable/NEWevents.h new file mode 100644 index 0000000..cef722a --- /dev/null +++ b/wintable/NEWevents.h @@ -0,0 +1,54 @@ +// 5 december 2014 + +static handlerfunc keyDownHandlers[] = { + NULL, +}; + +static handlerfunc keyUpHandlers[] = { + NULL, +}; + +static handlerfunc charHandlers[] = { + NULL, +}; + +static handlerfunc mouseMoveHandlers[] = { + NULL, +}; + +static handlerfunc mouseLeaveHandlers[] = { + NULL, +}; + +static handlerfunc lbuttonDownHandlers[] = { + NULL, +}; + +static handlerufnc lbuttonUpHandlers[] = { + NULL, +}; + +static handlerfunc mouseWheelHandlers[] = { + NULL, +}; + +// TODO WM_MOUSEHOVER, other mouse buttons + +HANDLER(events) +{ + switch (uMsg) { +#define eventHandler(msg, array) \ + case msg: \ + return runHandlers(array, t, uMsg, wParam, lParam, lResult); + eventHandler(WM_KEYDOWN, keyDownHandlers) + eventHandler(WM_KEYUP, keyUpHandlers) + eventHandler(WM_CHAR, charHandlers) + eventHandler(WM_MOUSEMOVE, mouseMoveHandlers) + eventHandler(WM_MOUSELEAVE, mouseLeaveHandlers) + eventHandler(WM_LBUTTONDOWN, lbuttonDownHandlers) + eventHandler(WM_LBUTTONUP, lbuttonUpHandlers) + eventHandler(WM_MOUSEWHEEL, mouseWheelHandlers) +#undef eventHandler + } + return FALSE; +} diff --git a/wintable/NEWutil.h b/wintable/NEWutil.h index e10dd77..c6cbfb3 100644 --- a/wintable/NEWutil.h +++ b/wintable/NEWutil.h @@ -1,6 +1,7 @@ // 4 december 2014 typedef BOOL (*handlerfunc)(struct table *, UINT, WPARAM, LPARAM, LRESULT *); +#define HANDLER(name) static BOOL name(struct table *t, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) static BOOL runHandlers(handlerfunc *list, struct table *t, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) {