summaryrefslogtreecommitdiff
path: root/redo/containerctrls_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-02 22:35:58 -0400
committerPietro Gagliardi <[email protected]>2014-08-02 22:35:58 -0400
commitd018953d7ef1b276cc3229e04ba6fc75018c888a (patch)
tree3f980a017ca498bf499ff9c5e6a53210606b12f9 /redo/containerctrls_windows.go
parent1f6bcde3d9ddcab921f2f4347148f6784ca36a14 (diff)
Split all the Control implementations into their own files and renamed the containerctrls implementation files to say tab instead as they only hold Tab. This is the first part of what should hopefully be the final restructuring.
Diffstat (limited to 'redo/containerctrls_windows.go')
-rw-r--r--redo/containerctrls_windows.go110
1 files changed, 0 insertions, 110 deletions
diff --git a/redo/containerctrls_windows.go b/redo/containerctrls_windows.go
deleted file mode 100644
index e9d116b..0000000
--- a/redo/containerctrls_windows.go
+++ /dev/null
@@ -1,110 +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 {
- *controlbase
- tabs []*sizer
- supersetParent func(p *controlParent)
- superallocate func(x int, y int, width int, height int, d *sizing) []*allocation
-}
-
-func newTab() Tab {
- c := newControl(C.xWC_TABCONTROL,
- C.TCS_TOOLTIPS | C.WS_TABSTOP,
- 0)
- t := &tab{
- controlbase: c,
- }
- t.supersetParent = t.fsetParent
- t.fsetParent = t.tabsetParent
- t.fpreferredSize = t.tabpreferredSize
- t.superallocate = t.fallocate
- t.fallocate = t.taballocate
- C.controlSetControlFont(t.hwnd)
- C.setTabSubclass(t.hwnd, unsafe.Pointer(t))
- return t
-}
-
-func (t *tab) tabsetParent(p *controlParent) {
- t.supersetParent(p)
- for _, c := range t.tabs {
- c.child.setParent(p)
- }
-}
-
-func (t *tab) Append(name string, control Control) {
- s := new(sizer)
- t.tabs = append(t.tabs, s)
- s.child = control
- if t.parent != nil {
- s.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 {
- s.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()
-}
-
-func (t *tab) tabpreferredSize(d *sizing) (width, height int) {
- // TODO only consider the size of the current tab?
- for _, s := range t.tabs {
- w, h := s.child.preferredSize(d)
- if width < w {
- width = w
- }
- if height < h {
- height = h
- }
- }
- return width, height + int(C.tabGetTabHeight(t.hwnd))
-}
-
-// a tab control contains other controls; size appropriately
-// TODO change this to commitResize()
-func (t *tab) taballocate(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 _, s := range t.tabs {
- // because each widget is actually a child of the Window, the origin is the one we calculated above
- s.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.superallocate(x, y, width, height, d)
-}