(widget Widget, r Rectangle)
| 212 | } |
| 213 | |
| 214 | func (l *GridLayout) SetRange(widget Widget, r Rectangle) error { |
| 215 | if widget == nil { |
| 216 | return newError("widget required") |
| 217 | } |
| 218 | if l.container == nil { |
| 219 | return newError("container required") |
| 220 | } |
| 221 | if !l.container.Children().containsHandle(widget.Handle()) { |
| 222 | return newError("widget must be child of container") |
| 223 | } |
| 224 | if r.X < 0 || r.Y < 0 { |
| 225 | return newError("range.X and range.Y must be >= 0") |
| 226 | } |
| 227 | if r.Width < 1 || r.Height < 1 { |
| 228 | return newError("range.Width and range.Height must be >= 1") |
| 229 | } |
| 230 | |
| 231 | wb := widget.AsWidgetBase() |
| 232 | |
| 233 | info := l.widgetBase2Info[wb] |
| 234 | if info == nil { |
| 235 | info = new(gridLayoutWidgetInfo) |
| 236 | } else { |
| 237 | l.setWidgetOnCells(nil, rangeFromGridLayoutWidgetInfo(info)) |
| 238 | } |
| 239 | |
| 240 | l.ensureSufficientSize(r.Y+r.Height, r.X+r.Width) |
| 241 | |
| 242 | cell := &l.cells[r.Y][r.X] |
| 243 | cell.row = r.Y |
| 244 | cell.column = r.X |
| 245 | |
| 246 | if info.cell == nil { |
| 247 | // We have to do this _after_ calling ensureSufficientSize(). |
| 248 | l.widgetBase2Info[wb] = info |
| 249 | } |
| 250 | |
| 251 | info.cell = cell |
| 252 | info.spanHorz = r.Width |
| 253 | info.spanVert = r.Height |
| 254 | |
| 255 | l.setWidgetOnCells(widget, r) |
| 256 | |
| 257 | return nil |
| 258 | } |
| 259 | |
| 260 | func (l *GridLayout) CreateLayoutItem(ctx *LayoutContext) ContainerLayoutItem { |
| 261 | wb2Item := make(map[*WidgetBase]LayoutItem) |
nothing calls this directly
no test coverage detected