summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--newctrl/control.go6
-rw-r--r--newctrl/control_windows.go4
-rw-r--r--newctrl/grid.go8
-rw-r--r--newctrl/group_windows.go1
-rw-r--r--newctrl/label_windows.go4
-rw-r--r--newctrl/simplegrid.go10
-rw-r--r--newctrl/stack.go8
-rw-r--r--newctrl/tab_windows.go5
8 files changed, 43 insertions, 3 deletions
diff --git a/newctrl/control.go b/newctrl/control.go
index 028b195..1f08ce2 100644
--- a/newctrl/control.go
+++ b/newctrl/control.go
@@ -8,12 +8,14 @@ type Control interface {
// nChildren() int // TODO
preferredSize(d *sizing) (width, height int)
resize(x int, y int, width int, height int, d *sizing)
+ nTabStops() int
}
type controlbase struct {
fsetParent func(p *controlParent)
fpreferredSize func(d *sizing) (width, height int)
fresize func(x int, y int, width int, height int, d *sizing)
+ fnTabStops func() int
}
func (c *controlbase) setParent(p *controlParent) {
@@ -27,3 +29,7 @@ func (c *controlbase) preferredSize(d *sizing) (width, height int) {
func (c *controlbase) resize(x int, y int, width int, height int, d *sizing) {
c.fresize(x, y, width, height, d)
}
+
+func (c *controlbase) nTabStops() int {
+ return c.fnTabStops()
+}
diff --git a/newctrl/control_windows.go b/newctrl/control_windows.go
index 1da8a60..687092a 100644
--- a/newctrl/control_windows.go
+++ b/newctrl/control_windows.go
@@ -21,6 +21,10 @@ func newControlSingleHWND(hwnd C.HWND) *controlSingleHWND {
c.controlbase = &controlbase{
fsetParent: c.setParent,
fresize: c.resize,
+ fnTabStops: func() int {
+ // most controls count as one tab stop
+ return 1
+ },
}
c.hwnd = hwnd
return c
diff --git a/newctrl/grid.go b/newctrl/grid.go
index 3c6f343..98abf9b 100644
--- a/newctrl/grid.go
+++ b/newctrl/grid.go
@@ -423,3 +423,11 @@ func (g *grid) preferredSize(d *sizing) (width, height int) {
return colwidth + (g.xmax-1)*d.xpadding,
rowheight + (g.ymax-1)*d.ypadding
}
+
+func (g *grid) nTabStops() int {
+ n := 0
+ for _, c := range g.controls {
+ n += c.control.nTabStops()
+ }
+ return n
+}
diff --git a/newctrl/group_windows.go b/newctrl/group_windows.go
index 6c68d9d..85292c1 100644
--- a/newctrl/group_windows.go
+++ b/newctrl/group_windows.go
@@ -21,6 +21,7 @@ func newGroup(text string, control Control) Group {
}
g.fpreferredSize = g.preferredSize
g.fresize = g.resize
+ g.fnTabStops = control.nTabStops // groupbox itself is not tabbable but the contents might be
g.SetText(text)
C.controlSetControlFont(g.hwnd)
control.setParent(&controlParent{g.hwnd})
diff --git a/newctrl/label_windows.go b/newctrl/label_windows.go
index f926081..61d842f 100644
--- a/newctrl/label_windows.go
+++ b/newctrl/label_windows.go
@@ -22,6 +22,10 @@ func newLabel(text string) Label {
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
}
l.fpreferredSize = l.preferredSize
+ l.fnTabStops = func() int {
+ // labels are not tab stops
+ return 0
+ }
l.SetText(text)
C.controlSetControlFont(l.hwnd)
return l
diff --git a/newctrl/simplegrid.go b/newctrl/simplegrid.go
index faa77c7..3bf6215 100644
--- a/newctrl/simplegrid.go
+++ b/newctrl/simplegrid.go
@@ -215,3 +215,13 @@ func (g *simpleGrid) preferredSize(d *sizing) (width int, height int) {
}
return width, height
}
+
+func (g *simpleGrid) nTabStops() int {
+ n := 0
+ for _, cc := range g.controls {
+ for _, c := range cc {
+ n += c.nTabStops()
+ }
+ }
+ return n
+} \ No newline at end of file
diff --git a/newctrl/stack.go b/newctrl/stack.go
index dfa4b64..7de2fbb 100644
--- a/newctrl/stack.go
+++ b/newctrl/stack.go
@@ -180,6 +180,14 @@ func (s *stack) preferredSize(d *sizing) (width int, height int) {
return
}
+func (s *stack) nTabStops() int {
+ n := 0
+ for _, c := range s.controls {
+ n += c.nTabStops()
+ }
+ return n
+}
+
// TODO the below needs to be changed
// Space returns a null Control intended for padding layouts with blank space.
diff --git a/newctrl/tab_windows.go b/newctrl/tab_windows.go
index c0c3bc9..e3fe01e 100644
--- a/newctrl/tab_windows.go
+++ b/newctrl/tab_windows.go
@@ -30,6 +30,7 @@ func newTab() Tab {
}
t.fpreferredSize = t.preferredSize
t.fresize = t.resize
+ // count tabs as 1 tab stop; the actual number of tab stops varies
C.controlSetControlFont(t.hwnd)
C.setTabSubclass(t.hwnd, unsafe.Pointer(t))
return t
@@ -67,12 +68,10 @@ func tabTabHasChildren(data unsafe.Pointer, which C.LRESULT) C.BOOL {
if len(t.tabs) == 0 { // currently no tabs
return C.FALSE
}
-return C.TRUE/*TODO
- if t.tabs[int(which)].nchildren > 0 {
+ if t.children[int(which)].nTabStops() > 0 {
return C.TRUE
}
return C.FALSE
-*/
}
func (t *tab) preferredSize(d *sizing) (width, height int) {