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-10-18 16:03:07 -05:00
|
|
|
*controlSingleObject
|
|
|
|
tabs []*container
|
|
|
|
children []Control
|
2014-07-25 22:11:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func newTab() Tab {
|
2014-10-18 16:03:07 -05:00
|
|
|
t := &tab{
|
|
|
|
controlSingleObject: newControlSingleObject(C.newTab()),
|
2014-08-04 16:07:06 -05:00
|
|
|
}
|
2014-10-18 16:03:07 -05:00
|
|
|
t.fpreferredSize = t.xpreferredSize
|
|
|
|
return t
|
2014-07-25 22:11:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) Append(name string, control Control) {
|
2014-10-27 23:13:18 -05:00
|
|
|
c := newContainer(control.resize)
|
2014-08-04 16:03:07 -05:00
|
|
|
t.tabs = append(t.tabs, c)
|
2014-10-18 16:03:07 -05:00
|
|
|
control.setParent(c.parent())
|
|
|
|
t.children = append(t.children, control)
|
2014-07-25 22:11:41 -05:00
|
|
|
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-07-25 22:11:41 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
func (t *tab) xpreferredSize(d *sizing) (width, height int) {
|
|
|
|
s := C.tabPreferredSize(t.id)
|
2014-08-03 19:08:25 -05:00
|
|
|
return int(s.width), int(s.height)
|
|
|
|
}
|
|
|
|
|
2014-10-27 22:57:54 -05:00
|
|
|
// no need to handle resize; the children containers handle that for us
|