ui/cocoa/GridLayout.m

changeset 799
f8ff8df41713
parent 785
b943e3d618f0
child 800
814d374fb689
equal deleted inserted replaced
798:504c45926386 799:f8ff8df41713
182 int row_ext = 0; 182 int row_ext = 0;
183 183
184 int preferred_width = 0; 184 int preferred_width = 0;
185 int preferred_height = 0; 185 int preferred_height = 0;
186 for(int j=0;j<ncols;j++) { 186 for(int j=0;j<ncols;j++) {
187 preferred_width += cols[j].preferred_size + colspacing; 187 preferred_width += cols[j].preferred_size;
188 if(cols[j].expand) { 188 if(cols[j].expand) {
189 col_ext++; 189 col_ext++;
190 } 190 }
191 } 191 }
192 for(int j=0;j<nrows;j++) { 192 for(int j=0;j<nrows;j++) {
193 preferred_height += rows[j].preferred_size + rowspacing; 193 preferred_height += rows[j].preferred_size;
194 if(rows[j].expand) { 194 if(rows[j].expand) {
195 row_ext++; 195 row_ext++;
196 } 196 }
197 }
198 if(ncols > 0) {
199 preferred_width += (ncols-1) * colspacing;
200 }
201 if(nrows > 0) {
202 preferred_height += (nrows-1) * rowspacing;
197 } 203 }
198 204
199 _preferredSize.width = preferred_width; 205 _preferredSize.width = preferred_width;
200 _preferredSize.height = preferred_height; 206 _preferredSize.height = preferred_height;
201 207
290 [self layout]; 296 [self layout];
291 } 297 }
292 return self.preferredSize; 298 return self.preferredSize;
293 } 299 }
294 300
295 - (void) addView:(NSView*)view { 301 - (void) addView:(NSView*)view margin:(NSEdgeInsets)margin {
296 _preferredSize.width = -1; 302 _preferredSize.width = -1;
297 _preferredSize.height = -1; 303 _preferredSize.height = -1;
298 304
299 if(_newline) { 305 if(_newline) {
300 _y++; 306 _y++;
303 } 309 }
304 310
305 GridElm elm; 311 GridElm elm;
306 elm.x = _x; 312 elm.x = _x;
307 elm.y = _y; 313 elm.y = _y;
308 elm.margin = 0; 314 elm.margin = margin;
309 elm.colspan = _uilayout.colspan; 315 elm.colspan = _uilayout.colspan;
310 elm.rowspan = _uilayout.rowspan; 316 elm.rowspan = _uilayout.rowspan;
311 if(_uilayout.fill) { 317 if(_uilayout.fill) {
312 elm.hfill = TRUE; 318 elm.hfill = TRUE;
313 elm.vfill = TRUE; 319 elm.vfill = TRUE;

mercurial