ui/cocoa/GridLayout.m

changeset 846
ffa983c223c1
parent 811
1391ba7e533f
child 851
367b2bbbc07e
equal deleted inserted replaced
845:f3ab28ed22e5 846:ffa983c223c1
30 30
31 31
32 32
33 @implementation GridLayout 33 @implementation GridLayout
34 34
35 @synthesize uilayout=_uilayout; 35 @synthesize container = _container;
36 @synthesize container=_container;
37 36
38 - (GridLayout*)init { 37 - (GridLayout*)init {
39 self = [super init]; 38 self = [super init];
40 _columnspacing = 0; 39 _columnspacing = 0;
41 _rowspacing = 0; 40 _rowspacing = 0;
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];

mercurial