summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tab_windows.go22
1 files changed, 7 insertions, 15 deletions
diff --git a/tab_windows.go b/tab_windows.go
index 1fd5a6a..1ff3c04 100644
--- a/tab_windows.go
+++ b/tab_windows.go
@@ -11,13 +11,10 @@ import "C"
/*
On Windows, container controls are just regular controls that notify their parent when the user wants to do things; changing the contents of a switching container (such as a tab control) must be done manually.
-
-We'll create a dummy window using the container window class for each tab page. This makes showing and hiding tabs a matter of showing and hiding one control.
*/
type tab struct {
*controlSingleHWND
- tabs []*container
children []Control
chainresize func(x int, y int, width int, height int, d *sizing)
// TODO don't save this (will make things easier)
@@ -43,14 +40,11 @@ func newTab() Tab {
// TODO margined
func (t *tab) Append(name string, control Control) {
- c := newContainer()
- control.setParent(&controlParent{c.hwnd})
- c.setParent(&controlParent{t.hwnd})
- t.tabs = append(t.tabs, c)
+ control.setParent(&controlParent{t.hwnd})
t.children = append(t.children, control)
// initially hide tab 1..n controls; if we don't, they'll appear over other tabs, resulting in weird behavior
- if len(t.tabs) != 1 {
- t.tabs[len(t.tabs)-1].hide()
+ if len(t.children) != 1 {
+ t.children[len(t.children)-1].containerHide()
}
C.tabAppend(t.hwnd, toUTF16(name))
}
@@ -58,7 +52,7 @@ func (t *tab) Append(name string, control Control) {
//export tabChanging
func tabChanging(data unsafe.Pointer, current C.LRESULT) {
t := (*tab)(data)
- t.tabs[int(current)].hide()
+ t.children[int(current)].containerHide()
}
//export tabChanged
@@ -66,13 +60,13 @@ func tabChanged(data unsafe.Pointer, new C.LRESULT) {
t := (*tab)(data)
t.current = int(new)
// TODO resize the new tab
- t.tabs[t.current].show()
+ t.children[t.current].containerShow()
}
//export tabTabHasChildren
func tabTabHasChildren(data unsafe.Pointer, which C.LRESULT) C.BOOL {
t := (*tab)(data)
- if len(t.tabs) == 0 { // currently no tabs
+ if len(t.children) == 0 { // currently no tabs
return C.FALSE
}
if t.children[int(which)].nTabStops() > 0 {
@@ -109,7 +103,5 @@ func tabResized(data unsafe.Pointer, r C.RECT) {
d := beginResize(t.hwnd)
// only need to resize the current tab; we resize new tabs when the tab changes in tabChanged() above
// because each widget is actually a child of the Window, the origin is the one we calculated above
- t.tabs[t.current].resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top), d)
- // TODO get the actual client rect
- t.children[t.current].resize(int(0), int(0), int(r.right - r.left), int(r.bottom - r.top), d)
+ t.children[t.current].resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top), d)
}