summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--box.go6
-rw-r--r--entry.go2
-rw-r--r--structs.go7
-rw-r--r--window.go50
4 files changed, 37 insertions, 28 deletions
diff --git a/box.go b/box.go
index 08d4918..2640742 100644
--- a/box.go
+++ b/box.go
@@ -120,6 +120,12 @@ func HardBox(gw *GuiWindow, axis int, name string) *GuiBox {
func HorizontalBreak(box *GuiBox) {
log.Println("VerticalSeparator added to box =", box.Name)
tmp := ui.NewHorizontalSeparator()
+ if (box == nil) {
+ return
+ }
+ if (box.UiBox == nil) {
+ return
+ }
box.UiBox.Append(tmp, false)
}
diff --git a/entry.go b/entry.go
index db5013a..d7f31c9 100644
--- a/entry.go
+++ b/entry.go
@@ -10,7 +10,7 @@ import "github.com/davecgh/go-spew/spew"
// functions for handling text entry boxes
func NewLabel(box *GuiBox, text string) {
- box.UiBox.Append(ui.NewLabel(text), false)
+ box.Append(ui.NewLabel(text), false)
}
func GetText(box *GuiBox, name string) string {
diff --git a/structs.go b/structs.go
index 0f1cd1b..59190f6 100644
--- a/structs.go
+++ b/structs.go
@@ -105,6 +105,13 @@ func (s GuiBox) SetTitle(title string) {
return
}
+func (s GuiBox) Append(child ui.Control, x bool) {
+ if (s.UiBox == nil) {
+ return
+ }
+ s.UiBox.Append(child, x)
+}
+
func (s GuiBox) InitTab(title string) *ui.Tab {
if (s.Window == nil) {
return nil
diff --git a/window.go b/window.go
index e170278..e64e10b 100644
--- a/window.go
+++ b/window.go
@@ -45,21 +45,17 @@ func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
// actual window but that does not appear to work on the MacOS or Windows
//
func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
- window := Data.WindowMap[name]
- if (window != nil) {
- box := window.BoxMap["MAINBOX"]
- log.Println("gui.InitWindow() tab already exists name =", name)
- ErrorWindow(box.Window, "Create Window Error", "Window " + name + " already exists")
- return nil
+ log.Println("InitGuiWindow() START")
+
+ var box *GuiBox
+ if (gw == nil) {
+ box = mapWindow(nil, name, Config.Height, Config.Width)
+ } else {
+ box = mapWindow(gw.UiWindow, name, Config.Height, Config.Width)
}
- // return mapWindow(window, name, Config.Height, Config.Width)
- log.Println("InitGuiWindow() START")
- var newGuiWindow GuiWindow
- newGuiWindow.Height = Config.Height
- newGuiWindow.Width = Config.Width
- newGuiWindow.Axis = axis
- newGuiWindow.Name = name
+ // box.Window = &newGuiWindow
+ newGuiWindow := box.Window
// This is the first window. One must create it here
if (gw == nil) {
@@ -75,7 +71,7 @@ func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
ui.Quit()
} else {
// allow a custom exit function
- Config.Exit(&newGuiWindow)
+ Config.Exit(newGuiWindow)
}
return true
})
@@ -102,15 +98,9 @@ func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
newGuiWindow.TabNumber = &tabnum
}
- Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
+ Data.WindowMap[newGuiWindow.Name] = newGuiWindow
- var box *GuiBox
- if (axis == Xaxis) {
- box = HardBox(&newGuiWindow, Xaxis, name)
- } else {
- box = HardBox(&newGuiWindow, Yaxis, name)
- }
- log.Println("InitGuiWindow() END *GuiWindow =", &newGuiWindow)
+ log.Println("InitGuiWindow() END *GuiWindow =", newGuiWindow)
return box
}
@@ -181,7 +171,18 @@ func initBlankWindow() ui.Control {
return hbox
}
+var master = 0
+
func mapWindow(window *ui.Window, title string, x int, y int) *GuiBox {
+ if (Data.WindowMap[title] != nil) {
+ log.Println("Data.WindowMap[title] already exists title =", title)
+ title = title + string(master)
+ }
+ if (Data.WindowMap[title] != nil) {
+ log.Println("Data.WindowMap[title] already exists title =", title)
+ panic("Data.WindowMap[newGuiWindow.Name] already exists")
+ return nil
+ }
var newGuiWindow GuiWindow
newGuiWindow.Width = x
newGuiWindow.Height = y
@@ -191,11 +192,6 @@ func mapWindow(window *ui.Window, title string, x int, y int) *GuiBox {
newGuiWindow.BoxMap = make(map[string]*GuiBox)
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
- if (Data.WindowMap[newGuiWindow.Name] != nil) {
- log.Println("Data.WindowMap[newGuiWindow.Name] already exists\n")
- panic("Data.WindowMap[newGuiWindow.Name] already exists")
- return nil
- }
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
var box GuiBox