Added facilities for notifications.

This commit is contained in:
Pietro Gagliardi 2015-01-07 17:05:38 -05:00
parent 3b81ebab98
commit 4f557f484c
2 changed files with 50 additions and 0 deletions

View File

@ -33,3 +33,20 @@ HANDLER(apiHandlers)
}
return FALSE;
}
static LRESULT notify(struct table *t, UINT code, intptr_t row, intptr_t column, uintptr_t data)
{
tableNM nm;
ZeroMemory(&nm, sizeof (tableNM));
nm.nmhdr.hwndFrom = t->hwnd;
// TODO check for error from here? 0 is a valid ID (IDCANCEL)
nm.nmhdr.idFrom = GetDlgCtrlID(t->hwnd);
nm.nmhdr.code = code;
nm.row = row;
nm.column = column;
nm.columnType = t->columnTypes[nm.column];
nm.data = data;
// TODO check for error from GetParent()?
return SendMessageW(GetParent(t->hwnd), WM_NOTIFY, (WPARAM) (nm.nmhdr.idFrom), (LPARAM) (&nm));
}

View File

@ -11,6 +11,7 @@
// - make sure all error messages involving InvalidateRect() are consistent with regards to "redrawing" and "queueing for redraw"
// - collect all resize-related tasks in a single function (so things like adding columns will refresh everything, not just horizontal scrolls; also would fix initial coordinates)
// - checkbox columns don't clip to the column width
// - send standard notification codes
#define tableWindowClass L"gouitable"
@ -28,6 +29,35 @@ enum {
nTableColumnTypes,
};
// notification codes
// note that these are positive; see http://blogs.msdn.com/b/oldnewthing/archive/2009/08/21/9877791.aspx
// each of these is of type tableNM
// all fields except data will always be set
enum {
// data parameter is always 0
// for tableColumnText return should be WCHAR *
// for tableColumnImage return should be HBITMAP
// for tableColumnCheckbox return is nonzero for checked, zero for unchecked
tableNotificationGetColumnData,
// data parameter is pointer, same as tableNotificationGetColumnData
// not sent for checkboxes
// no return
tableNotificationFreeColumnData,
// data is zero
// no return
tableNotificationToggleColumnCheck,
};
typedef struct tableNM tableNM;
struct tableNM {
NMHDR nmhdr;
intptr_t row;
intptr_t column;
int columnType;
uintptr_t data;
};
static void (*tablePanic)(const char *, DWORD) = NULL;
#define panic(...) (*tablePanic)(__VA_ARGS__, GetLastError())
#define abort $$$$ // prevent accidental use of abort()
@ -65,6 +95,9 @@ struct table {
struct tableAcc *ta;
};
// forward declaration (TODO needed?)
static LRESULT notify(struct table *, UINT, intptr_t, intptr_t, uintptr_t);
#include "util.h"
#include "coord.h"
#include "scroll.h"