2022-11-14 14:30:28 -06:00
|
|
|
package main
|
2022-10-19 13:23:22 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/andlabs/ui"
|
|
|
|
_ "github.com/andlabs/ui/winmanifest"
|
2022-11-14 14:30:28 -06:00
|
|
|
|
|
|
|
"git.wit.org/wit/gui/toolkit"
|
2022-10-19 13:23:22 -05:00
|
|
|
)
|
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
func (t *andlabsT) MessageWindow(msg1 string, msg2 string) {
|
2022-10-19 13:23:22 -05:00
|
|
|
ui.MsgBox(t.uiWindow, msg1, msg2)
|
|
|
|
}
|
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
func (t *andlabsT) ErrorWindow(msg1 string, msg2 string) {
|
2022-10-19 13:23:22 -05:00
|
|
|
ui.MsgBoxError(t.uiWindow, msg1, msg2)
|
|
|
|
}
|
|
|
|
|
2023-03-23 12:35:12 -05:00
|
|
|
func newWindow(a *toolkit.Action) {
|
|
|
|
w := a.Widget
|
2023-03-01 11:35:36 -06:00
|
|
|
var newt *andlabsT
|
2022-11-14 14:30:28 -06:00
|
|
|
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "toolkit NewWindow", w.Name, w.Width, w.Height)
|
2022-11-14 14:30:28 -06:00
|
|
|
|
|
|
|
if (w == nil) {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "wit/gui plugin error. widget == nil")
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
2022-11-06 19:57:20 -06:00
|
|
|
}
|
2023-03-01 11:35:36 -06:00
|
|
|
newt = new(andlabsT)
|
|
|
|
newt.tw = w
|
2022-11-14 14:30:28 -06:00
|
|
|
|
|
|
|
// 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 {
|
2023-03-01 11:35:36 -06:00
|
|
|
newt.commonChange(newt.tw)
|
|
|
|
return true
|
2022-10-19 13:23:22 -05:00
|
|
|
})
|
2022-11-14 14:30:28 -06:00
|
|
|
win.Show()
|
2023-03-01 11:35:36 -06:00
|
|
|
newt.uiWindow = win
|
2023-03-23 12:35:12 -05:00
|
|
|
newt.uiControl = win
|
2023-03-01 11:35:36 -06:00
|
|
|
// newt.UiWindowBad = win // deprecate this as soon as possible
|
|
|
|
newt.Name = w.Name
|
2022-11-14 14:30:28 -06:00
|
|
|
|
2023-03-23 12:35:12 -05:00
|
|
|
mapWidgetsToolkits(a, newt)
|
2022-11-14 14:30:28 -06:00
|
|
|
return
|
2022-10-19 13:23:22 -05:00
|
|
|
}
|
2022-10-20 06:55:42 -05:00
|
|
|
|
2022-11-14 14:30:28 -06:00
|
|
|
func (t *andlabsT) SetWindowTitle(title string) {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "toolkit NewWindow", t.Name, "title", title)
|
2022-10-20 06:55:42 -05:00
|
|
|
win := t.uiWindow
|
|
|
|
if (win != nil) {
|
|
|
|
win.SetTitle(title)
|
|
|
|
} else {
|
2023-02-25 14:05:25 -06:00
|
|
|
log(debugToolkit, "Setting the window title", title)
|
2022-10-20 06:55:42 -05:00
|
|
|
}
|
|
|
|
}
|
2023-03-12 08:47:16 -05:00
|
|
|
|
2023-03-23 12:35:12 -05:00
|
|
|
func doWindow(a *toolkit.Action) {
|
|
|
|
newWindow(a)
|
2023-03-12 08:47:16 -05:00
|
|
|
}
|