439 ]. |
439 ]. |
440 |
440 |
441 ! ! |
441 ! ! |
442 |
442 |
443 !PanelView methodsFor:'layout'! |
443 !PanelView methodsFor:'layout'! |
|
444 |
|
445 preferredExtent |
|
446 "return a good extent, one that makes subviews fit. |
|
447 Note that width is considered as given, and compute height here." |
|
448 |
|
449 |subViews xpos totalHeight maxHeightInRow first| |
|
450 |
|
451 "/ If I have an explicit preferredExtent.. |
|
452 explicitExtent notNil ifTrue:[ |
|
453 ^ explicitExtent |
|
454 ]. |
|
455 |
|
456 "/ If I have a cached preferredExtent value.. |
|
457 preferredExtent notNil ifTrue:[ |
|
458 ^ preferredExtent |
|
459 ]. |
|
460 |
|
461 subViews := self subViewsToConsider. |
|
462 subViews isEmptyOrNil ifTrue:[ |
|
463 ^ super preferredExtent. |
|
464 ]. |
|
465 |
|
466 xpos := horizontalSpace. |
|
467 |
|
468 totalHeight := 0. |
|
469 maxHeightInRow := 0. |
|
470 first := true. |
|
471 |
|
472 subViews do:[:eachChild | |childPreferredExtent| |
|
473 childPreferredExtent := eachChild preferredExtent. |
|
474 |
|
475 "go to next row, if this subview won't fit" |
|
476 first ifFalse: [ |
|
477 (xpos + childPreferredExtent x + horizontalSpace) > width |
|
478 ifTrue: [ |
|
479 xpos := horizontalSpace. |
|
480 totalHeight := totalHeight + maxHeightInRow + verticalSpace. |
|
481 maxHeightInRow := 0. |
|
482 ] |
|
483 ]. |
|
484 |
|
485 xpos := xpos + (childPreferredExtent x) + horizontalSpace. |
|
486 (maxHeightInRow < (childPreferredExtent y)) ifTrue:[ |
|
487 maxHeightInRow := childPreferredExtent y. |
|
488 ]. |
|
489 first := false |
|
490 ]. |
|
491 maxHeightInRow ~= 0 ifTrue:[ |
|
492 totalHeight := totalHeight + maxHeightInRow + verticalSpace. |
|
493 ]. |
|
494 |
|
495 ^ width @ totalHeight |
|
496 ! |
444 |
497 |
445 setChildPositions |
498 setChildPositions |
446 "(re)compute position of every child. |
499 "(re)compute position of every child. |
447 This method is redefined for different layout characteristics - you may |
500 This method is redefined for different layout characteristics - you may |
448 even create subclasses with completely different geometry management." |
501 even create subclasses with completely different geometry management." |