From 56042ac3b3a56915524ed133cf6d8df926dfaec1 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 17 Feb 2015 22:00:16 -0500 Subject: [PATCH] Fixed many build errors. Not done yet. --- table_windows.c | 3 ++- table_windows.go | 22 +++++++++++----------- uitask_windows.go | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/table_windows.c b/table_windows.c index 10bbb2c..ea5b50c 100644 --- a/table_windows.c +++ b/table_windows.c @@ -28,7 +28,8 @@ static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM tableFreeCellData(gotable, tnm->data); return 0; case tableNotificationCellCheckboxToggled: - // TODO + tableToggled(gotable, tnm->row, tnm->column); + return 0; // TODO selection changed } return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam); diff --git a/table_windows.go b/table_windows.go index 6c357c9..efc3e8d 100644 --- a/table_windows.go +++ b/table_windows.go @@ -19,7 +19,7 @@ type table struct { colcount C.int selected *event chainresize func(x int, y int, width int, height int, d *sizing) - freeTexts map[unsafe.Pointer]bool + freeTexts map[C.uintptr_t]bool freeLock sync.Mutex } @@ -31,7 +31,7 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table { controlSingleHWND: newControlSingleHWND(hwnd), tablebase: b, selected: newEvent(), - free: make(map[unsafe.Pointer]bool), + free: make(map[C.uintptr_t]bool), } t.fpreferredSize = t.xpreferredSize t.chainresize = t.fresize @@ -83,22 +83,22 @@ func (t *table) OnSelected(f func()) { } //export tableGetCell -func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) C.LRESULT { +func tableGetCell(data unsafe.Pointer, tnm *C.tableNM) C.LRESULT { t := (*table)(data) t.RLock() defer t.RUnlock() d := reflect.Indirect(reflect.ValueOf(t.data)) - datum := d.Index(int(item.iItem)).Field(int(item.iSubItem)) + datum := d.Index(int(tnm.row)).Field(int(tnm.column)) isText := true switch { case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)): i := datum.Interface().(*image.RGBA) hbitmap := C.toBitmap(unsafe.Pointer(i), C.intptr_t(i.Dx()), C.intptr_t(i.Dy())) - bitmap := unsafe.Pointer(hbitmap) + bitmap := C.uintptr_t(uintptr(unsafe.Pointer(hbitmap))) t.freeLock.Lock() t.free[bitmap] = true // bitmap freed with C.freeBitmap() t.freeLock.Unlock() - return C.LRESULT(uintptr(bmp)) + return C.LRESULT(bmp) case datum.Kind() == reflect.Bool: if datum.Bool() == true { return C.TRUE @@ -106,16 +106,16 @@ func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) C.LRESULT { return C.FALSE default: s := fmt.Sprintf("%v", datum) - text := unsafe.Pointer(toUTF16(s)) + text := C.uintptr_t(uintptr(unsafe.Pointer(toUTF16(s)))) t.freeLock.Lock() t.free[text] = false // text freed with C.free() t.freeLock.Unlock() - return C.LRESULT(uintptr(text)) + return C.LRESULT(text) } } -//export tableFreeData -func tableFreeData(gotable unsafe.Pointer, data unsafe.Pointer) { +//export tableFreeCellData +func tableFreeCellData(gotable unsafe.Pointer, data C.uintptr_t) { t := (*table)(gotable) t.freeLock.Lock() defer t.freeLock.Unlock() @@ -154,7 +154,7 @@ func tableColumnCount(data unsafe.Pointer) C.int { } //export tableToggled -func tableToggled(data unsafe.Pointer, row C.int, col C.int) { +func tableToggled(data unsafe.Pointer, row C.intptr_t, col C.intptr_t) { t := (*table)(data) t.Lock() defer t.Unlock() diff --git a/uitask_windows.go b/uitask_windows.go index 2d1fb54..b5c6c3c 100644 --- a/uitask_windows.go +++ b/uitask_windows.go @@ -9,7 +9,7 @@ import ( ) // #cgo CFLAGS: --std=c99 -// #cgo LDFLAGS: -luser32 -lkernel32 -lgdi32 -luxtheme -lmsimg32 -lcomdlg32 +// #cgo LDFLAGS: -luser32 -lkernel32 -lgdi32 -luxtheme -lmsimg32 -lcomdlg32 -lole32 -loleaut32 -loleacc -luuid // #include "winapi_windows.h" import "C"