summaryrefslogtreecommitdiff
path: root/redo/table_windows.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-14 09:20:20 -0400
committerPietro Gagliardi <[email protected]>2014-08-14 09:20:20 -0400
commitd384df97d0538ac46de936c10a4d4d8b91005b17 (patch)
tree60766d286aa6e167c994d66f53e3523b974333e4 /redo/table_windows.c
parent697b3cc1b0694db8b788175f6b377f5bcb15d5a2 (diff)
Implemented table column autoresize on Windows. Also fixed Windows/Mac OS X build.
Diffstat (limited to 'redo/table_windows.c')
-rw-r--r--redo/table_windows.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/redo/table_windows.c b/redo/table_windows.c
index a005600..5846c1c 100644
--- a/redo/table_windows.c
+++ b/redo/table_windows.c
@@ -19,23 +19,11 @@ static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
return 0;
}
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
- /* the autosize behavior is simple: always autosize until the user manually sizes, then never autosize again (this is my best guess as to how GTK+ behaves) */
+ /* see table.autoresize() in table_windows.go for the column autosize policy */
case WM_NOTIFY: /* from the contained header control */
if (nmhdr->code == HDN_BEGINTRACK)
tableStopColumnAutosize((void *) data);
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
- case WM_SIZE:
- return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
- /* TODO this causes weird issues with regards to item positioning on Windows XP */
- if (tableAutosizeColumns((void *) data)) {
- int i, nColumns;
-
- nColumns = tableColumnCount((void *) data);
- for (i = 0; i < nColumns; i++)
- if (SendMessageW(hwnd, LVM_SETCOLUMNWIDTH, (WPARAM) i, (LPARAM) LVSCW_AUTOSIZE_USEHEADER) == FALSE)
- xpanic("error resizing columns of results list view", GetLastError());
- }
- return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
case WM_NCDESTROY:
if ((*fv_RemoveWindowSubclass)(hwnd, tableSubProc, id) == FALSE)
xpanic("error removing Table subclass (which was for its own event handler)", GetLastError());
@@ -78,3 +66,12 @@ void tableAddExtendedStyles(HWND hwnd, LPARAM styles)
/* the bits of WPARAM specify which bits of LPARAM to look for; having WPARAM == LPARAM ensures that only the bits we want to add are affected */
SendMessageW(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, (WPARAM) styles, styles);
}
+
+void tableAutosizeColumns(HWND hwnd, int nColumns)
+{
+ int i;
+
+ for (i = 0; i < nColumns; i++)
+ if (SendMessageW(hwnd, LVM_SETCOLUMNWIDTH, (WPARAM) i, (LPARAM) LVSCW_AUTOSIZE_USEHEADER) == FALSE)
+ xpanic("error resizing columns of results list view", GetLastError());
+}