diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-25 23:11:41 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-25 23:11:41 -0400 |
| commit | ee5c6ff8461d5147fa74205f21b7fce6e5606d74 (patch) | |
| tree | 942d428fd6ceacececeb6ca23d50206f59abdd15 /redo/containers_darwin.go | |
| parent | 41f3ef292f2e0d70beb3722004c968881ca0fae2 (diff) | |
Implemented Tab on Mac OS X. Woo! I'll need to add justification for what I'm doing with the whole recursive call thing; when I get confirmation from the GTK+ camp I will.
Diffstat (limited to 'redo/containers_darwin.go')
| -rw-r--r-- | redo/containers_darwin.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/redo/containers_darwin.go b/redo/containers_darwin.go new file mode 100644 index 0000000..b42708c --- /dev/null +++ b/redo/containers_darwin.go @@ -0,0 +1,52 @@ +// 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) + // don't set beginResize; this container's resize() will be a recursive call + 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(tabview) +} + +func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation { + // set up the recursive calls + for _, c := range t.containers { + c.d = d + } + // and prepare the tabbed control itself + 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 { + c.resize(int(width), int(height)) + } +} |
