summaryrefslogtreecommitdiff
path: root/tab_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-30 23:02:02 -0400
committerPietro Gagliardi <[email protected]>2014-08-30 23:02:02 -0400
commit77bf566ebbcb62acd4d08d905d9542d6ff9b6b80 (patch)
treeeeb8e72bc3bf57f5be7f0c0af4319189ac6de838 /tab_darwin.m
parent155899c65ed32245e2ccad4197a10c77017d835b (diff)
...in with the new.
Diffstat (limited to 'tab_darwin.m')
-rw-r--r--tab_darwin.m40
1 files changed, 40 insertions, 0 deletions
diff --git a/tab_darwin.m b/tab_darwin.m
new file mode 100644
index 0000000..1c2920a
--- /dev/null
+++ b/tab_darwin.m
@@ -0,0 +1,40 @@
+// 25 july 2014
+
+#import "objc_darwin.h"
+#import "_cgo_export.h"
+#import <Cocoa/Cocoa.h>
+
+#define toNSTabView(x) ((NSTabView *) (x))
+#define toNSView(x) ((NSView *) (x))
+
+id newTab(void)
+{
+ NSTabView *t;
+
+ t = [[NSTabView alloc] initWithFrame:NSZeroRect];
+ setStandardControlFont((id) t); // safe; same selector provided by NSTabView
+ return (id) t;
+}
+
+void tabAppend(id t, char *name, id view)
+{
+ NSTabViewItem *i;
+
+ i = [[NSTabViewItem alloc] initWithIdentifier:nil];
+ [i setLabel:[NSString stringWithUTF8String:name]];
+ [i setView:toNSView(view)];
+ [toNSTabView(t) addTabViewItem:i];
+}
+
+struct xsize tabPreferredSize(id control)
+{
+ NSTabView *tv;
+ NSSize s;
+ struct xsize t;
+
+ tv = toNSTabView(control);
+ s = [tv minimumSize];
+ t.width = (intptr_t) s.width;
+ t.height = (intptr_t) s.height;
+ return t;
+}