2014-07-25 22:11:41 -05:00
|
|
|
// 25 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "objc_darwin.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type tab struct {
|
2014-07-30 11:34:54 -05:00
|
|
|
*controlbase
|
2014-07-25 22:11:41 -05:00
|
|
|
|
|
|
|
containers []*container
|
|
|
|
}
|
|
|
|
|
|
|
|
func newTab() Tab {
|
|
|
|
t := new(tab)
|
|
|
|
id := C.newTab(unsafe.Pointer(t))
|
2014-07-30 11:34:54 -05:00
|
|
|
t.controlbase = newControl(id)
|
2014-07-25 22:11:41 -05:00
|
|
|
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
|
2014-07-29 22:01:28 -05:00
|
|
|
c.child.setParent(&controlParent{tabview})
|
2014-07-25 22:11:41 -05:00
|
|
|
}
|
|
|
|
|
2014-07-30 11:34:54 -05:00
|
|
|
// no need to override Control.allocate() as only prepared the tabbed control; its children will be reallocated when that one is resized
|
2014-07-25 22:11:41 -05:00
|
|
|
|
|
|
|
//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 {
|
2014-07-28 14:02:27 -05:00
|
|
|
// the tab area's coordinate system is localized, so the origin is (0, 0)
|
|
|
|
c.resize(0, 0, int(width), int(height))
|
2014-07-25 22:11:41 -05:00
|
|
|
}
|
|
|
|
}
|