2019-05-08 15:04:18 -05:00
|
|
|
// based off andlabs/ui/examples/table.go
|
|
|
|
|
2019-05-08 15:09:17 -05:00
|
|
|
package gui
|
2019-05-08 15:04:18 -05:00
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-08 17:28:40 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2019-05-12 17:11:32 -05:00
|
|
|
type CellData struct {
|
|
|
|
Index int
|
2019-05-12 22:25:55 -05:00
|
|
|
HumanID int
|
2019-05-12 17:11:32 -05:00
|
|
|
Name string // what type of cell is this?
|
2019-05-08 15:04:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// hmm. will this stand the test of time?
|
2019-05-12 17:11:32 -05:00
|
|
|
type RowData struct {
|
|
|
|
Name string // what kind of row is this?
|
|
|
|
Status string // status of the row?
|
2019-05-08 15:04:18 -05:00
|
|
|
/*
|
|
|
|
// These may or may not be implementable
|
|
|
|
click func() // what function to call if the user clicks on it
|
|
|
|
doubleclick func() // what function to call if the user double clicks on it
|
|
|
|
*/
|
2019-05-12 17:11:32 -05:00
|
|
|
Cells [20]CellData
|
2019-05-12 20:05:17 -05:00
|
|
|
Human [20]HumanCellData
|
|
|
|
}
|
|
|
|
|
|
|
|
// hmm. will this stand the test of time?
|
|
|
|
type HumanCellData struct {
|
|
|
|
Name string // what kind of row is this?
|
|
|
|
Text ui.TableString
|
|
|
|
TextID int
|
|
|
|
Color ui.TableColor
|
|
|
|
ColorID int
|
2019-05-08 15:04:18 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 17:11:32 -05:00
|
|
|
type TableData struct {
|
|
|
|
RowCount int // This is the number of 'rows' which really means data elements not what the human sees
|
|
|
|
RowWidth int // This is how wide each row is
|
|
|
|
Rows []RowData // This is all the table data by row
|
2019-05-08 15:04:18 -05:00
|
|
|
generatedColumnTypes []ui.TableValue // generate this dynamically
|
2019-05-13 01:37:27 -05:00
|
|
|
// libUIevent func(*TableData, *ui.TableModel, int, int, ui.TableValue)
|
2019-05-12 17:11:32 -05:00
|
|
|
cellChangeEvent func(int, int, ui.TableValue)
|
2019-05-08 15:04:18 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 20:05:17 -05:00
|
|
|
func initRowBTcolor(mh *TableData, row int, intBG int, cell InputData) {
|
|
|
|
humanInt := cell.Index
|
|
|
|
|
2019-05-12 22:25:55 -05:00
|
|
|
// setup mapping from human readable indexes to internal libUI indexes
|
2019-05-12 20:05:17 -05:00
|
|
|
mh.Rows[row].Human[humanInt].Name = "BG"
|
|
|
|
mh.Rows[row].Human[humanInt].ColorID = intBG
|
|
|
|
mh.Rows[row].Human[humanInt].TextID = -1
|
|
|
|
|
2019-05-12 22:25:55 -05:00
|
|
|
mh.Rows[row].Cells[intBG].Name = "BG"
|
|
|
|
mh.Rows[row].Cells[intBG].HumanID = humanInt
|
|
|
|
|
2019-05-12 23:01:22 -05:00
|
|
|
log.Println("HumanID = row, intBG, humanInt", row, intBG, humanInt)
|
2019-05-08 17:28:40 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 20:05:17 -05:00
|
|
|
func initRowButtonColumn(mh *TableData, row int, buttonID int, junk string, cell InputData) {
|
2019-05-12 22:25:55 -05:00
|
|
|
humanInt := cell.Index
|
|
|
|
|
|
|
|
// setup mapping from human readable indexes to internal libUI indexes
|
|
|
|
mh.Rows[row].Human[humanInt].Name = "BUTTON"
|
|
|
|
mh.Rows[row].Human[humanInt].ColorID = -1
|
|
|
|
mh.Rows[row].Human[humanInt].TextID = buttonID
|
|
|
|
|
|
|
|
mh.Rows[row].Cells[buttonID].Name = "BUTTON"
|
|
|
|
mh.Rows[row].Cells[buttonID].HumanID = humanInt
|
2019-05-12 23:01:22 -05:00
|
|
|
|
|
|
|
log.Println("HumanID = row, buttonID, humanInt", row, buttonID, humanInt)
|
2019-05-08 17:28:40 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 20:05:17 -05:00
|
|
|
func initRowTextColorColumn(mh *TableData, row int, stringID int, colorID int, junk string, color ui.TableColor, cell InputData) {
|
2019-05-12 22:25:55 -05:00
|
|
|
humanInt := cell.Index
|
|
|
|
|
|
|
|
// setup mapping from human readable indexes to internal libUI indexes
|
|
|
|
mh.Rows[row].Human[humanInt].Name = "EDIT"
|
|
|
|
mh.Rows[row].Human[humanInt].ColorID = colorID
|
|
|
|
mh.Rows[row].Human[humanInt].TextID = stringID
|
|
|
|
|
|
|
|
// text for Column humanInt
|
|
|
|
mh.Rows[row].Cells[stringID].Name = "EDIT"
|
|
|
|
mh.Rows[row].Cells[stringID].HumanID = humanInt
|
2019-05-08 17:28:40 -05:00
|
|
|
|
2019-05-12 22:25:55 -05:00
|
|
|
mh.Rows[row].Cells[colorID].Name = "COLOR"
|
|
|
|
mh.Rows[row].Cells[colorID].HumanID = humanInt
|
2019-05-08 17:28:40 -05:00
|
|
|
}
|
|
|
|
|
2019-05-12 20:05:17 -05:00
|
|
|
func initRowTextColumn(mh *TableData, row int, stringID int, junk string, cell InputData) {
|
2019-05-12 22:25:55 -05:00
|
|
|
humanInt := cell.Index
|
|
|
|
|
|
|
|
// setup mapping from human readable indexes to internal libUI indexes
|
|
|
|
mh.Rows[row].Human[humanInt].Name = "EDIT"
|
|
|
|
mh.Rows[row].Human[humanInt].ColorID = -1
|
|
|
|
mh.Rows[row].Human[humanInt].TextID = stringID
|
|
|
|
|
|
|
|
mh.Rows[row].Cells[stringID].Name = "EDIT"
|
|
|
|
mh.Rows[row].Cells[stringID].HumanID = humanInt
|
2019-05-08 17:28:40 -05:00
|
|
|
}
|
|
|
|
|
2019-05-13 01:37:27 -05:00
|
|
|
/*
|
2019-05-12 17:11:32 -05:00
|
|
|
func defaultSetCellValue(mh *TableData, m *ui.TableModel, row, column int, value ui.TableValue) {
|
|
|
|
if (mh.Rows[row].Cells[column].Name == "BUTTON") {
|
2019-05-13 01:17:48 -05:00
|
|
|
log.Println("defaultSetCellValue() FOUND THE BUTTON!!!!!!! Button was pressed START", row, column)
|
2019-05-12 17:11:32 -05:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func simpleSetCellValue(mh *TableData, row, column int, value string) {
|
|
|
|
if (mh.Rows[row].Cells[column].Name == "BUTTON") {
|
2019-05-12 22:25:55 -05:00
|
|
|
log.Println("simpleSetCellValue() FOUND THE BUTTON!!!!!!! Button was pressed:", row, column)
|
2019-05-08 15:04:18 -05:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2019-05-13 01:37:27 -05:00
|
|
|
*/
|