2014-07-30 01:06:01 -05:00
|
|
|
// 30 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
2014-07-30 11:36:00 -05:00
|
|
|
// Control represents a control.
|
|
|
|
type Control interface {
|
2014-10-02 09:05:53 -05:00
|
|
|
setParent(p *controlParent) // controlParent defined per-platform
|
2014-10-18 16:03:07 -05:00
|
|
|
preferredSize(d *sizing) (width, height int)
|
|
|
|
resize(x int, y int, width int, height int, d *sizing)
|
|
|
|
nTabStops() int // used by the Windows backend
|
2014-10-26 14:15:13 -05:00
|
|
|
|
|
|
|
// these are provided for Tab on Windows, where we have to show and hide the individual tab pages manually
|
|
|
|
// if we ever get something like a SidebarStack of some sort, we'll need to implement this everywhere
|
|
|
|
containerShow() // show if and only if programmer said to show
|
|
|
|
containerHide() // hide regardless of whether programmer said to hide
|
2014-07-30 11:36:00 -05:00
|
|
|
}
|
|
|
|
|
2014-10-18 16:03:07 -05:00
|
|
|
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
|
2014-10-26 14:15:13 -05:00
|
|
|
fcontainerShow func()
|
|
|
|
fcontainerHide func()
|
2014-10-18 16:03:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// children should not use the same name as these, otherwise weird things will happen
|
|
|
|
|
|
|
|
func (c *controlbase) setParent(p *controlParent) {
|
|
|
|
c.fsetParent(p)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *controlbase) preferredSize(d *sizing) (width, height int) {
|
|
|
|
return c.fpreferredSize(d)
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
2014-07-30 19:38:01 -05:00
|
|
|
}
|
2014-10-26 14:15:13 -05:00
|
|
|
|
|
|
|
func (c *controlbase) containerShow() {
|
|
|
|
c.fcontainerShow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *controlbase) containerHide() {
|
|
|
|
c.fcontainerHide()
|
|
|
|
}
|