diff options
| author | Pietro Gagliardi <[email protected]> | 2015-01-07 17:05:38 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-01-07 17:05:38 -0500 |
| commit | 4f557f484c65e11f7ba35aa3aca8c72a6ad2a73e (patch) | |
| tree | e8667618007ed782cf29e76683f03ac2cb5b475b | |
| parent | 3b81ebab986d619742fffc052d4fca6a8c5080fd (diff) | |
Added facilities for notifications.
| -rw-r--r-- | wintable/api.h | 17 | ||||
| -rw-r--r-- | wintable/main.h | 33 |
2 files changed, 50 insertions, 0 deletions
diff --git a/wintable/api.h b/wintable/api.h index 7ec9afc..fb0e1c0 100644 --- a/wintable/api.h +++ b/wintable/api.h @@ -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)); +} diff --git a/wintable/main.h b/wintable/main.h index 3999d7b..670f620 100644 --- a/wintable/main.h +++ b/wintable/main.h @@ -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" |
