Fixed many build errors. Not done yet.

This commit is contained in:
Pietro Gagliardi 2015-02-17 22:00:16 -05:00
parent 1913564fda
commit 56042ac3b3
3 changed files with 14 additions and 13 deletions

View File

@ -28,7 +28,8 @@ static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
tableFreeCellData(gotable, tnm->data); tableFreeCellData(gotable, tnm->data);
return 0; return 0;
case tableNotificationCellCheckboxToggled: case tableNotificationCellCheckboxToggled:
// TODO tableToggled(gotable, tnm->row, tnm->column);
return 0;
// TODO selection changed // TODO selection changed
} }
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam); return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);

View File

@ -19,7 +19,7 @@ type table struct {
colcount C.int colcount C.int
selected *event selected *event
chainresize func(x int, y int, width int, height int, d *sizing) 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 freeLock sync.Mutex
} }
@ -31,7 +31,7 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
controlSingleHWND: newControlSingleHWND(hwnd), controlSingleHWND: newControlSingleHWND(hwnd),
tablebase: b, tablebase: b,
selected: newEvent(), selected: newEvent(),
free: make(map[unsafe.Pointer]bool), free: make(map[C.uintptr_t]bool),
} }
t.fpreferredSize = t.xpreferredSize t.fpreferredSize = t.xpreferredSize
t.chainresize = t.fresize t.chainresize = t.fresize
@ -83,22 +83,22 @@ func (t *table) OnSelected(f func()) {
} }
//export tableGetCell //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 := (*table)(data)
t.RLock() t.RLock()
defer t.RUnlock() defer t.RUnlock()
d := reflect.Indirect(reflect.ValueOf(t.data)) 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 isText := true
switch { switch {
case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)): case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)):
i := datum.Interface().(*image.RGBA) i := datum.Interface().(*image.RGBA)
hbitmap := C.toBitmap(unsafe.Pointer(i), C.intptr_t(i.Dx()), C.intptr_t(i.Dy())) 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.freeLock.Lock()
t.free[bitmap] = true // bitmap freed with C.freeBitmap() t.free[bitmap] = true // bitmap freed with C.freeBitmap()
t.freeLock.Unlock() t.freeLock.Unlock()
return C.LRESULT(uintptr(bmp)) return C.LRESULT(bmp)
case datum.Kind() == reflect.Bool: case datum.Kind() == reflect.Bool:
if datum.Bool() == true { if datum.Bool() == true {
return C.TRUE return C.TRUE
@ -106,16 +106,16 @@ func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) C.LRESULT {
return C.FALSE return C.FALSE
default: default:
s := fmt.Sprintf("%v", datum) s := fmt.Sprintf("%v", datum)
text := unsafe.Pointer(toUTF16(s)) text := C.uintptr_t(uintptr(unsafe.Pointer(toUTF16(s))))
t.freeLock.Lock() t.freeLock.Lock()
t.free[text] = false // text freed with C.free() t.free[text] = false // text freed with C.free()
t.freeLock.Unlock() t.freeLock.Unlock()
return C.LRESULT(uintptr(text)) return C.LRESULT(text)
} }
} }
//export tableFreeData //export tableFreeCellData
func tableFreeData(gotable unsafe.Pointer, data unsafe.Pointer) { func tableFreeCellData(gotable unsafe.Pointer, data C.uintptr_t) {
t := (*table)(gotable) t := (*table)(gotable)
t.freeLock.Lock() t.freeLock.Lock()
defer t.freeLock.Unlock() defer t.freeLock.Unlock()
@ -154,7 +154,7 @@ func tableColumnCount(data unsafe.Pointer) C.int {
} }
//export tableToggled //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 := (*table)(data)
t.Lock() t.Lock()
defer t.Unlock() defer t.Unlock()

View File

@ -9,7 +9,7 @@ import (
) )
// #cgo CFLAGS: --std=c99 // #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" // #include "winapi_windows.h"
import "C" import "C"