2024-01-18 00:08:37 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-02-01 11:59:21 -06:00
|
|
|
log "go.wit.com/log"
|
2024-02-09 09:30:23 -06:00
|
|
|
"go.wit.com/toolkits/tree"
|
2024-01-18 04:10:08 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-18 00:08:37 -06:00
|
|
|
)
|
|
|
|
|
2024-02-09 09:30:23 -06:00
|
|
|
func setChecked(n *tree.Node, b bool) {
|
|
|
|
if n.WidgetType != widget.Checkbox {
|
|
|
|
}
|
|
|
|
var tk *guiWidget
|
|
|
|
tk = n.TK.(*guiWidget)
|
|
|
|
|
|
|
|
if tk.node.State.Label == "" {
|
|
|
|
tk.node.State.Label = "BLANK"
|
|
|
|
}
|
|
|
|
if tk.node.State.Checked {
|
|
|
|
log.Log(WARN, "setCheckbox() got true", tk.node.State.Checked)
|
|
|
|
tk.labelN = "X " + tk.node.State.Label
|
|
|
|
} else {
|
|
|
|
log.Log(WARN, "setCheckbox() got false", tk.node.State.Checked)
|
|
|
|
tk.labelN = " " + tk.node.State.Label
|
|
|
|
}
|
|
|
|
|
|
|
|
tk.Hide()
|
|
|
|
tk.Show()
|
|
|
|
}
|
|
|
|
|
2024-02-01 11:59:21 -06:00
|
|
|
// redraw the checkbox
|
|
|
|
func (w *guiWidget) setCheckbox() {
|
2024-01-28 02:20:31 -06:00
|
|
|
if w.node.WidgetType != widget.Checkbox {
|
2024-02-01 11:59:21 -06:00
|
|
|
log.Log(WARN, "setCheckbox() being run on widget:", w.node.WidgetType)
|
2024-01-18 00:08:37 -06:00
|
|
|
return
|
|
|
|
}
|
2024-01-28 03:33:08 -06:00
|
|
|
if w.node.State.Label == "" {
|
|
|
|
w.node.State.Label = "BLANK"
|
|
|
|
}
|
2024-02-01 11:59:21 -06:00
|
|
|
if w.node.State.Checked {
|
|
|
|
log.Log(WARN, "setCheckbox() got true", w.node.State.Checked)
|
2024-01-28 03:33:08 -06:00
|
|
|
w.labelN = "X " + w.node.State.Label
|
2024-02-01 11:59:21 -06:00
|
|
|
// w.changed = true
|
2024-01-18 00:08:37 -06:00
|
|
|
} else {
|
2024-02-01 11:59:21 -06:00
|
|
|
log.Log(WARN, "setCheckbox() got false", w.node.State.Checked)
|
2024-01-28 03:33:08 -06:00
|
|
|
w.labelN = " " + w.node.State.Label
|
2024-02-01 11:59:21 -06:00
|
|
|
// w.changed = true
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|
2024-02-01 11:59:21 -06:00
|
|
|
// t := len(w.labelN) + 3
|
|
|
|
// w.gocuiSize.w1 = w.gocuiSize.w0 + t
|
2024-01-18 00:08:37 -06:00
|
|
|
|
2024-02-05 03:05:37 -06:00
|
|
|
w.Hide()
|
2024-02-05 02:22:58 -06:00
|
|
|
w.Show()
|
2024-01-18 00:08:37 -06:00
|
|
|
}
|