summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-05 14:11:37 -0600
committerJeff Carr <[email protected]>2025-02-05 14:11:37 -0600
commit3fa508f786fc6830640ce185145eb07253429f71 (patch)
treea6d4bc489b45060467a9f7022c2ca5101c3972b0
parentd75bfa639c6fac0fe5b279aeddb28e4f8d861bb4 (diff)
add windowFrame widget for windows
-rw-r--r--structs.go1
-rw-r--r--window.go50
2 files changed, 51 insertions, 0 deletions
diff --git a/structs.go b/structs.go
index 55ab07d..718bb47 100644
--- a/structs.go
+++ b/structs.go
@@ -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 // ?
diff --git a/window.go b/window.go
index 3a2cc13..50c08a3 100644
--- a/window.go
+++ b/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
+}