Cleaned out the cell width type init from the data init
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
9ef3b54c01
commit
f754cd7030
32
gui.go
32
gui.go
|
@ -254,6 +254,21 @@ func AddEntriesDemo() {
|
||||||
maintab.SetMargined(tabcount, true)
|
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) {
|
func initRow(mh *tableData, row int) {
|
||||||
initRowBTcolor (mh, row, 0)
|
initRowBTcolor (mh, row, 0)
|
||||||
initRowTextColorColumn(mh, row, 1, 2, "diff1", ui.TableColor{0.0, 0, 0.9, 1})
|
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
|
mh.libUIevent = defaultSetCellValue
|
||||||
|
|
||||||
tmpBTindex := 0
|
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)
|
initBTcolor (mh, 0)
|
||||||
initTextColorColumn(mh, 1, 2, "really fun", ui.TableColor{0.9, 0, 0, 1})
|
initTextColorColumn(mh, 1, 2, "really fun", ui.TableColor{0.9, 0, 0, 1})
|
||||||
initButtonColumn (mh, 3, "but3ton")
|
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})
|
initTextColorColumn(mh, 6, 7, "jwc67blah", ui.TableColor{0.3, 0.1, 0.9, 1})
|
||||||
initTextColumn (mh, 8, "jwc8blah")
|
initTextColumn (mh, 8, "jwc8blah")
|
||||||
initButtonColumn (mh, 9, "but9ton")
|
initButtonColumn (mh, 9, "but9ton")
|
||||||
|
*/
|
||||||
|
|
||||||
// spew.Dump(mh)
|
// spew.Dump(mh)
|
||||||
log.Println(mh)
|
log.Println(mh)
|
||||||
|
@ -288,10 +314,12 @@ func AddTableTab(name string, rowcount int, row1name string) {
|
||||||
b := make([]rowData, 5)
|
b := make([]rowData, 5)
|
||||||
mh.rows = append(mh.rows, b...)
|
mh.rows = append(mh.rows, b...)
|
||||||
|
|
||||||
initRow(mh, 2)
|
for row := 0; row < mh.rowcount; row++ {
|
||||||
|
initRow(mh, row)
|
||||||
|
}
|
||||||
|
|
||||||
initRow(mh, mh.rowcount)
|
initRow(mh, mh.rowcount)
|
||||||
mh.rowcount = rowcount + 1
|
mh.rowcount = rowcount + 1
|
||||||
|
|
||||||
log.Println(mh)
|
log.Println(mh)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
65
table.go
65
table.go
|
@ -11,6 +11,11 @@ import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
var img [2]*ui.Image
|
var img [2]*ui.Image
|
||||||
|
|
||||||
|
/*
|
||||||
|
img[0] = ui.NewImage(16, 16)
|
||||||
|
img[1] = ui.NewImage(16, 16)
|
||||||
|
*/
|
||||||
|
|
||||||
type cellData struct {
|
type cellData struct {
|
||||||
index int
|
index int
|
||||||
value ui.TableValue
|
value ui.TableValue
|
||||||
|
@ -32,31 +37,12 @@ type rowData struct {
|
||||||
|
|
||||||
type tableData struct {
|
type tableData struct {
|
||||||
rowcount int // This is the number of 'rows' which really means data elements not what the human sees
|
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
|
rows []rowData // This is all the table data by row
|
||||||
generatedColumnTypes []ui.TableValue // generate this dynamically
|
generatedColumnTypes []ui.TableValue // generate this dynamically
|
||||||
libUIevent func(*tableData, *ui.TableModel, int, int, ui.TableValue)
|
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) {
|
func initRowBTcolor(mh *tableData, row int, intBG int) {
|
||||||
// alternate background of each row light and dark
|
// alternate background of each row light and dark
|
||||||
if (row % 2) == 1 {
|
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) {
|
func initRowButtonColumn(mh *tableData, row int, buttonID int, junk string) {
|
||||||
// set the button text for Column ?
|
// 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].value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
|
||||||
mh.rows[row].cells[buttonID].name = "BUTTON"
|
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) {
|
func initRowTextColorColumn(mh *tableData, row int, stringID int, colorID int, junk string, color ui.TableColor) {
|
||||||
// text for Column ?
|
// text for Column ?
|
||||||
mh.rows[row].cells[stringID].value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
|
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"
|
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) {
|
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].value = ui.TableString(fmt.Sprintf("%s %d", junk, row))
|
||||||
mh.rows[row].cells[stringID].name = "EDIT"
|
mh.rows[row].cells[stringID].name = "EDIT"
|
||||||
|
|
Loading…
Reference in New Issue