Migrated the Mac OS X Table implementation. Untested due to VM issues.
This commit is contained in:
parent
8ec518dfe8
commit
1d091637d8
|
@ -5,7 +5,7 @@
|
|||
|
||||
#define toNSInteger(x) ((NSInteger) (x))
|
||||
|
||||
id toImageListImage(void *pixels, intptr_t width, intptr_t height, intptr_t stride)
|
||||
id toTableImage(void *pixels, intptr_t width, intptr_t height, intptr_t stride)
|
||||
{
|
||||
NSBitmapImageRep *bitmap;
|
||||
NSImage *image;
|
||||
|
@ -26,5 +26,6 @@ id toImageListImage(void *pixels, intptr_t width, intptr_t height, intptr_t stri
|
|||
memcpy((void *) [bitmap bitmapData], pixels, [bitmap bytesPerPlane]);
|
||||
image = [[NSImage alloc] initWithSize:NSMakeSize((CGFloat) width, (CGFloat) height)];
|
||||
[image addRepresentation:bitmap];
|
||||
// TODO release bitmap?
|
||||
return (id) image;
|
||||
}
|
|
@ -146,8 +146,8 @@ extern void areaEndTextFieldEditing(id, id);
|
|||
/* common_darwin.m */
|
||||
extern void disableAutocorrect(id);
|
||||
|
||||
/* imagerep_darwin.m */
|
||||
extern id toImageListImage(void *, intptr_t, intptr_t, intptr_t);
|
||||
/* image_darwin.m */
|
||||
extern id toTableImage(void *, intptr_t, intptr_t, intptr_t);
|
||||
|
||||
/* dialog_darwin.m */
|
||||
extern void openFile(id, void *);
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
"image"
|
||||
)
|
||||
|
||||
// #include "objc_darwin.h"
|
||||
|
@ -16,7 +17,6 @@ type table struct {
|
|||
|
||||
*scroller
|
||||
|
||||
images []C.id
|
||||
selected *event
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
|
|||
coltype := C.colTypeText
|
||||
editable := false
|
||||
switch {
|
||||
case ty.Field(i).Type == reflect.TypeOf(ImageIndex(0)):
|
||||
case ty.Field(i).Type == reflect.TypeOf((*image.RGBA)(nil)):
|
||||
coltype = C.colTypeImage
|
||||
case ty.Field(i).Type.Kind() == reflect.Bool:
|
||||
coltype = C.colTypeCheckbox
|
||||
|
@ -88,10 +88,11 @@ func goTableDataSource_getValue(data unsafe.Pointer, row C.intptr_t, col C.intpt
|
|||
d := reflect.Indirect(reflect.ValueOf(t.data))
|
||||
datum := d.Index(int(row)).Field(int(col))
|
||||
switch {
|
||||
case datum.Type() == reflect.TypeOf(ImageIndex(0)):
|
||||
case datum.Type() == reflect.TypeOf((*image.RGBA)(nil)):
|
||||
*outtype = C.colTypeImage
|
||||
d := datum.Interface().(ImageIndex)
|
||||
return unsafe.Pointer(t.images[d])
|
||||
d := datum.Interface().(*image.RGBA)
|
||||
img := C.toTableImage(unsafe.Pointer(pixelData(img)), C.intptr_t(d.Rect.Dx()), C.intptr_t(d.Rect.Dy()), C.intptr_t(d.Stride))
|
||||
return unsafe.Pointer(img)
|
||||
case datum.Kind() == reflect.Bool:
|
||||
*outtype = C.colTypeCheckbox
|
||||
if datum.Bool() == true {
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
ret = goTableDataSource_getValue(self->gotable, (intptr_t) row, colnum, &type);
|
||||
switch (type) {
|
||||
case colTypeImage:
|
||||
// TODO free the returned image when done somehow
|
||||
return (id) ret;
|
||||
case colTypeCheckbox:
|
||||
if (ret == NULL)
|
||||
|
|
Loading…
Reference in New Issue