summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui.go32
-rw-r--r--table.go65
2 files changed, 36 insertions, 61 deletions
diff --git a/gui.go b/gui.go
index 30ba6bf..d71037e 100644
--- a/gui.go
+++ b/gui.go
@@ -254,6 +254,21 @@ func AddEntriesDemo() {
maintab.SetMargined(tabcount, true)
}
+func initColumnNames(mh *tableData, cellJWC string) {
+ if (cellJWC == "BG") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
+ } else if (cellJWC == "BUTTON") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
+ } else if (cellJWC == "TEXTCOLOR") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
+ } else if (cellJWC == "TEXT") {
+ mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
+ } else {
+ panic("I don't know what this is in initColumnNames")
+ }
+}
+
func initRow(mh *tableData, row int) {
initRowBTcolor (mh, row, 0)
initRowTextColorColumn(mh, row, 1, 2, "diff1", ui.TableColor{0.0, 0, 0.9, 1})
@@ -274,6 +289,16 @@ func AddTableTab(name string, rowcount int, row1name string) {
mh.libUIevent = defaultSetCellValue
tmpBTindex := 0
+
+ initColumnNames(mh, "BG")
+ initColumnNames(mh, "TEXTCOLOR")
+ initColumnNames(mh, "BUTTON")
+ initColumnNames(mh, "TEXTCOLOR")
+ initColumnNames(mh, "TEXTCOLOR")
+ initColumnNames(mh, "TEXT")
+ initColumnNames(mh, "BUTTON")
+
+/*
initBTcolor (mh, 0)
initTextColorColumn(mh, 1, 2, "really fun", ui.TableColor{0.9, 0, 0, 1})
initButtonColumn (mh, 3, "but3ton")
@@ -281,6 +306,7 @@ func AddTableTab(name string, rowcount int, row1name string) {
initTextColorColumn(mh, 6, 7, "jwc67blah", ui.TableColor{0.3, 0.1, 0.9, 1})
initTextColumn (mh, 8, "jwc8blah")
initButtonColumn (mh, 9, "but9ton")
+*/
// spew.Dump(mh)
log.Println(mh)
@@ -288,10 +314,12 @@ func AddTableTab(name string, rowcount int, row1name string) {
b := make([]rowData, 5)
mh.rows = append(mh.rows, b...)
- initRow(mh, 2)
+ for row := 0; row < mh.rowcount; row++ {
+ initRow(mh, row)
+ }
+
initRow(mh, mh.rowcount)
mh.rowcount = rowcount + 1
-
log.Println(mh)
/*
diff --git a/table.go b/table.go
index bfd9317..0c3505c 100644
--- a/table.go
+++ b/table.go
@@ -11,6 +11,11 @@ import _ "github.com/andlabs/ui/winmanifest"
var img [2]*ui.Image
+/*
+ img[0] = ui.NewImage(16, 16)
+ img[1] = ui.NewImage(16, 16)
+*/
+
type cellData struct {
index int
value ui.TableValue
@@ -32,31 +37,12 @@ type rowData struct {
type tableData struct {
rowcount int // This is the number of 'rows' which really means data elements not what the human sees
+ rowWidth int // This is how wide each row is
rows []rowData // This is all the table data by row
generatedColumnTypes []ui.TableValue // generate this dynamically
libUIevent func(*tableData, *ui.TableModel, int, int, ui.TableValue)
}
-func initBTcolor(mh *tableData, intBG int) {
- img[0] = ui.NewImage(16, 16)
- img[1] = ui.NewImage(16, 16)
-
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{})
-
- for i := 0; i < mh.rowcount; i++ {
- log.Println("i=",i)
-
- // alternate background of each row light and dark
- if (i % 2) == 1 {
- mh.rows[i].cells[intBG].value = ui.TableColor{0.5, 0.5, 0.5, .7}
- mh.rows[i].cells[intBG].name = "BG"
- } else {
- mh.rows[i].cells[intBG].value = ui.TableColor{0.1, 0.1, 0.1, .1}
- mh.rows[i].cells[intBG].name = "BG"
- }
- }
-}
-
func initRowBTcolor(mh *tableData, row int, intBG int) {
// alternate background of each row light and dark
if (row % 2) == 1 {
@@ -68,39 +54,12 @@ func initRowBTcolor(mh *tableData, row int, intBG int) {
}
}
-func initButtonColumn(mh *tableData, buttonID int, junk string) {
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
-
- for i := 0; i < mh.rowcount; i++ {
- // set the button text for Column ?
- mh.rows[i].cells[buttonID].value = ui.TableString(fmt.Sprintf("%s %d", junk, i))
- mh.rows[i].cells[buttonID].name = "BUTTON"
- }
-}
-
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{})
-
- for i := 0; i < mh.rowcount; i++ {
- log.Println("i=",i)
-
- // text for Column ?
- mh.rows[i].cells[stringID].value = ui.TableString(fmt.Sprintf("%s %d", junk, i))
- mh.rows[i].cells[stringID].name = "EDIT"
-
- // text color for Column ?
- mh.rows[i].cells[colorID].value = color
- mh.rows[i].cells[colorID].name = "COLOR"
- }
-}
-
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))
@@ -111,18 +70,6 @@ func initRowTextColorColumn(mh *tableData, row int, stringID int, colorID int, j
mh.rows[row].cells[colorID].name = "COLOR"
}
-func initTextColumn(mh *tableData, stringID int, junk string) {
- mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString(""))
-
- for i := 0; i < mh.rowcount; i++ {
- log.Println("i=",i)
-
- // text for Column ?
- mh.rows[i].cells[stringID].value = ui.TableString(fmt.Sprintf("%s %d", junk, i))
- mh.rows[i].cells[stringID].name = "EDIT"
- }
-}
-
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"