diff --git a/table.go b/table.go index 9921b97..b3d8ca9 100644 --- a/table.go +++ b/table.go @@ -4,10 +4,8 @@ package main import "fmt" import "log" -// import "os" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" -import "github.com/davecgh/go-spew/spew" var img [2]*ui.Image @@ -59,21 +57,6 @@ func initBTcolor(mh *modelHandler) { } } -func initValues(mh *modelHandler) { - mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) - mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableColor{}) - - for i := 0; i < mh.rowcount; i++ { - // text for Column 0 - mh.rows[i].cells[1].value = ui.TableString(fmt.Sprintf("fun %d", i)) - mh.rows[i].cells[1].name = "EDIT" - - // text color for Column 0 - mh.rows[i].cells[2].value = ui.TableColor{0.9, 0, 0, 1} - mh.rows[i].cells[2].name = "COLOR" - } -} - func initButtonColumn(mh *modelHandler, buttonID int, junk string) { mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) @@ -113,31 +96,6 @@ func initTextColumn(mh *modelHandler, stringID int, junk string) { } } -func newModelHandler(rowcount int) *modelHandler { - mh := new(modelHandler) - - mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0 - mh.rowcount = rowcount - - // This is the standard callback function from libUI when the user does something - mh.libUIevent = defaultSetCellValue - - mh.rows = make([]rowData, mh.rowcount) - - initBTcolor(mh) - // initValues(mh) - initTextColorColumn(mh, 1, 2, "really fun", ui.TableColor{0.9, 0, 0, 1}) - initButtonColumn (mh, 3, "but3ton") - initTextColorColumn(mh, 4, 5, "jwc45blah", ui.TableColor{0.0, 0.9, 0.4, 1}) - initTextColorColumn(mh, 6, 7, "jwc67blah", ui.TableColor{0.3, 0.1, 0.9, 1}) - initTextColumn (mh, 8, "jwc8blah") - // initButtonColumn(mh, 9, "but9ton") - - log.Println("Called newModelHandler() with mh=", mh) - spew.Dump(mh) - return mh -} - func appendTextColorColumn(mh *modelHandler, table *ui.Table, stringID int, colorID int, columnName string) { table.AppendTextColumn(columnName, stringID, ui.TableModelColumnAlwaysEditable, &ui.TableTextColumnOptionalParams{ @@ -150,7 +108,24 @@ func appendTextColumn(mh *modelHandler, table *ui.Table, stringID int, columnNam } func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *modelHandler, *ui.TableModel) { - mh := newModelHandler(rowcount) + mh := new(modelHandler) + + mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0 + mh.rowcount = rowcount + + // This is the standard callback function from libUI when the user does something + mh.libUIevent = defaultSetCellValue + + mh.rows = make([]rowData, mh.rowcount) + + initBTcolor(mh) + initTextColorColumn(mh, 1, 2, "really fun", ui.TableColor{0.9, 0, 0, 1}) + initButtonColumn (mh, 3, "but3ton") + initTextColorColumn(mh, 4, 5, "jwc45blah", ui.TableColor{0.0, 0.9, 0.4, 1}) + initTextColorColumn(mh, 6, 7, "jwc67blah", ui.TableColor{0.3, 0.1, 0.9, 1}) + initTextColumn (mh, 8, "jwc8blah") + // initButtonColumn(mh, 9, "but9ton") + mh.name = name model := ui.NewTableModel(mh) @@ -160,12 +135,13 @@ func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *modelHan RowBackgroundColorModelColumn: mh.rowBGcolor, }) - table.AppendTextColumn(row1Name, 1, ui.TableModelColumnAlwaysEditable, nil) + table.AppendTextColumn (row1Name, 1, ui.TableModelColumnAlwaysEditable, nil) table.AppendButtonColumn("Details", 3, ui.TableModelColumnAlwaysEditable) - appendTextColorColumn(mh, table, 4, 5, "testcolor") - appendTextColorColumn(mh, table, 6, 7, "appendTest") - appendTextColumn(mh, table, 8, "jwc8col") + appendTextColorColumn (mh, table, 4, 5, "testcolor") + appendTextColorColumn (mh, table, 6, 7, "appendTest") + appendTextColumn (mh, table, 8, "jwc8col") + // table.AppendButtonColumn("button9", 9, ui.TableModelColumnAlwaysEditable) return table, mh, model