summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/container_unix.c2
-rw-r--r--redo/table_windows.c23
-rw-r--r--redo/table_windows.go22
-rw-r--r--redo/winapi_windows.h1
4 files changed, 26 insertions, 22 deletions
diff --git a/redo/container_unix.c b/redo/container_unix.c
index b478ee3..8e3f335 100644
--- a/redo/container_unix.c
+++ b/redo/container_unix.c
@@ -1,3 +1,5 @@
+// +build !windows,!darwin
+
/* 13 august 2014 */
#include "gtk_unix.h"
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());
+}
diff --git a/redo/table_windows.go b/redo/table_windows.go
index 4e6a0e2..93ff9c1 100644
--- a/redo/table_windows.go
+++ b/redo/table_windows.go
@@ -60,21 +60,22 @@ func tableGetCellText(data unsafe.Pointer, row C.int, col C.int, str *C.LPWSTR)
*str = toUTF16(s)
}
+// the column autoresize policy is simple:
+// on every table.commitResize() call, if the columns have not been resized by the user, autoresize
+func (t *table) autoresize() {
+ t.RLock()
+ defer t.RUnlock()
+ if !t.noautosize {
+ C.tableAutosizeColumns(t._hwnd, t.colcount)
+ }
+}
+
//export tableStopColumnAutosize
func tableStopColumnAutosize(data unsafe.Pointer) {
t := (*table)(data)
t.noautosize = true
}
-//export tableAutosizeColumns
-func tableAutosizeColumns(data unsafe.Pointer) C.BOOL {
- t := (*table)(data)
- if t.noautosize {
- return C.FALSE
- }
- return C.TRUE
-}
-
//export tableColumnCount
func tableColumnCount(data unsafe.Pointer) C.int {
t := (*table)(data)
@@ -106,6 +107,9 @@ func (t *table) preferredSize(d *sizing) (width, height int) {
func (t *table) commitResize(a *allocation, d *sizing) {
basecommitResize(t, a, d)
+ t.RLock()
+ defer t.RUnlock()
+ t.autoresize()
}
func (t *table) getAuxResizeInfo(d *sizing) {
diff --git a/redo/winapi_windows.h b/redo/winapi_windows.h
index 2d42427..23b7462 100644
--- a/redo/winapi_windows.h
+++ b/redo/winapi_windows.h
@@ -97,6 +97,7 @@ extern void setTableSubclass(HWND, void *);
extern void tableAppendColumn(HWND, int, LPWSTR);
extern void tableUpdate(HWND, int);
extern void tableAddExtendedStyles(HWND, LPARAM);
+extern void tableAutosizeColumns(HWND, int);
/* container_windows.c */
extern DWORD makeContainerWindowClass(char **);