summaryrefslogtreecommitdiff
path: root/table.go
blob: 35d64c945b9ee9a05a98bd0b6c1679d2986c6650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// a table is a grid with X columns and 1 row of header names
// that means that the toolkits might be able to sort the table
// pushing traditional application development to the display
// is that a good idea?

package gui

import (
	"go.wit.com/lib/protobuf/guipb"
	"go.wit.com/log"
	"go.wit.com/widget"
)

// should this be a gadget or in here with the widget primatives?
// a table is a group of widgets. Then again, Grid & Box 'widgets' are
// really groups of widgets also

/*
mytable := NewTable(5) // make a table with 5 things

type mytable struct {
	first TableRow(1, Widget.TextBox, "First Name")
	song	TableRow(2, Widget.Label, "Favorite Song")

func (t *Table) NewRow() *TableRow {
	r := new(myRow)
	r.first =
	r.Cell1 = whatever widget type first is
	r.Cell2 = whatever widget type song is


type songTable TableDef {
	first TableCell `default:string`
	song TableCell
	GuiPlugin  string `arg:"Label" header:"Favorite Song"`
}

func makeSongTable() {
	tb := NewTable(5)

func Show() {
	for each row {
		for loop all strings()
		is string button?
		for loop all ints()
		for loop all times()
		for loop all bools()

	}s

func RefreshTime(t *time.Duration) {
}
*/

func NewTable(title string) *NodeTable {
	t := new(NodeTable)
	/*
		t.pb = new(guipb.Table)
		t.pb.Title = title
	*/
	t.n = me.rootNode.newNode(title, widget.Table)
	t.n.label = title

	return t
}

type NodeColumn struct {
	Title string
	Vals  []string
}

type NodeTable struct {
	n *Node
	// pb *guipb.Table
}

func (t *NodeTable) ShowTable(pb *guipb.Table) {
	log.Info("gui.ShowTable")
	// make a new action and populate the current node state
	a := getNewAction(t.n, widget.Show)
	/*
		if t.pb == nil {
			log.Info("error: TablePB == nil")
			return
		}
	*/
	nt := guipb.NewTables()
	nt.Append(pb)
	a.TablePB, err = nt.Marshal()
	if err != nil {
		log.Info("unmarshal error", err)
		return
	}
	log.Info("send action to plugin", t.n.label, "pb len =", len(a.TablePB))
	sendActionToPlugin(a)

	/*
		newNode := parent.newNode(name, widget.Button)
		newNode.Custom = custom
		newNode.label = name
		newNode.progname = name

		// inform the toolkits
		sendAction(newNode, widget.Add)
	*/
	// return newNode
}