summaryrefslogtreecommitdiff
path: root/redo/table_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-29 10:54:52 -0400
committerPietro Gagliardi <[email protected]>2014-07-29 10:54:52 -0400
commit8d7f0c9a62b9108e262380ae62f8c8b9cbb12bfc (patch)
treeb90dcbac59d436552494e02e302ae27e820cd8f5 /redo/table_darwin.m
parent4e0436da18ef5e8e0c4bbc1c17e5bd5932515991 (diff)
Wrote up the data model for Mac OS X Tables; now Tables work everywhere!
Diffstat (limited to 'redo/table_darwin.m')
-rw-r--r--redo/table_darwin.m27
1 files changed, 27 insertions, 0 deletions
diff --git a/redo/table_darwin.m b/redo/table_darwin.m
index 45e9b0b..7fdef24 100644
--- a/redo/table_darwin.m
+++ b/redo/table_darwin.m
@@ -14,6 +14,24 @@
@end
@implementation goTableDataSource
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)view
+{
+ return (NSInteger) goTableDataSource_getRowCount(self->gotable);
+}
+
+- (id)tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)col row:(NSInteger)row
+{
+ char *str;
+ NSString *s;
+
+ // TODO there has to be a better way to get the column index
+ str = goTableDataSource_getValue(self->gotable, (intptr_t) row, (intptr_t) [[view tableColumns] indexOfObject:col]);
+ s = [NSString stringWithUTF8String:str];
+ free(str); // allocated with C.CString() on the Go side
+ return s;
+}
+
@end
id newTable(void)
@@ -59,3 +77,12 @@ id newScrollView(id content)
[sv setDocumentView:toNSView(content)];
return (id) sv;
}
+
+void tableMakeDataSource(id table, void *gotable)
+{
+ goTableDataSource *model;
+
+ model = [goTableDataSource new];
+ model->gotable = gotable;
+ [toNSTableView(table) setDataSource:model];
+}