BuildLayout builds and returns a GridLayout with the specified attributes
(b *Builder, am map[string]interface{})
| 113 | |
| 114 | // BuildLayout builds and returns a GridLayout with the specified attributes |
| 115 | func (bl *BuilderLayoutGrid) BuildLayout(b *Builder, am map[string]interface{}) (ILayout, error) { |
| 116 | |
| 117 | // Get number of columns |
| 118 | v := am[AttribCols] |
| 119 | if v == nil { |
| 120 | return nil, b.err(am, AttribCols, "Number of columns must be supplied") |
| 121 | } |
| 122 | cols := v.(int) |
| 123 | if cols <= 0 { |
| 124 | return nil, b.err(am, AttribCols, "Invalid number of columns") |
| 125 | } |
| 126 | |
| 127 | // Creates layout |
| 128 | l := NewGridLayout(cols) |
| 129 | |
| 130 | // Sets optional horizontal alignment |
| 131 | if ah := am[AttribAlignh]; ah != nil { |
| 132 | l.SetAlignH(ah.(Align)) |
| 133 | } |
| 134 | |
| 135 | // Sets optional vertical alignment |
| 136 | if av := am[AttribAlignv]; av != nil { |
| 137 | l.SetAlignV(av.(Align)) |
| 138 | } |
| 139 | |
| 140 | // Sets optional horizontal expand flag |
| 141 | if eh := am[AttribExpandh]; eh != nil { |
| 142 | l.SetExpandH(eh.(bool)) |
| 143 | } |
| 144 | |
| 145 | // Sets optional vertical expand flag |
| 146 | if ev := am[AttribExpandv]; ev != nil { |
| 147 | l.SetExpandV(ev.(bool)) |
| 148 | } |
| 149 | |
| 150 | return l, nil |
| 151 | } |
| 152 | |
| 153 | // BuildParams builds and returns a pointer to GridLayoutParams with the specified attributes |
| 154 | func (bl *BuilderLayoutGrid) BuildParams(b *Builder, am map[string]interface{}) (interface{}, error) { |
nothing calls this directly
no test coverage detected