summaryrefslogtreecommitdiff
path: root/add.go
blob: 641d16ccb49434eaf8df8d7d0c84a4519b6dc25c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main

import (
	"go.wit.com/log"
	"go.wit.com/toolkits/tree"
	"go.wit.com/widget"
)

func add(a *widget.Action) *tree.Node {
	log.Log(ANDLABS, "add()", a.WidgetId, a.WidgetType, a.State.ProgName)
	if a.WidgetType == widget.Root {
		if me.treeRoot == nil {
			me.treeRoot = me.myTree.AddNode(a)
		}
		return me.treeRoot
	}
	n := me.myTree.AddNode(a)

	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, a.State.Checked)
	case widget.Spinner:
		newSpinner(p, n)
	case widget.Slider:
		newSlider(p, n)
	case widget.Dropdown:
		newDropdown(p, n)
		setText(n, a)
	case widget.Combobox:
		newCombobox(p, n)
		setText(n, a)
	case widget.Textbox:
		newTextbox(p, n)
		setText(n, a)
	/*
		case widget.Image:
			newImage(p, n)
	*/
	default:
		log.Log(ERROR, "add() error TODO: ", n.WidgetType, n.State.ProgName)
	}

	return n
}