Added the new Windows Table event handling framework.

This commit is contained in:
Pietro Gagliardi 2014-12-05 10:18:37 -05:00
parent 19358785f6
commit f7daa5580f
2 changed files with 55 additions and 0 deletions

54
wintable/NEWevents.h Normal file
View File

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

View File

@ -1,6 +1,7 @@
// 4 december 2014 // 4 december 2014
typedef BOOL (*handlerfunc)(struct table *, UINT, WPARAM, LPARAM, LRESULT *); 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) static BOOL runHandlers(handlerfunc *list, struct table *t, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
{ {