summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/window.go
blob: f51536b3f5cc6f7dfe37cb5a85377d456147f531 (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
package main

import (
	"github.com/andlabs/ui"
	_ "github.com/andlabs/ui/winmanifest"
)

func (t *guiWidget) MessageWindow(msg1 string, msg2 string) {
	ui.MsgBox(t.uiWindow, msg1, msg2)
}

func (t *guiWidget) ErrorWindow(msg1 string, msg2 string) {
	ui.MsgBoxError(t.uiWindow, msg1, msg2)
}

func newWindow(n *node) {
	var newt *guiWidget

	newt = new(guiWidget)

	// menubar bool is if the OS defined border on the window should be used
	win := ui.NewWindow(n.Name, n.X, n.Y, menubar)
	win.SetBorderless(canvas)
	win.SetMargined(margin)
	win.OnClosing(func(*ui.Window) bool {
		n.doUserEvent()
		return true
	})
	newt.uiWindow = win
	newt.uiControl = win

	n.tk = newt
	win.Show()
	return
}

func (n *node) SetWindowTitle(title string) {
	log(debugToolkit, "toolkit NewWindow", n.Text, "title", title)
	win := n.tk.uiWindow
	if (win == nil) {
		log(debugError, "Error: no window", n.WidgetId)
	} else {
		win.SetTitle(title)
		log(debugToolkit, "Setting the window title", title)
	}
}