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
|
package main
// implements widgets 'Window' and 'Tab'
import (
"strings"
"go.wit.com/log"
"go.wit.com/widget"
)
func (w *guiWidget) Width() int {
if w.frame {
return w.gocuiSize.w1 - w.gocuiSize.w0
}
return w.gocuiSize.w1 - w.gocuiSize.w0 - 1
}
func (w *guiWidget) Height() int {
if w.frame {
return w.gocuiSize.h1 - w.gocuiSize.h0
}
return w.gocuiSize.h1 - w.gocuiSize.h0 - 1
}
func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
w := len(widget.GetString(tk.value))
lines := strings.Split(widget.GetString(tk.value), "\n")
h := len(lines)
// tk := n.tk
if tk.isFake {
tk.gocuiSize.w0 = sizeW
tk.gocuiSize.h0 = sizeH
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH
return
}
if tk.frame {
tk.gocuiSize.w0 = sizeW
tk.gocuiSize.h0 = sizeH
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH
} else {
tk.gocuiSize.w0 = sizeW - 1
tk.gocuiSize.h0 = sizeH - 1
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + 1
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + 1
}
}
func redoWindows(nextW int, nextH int) {
wRoot := me.treeRoot.TK.(*guiWidget)
for _, win := range wRoot.children {
if win.node.WidgetType != widget.Window {
continue
}
var tabs bool
for _, child := range win.children {
if child.node.WidgetType == widget.Tab {
tabs = true
}
}
if tabs {
// window is tabs. Don't show it as a standard button
win.frame = false
win.hasTabs = true
} else {
win.frame = false
win.hasTabs = false
}
win.gocuiSetWH(nextW, nextH)
win.deleteView()
win.showView()
sizeW := win.Width() + me.WindowPadW
sizeH := win.Height()
nextW += sizeW
log.Log(NOW, "redoWindows() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, win.String())
if win.hasTabs {
win.redoTabs(me.TabW, me.TabH)
}
}
}
func (p *guiWidget) redoTabs(nextW int, nextH int) {
for _, w := range p.children {
if w.node.WidgetType != widget.Tab {
continue
}
w.frame = true
w.gocuiSetWH(nextW, nextH)
w.deleteView()
// setCurrentTab(n)
// if (len(w.cuiName) < 4) {
// w.cuiName = "abcd"
// }
w.showView()
sizeW := w.Width() + me.TabPadW
sizeH := w.Height()
log.Log(NOW, "redoTabs() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, w.String())
nextW += sizeW
}
}
func (p *guiWidget) drawWindow(nextW int, nextH int) {
for _, w := range p.children {
w.frame = true
w.gocuiSetWH(nextW, nextH)
w.deleteView()
// setCurrentTab(n)
// if (len(w.cuiName) < 4) {
// w.cuiName = "abcd"
// }
w.showView()
sizeW := w.Width() + me.TabPadW
sizeH := w.Height()
log.Log(NOW, "redoTabs() start nextW,H =", nextW, nextH, "gocuiSize.W,H =", sizeW, sizeH, w.String())
nextW += sizeW
}
}
|