summaryrefslogtreecommitdiff
path: root/widgetAdd.go
blob: 0686c86a1a476deb36c4797e45f9118fa2975a8b (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
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

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

var fakeStartWidth int = me.FakeW
var fakeStartHeight int = me.TabH + me.FramePadH

// setup fake labels for non-visible things off screen
func setFake(n *tree.Node) {
	var w *guiWidget
	w = n.TK.(*guiWidget)
	w.isFake = true

	w.gocuiSetWH(fakeStartWidth, fakeStartHeight)

	fakeStartHeight += w.gocuiSize.Height()
	// TODO: use the actual max hight of the terminal window
	if fakeStartHeight > 24 {
		fakeStartHeight = me.TabH
		fakeStartWidth += me.FakeW
	}
}

// mostly just sets the colors of things
func addWidget(n *tree.Node) {
	if !me.ok {
		log.Log(INFO, "addWidget() START NOT OKAY")
		log.Log(INFO, "addWidget() START NOT OKAY")
		log.Log(INFO, "addWidget() START NOT OKAY")
		waitOK()
	}
	tk := n.TK.(*guiWidget)
	log.Log(INFO, "setStartWH() w.id =", n.WidgetId, "n.name", n.String())
	switch n.WidgetType {
	case widget.Root:
		log.Log(INFO, "setStartWH() rootNode w.id =", n.WidgetId, "w.name", n.String())
		setFake(n)
		return
	case widget.Flag:
		setFake(n)
		return
	case widget.Window:
		tk.frame = false
		tk.labelN = tk.GetText() + "  X"
		me.newWindowTrigger <- tk
		redoWindows(0, 0)
		return
	case widget.Stdout:
		tk.labelN = "moreSTDOUT"
		n.State.ProgName = "moreSTDOUT"
		n.State.Label = "moreSTDOUT"
		tk.isFake = true
		return
	case widget.Tab:
		return
	case widget.Button:
		tk.setColorButton()
		if tk.IsEnabled() {
		} else {
			tk.setColorDisable()
		}
		return
	case widget.Checkbox:
		tk.setColorInput()
		tk.labelN = "X " + n.State.Label
		return
	case widget.Dropdown:
		tk.setColorInput()
		return
	case widget.Textbox:
		n.State.Label = ""
		tk.labelN = "    "
		tk.setColorInput()
		return
	case widget.Combobox:
		tk.setColorInput()
		return
	case widget.Box:
		tk.isFake = true
		setFake(n)
		return
	case widget.Grid:
		tk.isFake = true
		setFake(n)
		return
	case widget.Group:
		tk.setColorLabel()
		tk.frame = false
		return
	case widget.Label:
		if tk.node.InTable() {
			if tk.node.State.AtH == 0 {
				// this is the table header
				tk.setColorLabelTable()
			} else {
				// todo: highlight the whole table row
				tk.setColorLabel()
			}
		} else {
			tk.setColorLabel()
		}
		tk.frame = false
		return
	default:
		/*
			if n.IsCurrent() {
				n.updateCurrent()
			}
		*/
	}
	tk.dumpWidget("addWidget()unknown")
}