diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-02 22:35:58 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-02 22:35:58 -0400 |
| commit | d018953d7ef1b276cc3229e04ba6fc75018c888a (patch) | |
| tree | 3f980a017ca498bf499ff9c5e6a53210606b12f9 /redo/tab_darwin.go | |
| parent | 1f6bcde3d9ddcab921f2f4347148f6784ca36a14 (diff) | |
Split all the Control implementations into their own files and renamed the containerctrls implementation files to say tab instead as they only hold Tab. This is the first part of what should hopefully be the final restructuring.
Diffstat (limited to 'redo/tab_darwin.go')
| -rw-r--r-- | redo/tab_darwin.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/redo/tab_darwin.go b/redo/tab_darwin.go new file mode 100644 index 0000000..ef834ad --- /dev/null +++ b/redo/tab_darwin.go @@ -0,0 +1,50 @@ +// 25 july 2014 + +package ui + +import ( + "unsafe" +) + +// #include "objc_darwin.h" +import "C" + +type tab struct { + *controlbase + + tabs []*sizer +} + +func newTab() Tab { + t := new(tab) + id := C.newTab(unsafe.Pointer(t)) + t.controlbase = newControl(id) + t.fpreferredSize = t.tabpreferredSize + return t +} + +func (t *tab) Append(name string, control Control) { + s := new(sizer) + t.tabs = append(t.tabs, s) + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) + tabview := C.tabAppend(t.id, cname) + s.child = control + s.child.setParent(&controlParent{tabview}) +} + +func (t *tab) tabpreferredSize(d *sizing) (width, height int) { + s := C.tabPrefSize(t.id) + return int(s.width), int(s.height) +} + +// no need to override Control.commitResize() as only prepared the tabbed control; its children will be reallocated when that one is resized + +//export tabResized +func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) { + t := (*tab)(unsafe.Pointer(data)) + for _, s := range t.tabs { + // the tab area's coordinate system is localized, so the origin is (0, 0) + s.resize(0, 0, int(width), int(height)) + } +} |
