summaryrefslogtreecommitdiff
path: root/redo/containers_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-30 00:54:50 -0400
committerPietro Gagliardi <[email protected]>2014-07-30 00:54:50 -0400
commit5a51263adc6d2e8ee7ea0dac4d92a66755c07cb1 (patch)
tree0ee46724c8518419cce73cc2fdeda0ed3399357e /redo/containers_windows.go
parent8b1756e95236202c3baccb4a4c56c40abb12b446 (diff)
Renamed the controls* and containers* files to basicctrls* and containerctrls*, respectively, in preparation for the widget hierarchy redo.
Diffstat (limited to 'redo/containers_windows.go')
-rw-r--r--redo/containers_windows.go88
1 files changed, 0 insertions, 88 deletions
diff --git a/redo/containers_windows.go b/redo/containers_windows.go
deleted file mode 100644
index cc881e7..0000000
--- a/redo/containers_windows.go
+++ /dev/null
@@ -1,88 +0,0 @@
-// 25 july 2014
-
-package ui
-
-import (
- "unsafe"
-)
-
-// #include "winapi_windows.h"
-import "C"
-
-/*
-On Windows, container controls are just regular controls; their children have to be children of the parent window, and changing the contents of a switching container (such as a tab control) must be done manually.
-
-TODO
-- make sure all tabs cannot be deselected (that is, make sure the current tab can never have index -1)
-- see if we can safely make the controls children of the tab control itself or if that would just screw our subclassing
-*/
-
-type tab struct {
- *widgetbase
- tabs []*container
-}
-
-func newTab() Tab {
- w := newWidget(C.xWC_TABCONTROL,
- C.TCS_TOOLTIPS | C.WS_TABSTOP,
- 0)
- t := &tab{
- widgetbase: w,
- }
- C.controlSetControlFont(w.hwnd)
- C.setTabSubclass(w.hwnd, unsafe.Pointer(t))
- return t
-}
-
-func (t *tab) setParent(p *controlParent) {
- t.widgetbase.setParent(p)
- for _, c := range t.tabs {
- c.child.setParent(p)
- }
-}
-
-func (t *tab) Append(name string, control Control) {
- c := new(container)
- t.tabs = append(t.tabs, c)
- c.child = control
- if t.parent != nil {
- c.child.setParent(&controlParent{t.parent})
- }
- // 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 {
- c.child.containerHide()
- }
- C.tabAppend(t.hwnd, toUTF16(name))
-}
-
-//export tabChanging
-func tabChanging(data unsafe.Pointer, current C.LRESULT) {
- t := (*tab)(data)
- t.tabs[int(current)].child.containerHide()
-}
-
-//export tabChanged
-func tabChanged(data unsafe.Pointer, new C.LRESULT) {
- t := (*tab)(data)
- t.tabs[int(new)].child.containerShow()
-}
-
-// a tab control contains other controls; size appropriately
-func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
- var r C.RECT
-
- // figure out what the rect for each child is...
- r.left = C.LONG(x) // load structure with the window's rect
- r.top = C.LONG(y)
- r.right = C.LONG(x + width)
- r.bottom = C.LONG(y + height)
- C.tabGetContentRect(t.hwnd, &r)
- // and allocate
- // don't allocate to just the current tab; allocate to all tabs!
- for _, c := range t.tabs {
- // because each widget is actually a child of the Window, the origin is the one we calculated above
- c.resize(int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top))
- }
- // and now allocate the tab control itself
- return t.widgetbase.allocate(x, y, width, height, d)
-}