2019-05-08 15:09:17 -05:00
|
|
|
package gui
|
2019-05-08 15:04:18 -05:00
|
|
|
|
|
|
|
import "log"
|
2019-05-31 11:01:46 -05:00
|
|
|
import "fmt"
|
2019-05-08 15:04:18 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-24 21:29:08 -05:00
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
2019-05-21 16:39:46 -05:00
|
|
|
import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2019-06-01 04:58:49 -05:00
|
|
|
// THIS IS CLEAN (all that is left is the 'ADD VM')
|
2019-06-01 01:45:53 -05:00
|
|
|
|
2019-05-21 16:39:46 -05:00
|
|
|
func InitColumns(mh *TableData, parts []TableColumnData) {
|
2019-05-12 14:54:11 -05:00
|
|
|
tmpBTindex := 0
|
2019-05-13 02:30:38 -05:00
|
|
|
humanID := 0
|
2019-05-12 14:54:11 -05:00
|
|
|
for key, foo := range parts {
|
2019-05-13 02:30:38 -05:00
|
|
|
log.Println("key, foo =", key, foo)
|
2019-05-13 02:08:59 -05:00
|
|
|
|
|
|
|
parts[key].Index = humanID
|
|
|
|
humanID += 1
|
|
|
|
|
|
|
|
if (foo.CellType == "BG") {
|
2019-05-13 02:46:11 -05:00
|
|
|
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
|
2019-05-13 02:08:59 -05:00
|
|
|
initRowBTcolor (mh, tmpBTindex, parts[key])
|
|
|
|
tmpBTindex += 1
|
|
|
|
} else if (foo.CellType == "BUTTON") {
|
2019-05-13 02:46:11 -05:00
|
|
|
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
|
2019-05-13 02:08:59 -05:00
|
|
|
initRowButtonColumn (mh, tmpBTindex, parts[key].Heading, parts[key])
|
|
|
|
tmpBTindex += 1
|
|
|
|
} else if (foo.CellType == "TEXTCOLOR") {
|
2019-05-13 02:46:11 -05:00
|
|
|
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
|
|
|
|
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
|
2019-05-13 02:08:59 -05:00
|
|
|
initRowTextColorColumn(mh, tmpBTindex, tmpBTindex + 1, parts[key].Heading, ui.TableColor{0.0, 0, 0.9, 1}, parts[key])
|
|
|
|
tmpBTindex += 2
|
|
|
|
} else if (foo.CellType == "TEXT") {
|
2019-05-13 02:46:11 -05:00
|
|
|
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
|
2019-05-13 02:08:59 -05:00
|
|
|
initRowTextColumn (mh, tmpBTindex, parts[key].Heading, parts[key])
|
|
|
|
tmpBTindex += 1
|
|
|
|
} else {
|
|
|
|
panic("I don't know what this is in initColumnNames")
|
|
|
|
}
|
2019-05-12 14:54:11 -05:00
|
|
|
}
|
2019-05-13 02:46:11 -05:00
|
|
|
}
|
|
|
|
|
2019-05-31 22:14:15 -05:00
|
|
|
func AddTableTab(gw *GuiWindow, name string, rowcount int, parts []TableColumnData, account *pb.Account) *TableData {
|
2019-05-13 02:46:11 -05:00
|
|
|
mh := new(TableData)
|
|
|
|
|
|
|
|
mh.RowCount = rowcount
|
|
|
|
mh.Rows = make([]RowData, mh.RowCount)
|
|
|
|
|
|
|
|
InitColumns(mh, parts)
|
2019-05-12 14:54:11 -05:00
|
|
|
|
|
|
|
model := ui.NewTableModel(mh)
|
|
|
|
table := ui.NewTable(
|
|
|
|
&ui.TableParams{
|
|
|
|
Model: model,
|
2019-05-13 02:46:11 -05:00
|
|
|
RowBackgroundColorModelColumn: 0, // Row Background color is always index zero
|
2019-05-12 14:54:11 -05:00
|
|
|
})
|
|
|
|
|
2019-05-13 02:46:11 -05:00
|
|
|
tmpBTindex := 0
|
2019-05-12 14:54:11 -05:00
|
|
|
for key, foo := range parts {
|
|
|
|
log.Println(key, foo)
|
|
|
|
if (foo.CellType == "BG") {
|
|
|
|
} else if (foo.CellType == "BUTTON") {
|
|
|
|
tmpBTindex += 1
|
|
|
|
table.AppendButtonColumn(foo.Heading, tmpBTindex, ui.TableModelColumnAlwaysEditable)
|
|
|
|
} else if (foo.CellType == "TEXTCOLOR") {
|
|
|
|
tmpBTindex += 1
|
2019-05-13 01:37:27 -05:00
|
|
|
table.AppendTextColumn(foo.Heading, tmpBTindex, ui.TableModelColumnAlwaysEditable,
|
|
|
|
&ui.TableTextColumnOptionalParams{
|
|
|
|
ColorModelColumn: tmpBTindex + 1,
|
|
|
|
});
|
2019-05-12 14:54:11 -05:00
|
|
|
tmpBTindex += 1
|
|
|
|
} else if (foo.CellType == "TEXT") {
|
|
|
|
tmpBTindex += 1
|
2019-05-13 01:37:27 -05:00
|
|
|
table.AppendTextColumn(foo.Heading, tmpBTindex, ui.TableModelColumnAlwaysEditable, nil)
|
2019-05-12 14:54:11 -05:00
|
|
|
} else {
|
|
|
|
panic("I don't know what this is in initColumnNames")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-31 19:37:53 -05:00
|
|
|
var gb *GuiBox
|
|
|
|
gb = new(GuiBox)
|
|
|
|
|
2019-06-01 16:10:12 -05:00
|
|
|
// gb.EntryMap = make(map[string]*GuiEntry)
|
|
|
|
// gb.EntryMap["test"] = nil
|
2019-05-31 19:37:53 -05:00
|
|
|
|
2019-05-21 16:39:46 -05:00
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
2019-05-31 19:37:53 -05:00
|
|
|
gb.UiBox = vbox
|
2019-06-01 14:43:40 -05:00
|
|
|
gb.Window = gw
|
2019-05-31 19:37:53 -05:00
|
|
|
gw.BoxMap[name] = gb
|
2019-05-31 22:14:15 -05:00
|
|
|
mh.Box = gb
|
2019-05-21 16:39:46 -05:00
|
|
|
|
|
|
|
vbox.Append(table, true)
|
2019-05-31 19:37:53 -05:00
|
|
|
gw.UiTab.Append(name, vbox)
|
2019-05-12 17:11:32 -05:00
|
|
|
|
2019-05-21 16:39:46 -05:00
|
|
|
vbox.Append(ui.NewVerticalSeparator(), false)
|
|
|
|
|
|
|
|
hbox := ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
|
|
|
|
vbox.Append(hbox, false)
|
|
|
|
|
2019-05-12 17:11:32 -05:00
|
|
|
return mh
|
2019-05-12 14:54:11 -05:00
|
|
|
}
|
|
|
|
|
2019-05-31 11:01:46 -05:00
|
|
|
func MessageWindow(gw *GuiWindow, msg1 string, msg2 string) {
|
2019-05-31 19:37:53 -05:00
|
|
|
ui.MsgBox(gw.UiWindow, msg1, msg2)
|
2019-05-24 18:19:22 -05:00
|
|
|
}
|
|
|
|
|
2019-05-31 11:01:46 -05:00
|
|
|
func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
|
2019-05-31 19:37:53 -05:00
|
|
|
ui.MsgBoxError(gw.UiWindow, msg1, msg2)
|
2019-05-24 18:19:22 -05:00
|
|
|
}
|
|
|
|
|
2019-05-24 11:02:35 -05:00
|
|
|
// This is the default mouse click handler
|
|
|
|
// Every mouse click that hasn't been assigned to
|
|
|
|
// something specific will fall into this routine
|
|
|
|
// By default, all it runs is the call back to
|
|
|
|
// the main program that is using this library
|
2019-05-26 13:54:33 -05:00
|
|
|
//
|
|
|
|
// This routine MUST be here as this is how the andlabs/ui works
|
2019-05-24 14:51:04 -05:00
|
|
|
// This is the raw routine passed to every button in andlabs libui / ui
|
2019-05-26 13:54:33 -05:00
|
|
|
//
|
2019-05-30 10:55:54 -05:00
|
|
|
// There is a []GuiButton which has all the buttons. We search
|
2019-05-26 13:54:33 -05:00
|
|
|
// for the button and then call the function below
|
|
|
|
//
|
2019-05-22 12:39:56 -05:00
|
|
|
func defaultButtonClick(button *ui.Button) {
|
2019-05-26 13:54:33 -05:00
|
|
|
log.Println("defaultButtonClick() LOOK FOR BUTTON button =", button)
|
2019-05-24 11:02:35 -05:00
|
|
|
for key, foo := range Data.AllButtons {
|
2019-05-26 13:54:33 -05:00
|
|
|
if (Data.Debug) {
|
2019-05-26 15:53:54 -05:00
|
|
|
log.Println("defaultButtonClick() Data.AllButtons =", key, foo)
|
2019-06-01 04:58:49 -05:00
|
|
|
// spew.Dump(foo)
|
2019-05-26 13:54:33 -05:00
|
|
|
}
|
2019-05-24 11:02:35 -05:00
|
|
|
if Data.AllButtons[key].B == button {
|
2019-05-26 15:53:54 -05:00
|
|
|
log.Println("\tdefaultButtonClick() BUTTON MATCHED")
|
|
|
|
log.Println("\tdefaultButtonClick() Data.AllButtons[key].Action =", Data.AllButtons[key].Action)
|
2019-05-24 11:02:35 -05:00
|
|
|
if Data.AllButtons[key].custom != nil {
|
2019-05-26 15:53:54 -05:00
|
|
|
log.Println("\tdefaultButtonClick() DOING CUSTOM FUNCTION")
|
2019-06-01 04:58:49 -05:00
|
|
|
Data.AllButtons[key].custom(Data.AllButtons[key])
|
2019-05-24 11:02:35 -05:00
|
|
|
return
|
|
|
|
}
|
2019-06-01 04:58:49 -05:00
|
|
|
if (Data.MouseClick != nil) {
|
|
|
|
Data.MouseClick(Data.AllButtons[key])
|
|
|
|
} else {
|
|
|
|
log.Println("\tdefaultButtonClick() IGNORING BUTTON. MouseClick() is nil")
|
|
|
|
}
|
2019-05-23 19:44:00 -05:00
|
|
|
return
|
2019-05-22 12:39:56 -05:00
|
|
|
}
|
|
|
|
}
|
2019-05-26 15:53:54 -05:00
|
|
|
log.Println("\tdefaultButtonClick() BUTTON NOT FOUND")
|
2019-05-26 13:54:33 -05:00
|
|
|
if (Data.Debug) {
|
2019-05-26 15:53:54 -05:00
|
|
|
panic("defaultButtonClick() SHOULD NOT HAVE UNMAPPED BUTTONS")
|
2019-05-24 11:02:35 -05:00
|
|
|
}
|
2019-05-22 12:39:56 -05:00
|
|
|
}
|
|
|
|
|
2019-05-30 10:55:54 -05:00
|
|
|
func AddButton(b *GuiButton, name string) *ui.Button {
|
2019-05-27 19:23:19 -05:00
|
|
|
newB := ui.NewButton(name)
|
|
|
|
newB.OnClicked(defaultButtonClick)
|
|
|
|
|
|
|
|
b.B = newB
|
2019-05-30 13:56:34 -05:00
|
|
|
Data.AllButtons = append(Data.AllButtons, b)
|
2019-05-27 19:23:19 -05:00
|
|
|
return newB
|
|
|
|
}
|
|
|
|
|
2019-06-01 03:20:20 -05:00
|
|
|
func AddButtonToBox(box *GuiBox, button *GuiButton) {
|
|
|
|
box.UiBox.Append(button.B, false)
|
|
|
|
}
|
|
|
|
|
2019-06-01 00:28:02 -05:00
|
|
|
func CreateButton(box *GuiBox, a *pb.Account, vm *pb.Event_VM, name string, action string, custom func(*GuiButton)) *GuiButton {
|
2019-05-30 10:52:28 -05:00
|
|
|
newUiB := ui.NewButton(name)
|
|
|
|
newUiB.OnClicked(defaultButtonClick)
|
|
|
|
|
2019-05-30 13:41:23 -05:00
|
|
|
var newB *GuiButton
|
2019-05-31 15:15:38 -05:00
|
|
|
newB = new(GuiButton)
|
|
|
|
newB.B = newUiB
|
2019-06-01 14:43:40 -05:00
|
|
|
if (box.Window == nil) {
|
|
|
|
log.Println("CreateButton() box.Window == nil")
|
2019-05-31 19:37:53 -05:00
|
|
|
panic("crap")
|
|
|
|
}
|
2019-06-01 14:43:40 -05:00
|
|
|
newB.GW = box.Window
|
2019-05-30 10:52:28 -05:00
|
|
|
newB.Account = a
|
2019-05-31 15:15:38 -05:00
|
|
|
newB.VM = vm
|
2019-05-31 19:37:53 -05:00
|
|
|
newB.Box = box
|
2019-05-30 10:52:28 -05:00
|
|
|
newB.Action = action
|
|
|
|
newB.custom = custom
|
2019-05-30 13:56:34 -05:00
|
|
|
Data.AllButtons = append(Data.AllButtons, newB)
|
2019-05-30 13:41:23 -05:00
|
|
|
return newB
|
2019-05-24 02:04:14 -05:00
|
|
|
}
|
|
|
|
|
2019-05-31 19:37:53 -05:00
|
|
|
func CreateFontButton(box *GuiBox, action string) *GuiButton {
|
2019-05-22 12:39:56 -05:00
|
|
|
|
2019-05-26 13:54:33 -05:00
|
|
|
// create a 'fake' button entry for the mouse clicks
|
2019-05-31 19:37:53 -05:00
|
|
|
var newGB GuiButton
|
|
|
|
newGB.Action = action
|
|
|
|
newGB.FB = ui.NewFontButton()
|
|
|
|
newGB.Box = box
|
2019-06-01 15:41:45 -05:00
|
|
|
newGB.Area = box.Window.Area
|
2019-05-31 19:37:53 -05:00
|
|
|
Data.AllButtons = append(Data.AllButtons, &newGB)
|
|
|
|
|
|
|
|
newGB.FB.OnChanged(func (*ui.FontButton) {
|
|
|
|
log.Println("FontButton.OnChanged() START mouseClick(&newBM)", newGB)
|
2019-06-01 04:58:49 -05:00
|
|
|
if (Data.MouseClick != nil) {
|
|
|
|
Data.MouseClick(&newGB)
|
|
|
|
}
|
2019-05-26 13:54:33 -05:00
|
|
|
})
|
2019-05-31 19:37:53 -05:00
|
|
|
return &newGB
|
2019-05-22 12:39:56 -05:00
|
|
|
}
|
2019-05-31 11:01:46 -05:00
|
|
|
|
|
|
|
func GetText(box *GuiBox, name string) string {
|
|
|
|
if (box == nil) {
|
|
|
|
log.Println("gui.GetText() ERROR box == nil")
|
|
|
|
return ""
|
|
|
|
}
|
2019-06-01 16:10:12 -05:00
|
|
|
if (box.Window.EntryMap == nil) {
|
|
|
|
log.Println("gui.GetText() ERROR b.Box.Window.EntryMap == nil")
|
2019-05-31 11:01:46 -05:00
|
|
|
return ""
|
|
|
|
}
|
2019-06-01 16:10:12 -05:00
|
|
|
spew.Dump(box.Window.EntryMap)
|
|
|
|
if (box.Window.EntryMap[name] == nil) {
|
|
|
|
log.Println("gui.GetText() ERROR box.Window.EntryMap[", name, "] == nil ")
|
2019-05-31 11:01:46 -05:00
|
|
|
return ""
|
|
|
|
}
|
2019-06-01 16:10:12 -05:00
|
|
|
e := box.Window.EntryMap[name]
|
|
|
|
log.Println("gui.GetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
|
2019-05-31 11:01:46 -05:00
|
|
|
log.Println("gui.GetText() END")
|
2019-06-01 00:28:02 -05:00
|
|
|
return e.UiEntry.Text()
|
2019-05-31 11:01:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func SetText(box *GuiBox, name string, value string) error {
|
|
|
|
if (box == nil) {
|
|
|
|
return fmt.Errorf("gui.SetText() ERROR box == nil")
|
|
|
|
}
|
2019-06-01 16:10:12 -05:00
|
|
|
if (box.Window.EntryMap == nil) {
|
|
|
|
return fmt.Errorf("gui.SetText() ERROR b.Box.Window.EntryMap == nil")
|
2019-05-31 11:01:46 -05:00
|
|
|
}
|
2019-06-01 16:10:12 -05:00
|
|
|
spew.Dump(box.Window.EntryMap)
|
|
|
|
if (box.Window.EntryMap[name] == nil) {
|
|
|
|
return fmt.Errorf("gui.SetText() ERROR box.Window.EntryMap[", name, "] == nil ")
|
2019-05-31 11:01:46 -05:00
|
|
|
}
|
2019-06-01 16:10:12 -05:00
|
|
|
e := box.Window.EntryMap[name]
|
|
|
|
log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
|
2019-06-01 00:28:02 -05:00
|
|
|
e.UiEntry.SetText(value)
|
2019-06-01 16:10:12 -05:00
|
|
|
log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text())
|
2019-05-31 11:01:46 -05:00
|
|
|
log.Println("gui.SetText() END")
|
|
|
|
return nil
|
|
|
|
}
|
2019-06-01 01:45:53 -05:00
|
|
|
|
|
|
|
// 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 {
|
|
|
|
// Start 'Nickname' vertical box
|
|
|
|
hboxN := ui.NewHorizontalBox()
|
|
|
|
hboxN.SetPadded(true)
|
|
|
|
hboxN.Append(ui.NewLabel(a), false)
|
|
|
|
|
|
|
|
e := defaultMakeEntry(startValue, edit, action)
|
|
|
|
hboxN.Append(e.UiEntry, false)
|
|
|
|
|
|
|
|
box.UiBox.Append(hboxN, false)
|
|
|
|
// End 'Nickname' vertical box
|
|
|
|
|
|
|
|
return e
|
|
|
|
}
|
2019-06-01 03:20:20 -05:00
|
|
|
|
|
|
|
func NewLabel(box *GuiBox, text string) {
|
|
|
|
box.UiBox.Append(ui.NewLabel(text), false)
|
|
|
|
}
|
2019-06-01 04:13:18 -05:00
|
|
|
|
|
|
|
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
|
2019-06-01 16:10:12 -05:00
|
|
|
box.Window.EntryMap[name] = ge
|
2019-06-01 04:13:18 -05:00
|
|
|
|
|
|
|
return ge
|
|
|
|
}
|
|
|
|
|
2019-06-01 13:45:15 -05:00
|
|
|
func HardHorizontalBreak(box *GuiBox) {
|
|
|
|
log.Println("HardHorizontalBreak START")
|
2019-06-01 14:43:40 -05:00
|
|
|
gw := box.Window
|
2019-06-01 13:45:15 -05:00
|
|
|
mainbox := gw.mainbox
|
|
|
|
|
|
|
|
tmp := ui.NewHorizontalSeparator()
|
|
|
|
mainbox.Append(tmp, false)
|
|
|
|
|
|
|
|
hbox := ui.NewVerticalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
box.UiBox = hbox
|
|
|
|
mainbox.Append(hbox, true)
|
|
|
|
log.Println("HardHorizontalBreak END")
|
|
|
|
}
|
|
|
|
|
|
|
|
func HardVerticalBreak(box *GuiBox) {
|
|
|
|
log.Println("HardVerticalBreak START")
|
2019-06-01 14:43:40 -05:00
|
|
|
gw := box.Window
|
2019-06-01 13:45:15 -05:00
|
|
|
mainbox := gw.mainbox
|
|
|
|
|
|
|
|
tmp := ui.NewVerticalSeparator()
|
|
|
|
mainbox.Append(tmp, false)
|
|
|
|
|
|
|
|
hbox := ui.NewVerticalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
box.UiBox = hbox
|
|
|
|
mainbox.Append(hbox, false)
|
|
|
|
log.Println("HardVerticalBreak END")
|
|
|
|
}
|
|
|
|
|
2019-06-01 04:58:49 -05:00
|
|
|
func HorizontalBreak(box *GuiBox) {
|
|
|
|
tmp := ui.NewHorizontalSeparator()
|
|
|
|
box.UiBox.Append(tmp, false)
|
|
|
|
}
|
|
|
|
|
2019-06-01 13:45:15 -05:00
|
|
|
func VerticalBreak(box *GuiBox) {
|
|
|
|
tmp := ui.NewVerticalSeparator()
|
|
|
|
box.UiBox.Append(tmp, false)
|
|
|
|
}
|
|
|
|
|
2019-06-01 04:13:18 -05:00
|
|
|
func AddGenericBox(gw *GuiWindow) *GuiBox {
|
|
|
|
var gb *GuiBox
|
|
|
|
gb = new(GuiBox)
|
|
|
|
|
2019-06-01 16:10:12 -05:00
|
|
|
// gb.EntryMap = make(map[string]*GuiEntry)
|
|
|
|
// gb.EntryMap["test"] = nil
|
2019-06-01 04:13:18 -05:00
|
|
|
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
// gw.Box1 = vbox
|
|
|
|
gb.UiBox = vbox
|
2019-06-01 14:43:40 -05:00
|
|
|
gb.Window = gw
|
2019-06-01 04:13:18 -05:00
|
|
|
|
|
|
|
hbox := ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
vbox.Append(hbox, false)
|
|
|
|
|
|
|
|
return gb
|
|
|
|
}
|
|
|
|
|
2019-06-01 04:58:49 -05:00
|
|
|
func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
|
|
|
log.Println("CreateAddVmBox() START name =", name)
|
|
|
|
|
|
|
|
var box *GuiBox
|
|
|
|
box = new(GuiBox)
|
|
|
|
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
box.UiBox = vbox
|
2019-06-01 14:43:40 -05:00
|
|
|
box.Window = gw
|
2019-06-01 04:58:49 -05:00
|
|
|
gw.BoxMap["ADD VM" + name] = box
|
|
|
|
|
|
|
|
hbox := ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
vbox.Append(hbox, false)
|
|
|
|
|
|
|
|
AddBoxToTab(name, gw.UiTab, vbox)
|
|
|
|
|
|
|
|
return box
|
2019-06-01 04:13:18 -05:00
|
|
|
}
|
2019-06-01 05:24:38 -05:00
|
|
|
|
|
|
|
func CreateBox(gw *GuiWindow, name string) *GuiBox {
|
|
|
|
log.Println("CreateVmBox() START")
|
|
|
|
log.Println("CreateVmBox() vm.Name =", name)
|
|
|
|
log.Println("CreateVmBox() gw =", gw)
|
|
|
|
|
|
|
|
var box *GuiBox
|
|
|
|
box = new(GuiBox)
|
|
|
|
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
log.Println("CreateVmBox() vbox =", vbox)
|
|
|
|
log.Println("CreateVmBox() box.UiBox =", box.UiBox)
|
|
|
|
box.UiBox = vbox
|
2019-06-01 14:43:40 -05:00
|
|
|
log.Println("CreateVmBox() box.Window =", box.Window)
|
|
|
|
box.Window = gw
|
2019-06-01 05:24:38 -05:00
|
|
|
log.Println("CreateVmBox() gw.BoxMap =", gw.BoxMap)
|
|
|
|
gw.BoxMap[name] = box
|
|
|
|
|
|
|
|
hboxAccount := ui.NewHorizontalBox()
|
|
|
|
hboxAccount.SetPadded(true)
|
|
|
|
vbox.Append(hboxAccount, false)
|
|
|
|
|
|
|
|
box.UiBox = hboxAccount
|
|
|
|
|
|
|
|
AddBoxToTab(name, gw.UiTab, vbox)
|
|
|
|
|
|
|
|
return box
|
|
|
|
}
|