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-08-03 19:08:25 -05:00
|
|
|
_id C.id
|
|
|
|
tabs []*sizer
|
2014-07-25 22:11:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func newTab() Tab {
|
|
|
|
t := new(tab)
|
2014-08-03 19:08:25 -05:00
|
|
|
t._id = C.newTab(unsafe.Pointer(t))
|
2014-07-25 22:11:41 -05:00
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) Append(name string, control Control) {
|
2014-08-02 06:28:20 -05:00
|
|
|
s := new(sizer)
|
|
|
|
t.tabs = append(t.tabs, s)
|
2014-07-25 22:11:41 -05:00
|
|
|
cname := C.CString(name)
|
|
|
|
defer C.free(unsafe.Pointer(cname))
|
2014-08-03 19:08:25 -05:00
|
|
|
tabview := C.tabAppend(t._id, cname)
|
2014-08-02 06:28:20 -05:00
|
|
|
s.child = control
|
|
|
|
s.child.setParent(&controlParent{tabview})
|
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))
|
2014-08-02 06:28:20 -05:00
|
|
|
for _, s := range t.tabs {
|
2014-07-28 14:02:27 -05:00
|
|
|
// the tab area's coordinate system is localized, so the origin is (0, 0)
|
2014-08-02 06:28:20 -05:00
|
|
|
s.resize(0, 0, int(width), int(height))
|
2014-07-25 22:11:41 -05:00
|
|
|
}
|
|
|
|
}
|
2014-08-03 19:08:25 -05:00
|
|
|
|
|
|
|
func (t *tab) id() C.id {
|
|
|
|
return t._id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) setParent(p *controlParent) {
|
|
|
|
basesetParent(t, p)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
|
|
|
return baseallocate(t, x, y, width, height, d)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) preferredSize(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
|
|
|
|
func (t *tab) commitResize(a *allocation, d *sizing) {
|
|
|
|
basecommitResize(t, a, d)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) getAuxResizeInfo(d *sizing) {
|
|
|
|
basegetAuxResizeInfo(t, d)
|
|
|
|
}
|