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
|
package main
import (
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
"git.wit.org/wit/gui/toolkit"
)
func (t *andlabsT) MessageWindow(msg1 string, msg2 string) {
ui.MsgBox(t.uiWindow, msg1, msg2)
}
func (t *andlabsT) ErrorWindow(msg1 string, msg2 string) {
ui.MsgBoxError(t.uiWindow, msg1, msg2)
}
func newWindow(w *toolkit.Widget) {
var newt *andlabsT
log(debugToolkit, "toolkit NewWindow", w.Name, w.Width, w.Height)
if (w == nil) {
log(debugToolkit, "wit/gui plugin error. widget == nil")
return
}
newt = new(andlabsT)
newt.tw = w
// menubar bool is if the OS defined border on the window should be used
win := ui.NewWindow(w.Name, w.Width, w.Height, menubar)
win.SetBorderless(canvas)
win.SetMargined(margin)
win.OnClosing(func(*ui.Window) bool {
newt.commonChange(newt.tw)
return true
})
win.Show()
newt.uiWindow = win
// newt.UiWindowBad = win // deprecate this as soon as possible
newt.Name = w.Name
mapWidgetsToolkits(w, newt)
return
}
func (t *andlabsT) SetWindowTitle(title string) {
log(debugToolkit, "toolkit NewWindow", t.Name, "title", title)
win := t.uiWindow
if (win != nil) {
win.SetTitle(title)
} else {
log(debugToolkit, "Setting the window title", title)
}
}
func doWindow(c *toolkit.Widget) {
if broken(c) {
return
}
if (c.Action == "New") {
newWindow(c)
return
}
ct := mapToolkits[c]
if (ct == nil) {
log(debugError, "Trying to do something on a widget that doesn't work or doesn't exist or something", c)
return
}
if (ct.uiWindow == nil) {
log(debugError, "Window() uiWindow == nil", ct)
return
}
log(debugChange, "Going to attempt:", c.Action)
switch c.Action {
case "Show":
ct.uiWindow.Show()
case "Hide":
ct.uiWindow.Hide()
case "Enable":
ct.uiWindow.Enable()
case "Disable":
ct.uiWindow.Disable()
case "Get":
c.S = ct.uiWindow.Title()
case "Set":
ct.uiWindow.SetTitle(c.S)
case "SetText":
ct.uiWindow.SetTitle(c.S)
case "SetMargin":
ct.uiWindow.SetMargined(c.B)
case "SetBorder":
ct.uiWindow.SetBorderless(c.B)
case "Delete":
ct.uiWindow.Destroy()
default:
log(debugError, "Can't do", c.Action, "to a Window")
}
}
|