diff options
| -rw-r--r-- | box.go | 36 | ||||
| -rw-r--r-- | entry.go | 89 |
2 files changed, 7 insertions, 118 deletions
@@ -13,7 +13,8 @@ import _ "github.com/andlabs/ui/winmanifest" // add(gw.BoxMap["MAINBOX"], newbox, name) // use this to add a box off the main box // add(gw.BoxMap["BUTTONBOX"], newbox, name) // use this to add something to the box called 'BUTTONBOX' // add(box, newbox, name) // add 'newbox' to 'box' and call it 'name' -func add(box *GuiBox, newbox *GuiBox) { +/* +func add2(box *GuiBox, newbox *GuiBox) { log.Println("gui.add() START box =", box) log.Println("gui.add() START newbox =", newbox) if (box == nil) { @@ -72,6 +73,7 @@ func add(box *GuiBox, newbox *GuiBox) { box.Window.BoxMap[newbox.Name] = newbox log.Println("gui.add() END") } +*/ func (n *Node) AddBox(axis int, name string) *Node { newBox := new(GuiBox) @@ -102,35 +104,6 @@ func (n *Node) AddBox(axis int, name string) *Node { return newNode } -/* -func (b *GuiBox) NewBox(axis int, name string) *GuiBox { - log.Println("gui.NewBox() START") - n := b.FindNode() - if (n == nil) { - log.Println("gui.NewBox() SERIOUS ERROR. CAN NOT FIND NODE") - panic("gui.NewBox() SERIOUS ERROR. CAN NOT FIND NODE") - } else { - log.Println("gui.NewBox() node =", n.Name) - } - var newbox *GuiBox - newbox = new(GuiBox) - newbox.Window = b.Window - newbox.Name = name - - var uiBox *ui.Box - if (axis == Xaxis) { - uiBox = ui.NewHorizontalBox() - } else { - uiBox = ui.NewVerticalBox() - } - uiBox.SetPadded(true) - newbox.UiBox = uiBox - add(b, newbox) - // panic("gui.NewBox") - return newbox -} -*/ - func HardBox(gw *GuiWindow, axis int, name string) *GuiBox { log.Println("HardBox() START axis =", axis) @@ -164,7 +137,8 @@ func HardBox(gw *GuiWindow, axis int, name string) *GuiBox { newbox.UiBox = uiBox newbox.Name = name - add(gw.BoxMap["MAINBOX"], newbox) + // TODO: removed Oct 31 + // add(gw.BoxMap["MAINBOX"], newbox) log.Println("HardBox END") return newbox @@ -1,18 +1,14 @@ package gui import "log" -import "fmt" +// import "fmt" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" -import "github.com/davecgh/go-spew/spew" +// import "github.com/davecgh/go-spew/spew" // functions for handling text entry boxes -func NewLabel(box *GuiBox, text string) { - box.Append(ui.NewLabel(text), false) -} - func (n *Node) NewLabel(text string) *Node { // make new node here // n.Append(ui.NewLabel(text), false) @@ -24,22 +20,6 @@ func (n *Node) NewLabel(text string) *Node { return newNode } -func (b *GuiBox) GetText(name string) string { - if (b.Window.EntryMap == nil) { - log.Println("gui.GetText() ERROR b.Box.Window.EntryMap == nil") - return "" - } - spew.Dump(b.Window.EntryMap) - if (b.Window.EntryMap[name] == nil) { - log.Println("gui.GetText() ERROR box.Window.EntryMap[", name, "] == nil ") - return "" - } - e := b.Window.EntryMap[name] - log.Println("gui.GetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text()) - log.Println("gui.GetText() END") - return e.UiEntry.Text() -} - func (n *Node) SetText(value string) error { log.Println("gui.SetText() value =", value) if (n.uiText != nil) { @@ -53,71 +33,6 @@ func (n *Node) SetText(value string) error { return nil } -func SetText(box *GuiBox, name string, value string) error { - if (box == nil) { - return fmt.Errorf("gui.SetText() ERROR box == nil") - } - if (box.Window.EntryMap == nil) { - return fmt.Errorf("gui.SetText() ERROR b.Box.Window.EntryMap == nil") - } - spew.Dump(box.Window.EntryMap) - if (box.Window.EntryMap[name] == nil) { - return fmt.Errorf("gui.SetText() ERROR box.Window.EntryMap[" + name + "] == nil ") - } - e := box.Window.EntryMap[name] - log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text()) - e.UiEntry.SetText(value) - log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text()) - log.Println("gui.SetText() END") - return nil -} - -// makeEntryBox(box, "hostname:", "blah.foo.org") { -func MakeEntryVbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { - // Start 'Nickname' vertical box - vboxN := ui.NewVerticalBox() - vboxN.SetPadded(true) - vboxN.Append(ui.NewLabel(a), false) - - e := defaultMakeEntry(startValue, edit, action) - - vboxN.Append(e.UiEntry, false) - box.UiBox.Append(vboxN, false) - // End 'Nickname' vertical box - - return e -} - -func MakeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { - hboxN := ui.NewHorizontalBox() - hboxN.SetPadded(true) - hboxN.Append(ui.NewLabel(a), false) - - e := defaultMakeEntry(startValue, edit, action) - hboxN.Append(e.UiEntry, true) - - box.UiBox.Append(hboxN, true) - - return e -} - -func AddEntry(box *GuiBox, name string) *GuiEntry { - var ge *GuiEntry - ge = new(GuiEntry) - - ue := ui.NewEntry() - ue.SetReadOnly(false) - ue.OnChanged(func(*ui.Entry) { - log.Println("gui.AddEntry() OK. ue.Text() =", ue.Text()) - }) - box.UiBox.Append(ue, false) - - ge.UiEntry = ue - box.Window.EntryMap[name] = ge - - return ge -} - func defaultEntryChange(e *ui.Entry) { for key, em := range Data.AllEntries { if (Config.Debug) { |
