diff options
| author | Pietro Gagliardi <[email protected]> | 2015-02-17 22:17:58 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-02-17 22:17:58 -0500 |
| commit | 1fd265135d17d682b3e0f884502ffa2037a379ae (patch) | |
| tree | dede7dca0e36061c115ccb5b92881af21d87e0d0 /table_windows.go | |
| parent | 56042ac3b3a56915524ed133cf6d8df926dfaec1 (diff) | |
Fixed the other build errors. Awesome, Go's linker won't recognize the COM IIDs in uuid.dll; guess we're bumping the minimum required version of Go, maybe?...
Diffstat (limited to 'table_windows.go')
| -rw-r--r-- | table_windows.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/table_windows.go b/table_windows.go index efc3e8d..e2aecf1 100644 --- a/table_windows.go +++ b/table_windows.go @@ -7,6 +7,7 @@ import ( "reflect" "unsafe" "sync" + "image" ) // #include "winapi_windows.h" @@ -19,7 +20,7 @@ type table struct { colcount C.int selected *event chainresize func(x int, y int, width int, height int, d *sizing) - freeTexts map[C.uintptr_t]bool + free map[C.uintptr_t]bool freeLock sync.Mutex } @@ -39,7 +40,7 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table { C.setTableSubclass(t.hwnd, unsafe.Pointer(t)) for i := 0; i < ty.NumField(); i++ { coltype := C.WPARAM(C.tableColumnText) - switch ty.Field(i).Type { + switch { case ty.Field(i).Type == reflect.TypeOf((*image.RGBA)(nil)): coltype = C.tableColumnImage case ty.Field(i).Type.Kind() == reflect.Bool: @@ -89,16 +90,15 @@ func tableGetCell(data unsafe.Pointer, tnm *C.tableNM) C.LRESULT { defer t.RUnlock() d := reflect.Indirect(reflect.ValueOf(t.data)) 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())) + hbitmap := C.toBitmap(unsafe.Pointer(i), C.intptr_t(i.Rect.Dx()), C.intptr_t(i.Rect.Dy())) 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(bmp) + return C.LRESULT(bitmap) case datum.Kind() == reflect.Bool: if datum.Bool() == true { return C.TRUE @@ -124,7 +124,7 @@ func tableFreeCellData(gotable unsafe.Pointer, data C.uintptr_t) { panic(fmt.Errorf("undefined data %p in tableFreeData()", data)) } if b == false { - C.free(data) + C.free(unsafe.Pointer(uintptr(data))) } else { C.freeBitmap(data) } |
