summaryrefslogtreecommitdiff
path: root/redo/containerctrls_darwin.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-30 00:54:50 -0400
committerPietro Gagliardi <[email protected]>2014-07-30 00:54:50 -0400
commit5a51263adc6d2e8ee7ea0dac4d92a66755c07cb1 (patch)
tree0ee46724c8518419cce73cc2fdeda0ed3399357e /redo/containerctrls_darwin.go
parent8b1756e95236202c3baccb4a4c56c40abb12b446 (diff)
Renamed the controls* and containers* files to basicctrls* and containerctrls*, respectively, in preparation for the widget hierarchy redo.
Diffstat (limited to 'redo/containerctrls_darwin.go')
-rw-r--r--redo/containerctrls_darwin.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/redo/containerctrls_darwin.go b/redo/containerctrls_darwin.go
new file mode 100644
index 0000000..0e0221a
--- /dev/null
+++ b/redo/containerctrls_darwin.go
@@ -0,0 +1,48 @@
+// 25 july 2014
+
+package ui
+
+import (
+ "unsafe"
+)
+
+// #include "objc_darwin.h"
+import "C"
+
+type tab struct {
+ *widgetbase
+
+ containers []*container
+}
+
+func newTab() Tab {
+ t := new(tab)
+ id := C.newTab(unsafe.Pointer(t))
+ t.widgetbase = newWidget(id)
+ return t
+}
+
+func (t *tab) Append(name string, control Control) {
+ // TODO isolate and standardize
+ c := new(container)
+ t.containers = append(t.containers, c)
+ cname := C.CString(name)
+ defer C.free(unsafe.Pointer(cname))
+ tabview := C.tabAppend(t.id, cname)
+ c.child = control
+ c.child.setParent(&controlParent{tabview})
+}
+
+func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
+ // only prepared the tabbed control; its children will be reallocated when that one is resized
+ return t.widgetbase.allocate(x, y, width, height, d)
+}
+
+//export tabResized
+func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) {
+ t := (*tab)(unsafe.Pointer(data))
+ for _, c := range t.containers {
+ // the tab area's coordinate system is localized, so the origin is (0, 0)
+ c.resize(0, 0, int(width), int(height))
+ }
+}