summaryrefslogtreecommitdiff
path: root/node.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-10-19 13:23:22 -0500
committerJeff Carr <[email protected]>2022-10-19 13:23:22 -0500
commitf3af1f5b7ff78b3f73d7510622fc9633dec36d35 (patch)
treee4868584d5e19942938aaa122b2e1cab377db000 /node.go
parentf7b1036e544238d65b0e3ad46d08075aa4177032 (diff)
Refactor to 'gui/toolkit/'
* add a example cmds/consolemouse uses a console button to launch the andlabs/ui * fix wrong return value in toolkit/NewLabel() * redirect STDIN output to a file * wonderful fix of Window() exit * finally remove the ancient stupid variables x & y * phase out struct 'box' and use 'node' instead * better names for things: use NewFoo() and NewBar()
Diffstat (limited to 'node.go')
-rw-r--r--node.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/node.go b/node.go
new file mode 100644
index 0000000..2c63c74
--- /dev/null
+++ b/node.go
@@ -0,0 +1,40 @@
+package gui
+
+import "strconv"
+// import "fmt"
+
+/*
+ generic function to create a new node on the binary tree
+*/
+func (n *Node) New(title string) *Node {
+ var newN *Node
+
+ newN = addNode(title, n.Width, n.Height)
+
+ n.Append(newN)
+ newN.parent = n
+ return newN
+}
+
+/*
+ raw create function for a new node struct
+*/
+func addNode(title string, w int, h int) *Node {
+ var n Node
+ n.Name = title
+ n.Width = w
+ n.Height = h
+
+ id := Config.prefix + strconv.Itoa(Config.counter)
+ Config.counter += 1
+ n.id = id
+ /*
+ if (Data.NodeMap[title] != nil) {
+ panic(fmt.Sprintf("Duplicate window name = %s\n", title))
+ } else {
+ Data.NodeMap[title] = &n
+ }
+ */
+
+ return &n
+}