// 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 ShowTable(pb *guipb.Table) { // make a new action and populate the current node state a := getNewAction(me.rootNode, widget.Show) makeTableWidgets(pb) 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", "pb len =", len(a.TablePB)) sendActionToPlugin(a) } func makeTableWidgets(pb *guipb.Table) { if pb == nil { log.Info("pb was nil") return } if me.rootNode == nil { log.Info("me.rootNode was nil") return } win := addNode() pb.Window = new(guipb.Widget) pb.Window.Id = int64(win.id) pb.Window.Name = pb.Title grid := addNode() pb.Grid = new(guipb.Widget) pb.Grid.Id = int64(grid.id) for i, r := range pb.StringRows { log.Info("gui: got string row:", pb.Title, i, r.Header, r.Vals) for _, v := range r.Vals { label := addNode() pbwidget := new(guipb.Widget) pbwidget.Id = int64(label.id) pbwidget.Name = v r.Widgets = append(r.Widgets, pbwidget) log.Info("gui: added new WidgetS", pbwidget) } } for i, r := range pb.IntRows { log.Info("gui: got int row:", i, r.Header, r.Vals) for _, v := range r.Vals { label := addNode() pbwidget := new(guipb.Widget) pbwidget.Id = int64(label.id) pbwidget.Size = v r.Widgets = append(r.Widgets, pbwidget) log.Info("gui: added new int", pbwidget) } } } /* 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) 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) } */