2019-06-03 20:53:14 -05:00
|
|
|
package gui
|
|
|
|
|
2021-10-06 10:43:58 -05:00
|
|
|
import (
|
2024-01-03 18:15:54 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-05 13:18:44 -06:00
|
|
|
"go.wit.com/gui/widget"
|
2021-10-06 10:43:58 -05:00
|
|
|
)
|
2019-06-03 20:53:14 -05:00
|
|
|
|
2021-10-31 14:21:36 -05:00
|
|
|
// This routine creates a blank window with a Title and size (W x H)
|
2023-04-08 15:34:36 -05:00
|
|
|
|
2023-05-09 18:50:16 -05:00
|
|
|
func (parent *Node) NewWindow(title string) *Node {
|
2023-04-08 15:34:36 -05:00
|
|
|
var newNode *Node
|
|
|
|
|
|
|
|
// Windows are created off of the master node of the Binary Tree
|
2024-01-05 13:18:44 -06:00
|
|
|
newNode = parent.newNode(title, widget.Window)
|
2023-05-09 20:25:37 -05:00
|
|
|
newNode.Custom = StandardExit
|
2023-04-08 15:34:36 -05:00
|
|
|
|
2024-01-03 18:15:54 -06:00
|
|
|
log.Info("NewWindow()", title)
|
2024-01-11 19:32:40 -06:00
|
|
|
newNode.progname = title
|
|
|
|
newNode.value = title
|
2023-04-08 15:34:36 -05:00
|
|
|
|
2024-01-13 22:02:12 -06:00
|
|
|
// inform the toolkits
|
|
|
|
sendAction(newNode, widget.Add)
|
2024-01-06 13:53:15 -06:00
|
|
|
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)
|
2023-04-08 15:34:36 -05:00
|
|
|
return newNode
|
|
|
|
}
|
2024-01-06 13:53:15 -06:00
|
|
|
|
|
|
|
// TODO: should do this recursively
|
|
|
|
func (n *Node) UnDraw() *Node {
|
2024-01-13 22:02:12 -06:00
|
|
|
if ! n.Ready() { return n }
|
|
|
|
|
2024-01-06 13:53:15 -06:00
|
|
|
n.hidden = true
|
2024-01-13 22:02:12 -06:00
|
|
|
n.changed = true
|
|
|
|
|
|
|
|
// inform the toolkits
|
|
|
|
sendAction(n, widget.Delete)
|
2024-01-06 13:53:15 -06:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: should do this recursively
|
|
|
|
func (n *Node) Draw() *Node {
|
2024-01-13 22:02:12 -06:00
|
|
|
if ! n.Ready() { return n }
|
|
|
|
|
2024-01-06 13:53:15 -06:00
|
|
|
n.hidden = false
|
2024-01-13 22:02:12 -06:00
|
|
|
n.changed= true
|
2024-01-06 13:53:15 -06:00
|
|
|
|
2024-01-13 22:02:12 -06:00
|
|
|
// inform the toolkits
|
|
|
|
sendAction(n, widget.Add)
|
2024-01-06 13:53:15 -06:00
|
|
|
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
|
2024-01-13 22:02:12 -06:00
|
|
|
/*
|
2024-01-06 13:53:15 -06:00
|
|
|
func (n *Node) PixelSize(w, h int) *Node {
|
|
|
|
n.width = w
|
|
|
|
n.height = w
|
|
|
|
return n
|
|
|
|
}
|
2024-01-13 22:02:12 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
func (n *Node) TestDraw() {
|
|
|
|
if (n == nil) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// enable and
|
|
|
|
n.hidden = false
|
|
|
|
n.changed = true
|
|
|
|
log.Warn("TestDraw() sending widget.Add", n.id, n.WidgetType, n.progname)
|
|
|
|
sendAction(n, widget.Add)
|
|
|
|
|
|
|
|
for _, child := range n.children {
|
|
|
|
child.TestDraw()
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|