buildButton builds a gui object of type: Button
(b *Builder, am map[string]interface{})
| 167 | |
| 168 | // buildButton builds a gui object of type: Button |
| 169 | func buildButton(b *Builder, am map[string]interface{}) (IPanel, error) { |
| 170 | |
| 171 | // Builds button and set commont attributes |
| 172 | var text string |
| 173 | if am[AttribText] != nil { |
| 174 | text = am[AttribText].(string) |
| 175 | } |
| 176 | button := NewButton(text) |
| 177 | err := b.SetAttribs(am, button) |
| 178 | if err != nil { |
| 179 | return nil, err |
| 180 | } |
| 181 | |
| 182 | // Sets optional icon(s) |
| 183 | if icon := am[AttribIcon]; icon != nil { |
| 184 | button.SetIcon(icon.(string)) |
| 185 | } |
| 186 | |
| 187 | // Sets optional image from file |
| 188 | // If path is not absolute join with user supplied image base path |
| 189 | if imgf := am[AttribImageFile]; imgf != nil { |
| 190 | path := imgf.(string) |
| 191 | if !filepath.IsAbs(path) { |
| 192 | path = filepath.Join(b.imgpath, path) |
| 193 | } |
| 194 | err := button.SetImage(path) |
| 195 | if err != nil { |
| 196 | return nil, err |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | return button, nil |
| 201 | } |
| 202 | |
| 203 | // buildEdit builds a gui object of type: "Edit" |
| 204 | func buildEdit(b *Builder, am map[string]interface{}) (IPanel, error) { |
nothing calls this directly
no test coverage detected