gocui/checkbox.go

54 lines
1.2 KiB
Go

package main
import (
log "go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
)
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()
}
// redraw the checkbox
func (w *guiWidget) setCheckbox() {
if w.node.WidgetType != widget.Checkbox {
log.Log(WARN, "setCheckbox() being run on widget:", w.node.WidgetType)
return
}
if w.node.State.Label == "" {
w.node.State.Label = "BLANK"
}
if w.node.State.Checked {
log.Log(WARN, "setCheckbox() got true", w.node.State.Checked)
w.labelN = "X " + w.node.State.Label
// w.changed = true
} else {
log.Log(WARN, "setCheckbox() got false", w.node.State.Checked)
w.labelN = " " + w.node.State.Label
// w.changed = true
}
// t := len(w.labelN) + 3
// w.gocuiSize.w1 = w.gocuiSize.w0 + t
w.Hide()
w.Show()
}