andlabs/add.go

76 lines
1.4 KiB
Go

package main
import (
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
)
func add(n *tree.Node) {
p := n.Parent
switch n.WidgetType {
case widget.Window:
newWindow(p, n)
case widget.Group:
newGroup(p, n)
case widget.Grid:
newGrid(n)
case widget.Box:
newBox(n)
case widget.Label:
newLabel(p, n)
case widget.Button:
newButton(p, n)
case widget.Checkbox:
newCheckbox(p, n)
setChecked(n, n.State.Checked)
case widget.Spinner:
newSpinner(p, n)
case widget.Slider:
newSlider(p, n)
case widget.Dropdown:
newDropdown(p, n)
setText(n, n.State.DefaultS)
case widget.Combobox:
newCombobox(p, n)
setText(n, n.State.DefaultS)
case widget.Textbox:
newTextbox(p, n)
setText(n, n.State.DefaultS)
/*
case widget.Image:
newImage(p, n)
*/
default:
log.Log(ERROR, "add() error TODO: ", n.WidgetType, n.ProgName())
}
}
func newAdd(n *tree.Node) {
if n == nil {
log.Warn("Tree Error: Add() sent n == nil")
return
}
if n.WidgetType == widget.Root {
me.treeRoot = n
return
}
add(n)
if n.TK == nil {
log.Warn("Tree sent an action on a widget we didn't seem to have.")
// do this init here again? Probably something
// went wrong and we should reset the our while gocui.View tree
n.TK = initWidget(n)
}
// show(n, !a.State.Hidden)
if n.Hidden() {
hide(n)
} else {
if n.State.Enable {
// nothing to do
} else {
enable(n, false)
}
}
}