summaryrefslogtreecommitdiff
path: root/basicWindow.go
blob: ba4f0bff88df3509e2aa266eea29b700487112dd (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
	A Standard Window
*/
package gadgets

import 	(
	"go.wit.com/log"
	"go.wit.com/gui/gui"
)

type BasicWindow struct {
	hidden	bool
	name	string

	p	*gui.Node	// parent widget
	win	*gui.Node	// window widget
	box	*gui.Node	// box

	Custom func()
}

func (w *BasicWindow) Hide() {
	w.win.Hide()
	w.hidden = true
	return
}

func (w *BasicWindow) Show() {
	w.win.Show()
	w.hidden = false
	return
}

func (w *BasicWindow) Toggle() {
	if w.hidden {
		w.Show()
		w.hidden = false
	} else {
		w.Hide()
		w.hidden = true
	}
	return
}

func (w *BasicWindow) Box() *gui.Node {
	return w.box
}

func NewBasicWindow(parent *gui.Node, name string) *BasicWindow {
	var w *BasicWindow
	w = &BasicWindow {
		p: parent,
		name: name,
	}

	// various timeout settings
	w.win = w.p.NewWindow(name)
	w.win.Custom = func() {
		log.Println("BasicWindow.Custom() closed. TODO: handle this", w.name)
	}
	w.box = w.win.NewBox("hBox", true)

	return w
}