summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui.go28
-rw-r--r--table.go34
2 files changed, 62 insertions, 0 deletions
diff --git a/gui.go b/gui.go
index d359a8e..c7b6333 100644
--- a/gui.go
+++ b/gui.go
@@ -254,6 +254,16 @@ func AddEntriesDemo() {
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) {
mh := new(tableData)
@@ -272,6 +282,24 @@ func AddTableTab(name string, rowcount int, row1name string) {
initTextColumn (mh, 8, "jwc8blah")
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)
table := ui.NewTable(
diff --git a/table.go b/table.go
index 0b7f539..bfd9317 100644
--- a/table.go
+++ b/table.go
@@ -7,6 +7,8 @@ import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
+// import "github.com/davecgh/go-spew/spew"
+
var img [2]*ui.Image
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) {
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) {
mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
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) {
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) {
table.AppendTextColumn(columnName, stringID, ui.TableModelColumnAlwaysEditable,
&ui.TableTextColumnOptionalParams{