From 9f8ae4051603d4d1bab02465c9662236644bb83d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 18 Feb 2015 01:51:57 -0500 Subject: [PATCH] Began fixing the new Windows Table. In its current state one bug is fixed and another has been spotted, with the diagnosis coming next. --- table_windows.c | 6 ++++++ table_windows.go | 3 ++- winapi_windows.h | 1 + wintable/draw.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/table_windows.c b/table_windows.c index ea5b50c..dbbcde2 100644 --- a/table_windows.c +++ b/table_windows.c @@ -57,6 +57,12 @@ void setTableSubclass(HWND hwnd, void *data) xpanic("error subclassing Table to give it its own event handler", GetLastError()); } +// TODO rename all of these functions to start with gotable, and all the exported ones in Go too +void gotableSetRowCount(HWND hwnd, intptr_t count) +{ + SendMessageW(hwnd, tableSetRowCount, 0, (LPARAM) (&count)); +} + void tableAutosizeColumns(HWND hwnd, int nColumns) { int i; diff --git a/table_windows.go b/table_windows.go index 1be54a6..3b8d3dc 100644 --- a/table_windows.go +++ b/table_windows.go @@ -62,7 +62,7 @@ func (t *table) Unlock() { Do(func() { t.RLock() defer t.RUnlock() - C.SendMessageW(t.hwnd, C.tableSetRowCount, 0, C.LPARAM(C.intptr_t(reflect.Indirect(reflect.ValueOf(t.data)).Len()))) + C.gotableSetRowCount(t.hwnd, C.intptr_t(reflect.Indirect(reflect.ValueOf(t.data)).Len())) }) }() } @@ -90,6 +90,7 @@ func tableGetCell(data unsafe.Pointer, tnm *C.tableNM) C.LRESULT { t.RLock() defer t.RUnlock() d := reflect.Indirect(reflect.ValueOf(t.data)) +fmt.Printf("%#v\n", *tnm) datum := d.Index(int(tnm.row)).Field(int(tnm.column)) switch { case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)): diff --git a/winapi_windows.h b/winapi_windows.h index 49e3827..b2b883d 100644 --- a/winapi_windows.h +++ b/winapi_windows.h @@ -110,6 +110,7 @@ extern void tabLeaveChildren(HWND); extern LPWSTR xtableWindowClass; extern void doInitTable(void); extern void setTableSubclass(HWND, void *); +extern void gotableSetRowCount(HWND, intptr_t); /* TODO extern void tableAutosizeColumns(HWND, int); extern intptr_t tableSelectedItem(HWND); diff --git a/wintable/draw.h b/wintable/draw.h index 3aeb300..2c6267a 100644 --- a/wintable/draw.h +++ b/wintable/draw.h @@ -166,6 +166,7 @@ static void draw(struct table *t, HDC dc, RECT cliprect, RECT client) p.xoff = SendMessageW(t->header, HDM_GETBITMAPMARGIN, 0, 0); p.y = client.top; +printf("%d %d\n", t->vscrollpos, t->count); for (i = t->vscrollpos; i < t->count; i++) { p.row = i; p.x = client.left - t->hscrollpos;