From 9b58fc0eb04b67001e91eeff43a8ddb04940ad54 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 8 May 2019 04:05:14 -0700 Subject: [PATCH] first successful column append Signed-off-by: Jeff Carr --- table.go | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/table.go b/table.go index 659f7b1..46d0ac3 100644 --- a/table.go +++ b/table.go @@ -94,6 +94,42 @@ func initValues(mh *modelHandler) { mh.rows[i].cells[8].value = ui.TableColor{0.9, 0, 0, 1} mh.rows[i].cells[8].name = "COLOR" } +} + +func initColorColumn(mh *modelHandler, stringID int, colorID int) { + 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("append %d", i)) + mh.rows[i].cells[stringID].name = "EDIT" + + // text color for Column ? + mh.rows[i].cells[colorID].value = ui.TableColor{0.0, 0.9, 0.4, 1} + mh.rows[i].cells[colorID].name = "COLOR" + } + + // mh.rowcount = mh.rowcount + 2 + +} + +func appendColorColumn(mh *modelHandler, table *ui.Table, stringID int, colorID int) { + log.Println("mh.rows=", mh.rows) + + textid := mh.rowcount + 1 + log.Println("textid=", textid) + colorid := mh.rowcount + 2 + log.Println("colorid=", colorid) + + // text color doesn't work like this? + table.AppendTextColumn("testappend", stringID, ui.TableModelColumnAlwaysEditable, + &ui.TableTextColumnOptionalParams{ + ColorModelColumn: colorID, + }); + // os.Exit(-1) } @@ -110,6 +146,8 @@ func newModelHandler(rowcount int) *modelHandler { initValues(mh) + initColorColumn(mh, 6, 7) + log.Println("Called newModelHandler() with mh=", mh) spew.Dump(mh) return mh @@ -130,11 +168,12 @@ func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *modelHan table.AppendButtonColumn("Details", 3, ui.TableModelColumnAlwaysEditable) // text color doesn't work like this? - table.AppendTextColumn("testcolor", 4, ui.TableModelColumnAlwaysEditable, + table.AppendTextColumn("testcolor", 4, ui.TableModelColumnAlwaysEditable, &ui.TableTextColumnOptionalParams{ ColorModelColumn: 5, }); + appendColorColumn(mh, table, 6, 7) /* table.AppendImageTextColumn("testimagecolor", 6, 7, ui.TableModelColumnNeverEditable,