try to clean up this wrapper code
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
27bf7bb709
commit
b92903ad15
22
gui.go
22
gui.go
|
@ -17,6 +17,13 @@ var tabcount int
|
|||
var jcarrButton *ui.Button
|
||||
var jcarrEntry *ui.MultilineEntry
|
||||
|
||||
type InputData struct {
|
||||
Index int
|
||||
CellType string
|
||||
Heading string
|
||||
Color string
|
||||
}
|
||||
|
||||
func buttonClick(button *ui.Button) {
|
||||
log.Println("hostname =", config.String("hostname"), button)
|
||||
spew.Dump(button)
|
||||
|
@ -280,16 +287,16 @@ func initRow(mh *TableData, row int, parts []InputData) {
|
|||
for key, foo := range parts {
|
||||
log.Println(key, foo)
|
||||
if (foo.CellType == "BG") {
|
||||
initRowBTcolor (mh, row, tmpBTindex)
|
||||
initRowBTcolor (mh, row, tmpBTindex, parts[key])
|
||||
tmpBTindex += 1
|
||||
} else if (foo.CellType == "BUTTON") {
|
||||
initRowButtonColumn (mh, row, tmpBTindex, "diff2")
|
||||
initRowButtonColumn (mh, row, tmpBTindex, parts[key].Heading, parts[key])
|
||||
tmpBTindex += 1
|
||||
} else if (foo.CellType == "TEXTCOLOR") {
|
||||
initRowTextColorColumn(mh, row, tmpBTindex, tmpBTindex + 1, "diff1", ui.TableColor{0.0, 0, 0.9, 1})
|
||||
initRowTextColorColumn(mh, row, tmpBTindex, tmpBTindex + 1, parts[key].Heading, ui.TableColor{0.0, 0, 0.9, 1}, parts[key])
|
||||
tmpBTindex += 2
|
||||
} else if (foo.CellType == "TEXT") {
|
||||
initRowTextColumn (mh, row, tmpBTindex, "diff5")
|
||||
initRowTextColumn (mh, row, tmpBTindex, parts[key].Heading, parts[key])
|
||||
tmpBTindex += 1
|
||||
} else {
|
||||
panic("I don't know what this is in initColumnNames")
|
||||
|
@ -297,13 +304,6 @@ func initRow(mh *TableData, row int, parts []InputData) {
|
|||
}
|
||||
}
|
||||
|
||||
type InputData struct {
|
||||
Index int
|
||||
CellType string
|
||||
Heading string
|
||||
Color string
|
||||
}
|
||||
|
||||
func AddSampleTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []InputData) {
|
||||
mh := new(TableData)
|
||||
|
||||
|
|
40
table.go
40
table.go
|
@ -34,6 +34,17 @@ type RowData struct {
|
|||
doubleclick func() // what function to call if the user double clicks on it
|
||||
*/
|
||||
Cells [20]CellData
|
||||
Human [20]HumanCellData
|
||||
}
|
||||
|
||||
// hmm. will this stand the test of time?
|
||||
type HumanCellData struct {
|
||||
Name string // what kind of row is this?
|
||||
Text ui.TableString
|
||||
TextID int
|
||||
Color ui.TableColor
|
||||
ColorID int
|
||||
Event func() // what function to call if there is an event on this
|
||||
}
|
||||
|
||||
type TableData struct {
|
||||
|
@ -45,7 +56,28 @@ type TableData struct {
|
|||
cellChangeEvent func(int, int, ui.TableValue)
|
||||
}
|
||||
|
||||
func initRowBTcolor(mh *TableData, row int, intBG int) {
|
||||
/*
|
||||
func initHumanCell(mh *TableData, row int, cell InputData) {
|
||||
humanInt := cell.Index
|
||||
|
||||
intBG := cell.ColorID
|
||||
mh.Rows[row].Human[humanInt].Name = cell.CellType
|
||||
mh.Rows[row].Human[humanInt].Color = cell.Color
|
||||
mh.Rows[row].Human[humanInt].ColorID = intBG
|
||||
mh.Rows[row].Human[humanInt].Text = ui.TableValue{}
|
||||
mh.Rows[row].Human[humanInt].TextID = -1
|
||||
}
|
||||
*/
|
||||
|
||||
func initRowBTcolor(mh *TableData, row int, intBG int, cell InputData) {
|
||||
humanInt := cell.Index
|
||||
|
||||
mh.Rows[row].Human[humanInt].Name = "BG"
|
||||
mh.Rows[row].Human[humanInt].Color = ui.TableColor{0.5, 0.5, 0.5, .7}
|
||||
mh.Rows[row].Human[humanInt].ColorID = intBG
|
||||
// mh.Rows[row].Human[humanInt].Text = ui.TableValue{}
|
||||
mh.Rows[row].Human[humanInt].TextID = -1
|
||||
|
||||
// alternate background of each row light and dark
|
||||
if (row % 2) == 1 {
|
||||
mh.Rows[row].Cells[intBG].Value = ui.TableColor{0.5, 0.5, 0.5, .7}
|
||||
|
@ -56,13 +88,13 @@ func initRowBTcolor(mh *TableData, row int, intBG int) {
|
|||
}
|
||||
}
|
||||
|
||||
func initRowButtonColumn(mh *TableData, row int, buttonID int, junk string) {
|
||||
func initRowButtonColumn(mh *TableData, row int, buttonID int, junk string, cell InputData) {
|
||||
// set the button text for Column ?
|
||||
mh.Rows[row].Cells[buttonID].Value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
|
||||
mh.Rows[row].Cells[buttonID].Name = "BUTTON"
|
||||
}
|
||||
|
||||
func initRowTextColorColumn(mh *TableData, row int, stringID int, colorID int, junk string, color ui.TableColor) {
|
||||
func initRowTextColorColumn(mh *TableData, row int, stringID int, colorID int, junk string, color ui.TableColor, cell InputData) {
|
||||
// text for Column ?
|
||||
mh.Rows[row].Cells[stringID].Value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
|
||||
mh.Rows[row].Cells[stringID].Name = "EDIT"
|
||||
|
@ -72,7 +104,7 @@ func initRowTextColorColumn(mh *TableData, row int, stringID int, colorID int, j
|
|||
mh.Rows[row].Cells[colorID].Name = "COLOR"
|
||||
}
|
||||
|
||||
func initRowTextColumn(mh *TableData, row int, stringID int, junk string) {
|
||||
func initRowTextColumn(mh *TableData, row int, stringID int, junk string, cell InputData) {
|
||||
mh.Rows[row].Cells[stringID].Value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
|
||||
mh.Rows[row].Cells[stringID].Name = "EDIT"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue