Rename 'modelHandler' to 'tableData' as all it stores is the data

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-08 08:55:51 -07:00
parent 515ed74f58
commit 37fefba92f
2 changed files with 15 additions and 15 deletions

View File

@ -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
}

View File

@ -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)