2019-05-07 21:31:58 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "os"
|
|
|
|
import "log"
|
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-07 21:45:59 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
2019-05-07 21:31:58 -05:00
|
|
|
|
|
|
|
func (mh *modelHandler) NumRows(m *ui.TableModel) int {
|
|
|
|
// log.Println("NumRows() with m=", m)
|
|
|
|
return mh.rows
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
if (mh.funcColumnTypes == nil) {
|
|
|
|
log.Println("ColumnTypes NOT DEFINED. This table wasn't setup correctly! mh.funcColmnTypes == nil")
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
|
|
|
return mh.funcColumnTypes()
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)
|
|
|
|
func (mh *modelHandler) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
|
|
|
|
if (mh.scanCellValue == nil) {
|
|
|
|
log.Println("CellValue NOT DEFINED. This table wasn't setup correctly! mh.scanCellValue == nil")
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
|
|
|
return mh.scanCellValue(mh, row, column)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mh *modelHandler) SetCellValue(m *ui.TableModel, row, column int, value ui.TableValue) {
|
2019-05-07 21:45:59 -05:00
|
|
|
log.Println("SetCallValue() START row=", row, "column=", column, "value=", value)
|
|
|
|
// spew.Dump(m)
|
|
|
|
// spew.Dump(mh)
|
|
|
|
if (mh.setCellValue == nil) {
|
|
|
|
log.Println("CellValue NOT DEFINED. This table wasn't setup correctly! mh.scanCellValue == nil")
|
|
|
|
os.Exit(-1)
|
2019-05-07 21:31:58 -05:00
|
|
|
}
|
2019-05-07 21:45:59 -05:00
|
|
|
// spew.Dump(m)
|
|
|
|
mh.setCellValue(mh, m, row, column, value)
|
2019-05-07 21:31:58 -05:00
|
|
|
log.Println("SetCallValue() END")
|
|
|
|
}
|