--- a/PanelView.st Mon Mar 23 16:18:40 2009 +0100
+++ b/PanelView.st Tue Mar 24 16:35:41 2009 +0100
@@ -442,6 +442,59 @@
!PanelView methodsFor:'layout'!
+preferredExtent
+ "return a good extent, one that makes subviews fit.
+ Note that width is considered as given, and compute height here."
+
+ |subViews xpos totalHeight maxHeightInRow first|
+
+ "/ If I have an explicit preferredExtent..
+ explicitExtent notNil ifTrue:[
+ ^ explicitExtent
+ ].
+
+ "/ If I have a cached preferredExtent value..
+ preferredExtent notNil ifTrue:[
+ ^ preferredExtent
+ ].
+
+ subViews := self subViewsToConsider.
+ subViews isEmptyOrNil ifTrue:[
+ ^ super preferredExtent.
+ ].
+
+ xpos := horizontalSpace.
+
+ totalHeight := 0.
+ maxHeightInRow := 0.
+ first := true.
+
+ subViews do:[:eachChild | |childPreferredExtent|
+ childPreferredExtent := eachChild preferredExtent.
+
+ "go to next row, if this subview won't fit"
+ first ifFalse: [
+ (xpos + childPreferredExtent x + horizontalSpace) > width
+ ifTrue: [
+ xpos := horizontalSpace.
+ totalHeight := totalHeight + maxHeightInRow + verticalSpace.
+ maxHeightInRow := 0.
+ ]
+ ].
+
+ xpos := xpos + (childPreferredExtent x) + horizontalSpace.
+ (maxHeightInRow < (childPreferredExtent y)) ifTrue:[
+ maxHeightInRow := childPreferredExtent y.
+ ].
+ first := false
+ ].
+ maxHeightInRow ~= 0 ifTrue:[
+ totalHeight := totalHeight + maxHeightInRow + verticalSpace.
+ ].
+
+ ^ width @ totalHeight
+!
+
setChildPositions
"(re)compute position of every child.
This method is redefined for different layout characteristics - you may
@@ -565,5 +618,5 @@
!PanelView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.41 2009-02-26 16:48:59 fm Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.42 2009-03-24 15:35:41 stefan Exp $'
! !