blob: 4afe08b299c476659e1c71078b4aa64d81ef266d (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
package main
import (
"strconv"
"git.wit.org/wit/gui/toolkit"
)
func initWidget(n *node) *guiWidget {
var w *guiWidget
w = new(guiWidget)
// Set(w, "default")
w.frame = true
// set the name used by gocui to the id
w.cuiName = strconv.Itoa(n.WidgetId)
if n.WidgetType == toolkit.Root {
log(logInfo, "setupWidget() FOUND ROOT w.id =", n.WidgetId)
n.WidgetId = 0
me.rootNode = n
return w
}
if (n.WidgetType == toolkit.Box) {
if (n.B) {
n.horizontal = true
} else {
n.horizontal = false
}
}
if (n.WidgetType == toolkit.Grid) {
w.widths = make(map[int]int) // how tall each row in the grid is
w.heights = make(map[int]int) // how wide each column in the grid is
}
return w
}
func setupCtrlDownWidget() {
a := new(toolkit.Action)
a.Name = "ctrlDown"
a.WidgetType = toolkit.Dialog
a.WidgetId = -1
a.ParentId = 0
n := addNode(a)
me.ctrlDown = n
}
func (n *node) deleteView() {
w := n.tk
if (w.v != nil) {
w.v.Visible = false
return
}
// make sure the view isn't really there
me.baseGui.DeleteView(w.cuiName)
w.v = nil
}
// searches the binary tree for a WidgetId
func (n *node) findWidgetName(name string) *node {
if (n == nil) {
return nil
}
if n.tk.cuiName == name {
return n
}
for _, child := range n.children {
newN := child.findWidgetName(name)
if (newN != nil) {
return newN
}
}
return nil
}
func (n *node) IsCurrent() bool {
w := n.tk
if (n.WidgetType == toolkit.Tab) {
return w.isCurrent
}
if (n.WidgetType == toolkit.Window) {
return w.isCurrent
}
if (n.WidgetType == toolkit.Root) {
return false
}
return n.parent.IsCurrent()
}
func (n *node) Visible() bool {
if (n == nil) {
return false
}
if (n.tk == nil) {
return false
}
if (n.tk.v == nil) {
return false
}
return n.tk.v.Visible
}
func (n *node) SetVisible(b bool) {
if (n == nil) {
return
}
if (n.tk == nil) {
return
}
if (n.tk.v == nil) {
return
}
n.tk.v.Visible = b
}
func addDropdown() *node {
n := new(node)
n.WidgetType = toolkit.Flag
n.WidgetId = -2
n.ParentId = 0
// copy the data from the action message
n.Name = "DropBox"
n.Text = "DropBox text"
// store the internal toolkit information
n.tk = new(guiWidget)
n.tk.frame = true
// set the name used by gocui to the id
n.tk.cuiName = "-1 dropbox"
n.tk.color = &colorFlag
// add this new widget on the binary tree
n.parent = me.rootNode
if n.parent != nil {
n.parent.children = append(n.parent.children, n)
}
return n
}
|