| 291 } |
290 } |
| 292 frame.size.height = row->size; |
291 frame.size.height = row->size; |
| 293 } else { |
292 } else { |
| 294 frame.size.height = elm->preferred_height; |
293 frame.size.height = elm->preferred_height; |
| 295 } |
294 } |
| |
295 frame.size.height -= elm->margin.top + elm->margin.bottom; |
| 296 |
296 |
| 297 frame.origin.x = col->pos + elm->margin.left; |
297 frame.origin.x = col->pos + elm->margin.left; |
| 298 frame.origin.y = row->pos + elm->margin.top; |
298 frame.origin.y = row->pos + elm->margin.top; |
| 299 NSRect viewFrame = [elm->view frameForAlignmentRect:frame]; |
299 NSRect viewFrame = [elm->view frameForAlignmentRect:frame]; |
| 300 elm->view.frame = viewFrame; |
300 elm->view.frame = viewFrame; |
| 310 [self layout]; |
310 [self layout]; |
| 311 } |
311 } |
| 312 return self.preferredSize; |
312 return self.preferredSize; |
| 313 } |
313 } |
| 314 |
314 |
| 315 - (void) addView:(NSView*)view margin:(NSEdgeInsets)margin { |
315 - (void) addView:(NSView*)view layout:(UiLayout*)layout { |
| 316 _preferredSize.width = -1; |
316 _preferredSize.width = -1; |
| 317 _preferredSize.height = -1; |
317 _preferredSize.height = -1; |
| 318 |
318 |
| 319 if(self.container->newline) { |
319 if(self.container->newline) { |
| 320 _y++; |
320 _y++; |
| 323 } |
323 } |
| 324 |
324 |
| 325 GridElm elm; |
325 GridElm elm; |
| 326 elm.x = _x; |
326 elm.x = _x; |
| 327 elm.y = _y; |
327 elm.y = _y; |
| 328 elm.margin = margin; |
328 elm.margin = NSEdgeInsetsMake(layout->margin_top, layout->margin_left, layout->margin_bottom, layout->margin_right); |
| 329 elm.colspan = _uilayout.colspan; |
329 elm.colspan = layout->colspan; |
| 330 elm.rowspan = _uilayout.rowspan; |
330 elm.rowspan = layout->rowspan; |
| 331 if(_uilayout.fill) { |
331 if(layout->fill) { |
| 332 elm.hfill = TRUE; |
332 elm.hfill = TRUE; |
| 333 elm.vfill = TRUE; |
333 elm.vfill = TRUE; |
| 334 elm.hexpand = TRUE; |
334 elm.hexpand = TRUE; |
| 335 elm.vexpand = TRUE; |
335 elm.vexpand = TRUE; |
| 336 } else { |
336 } else { |
| 337 elm.hfill = _uilayout.hfill; |
337 elm.hfill = layout->hfill; |
| 338 elm.vfill = _uilayout.vfill; |
338 elm.vfill = layout->vfill; |
| 339 elm.hexpand = _uilayout.hexpand; |
339 elm.hexpand = layout->hexpand; |
| 340 elm.vexpand = _uilayout.vexpand; |
340 elm.vexpand = layout->vexpand; |
| 341 } |
341 } |
| 342 elm.view = view; |
342 elm.view = view; |
| 343 cxListAdd(_children, &elm); |
343 cxListAdd(_children, &elm); |
| 344 |
344 |
| 345 [self addSubview:view]; |
345 [self addSubview:view]; |