Lines 196-207
Link Here
|
196 |
return extent; |
196 |
return extent; |
197 |
} |
197 |
} |
198 |
|
198 |
|
199 |
Point computeSize (Control control, boolean flushCache) { |
199 |
Point computeSize (Control control, boolean flushCache, double totalWidthWeight, double totalHeightWeight, int containerWidth, int containerHeight) { |
200 |
int wHint = SWT.DEFAULT, hHint = SWT.DEFAULT; |
200 |
int wHint = SWT.DEFAULT, hHint = SWT.DEFAULT; |
201 |
RowData data = (RowData) control.getLayoutData (); |
201 |
RowData data = (RowData) control.getLayoutData (); |
202 |
if (data != null) { |
202 |
if (data != null) { |
203 |
wHint = data.width; |
203 |
wHint = Math.max(data.width, (data.widthWeight > 0)?(int)(data.widthWeight/totalWidthWeight*containerWidth):data.width ); |
204 |
hHint = data.height; |
204 |
hHint = Math.max(data.height, (data.heightWeight > 0)?(int)(data.heightWeight/totalHeightWeight*containerHeight):data.height); |
205 |
} |
205 |
} |
206 |
return control.computeSize (wHint, hHint, flushCache); |
206 |
return control.computeSize (wHint, hHint, flushCache); |
207 |
} |
207 |
} |
Lines 229-249
Link Here
|
229 |
Point layoutHorizontal (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) { |
229 |
Point layoutHorizontal (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) { |
230 |
Control [] children = composite.getChildren (); |
230 |
Control [] children = composite.getChildren (); |
231 |
int count = 0; |
231 |
int count = 0; |
|
|
232 |
|
233 |
Rectangle rect = composite.getClientArea (); |
234 |
int totalWidthWeight = 0; |
235 |
int totalHeightWeight = 0; |
236 |
int heightToUse=rect.height - (marginTop + marginHeight * 2 + marginBottom); |
237 |
int widthToUse=rect.width - (marginLeft + marginWidth * 2 + marginRight); |
238 |
|
232 |
for (int i=0; i<children.length; i++) { |
239 |
for (int i=0; i<children.length; i++) { |
233 |
Control control = children [i]; |
240 |
Control control = children [i]; |
234 |
RowData data = (RowData) control.getLayoutData (); |
241 |
RowData data = (RowData) control.getLayoutData (); |
235 |
if (data == null || !data.exclude) { |
242 |
if (data == null || !data.exclude) { |
236 |
children [count++] = children [i]; |
243 |
children [count++] = children [i]; |
|
|
244 |
if( data != null ) { |
245 |
totalWidthWeight += data.widthWeight; |
246 |
totalHeightWeight += data.heightWeight; |
247 |
|
248 |
if( data.height != SWT.DEFAULT && data.heightWeight == 0 ) { |
249 |
heightToUse -= data.height; |
250 |
} |
251 |
|
252 |
if( data.width != SWT.DEFAULT && data.widthWeight == 0 ) { |
253 |
widthToUse -= data.width; |
254 |
} |
255 |
} |
237 |
} |
256 |
} |
238 |
} |
257 |
} |
|
|
258 |
|
259 |
heightToUse -= spacing * count; |
260 |
widthToUse -= spacing * count; |
261 |
|
239 |
if (count == 0) { |
262 |
if (count == 0) { |
240 |
return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom); |
263 |
return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom); |
241 |
} |
264 |
} |
242 |
int childWidth = 0, childHeight = 0, maxHeight = 0; |
265 |
int childWidth = 0, childHeight = 0, maxHeight = 0; |
|
|
266 |
|
267 |
|
243 |
if (!pack) { |
268 |
if (!pack) { |
244 |
for (int i=0; i<count; i++) { |
269 |
for (int i=0; i<count; i++) { |
245 |
Control child = children [i]; |
270 |
Control child = children [i]; |
246 |
Point size = computeSize (child, flushCache); |
271 |
Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,widthToUse,heightToUse); |
247 |
childWidth = Math.max (childWidth, size.x); |
272 |
childWidth = Math.max (childWidth, size.x); |
248 |
childHeight = Math.max (childHeight, size.y); |
273 |
childHeight = Math.max (childHeight, size.y); |
249 |
} |
274 |
} |
Lines 251-257
Link Here
|
251 |
} |
276 |
} |
252 |
int clientX = 0, clientY = 0; |
277 |
int clientX = 0, clientY = 0; |
253 |
if (move) { |
278 |
if (move) { |
254 |
Rectangle rect = composite.getClientArea (); |
279 |
|
255 |
clientX = rect.x; |
280 |
clientX = rect.x; |
256 |
clientY = rect.y; |
281 |
clientY = rect.y; |
257 |
} |
282 |
} |
Lines 266-272
Link Here
|
266 |
for (int i=0; i<count; i++) { |
291 |
for (int i=0; i<count; i++) { |
267 |
Control child = children [i]; |
292 |
Control child = children [i]; |
268 |
if (pack) { |
293 |
if (pack) { |
269 |
Point size = computeSize (child, flushCache); |
294 |
Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,widthToUse,heightToUse); |
270 |
childWidth = size.x; |
295 |
childWidth = size.x; |
271 |
childHeight = size.y; |
296 |
childHeight = size.y; |
272 |
} |
297 |
} |
Lines 336-356
Link Here
|
336 |
Point layoutVertical (Composite composite, boolean move, boolean wrap, int height, boolean flushCache) { |
361 |
Point layoutVertical (Composite composite, boolean move, boolean wrap, int height, boolean flushCache) { |
337 |
Control [] children = composite.getChildren (); |
362 |
Control [] children = composite.getChildren (); |
338 |
int count = 0; |
363 |
int count = 0; |
|
|
364 |
|
365 |
Rectangle rect = composite.getClientArea (); |
366 |
int totalWidthWeight = 0; |
367 |
int totalHeightWeight = 0; |
368 |
int heightToUse=rect.height - (marginTop + marginHeight * 2 + marginBottom); |
369 |
int widthToUse=rect.width - (marginLeft + marginWidth * 2 + marginRight); |
370 |
|
339 |
for (int i=0; i<children.length; i++) { |
371 |
for (int i=0; i<children.length; i++) { |
340 |
Control control = children [i]; |
372 |
Control control = children [i]; |
341 |
RowData data = (RowData) control.getLayoutData (); |
373 |
RowData data = (RowData) control.getLayoutData (); |
342 |
if (data == null || !data.exclude) { |
374 |
if (data == null || !data.exclude) { |
343 |
children [count++] = children [i]; |
375 |
children [count++] = children [i]; |
|
|
376 |
if( data != null ) { |
377 |
totalWidthWeight += data.widthWeight; |
378 |
totalHeightWeight += data.heightWeight; |
379 |
|
380 |
if( data.height != SWT.DEFAULT && data.heightWeight == 0 ) { |
381 |
heightToUse -= data.height; |
382 |
} |
383 |
|
384 |
if( data.width != SWT.DEFAULT && data.widthWeight == 0 ) { |
385 |
widthToUse -= data.width; |
386 |
} |
387 |
} |
344 |
} |
388 |
} |
345 |
} |
389 |
} |
|
|
390 |
|
391 |
heightToUse -= spacing * count; |
392 |
widthToUse -= spacing * count; |
393 |
|
346 |
if (count == 0) { |
394 |
if (count == 0) { |
347 |
return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom); |
395 |
return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom); |
348 |
} |
396 |
} |
349 |
int childWidth = 0, childHeight = 0, maxWidth = 0; |
397 |
int childWidth = 0, childHeight = 0, maxWidth = 0; |
|
|
398 |
|
399 |
|
350 |
if (!pack) { |
400 |
if (!pack) { |
351 |
for (int i=0; i<count; i++) { |
401 |
for (int i=0; i<count; i++) { |
352 |
Control child = children [i]; |
402 |
Control child = children [i]; |
353 |
Point size = computeSize (child, flushCache); |
403 |
Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,widthToUse,heightToUse); |
354 |
childWidth = Math.max (childWidth, size.x); |
404 |
childWidth = Math.max (childWidth, size.x); |
355 |
childHeight = Math.max (childHeight, size.y); |
405 |
childHeight = Math.max (childHeight, size.y); |
356 |
} |
406 |
} |
Lines 358-364
Link Here
|
358 |
} |
408 |
} |
359 |
int clientX = 0, clientY = 0; |
409 |
int clientX = 0, clientY = 0; |
360 |
if (move) { |
410 |
if (move) { |
361 |
Rectangle rect = composite.getClientArea (); |
411 |
|
362 |
clientX = rect.x; |
412 |
clientX = rect.x; |
363 |
clientY = rect.y; |
413 |
clientY = rect.y; |
364 |
} |
414 |
} |
Lines 373-379
Link Here
|
373 |
for (int i=0; i<count; i++) { |
423 |
for (int i=0; i<count; i++) { |
374 |
Control child = children [i]; |
424 |
Control child = children [i]; |
375 |
if (pack) { |
425 |
if (pack) { |
376 |
Point size = computeSize (child, flushCache); |
426 |
Point size = computeSize (child, flushCache,totalWidthWeight,totalHeightWeight,widthToUse,heightToUse); |
377 |
childWidth = size.x; |
427 |
childWidth = size.x; |
378 |
childHeight = size.y; |
428 |
childHeight = size.y; |
379 |
} |
429 |
} |