andlabs-ui/prev/tab_darwin.go

42 lines
812 B
Go
Raw Normal View History

// 25 july 2014
package ui
import (
"unsafe"
)
// #include "objc_darwin.h"
import "C"
type tab struct {
2014-10-18 16:03:07 -05:00
*controlSingleObject
tabs []*container
children []Control
}
func newTab() Tab {
2014-10-18 16:03:07 -05:00
t := &tab{
controlSingleObject: newControlSingleObject(C.newTab()),
}
2014-10-18 16:03:07 -05:00
t.fpreferredSize = t.xpreferredSize
return t
}
func (t *tab) Append(name string, control Control) {
2014-10-27 23:13:18 -05:00
c := newContainer(control.resize)
t.tabs = append(t.tabs, c)
2014-10-18 16:03:07 -05:00
control.setParent(c.parent())
t.children = append(t.children, control)
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
2014-10-18 16:03:07 -05:00
C.tabAppend(t.id, cname, c.id)
}
2014-10-18 16:03:07 -05:00
func (t *tab) xpreferredSize(d *sizing) (width, height int) {
s := C.tabPreferredSize(t.id)
return int(s.width), int(s.height)
}
// no need to handle resize; the children containers handle that for us