Implemented tabbing properly. Tab order still backwards.
This commit is contained in:
parent
634ef7d4d9
commit
3084d0f243
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue