summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-02-21 15:53:13 -0500
committerPietro Gagliardi <[email protected]>2015-02-21 15:53:31 -0500
commite252945cb386312d9fb79b2fbe3179e4b1e40a62 (patch)
tree68bb701867e568176f2ab44914662657e5b3159f
parent23e6739dfabd61fd732d9b78e13a55aeaa7c2c2d (diff)
Implemented Table column names on all platforms. Updates #40.
-rw-r--r--table_darwin.go6
-rw-r--r--table_unix.go6
-rw-r--r--table_windows.go11
3 files changed, 18 insertions, 5 deletions
diff --git a/table_darwin.go b/table_darwin.go
index 26418b6..1bfbe74 100644
--- a/table_darwin.go
+++ b/table_darwin.go
@@ -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 {
diff --git a/table_unix.go b/table_unix.go
index 0857014..97873b0 100644
--- a/table_unix.go
+++ b/table_unix.go
@@ -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
diff --git a/table_windows.go b/table_windows.go
index a26c2f0..159f1c2 100644
--- a/table_windows.go
+++ b/table_windows.go
@@ -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"
@@ -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