add windowFrame widget for windows
This commit is contained in:
parent
d75bfa639c
commit
3fa508f786
|
@ -99,6 +99,7 @@ type guiWidget struct {
|
|||
parent *guiWidget // mirrors the binary node tree
|
||||
children []*guiWidget // mirrors the binary node tree
|
||||
node *tree.Node // the pointer back to the tree
|
||||
windowFrame *guiWidget // this is the frame for a window widget
|
||||
hasTabs bool // does the window have tabs?
|
||||
currentTab bool // the visible tab
|
||||
value string // ?
|
||||
|
|
50
window.go
50
window.go
|
@ -6,6 +6,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"go.wit.com/toolkits/tree"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
|
@ -34,6 +35,15 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
|
|||
me.baseGui.SetView(tk.cuiName, tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1, 0)
|
||||
tk.Show()
|
||||
tk.showWidgets()
|
||||
|
||||
if tk.windowFrame == nil {
|
||||
tk.addWindowFrameTK(0 - tk.node.WidgetId)
|
||||
tk.windowFrame.node.State.Label = "windowFrame"
|
||||
tk.windowFrame.makeTK([]string{"windowFrame"})
|
||||
}
|
||||
tk.windowFrame.MoveToOffset(w, h+2)
|
||||
tk.windowFrame.drawView()
|
||||
tk.windowFrame.Show()
|
||||
}
|
||||
|
||||
// re-draws the buttons for each of the windows
|
||||
|
@ -48,3 +58,43 @@ func redoWindows(nextW int, nextH int) {
|
|||
nextH += 10
|
||||
}
|
||||
}
|
||||
|
||||
func (tk *guiWidget) addWindowFrameTK(wId int) {
|
||||
n := tk.addWindowFrame(wId)
|
||||
tk.windowFrame = n.TK.(*guiWidget)
|
||||
}
|
||||
|
||||
func (win *guiWidget) addWindowFrame(wId int) *tree.Node {
|
||||
n := new(tree.Node)
|
||||
n.WidgetType = widget.Flag
|
||||
n.WidgetId = wId
|
||||
n.ParentId = 0
|
||||
|
||||
// store the internal toolkit information
|
||||
tk := new(guiWidget)
|
||||
tk.frame = true
|
||||
tk.labelN = "DropBox text"
|
||||
|
||||
tk.node = n
|
||||
if tk.node.Parent == nil {
|
||||
tk.node.Parent = me.treeRoot
|
||||
}
|
||||
// copy the data from the action message
|
||||
tk.node.State.Label = "DropBox"
|
||||
|
||||
// set the name used by gocui to the id
|
||||
tk.cuiName = fmt.Sprintf("%d DR", wId)
|
||||
|
||||
tk.color = &colorFlag
|
||||
|
||||
// add this new widget on the binary tree
|
||||
tk.parent = win
|
||||
if tk.parent == nil {
|
||||
panic("addDropdown() didn't get treeRoot guiWidget")
|
||||
} else {
|
||||
tk.parent.children = append(tk.parent.children, tk)
|
||||
}
|
||||
|
||||
n.TK = tk
|
||||
return n
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue