diff options
| author | Pietro Gagliardi <[email protected]> | 2015-01-06 17:27:41 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-01-06 17:27:41 -0500 |
| commit | 22123fb676d26d309d428a892c453e35e684e367 (patch) | |
| tree | 9552f1a91a8b8995065e74573e8f59f448f2b08c /wintable/api.h | |
| parent | 720049bfd3c6d205859f3150dee33dee78dc3dc3 (diff) | |
Merged wintable/new/ into wintable/.
Diffstat (limited to 'wintable/api.h')
| -rw-r--r-- | wintable/api.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/wintable/api.h b/wintable/api.h new file mode 100644 index 0000000..7ec9afc --- /dev/null +++ b/wintable/api.h @@ -0,0 +1,35 @@ +// 8 december 2014 + +static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam) +{ + t->nColumns++; + t->columnTypes = (int *) tableRealloc(t->columnTypes, t->nColumns * sizeof (int), "adding the new column type to the current Table's list of column types"); + t->columnTypes[t->nColumns - 1] = (int) wParam; + // TODO make a panicNoErrCode() or panicArg() for this + if (t->columnTypes[t->nColumns - 1] >= nTableColumnTypes) + panic("invalid column type passed to tableAddColumn"); + headerAddColumn(t, (WCHAR *) lParam); + updateTableWidth(t); +} + +HANDLER(apiHandlers) +{ + switch (uMsg) { + case WM_SETFONT: + // don't free the old font; see http://blogs.msdn.com/b/oldnewthing/archive/2008/09/12/8945692.aspx + t->font = (HFONT) wParam; + SendMessageW(t->header, WM_SETFONT, wParam, lParam); + // TODO how to properly handle LOWORD(lParam) != FALSE? + // TODO depending on the result of the above, update table width to refresh t->headerHeight? + *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; +} |
