Skip to content

Commit

Permalink
Implemented Table column names on all platforms. Updates #40.
Browse files Browse the repository at this point in the history
  • Loading branch information
andlabs committed Feb 21, 2015
1 parent 23e6739 commit e252945
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 5 additions & 1 deletion table_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
// also sets the delegate
C.tableMakeDataSource(t.id, unsafe.Pointer(t))
for i := 0; i < ty.NumField(); i++ {
cname := C.CString(ty.Field(i).Name)
colname := ty.Field(i).Tag.Get("uicolumn")
if colname == "" {
colname = ty.Field(i).Name
}
cname := C.CString(colname)
coltype := C.colTypeText
editable := false
switch {
Expand Down
6 changes: 5 additions & 1 deletion table_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
C.gpointer(unsafe.Pointer(t)))
C.gtk_tree_view_set_model(t.treeview, t.modelgtk)
for i := 0; i < ty.NumField(); i++ {
cname := togstr(ty.Field(i).Name)
colname := ty.Field(i).Tag.Get("uicolumn")
if colname == "" {
colname = ty.Field(i).Name
}
cname := togstr(colname)
switch {
case ty.Field(i).Type == reflect.TypeOf((*image.RGBA)(nil)):
// can't use GDK_TYPE_PIXBUF here because it's a macro that expands to a function and cgo hates that
Expand Down
11 changes: 8 additions & 3 deletions table_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package ui
// - why are we not getting keyboard input (focus?) on a mouse click?
// - are we getting keyboard input (focus?) on tab?
// - random freezes on Windows 7 when resizing headers or clicking new rows; likely another package ui infrastructure issue though...
// - investigate japanese display in the table headers on wine (it has worked in the past in ANSI mode via Shift-JIS with what I assume is the same font, so huh?)

import (
"fmt"
Expand Down Expand Up @@ -53,9 +54,13 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
case ty.Field(i).Type.Kind() == reflect.Bool:
coltype = C.tableColumnCheckbox
}
colname := toUTF16(ty.Field(i).Name)
C.SendMessageW(t.hwnd, C.tableAddColumn, coltype, C.LPARAM(uintptr(unsafe.Pointer(colname))))
// TODO free colname
colname := ty.Field(i).Tag.Get("uicolumn")
if colname == "" {
colname = ty.Field(i).Name
}
ccolname := toUTF16(colname)
C.SendMessageW(t.hwnd, C.tableAddColumn, coltype, C.LPARAM(uintptr(unsafe.Pointer(ccolname))))
// TODO free ccolname
}
t.colcount = C.int(ty.NumField())
return t
Expand Down

0 comments on commit e252945

Please sign in to comment.