successfully inserted a row

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-08 15:28:40 -07:00
parent d977b24730
commit 224fdff8aa
2 changed files with 62 additions and 0 deletions

28
gui.go
View File

@ -254,6 +254,16 @@ func AddEntriesDemo() {
maintab.SetMargined(tabcount, true) maintab.SetMargined(tabcount, true)
} }
func initRow(mh *tableData, row int) {
initRowBTcolor (mh, row, 0)
initRowTextColorColumn(mh, row, 1, 2, "diff1", ui.TableColor{0.9, 0, 0, 1})
initRowButtonColumn (mh, row, 3, "diff2")
initRowTextColorColumn(mh, row, 4, 5, "diff3", ui.TableColor{0.0, 0.9, 0.4, 1})
initRowTextColorColumn(mh, row, 6, 7, "diff4", ui.TableColor{0.3, 0.1, 0.9, 1})
initRowTextColumn (mh, row, 8, "diff5")
initRowButtonColumn (mh, row, 9, "diff6")
}
func AddTableTab(name string, rowcount int, row1name string) { func AddTableTab(name string, rowcount int, row1name string) {
mh := new(tableData) mh := new(tableData)
@ -272,6 +282,24 @@ func AddTableTab(name string, rowcount int, row1name string) {
initTextColumn (mh, 8, "jwc8blah") initTextColumn (mh, 8, "jwc8blah")
initButtonColumn (mh, 9, "but9ton") initButtonColumn (mh, 9, "but9ton")
// spew.Dump(mh)
log.Println(mh)
b := make([]rowData, 5)
mh.rows = append(mh.rows, b...)
initRow(mh, mh.rowcount)
mh.rowcount = rowcount + 1
log.Println(mh)
/*
mh.rowcount = rowcount
initRow(mh, mh.rowcount)
spew.Dump(mh)
*/
model := ui.NewTableModel(mh) model := ui.NewTableModel(mh)
table := ui.NewTable( table := ui.NewTable(

View File

@ -7,6 +7,8 @@ import "log"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
var img [2]*ui.Image var img [2]*ui.Image
type cellData struct { type cellData struct {
@ -55,6 +57,17 @@ func initBTcolor(mh *tableData, intBG int) {
} }
} }
func initRowBTcolor(mh *tableData, row int, intBG int) {
// 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}
mh.rows[row].cells[intBG].name = "BG"
} else {
mh.rows[row].cells[intBG].value = ui.TableColor{0.1, 0.1, 0.1, .1}
mh.rows[row].cells[intBG].name = "BG"
}
}
func initButtonColumn(mh *tableData, buttonID int, junk string) { func initButtonColumn(mh *tableData, buttonID int, junk string) {
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
@ -65,6 +78,12 @@ func initButtonColumn(mh *tableData, buttonID int, junk string) {
} }
} }
func initRowButtonColumn(mh *tableData, row int, buttonID int, junk string) {
// 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 initTextColorColumn(mh *tableData, stringID int, colorID int, junk string, color ui.TableColor) { func initTextColorColumn(mh *tableData, stringID int, colorID int, junk string, color ui.TableColor) {
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{}) mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
@ -82,6 +101,16 @@ func initTextColorColumn(mh *tableData, stringID int, colorID int, junk string,
} }
} }
func initRowTextColorColumn(mh *tableData, row int, stringID int, colorID int, junk string, color ui.TableColor) {
// text for Column ?
mh.rows[row].cells[stringID].value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
mh.rows[row].cells[stringID].name = "EDIT"
// text color for Column ?
mh.rows[row].cells[colorID].value = color
mh.rows[row].cells[colorID].name = "COLOR"
}
func initTextColumn(mh *tableData, stringID int, junk string) { func initTextColumn(mh *tableData, stringID int, junk string) {
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
@ -94,6 +123,11 @@ func initTextColumn(mh *tableData, stringID int, junk string) {
} }
} }
func initRowTextColumn(mh *tableData, row int, stringID int, junk string) {
mh.rows[row].cells[stringID].value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
mh.rows[row].cells[stringID].name = "EDIT"
}
func appendTextColorColumn(mh *tableData, table *ui.Table, stringID int, colorID int, columnName string) { func appendTextColorColumn(mh *tableData, table *ui.Table, stringID int, colorID int, columnName string) {
table.AppendTextColumn(columnName, stringID, ui.TableModelColumnAlwaysEditable, table.AppendTextColumn(columnName, stringID, ui.TableModelColumnAlwaysEditable,
&ui.TableTextColumnOptionalParams{ &ui.TableTextColumnOptionalParams{