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
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"strings"
"go.wit.com/widget"
)
// expands the gocuiSize rectangle to fit
// all the text in tk.labelN
func (tk *guiWidget) textResize() {
var w, h int = 0, 0
for _, s := range strings.Split(tk.labelN, "\n") {
s = strings.TrimSpace(s)
// log.Log(INFO, "textResize() len =", len(s), i, s)
if w < len(s) {
w = len(s)
}
h += 1
}
// todo: fix all this old code
if tk.WidgetType() == widget.Textbox {
if w < 5 {
w = 5
}
}
// this is old code. now move this somewhere smarter
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW // TODO: move this FramePadW out of here
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH // TODO: fix this size computation
}
// deletes every view
func (w *guiWidget) hideWindow() {
if w == nil {
return
}
w.Hide()
for _, child := range w.children {
child.hideWindow()
}
}
func (w *guiWidget) hideWidgets() {
if w == nil {
return
}
switch w.WidgetType() {
case widget.Root:
case widget.Flag:
case widget.Window:
case widget.Box:
case widget.Grid:
default:
w.Hide()
}
for _, child := range w.children {
child.hideWidgets()
}
}
func hideFake() {
var w *guiWidget
w = me.treeRoot.TK.(*guiWidget)
w.hideFake()
}
func showFake() {
var w *guiWidget
w = me.treeRoot.TK.(*guiWidget)
w.showFake()
}
func (w *guiWidget) hideFake() {
if w.isFake {
w.Hide()
}
for _, child := range w.children {
child.hideFake()
}
}
// shows the 'fake' widgets for widgets that
// are not normally displayed (like a grid widget)
func (w *guiWidget) showFake() {
if w.isFake {
w.drawView()
w.dumpWidget("in showFake()")
}
for _, child := range w.children {
child.showFake()
}
}
func (w *guiWidget) showWidgets() {
w.Show()
for _, child := range w.children {
child.showWidgets()
}
}
|