PanelView.st
changeset 3861 53d5745e238b
parent 3843 1cc743b63926
child 3863 eceb130bb92b
equal deleted inserted replaced
3860:e62632c19c83 3861:53d5745e238b
   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."
   563 ! !
   616 ! !
   564 
   617 
   565 !PanelView class methodsFor:'documentation'!
   618 !PanelView class methodsFor:'documentation'!
   566 
   619 
   567 version
   620 version
   568     ^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.41 2009-02-26 16:48:59 fm Exp $'
   621     ^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.42 2009-03-24 15:35:41 stefan Exp $'
   569 ! !
   622 ! !