2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-21 11:40:08 -05:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
import "git.wit.org/wit/gui/toolkit"
|
2022-10-21 11:40:08 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
func (t andlabsT) NewCheckbox(name string, f func()) *andlabsT {
|
|
|
|
log(debugToolkit, "gui.Toolkit.NewCheckbox()", name)
|
2022-11-14 14:30:28 -06:00
|
|
|
var newt andlabsT
|
2022-10-21 11:40:08 -05:00
|
|
|
|
|
|
|
if t.broken() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
c := ui.NewCheckbox(name)
|
|
|
|
newt.uiCheckbox = c
|
|
|
|
newt.uiBox = t.uiBox
|
|
|
|
t.uiBox.Append(c, stretchy)
|
2023-02-25 14:05:25 -06:00
|
|
|
// newt.Custom = f
|
2022-10-21 11:40:08 -05:00
|
|
|
|
|
|
|
c.OnToggled(func(spin *ui.Checkbox) {
|
2023-02-25 14:05:25 -06:00
|
|
|
// log(debugToolkit, "gui.Toolkit.NewCheckbox() clicked", name)
|
2022-10-21 11:40:08 -05:00
|
|
|
newt.commonChange("Checkbox")
|
2023-02-25 14:05:25 -06:00
|
|
|
/*
|
|
|
|
if (f != nil) {
|
|
|
|
log(debugToolkit, "Run custom() here", f)
|
|
|
|
log(SPEW, f)
|
|
|
|
f()
|
|
|
|
} else {
|
|
|
|
log(debugToolkit, "No custom() function here")
|
|
|
|
}
|
|
|
|
*/
|
2022-10-21 11:40:08 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
return &newt
|
|
|
|
}
|
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
func (t andlabsT) Checked() bool {
|
2022-10-21 11:40:08 -05:00
|
|
|
if t.broken() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return t.uiCheckbox.Checked()
|
|
|
|
}
|
2023-02-25 14:05:25 -06:00
|
|
|
|
|
|
|
func NewCheckbox(parentW *toolkit.Widget, w *toolkit.Widget) {
|
|
|
|
log(debugToolkit, "gui.andlabs.NewCheckbox()", w.Name)
|
|
|
|
|
|
|
|
t := mapToolkits[parentW]
|
|
|
|
if (t == nil) {
|
|
|
|
listMap()
|
|
|
|
}
|
|
|
|
newt := t.NewCheckbox(w.Name, w.Custom)
|
|
|
|
newt.Custom = w.Custom
|
|
|
|
/*
|
|
|
|
if (w.Custom != nil) {
|
|
|
|
log(true, "go.andlabs.NewCheckbox() toolkit struct == nil. name=", parentW.Name, w.Name)
|
|
|
|
log(true, "Run custom() START here", w.Custom)
|
|
|
|
w.Custom()
|
|
|
|
log(true, "Run custom() END")
|
|
|
|
// exit("ran it here")
|
|
|
|
} else {
|
|
|
|
log(true, "No custom() function here")
|
|
|
|
// exit("nothing here")
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
mapWidgetsToolkits(w, newt)
|
|
|
|
}
|