package gui import ( "go.wit.com/log" "go.wit.com/widget" ) // Why have NewWindow() when there isn't just Window() // That's how smalltalk did things in 1972. Keep it Simple. // todo: remove 'New' from every function name // will that work? Are there problems with that? // Button() Grid() Box(), Label() // 2024/01/04 Naw, having NewWindow is more readable /* func (parent *Node) Window(title string) *Node { return parent.NewWindow(title) } */ // This routine creates a blank window with a Title 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.Log(INFO, "NewWindow()", title) newNode.progname = title newNode.label = title newNode.margin = true newNode.visable = true newNode.hidden = false // inform the toolkits sendAction(newNode, widget.Add) return newNode } // This creates a window off the root of the binary tree func NewWindow(title string) *Node { return me.rootNode.NewWindow(title) } func RawWindow(title string) *Node { return me.rootNode.RawWindow(title) } // 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.hidden = true newNode.visable = false log.Log(INFO, "RawWindow()", title) return newNode } /* // TODO: should do this recursively func (n *Node) UnDraw() *Node { if !n.Ready() { return n } n.hidden = true n.changed = true // inform the toolkits sendAction(n, widget.Delete) return n } */ // TODO: should do this recursively (on a window only) func (n *Node) Draw() *Node { if !n.Ready() { return n } n.hidden = false n.changed = true // inform the toolkits sendAction(n, widget.Add) 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 } */ // when a window is redrawn, every widget in the window // needs to be sent to the toolkit func (n *Node) TestDraw() { if n == nil { return } n.changed = true n.visable = true log.Log(INFO, "TestDraw() sending widget.Add", n.id, n.WidgetType, n.progname) sendAction(n, widget.Add) for _, child := range n.children { child.TestDraw() } return }