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
|
// nChildren() int // TODO
|
||||||
preferredSize(d *sizing) (width, height int)
|
preferredSize(d *sizing) (width, height int)
|
||||||
resize(x int, y int, width int, height int, d *sizing)
|
resize(x int, y int, width int, height int, d *sizing)
|
||||||
|
nTabStops() int
|
||||||
}
|
}
|
||||||
|
|
||||||
type controlbase struct {
|
type controlbase struct {
|
||||||
fsetParent func(p *controlParent)
|
fsetParent func(p *controlParent)
|
||||||
fpreferredSize func(d *sizing) (width, height int)
|
fpreferredSize func(d *sizing) (width, height int)
|
||||||
fresize func(x int, y int, width int, height int, d *sizing)
|
fresize func(x int, y int, width int, height int, d *sizing)
|
||||||
|
fnTabStops func() int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controlbase) setParent(p *controlParent) {
|
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) {
|
func (c *controlbase) resize(x int, y int, width int, height int, d *sizing) {
|
||||||
c.fresize(x, y, width, height, d)
|
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{
|
c.controlbase = &controlbase{
|
||||||
fsetParent: c.setParent,
|
fsetParent: c.setParent,
|
||||||
fresize: c.resize,
|
fresize: c.resize,
|
||||||
|
fnTabStops: func() int {
|
||||||
|
// most controls count as one tab stop
|
||||||
|
return 1
|
||||||
|
},
|
||||||
}
|
}
|
||||||
c.hwnd = hwnd
|
c.hwnd = hwnd
|
||||||
return c
|
return c
|
||||||
|
|
|
@ -423,3 +423,11 @@ func (g *grid) preferredSize(d *sizing) (width, height int) {
|
||||||
return colwidth + (g.xmax-1)*d.xpadding,
|
return colwidth + (g.xmax-1)*d.xpadding,
|
||||||
rowheight + (g.ymax-1)*d.ypadding
|
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.fpreferredSize = g.preferredSize
|
||||||
g.fresize = g.resize
|
g.fresize = g.resize
|
||||||
|
g.fnTabStops = control.nTabStops // groupbox itself is not tabbable but the contents might be
|
||||||
g.SetText(text)
|
g.SetText(text)
|
||||||
C.controlSetControlFont(g.hwnd)
|
C.controlSetControlFont(g.hwnd)
|
||||||
control.setParent(&controlParent{g.hwnd})
|
control.setParent(&controlParent{g.hwnd})
|
||||||
|
|
|
@ -22,6 +22,10 @@ func newLabel(text string) Label {
|
||||||
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
|
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
|
||||||
}
|
}
|
||||||
l.fpreferredSize = l.preferredSize
|
l.fpreferredSize = l.preferredSize
|
||||||
|
l.fnTabStops = func() int {
|
||||||
|
// labels are not tab stops
|
||||||
|
return 0
|
||||||
|
}
|
||||||
l.SetText(text)
|
l.SetText(text)
|
||||||
C.controlSetControlFont(l.hwnd)
|
C.controlSetControlFont(l.hwnd)
|
||||||
return l
|
return l
|
||||||
|
|
|
@ -215,3 +215,13 @@ func (g *simpleGrid) preferredSize(d *sizing) (width int, height int) {
|
||||||
}
|
}
|
||||||
return width, height
|
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
|
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
|
// TODO the below needs to be changed
|
||||||
|
|
||||||
// Space returns a null Control intended for padding layouts with blank space.
|
// Space returns a null Control intended for padding layouts with blank space.
|
||||||
|
|
|
@ -30,6 +30,7 @@ func newTab() Tab {
|
||||||
}
|
}
|
||||||
t.fpreferredSize = t.preferredSize
|
t.fpreferredSize = t.preferredSize
|
||||||
t.fresize = t.resize
|
t.fresize = t.resize
|
||||||
|
// count tabs as 1 tab stop; the actual number of tab stops varies
|
||||||
C.controlSetControlFont(t.hwnd)
|
C.controlSetControlFont(t.hwnd)
|
||||||
C.setTabSubclass(t.hwnd, unsafe.Pointer(t))
|
C.setTabSubclass(t.hwnd, unsafe.Pointer(t))
|
||||||
return 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
|
if len(t.tabs) == 0 { // currently no tabs
|
||||||
return C.FALSE
|
return C.FALSE
|
||||||
}
|
}
|
||||||
return C.TRUE/*TODO
|
if t.children[int(which)].nTabStops() > 0 {
|
||||||
if t.tabs[int(which)].nchildren > 0 {
|
|
||||||
return C.TRUE
|
return C.TRUE
|
||||||
}
|
}
|
||||||
return C.FALSE
|
return C.FALSE
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tab) preferredSize(d *sizing) (width, height int) {
|
func (t *tab) preferredSize(d *sizing) (width, height int) {
|
||||||
|
|
Loading…
Reference in New Issue