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());
}
// 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;

View File

@ -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)):

View File

@ -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);

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.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;