Began fixing the new Windows Table. In its current state one bug is fixed and another has been spotted, with the diagnosis coming next.

This commit is contained in:
Pietro Gagliardi 2015-02-18 01:51:57 -05:00
parent 847e9bfd2c
commit 9f8ae40516
4 changed files with 10 additions and 1 deletions

View File

@ -57,6 +57,12 @@ void setTableSubclass(HWND hwnd, void *data)
xpanic("error subclassing Table to give it its own event handler", GetLastError()); 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) void tableAutosizeColumns(HWND hwnd, int nColumns)
{ {
int i; int i;

View File

@ -62,7 +62,7 @@ func (t *table) Unlock() {
Do(func() { Do(func() {
t.RLock() t.RLock()
defer t.RUnlock() 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() t.RLock()
defer t.RUnlock() defer t.RUnlock()
d := reflect.Indirect(reflect.ValueOf(t.data)) d := reflect.Indirect(reflect.ValueOf(t.data))
fmt.Printf("%#v\n", *tnm)
datum := d.Index(int(tnm.row)).Field(int(tnm.column)) datum := d.Index(int(tnm.row)).Field(int(tnm.column))
switch { switch {
case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)): case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)):

View File

@ -110,6 +110,7 @@ extern void tabLeaveChildren(HWND);
extern LPWSTR xtableWindowClass; extern LPWSTR xtableWindowClass;
extern void doInitTable(void); extern void doInitTable(void);
extern void setTableSubclass(HWND, void *); extern void setTableSubclass(HWND, void *);
extern void gotableSetRowCount(HWND, intptr_t);
/* TODO /* TODO
extern void tableAutosizeColumns(HWND, int); extern void tableAutosizeColumns(HWND, int);
extern intptr_t tableSelectedItem(HWND); extern intptr_t tableSelectedItem(HWND);

View File

@ -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.xoff = SendMessageW(t->header, HDM_GETBITMAPMARGIN, 0, 0);
p.y = client.top; p.y = client.top;
printf("%d %d\n", t->vscrollpos, t->count);
for (i = t->vscrollpos; i < t->count; i++) { for (i = t->vscrollpos; i < t->count; i++) {
p.row = i; p.row = i;
p.x = client.left - t->hscrollpos; p.x = client.left - t->hscrollpos;