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-02 09:05:53 -05:00
_id C . id
tabs [ ] * container
2014-07-25 22:11:41 -05:00
}
func newTab ( ) Tab {
2014-08-04 16:07:06 -05:00
return & tab {
2014-10-02 09:05:53 -05:00
_id : C . newTab ( ) ,
2014-08-04 16:07:06 -05:00
}
2014-07-25 22:11:41 -05:00
}
func ( t * tab ) Append ( name string , control Control ) {
2014-08-04 16:03:07 -05:00
c := newContainer ( control )
t . tabs = append ( t . tabs , c )
2014-07-25 22:11:41 -05:00
cname := C . CString ( name )
defer C . free ( unsafe . Pointer ( cname ) )
2014-08-11 11:49:39 -05:00
C . tabAppend ( t . _id , cname , c . id )
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 ) {
2014-08-09 20:29:37 -05:00
s := C . tabPreferredSize ( t . _id )
2014-08-03 19:08:25 -05:00
return int ( s . width ) , int ( s . height )
}
2014-08-04 16:07:06 -05:00
// no need to override Control.commitResize() as only prepared the tabbed control; its children will be resized when that one is resized (and NSTabView itself will call setFrame: for us)
2014-08-03 19:08:25 -05:00
func ( t * tab ) commitResize ( a * allocation , d * sizing ) {
basecommitResize ( t , a , d )
}
func ( t * tab ) getAuxResizeInfo ( d * sizing ) {
basegetAuxResizeInfo ( t , d )
}