diff options
Diffstat (limited to 'tab_unix.go')
| -rw-r--r-- | tab_unix.go | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/tab_unix.go b/tab_unix.go index 79f7844..064f17f 100644 --- a/tab_unix.go +++ b/tab_unix.go @@ -12,30 +12,37 @@ import ( import "C" type tab struct { - _widget *C.GtkWidget + *controlSingleWidget container *C.GtkContainer notebook *C.GtkNotebook tabs []*container + children []Control + + chainresize func(x int, y int, width int, height int, d *sizing) } func newTab() Tab { widget := C.gtk_notebook_new() t := &tab{ - _widget: widget, + controlSingleWidget: newControlSingleWidget(widget), container: (*C.GtkContainer)(unsafe.Pointer(widget)), notebook: (*C.GtkNotebook)(unsafe.Pointer(widget)), } + t.chainresize = t.fresize + t.fresize = t.xresize // there are no scrolling arrows by default; add them in case there are too many tabs C.gtk_notebook_set_scrollable(t.notebook, C.TRUE) return t } func (t *tab) Append(name string, control Control) { - c := newContainer(control) + c := newContainer() t.tabs = append(t.tabs, c) // this calls gtk_container_add(), which, according to gregier in irc.gimp.net/#gtk+, acts just like gtk_notebook_append_page() c.setParent(&controlParent{t.container}) + control.setParent(c.parent()) + t.children = append(t.children, control) cname := togstr(name) defer freegstr(cname) C.gtk_notebook_set_tab_label_text(t.notebook, @@ -44,27 +51,13 @@ func (t *tab) Append(name string, control Control) { cname) } -func (t *tab) widget() *C.GtkWidget { - return t._widget -} - -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) xresize(x int, y int, width int, height int, d *sizing) { + // first, chain up to change the GtkFrame and its child container + t.chainresize(x, y, width, height, d) -func (t *tab) preferredSize(d *sizing) (width, height int) { - return basepreferredSize(t, d) -} - -// 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) + // now that the containers have the correct size, we can resize the children + for i, _ := range t.tabs { + a := t.tabs[i].allocation(false/*TODO*/) + t.children[i].resize(int(a.x), int(a.y), int(a.width), int(a.height), d) + } } |
