From 37fefba92f0243d90f25d6ae7a52ae13c7dda358 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 8 May 2019 08:55:51 -0700 Subject: [PATCH] Rename 'modelHandler' to 'tableData' as all it stores is the data Signed-off-by: Jeff Carr --- table.go | 22 +++++++++++----------- tableCallbacks.go | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/table.go b/table.go index b3d8ca9..a427f57 100644 --- a/table.go +++ b/table.go @@ -28,16 +28,16 @@ type rowData struct { cells [20]cellData } -type modelHandler struct { +type tableData struct { name string // I forgot where this goes rowcount int // This is the number of 'rows' which really means data elements not what the human sees rowBGcolor int // This is what index stores the row BG color (should always be 0) rows []rowData // This is all the table data by row generatedColumnTypes []ui.TableValue // generate this dynamically - libUIevent func(*modelHandler, *ui.TableModel, int, int, ui.TableValue) + libUIevent func(*tableData, *ui.TableModel, int, int, ui.TableValue) } -func initBTcolor(mh *modelHandler) { +func initBTcolor(mh *tableData) { img[0] = ui.NewImage(16, 16) img[1] = ui.NewImage(16, 16) @@ -57,7 +57,7 @@ func initBTcolor(mh *modelHandler) { } } -func initButtonColumn(mh *modelHandler, buttonID int, junk string) { +func initButtonColumn(mh *tableData, buttonID int, junk string) { mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) for i := 0; i < mh.rowcount; i++ { @@ -67,7 +67,7 @@ func initButtonColumn(mh *modelHandler, buttonID int, junk string) { } } -func initTextColorColumn(mh *modelHandler, stringID int, colorID int, junk string, color ui.TableColor) { +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{}) @@ -84,7 +84,7 @@ func initTextColorColumn(mh *modelHandler, stringID int, colorID int, junk strin } } -func initTextColumn(mh *modelHandler, stringID int, junk string) { +func initTextColumn(mh *tableData, stringID int, junk string) { mh.generatedColumnTypes = append(mh.generatedColumnTypes, ui.TableString("")) for i := 0; i < mh.rowcount; i++ { @@ -96,19 +96,19 @@ func initTextColumn(mh *modelHandler, stringID int, junk string) { } } -func appendTextColorColumn(mh *modelHandler, table *ui.Table, stringID int, colorID int, columnName string) { +func appendTextColorColumn(mh *tableData, table *ui.Table, stringID int, colorID int, columnName string) { table.AppendTextColumn(columnName, stringID, ui.TableModelColumnAlwaysEditable, &ui.TableTextColumnOptionalParams{ ColorModelColumn: colorID, }); } -func appendTextColumn(mh *modelHandler, table *ui.Table, stringID int, columnName string) { +func appendTextColumn(mh *tableData, table *ui.Table, stringID int, columnName string) { table.AppendTextColumn(columnName, stringID, ui.TableModelColumnAlwaysEditable, nil) } -func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *modelHandler, *ui.TableModel) { - mh := new(modelHandler) +func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *tableData, *ui.TableModel) { + mh := new(tableData) mh.rowBGcolor = 0 // this is the weird exception. Just always have this as 0 mh.rowcount = rowcount @@ -147,7 +147,7 @@ func makeTable(name string, rowcount int, row1Name string) (*ui.Table, *modelHan return table, mh, model } -func defaultSetCellValue(mh *modelHandler, m *ui.TableModel, row, column int, value ui.TableValue) { +func defaultSetCellValue(mh *tableData, m *ui.TableModel, row, column int, value ui.TableValue) { if (mh.rows[row].cells[column].name == "EDIT") { mh.rows[row].cells[column].value = value } diff --git a/tableCallbacks.go b/tableCallbacks.go index 200d024..42f91ef 100644 --- a/tableCallbacks.go +++ b/tableCallbacks.go @@ -12,22 +12,22 @@ import "log" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" -func (mh *modelHandler) NumRows(m *ui.TableModel) int { +func (mh *tableData) NumRows(m *ui.TableModel) int { return mh.rowcount } // FYI: this routine seems to be called around 10 to 100 times a second for each table -func (mh *modelHandler) ColumnTypes(m *ui.TableModel) []ui.TableValue { +func (mh *tableData) ColumnTypes(m *ui.TableModel) []ui.TableValue { return mh.generatedColumnTypes } // TODO: Figure out why this is being called 1000 times a second (10 times for each row & column) // Nevermind this TODO. Who gives a shit. This is a really smart way to treat the OS toolkits -func (mh *modelHandler) CellValue(m *ui.TableModel, row, column int) ui.TableValue { +func (mh *tableData) CellValue(m *ui.TableModel, row, column int) ui.TableValue { return mh.rows[row].cells[column].value } -func (mh *modelHandler) SetCellValue(m *ui.TableModel, row, column int, value ui.TableValue) { +func (mh *tableData) SetCellValue(m *ui.TableModel, row, column int, value ui.TableValue) { log.Println("SetCallValue() START row=", row, "column=", column, "value=", value) // spew.Dump(m) // spew.Dump(mh)