summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/table_windows.c9
-rw-r--r--redo/table_windows.go30
2 files changed, 37 insertions, 2 deletions
diff --git a/redo/table_windows.c b/redo/table_windows.c
index cd780d3..e2acbc9 100644
--- a/redo/table_windows.c
+++ b/redo/table_windows.c
@@ -42,10 +42,19 @@ static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
handle(hwnd, wParam, lParam, tableSetHot, (void *) data);
// and let the list view do its thing
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
+ case WM_LBUTTONDOWN:
+ handle(hwnd, wParam, lParam, tablePushed, (void *) data);
+ // and let the list view do its thing
+ return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
case WM_LBUTTONUP:
handle(hwnd, wParam, lParam, tableToggled, (void *) data);
// and let the list view do its thing
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
+ case WM_MOUSELEAVE:
+ // TODO doesn't work
+ tablePushed((void *) data, -1, -1); // in case button held as drag out
+ // and let the list view do its thing
+ return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
// 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)
diff --git a/redo/table_windows.go b/redo/table_windows.go
index fdb96d6..71049b5 100644
--- a/redo/table_windows.go
+++ b/redo/table_windows.go
@@ -18,6 +18,8 @@ type table struct {
colcount C.int
hotrow C.int
hotcol C.int
+ pushedrow C.int
+ pushedcol C.int
}
func finishNewTable(b *tablebase, ty reflect.Type) Table {
@@ -28,6 +30,8 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
tablebase: b,
hotrow: -1,
hotcol: -1,
+ pushedrow: -1,
+ pushedcol: -1,
}
C.setTableSubclass(t._hwnd, unsafe.Pointer(t))
// LVS_EX_FULLROWSELECT gives us selection across the whole row, not just the leftmost column; this makes the list view work like on other platforms
@@ -86,6 +90,11 @@ func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) {
} else {
curstate &^= C.checkboxStateHot
}
+ if item.iItem == t.pushedrow && item.iSubItem == t.pushedcol {
+ curstate |= C.checkboxStatePushed
+ } else {
+ curstate &^= C.checkboxStatePushed
+ }
item.state = (curstate + 1) << 12
default:
s := fmt.Sprintf("%v", datum)
@@ -126,14 +135,31 @@ func tableSetHot(data unsafe.Pointer, row C.int, col C.int) {
}
}
+//export tablePushed
+func tablePushed(data unsafe.Pointer, row C.int, col C.int) {
+ t := (*table)(data)
+ t.pushedrow = row
+ t.pushedcol = col
+ C.tableUpdate(t._hwnd, C.int(reflect.Indirect(reflect.ValueOf(t.data)).Len()))
+}
+
//export tableToggled
func tableToggled(data unsafe.Pointer, row C.int, col C.int) {
t := (*table)(data)
+ t.Lock()
+ defer func() {
+ // reset for next time
+ t.pushedrow = -1
+ t.pushedcol = -1
+ // and THEN unlock so the reset takes effect
+ t.Unlock()
+ }()
if row == -1 || col == -1 { // discard extras sent by handle() in table_windows.c
return
}
- t.Lock()
- defer t.Unlock()
+ if row != t.pushedrow || col != t.pushedcol { // mouse moved out
+ return
+ }
d := reflect.Indirect(reflect.ValueOf(t.data))
datum := d.Index(int(row)).Field(int(col))
if datum.Kind() == reflect.Bool {