summaryrefslogtreecommitdiff
path: root/window.go
blob: 54d43312b9eb779702ac56ecf37a56403b3aca2c (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
package gui

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

// This routine creates a blank window with a Title and size (W x H)

func (parent *Node) NewWindow(title string) *Node {
	var newNode *Node

	// Windows are created off of the master node of the Binary Tree
	newNode = parent.newNode(title, widget.Window)
	newNode.Custom = StandardExit

	log.Info("NewWindow()", title)

	if ! newNode.hidden {
		a := newAction(newNode, widget.Add)
		sendAction(a)
	}
	return newNode
}

// allow window create without actually sending it to the toolkit
func (parent *Node) RawWindow(title string) *Node {
	var newNode *Node

	// Windows are created off of the master node of the Binary Tree
	newNode = parent.newNode(title, widget.Window)
	newNode.Custom = StandardExit
	newNode.hidden = true

	log.Info("RawWindow()", title)
	return newNode
}

// TODO: should do this recursively
func (n *Node) UnDraw() *Node {
	if ! n.hidden {
		n.Hide()
	}
	n.hidden = true
	return n
}

// TODO: should do this recursively
func (n *Node) Draw() *Node {
	n.hidden = false

	a := newAction(n, widget.Add)
	sendAction(a)
	return n
}

// if the toolkit supports a gui with pixels, it might honor this. no promises
// consider this a 'recommendation' or developer 'preference' to the toolkit
func (n *Node) PixelSize(w, h int) *Node {
	n.width = w
	n.height = w
	return n
}