summaryrefslogtreecommitdiff
path: root/redo/tab_unix.go
blob: ba7d106fbcc47b029e49452c14d32e92cdcbbe3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// +build !windows,!darwin

// 25 july 2014

package ui

import (
	"unsafe"
)

// #include "gtk_unix.h"
import "C"

type tab struct {
	_widget		*C.GtkWidget
	notebook		*C.GtkNotebook

	tabs			[]*layout
}

func newTab() Tab {
	widget := C.gtk_notebook_new()
	t := &tab{
		_widget:		widget,
		notebook:		(*C.GtkNotebook)(unsafe.Pointer(widget)),
	}
	// 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) {
	tl := newLayout(control)
	t.tabs = append(t.tabs, tl)
	cname := togstr(name)
	defer freegstr(cname)
	tab := C.gtk_notebook_append_page(t.notebook,
		tl.layoutwidget,
		C.gtk_label_new(cname))
	if tab == -1 {
		panic("gtk_notebook_append_page() failed")
	}
}

func (t *tab) widget() *C.GtkWidget {
	return t._widget
}

func (t *tab) setParent(p *controlParent) {
	basesetParent(t, p)
}

func (t *tab) containerShow() {
	basecontainerShow(t)
}

func (t *tab) containerHide() {
	basecontainerHide(t)
}

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) {
	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(d)
}