diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-16 21:49:43 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-16 21:49:43 -0400 |
| commit | 5903dffe3c3f4572491c6575d431f066faa03caf (patch) | |
| tree | ecd8f87191bf297461eb2b0baac17135f8b6feac /redo/table_darwin.m | |
| parent | 37069eadcbd8960ac46031b3455f78463a6bdf3f (diff) | |
Implemented ImageList and Table ImageIndex on Mac OS X.
Diffstat (limited to 'redo/table_darwin.m')
| -rw-r--r-- | redo/table_darwin.m | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/redo/table_darwin.m b/redo/table_darwin.m index 70d9260..ab66682 100644 --- a/redo/table_darwin.m +++ b/redo/table_darwin.m @@ -32,15 +32,20 @@ - (id)tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)col row:(NSInteger)row { - char *str; + void *ret; NSString *s; intptr_t colnum; + char *str; + BOOL isObject = FALSE; colnum = ((goTableColumn *) col)->gocolnum; - str = goTableDataSource_getValue(self->gotable, (intptr_t) row, colnum); + ret = goTableDataSource_getValue(self->gotable, (intptr_t) row, colnum, &isObject); + if (isObject) + return (id) ret; + str = (char *) ret; s = [NSString stringWithUTF8String:str]; free(str); // allocated with C.CString() on the Go side - return s; + return (id) s; } @end @@ -58,12 +63,25 @@ id newTable(void) return (id) t; } -void tableAppendColumn(id t, intptr_t colnum, char *name) +void tableAppendColumn(id t, intptr_t colnum, char *name, int type) { goTableColumn *c; + NSImageCell *ic; c = [[goTableColumn alloc] initWithIdentifier:nil]; c->gocolnum = colnum; + switch (type) { + case colTypeImage: + ic = [[NSImageCell alloc] initImageCell:nil]; + // this is the behavior we want, which differs from the Interface Builder default of proportionally down + [ic setImageScaling:NSImageScaleProportionallyUpOrDown]; + // these two, however, ARE Interface Builder defaults + [ic setImageFrameStyle:NSImageFrameNone]; + [ic setImageAlignment:NSImageAlignCenter]; + [c setDataCell:ic]; + break; + } + // otherwise just use the current cell [c setEditable:NO]; [[c headerCell] setStringValue:[NSString stringWithUTF8String:name]]; setSmallControlFont((id) [c headerCell]); |
