diff -r 7abd3a234296 -r 3ffa271732f7 PanelView.st --- a/PanelView.st Mon May 08 17:19:27 1995 +0200 +++ b/PanelView.st Tue May 09 03:57:16 1995 +0200 @@ -10,18 +10,21 @@ hereby transferred. " +'From Smalltalk/X, Version:2.10.5 on 9-may-1995 at 12:05:18 pm'! + SimpleView subclass:#PanelView - instanceVariableNames:'hLayout vLayout verticalSpace horizontalSpace mustRearrange' - classVariableNames:'' - poolDictionaries:'' - category:'Views-Layout' + instanceVariableNames:'hLayout vLayout verticalSpace horizontalSpace mustRearrange + elementsChangeSize' + classVariableNames:'' + poolDictionaries:'' + category:'Views-Layout' ! PanelView comment:' COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.8 1995-05-03 00:36:46 claus Exp $ +$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.9 1995-05-09 01:56:22 claus Exp $ '! !PanelView class methodsFor:'documentation'! @@ -42,7 +45,7 @@ version " -$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.8 1995-05-03 00:36:46 claus Exp $ +$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.9 1995-05-09 01:56:22 claus Exp $ " ! @@ -84,95 +87,13 @@ defaults to ViewSpacing, which is 1mm mustRearrange internal flag, if rearrangement is needed + + elementsChangeSize + if true, the panel takes care of this situation. + By default, this is false. " ! ! -!PanelView methodsFor:'initialization'! - -initialize - super initialize. - - hLayout := vLayout := #center. "/ notice, this is ignored in this class - verticalSpace := ViewSpacing. - horizontalSpace := ViewSpacing. - mustRearrange := false -! - -realize - mustRearrange ifTrue:[ - self setChildPositions - ]. - super realize -! - -setChildPositionsIfChanged - "set all of my child positions - this is usually delayed, - until the panel is actually shown (since we dont know, if more - elements are to be added) thus avoiding repositioning the elements - over and over. However, sometimes it is nescessary, to force positioning - the elements, for example, before querying the relative position of - an element (modalBoxes do so, to position the ok-button under the mouse - pointer)." - - mustRearrange ifTrue:[ - self setChildPositions - ]. - -! ! - -!PanelView methodsFor:'accessing'! - -verticalSpace:numberOfPixels - "set the vertical space between elements (in pixels). - The default is computed for 1mm spacing." - - verticalSpace ~= numberOfPixels ifTrue:[ - verticalSpace := numberOfPixels. - self layoutChanged - ] -! - -horizontalSpace:numberOfPixels - "set the horizontal space between elements on pixels (default is 1mm)" - - horizontalSpace ~= numberOfPixels ifTrue:[ - horizontalSpace := numberOfPixels. - self layoutChanged - ] -! - -space:numberOfPixels - "set the space between elements in pixels (default is 1mm) for both directions" - - (verticalSpace ~= numberOfPixels - or:[horizontalSpace ~= numberOfPixels]) ifTrue:[ - horizontalSpace := numberOfPixels. - verticalSpace := numberOfPixels. - self layoutChanged - ] -! - -addSubView:aView - "redefined to recompute layout when a subview is added" - - super addSubView:aView. - self layoutChanged -! - -addSubView:newView after:aView - "redefined to recompute layout when a subview is added" - - super addSubView:newView after:aView. - self layoutChanged -! - -addSubView:newView before:aView - "redefined to recompute layout when a subview is added" - - super addSubView:newView before:aView. - self layoutChanged -! ! - !PanelView methodsFor:'event processing'! sizeChanged:how @@ -180,6 +101,19 @@ super sizeChanged:how. self layoutChanged +! + +update:something with:aParameter from:changedObject + something == #sizeOfView ifTrue:[ + " + an element changed its size + " + (subViews includes:changedObject) ifTrue:[ + self layoutChanged + ]. + ^ self + ]. + ^ super update:something with:aParameter from:changedObject ! ! !PanelView methodsFor:'private'! @@ -197,6 +131,15 @@ ] ! +addedView:aView + "added a new element" + + elementsChangeSize ifTrue:[ + aView addDependent:self + ]. + self layoutChanged +! + setChildPositions "(re)compute position of every child. This method is redefined for different layout characteristics - you may @@ -247,3 +190,107 @@ ]. mustRearrange := false ! ! + +!PanelView methodsFor:'initialization'! + +initialize + super initialize. + + hLayout := vLayout := #center. "/ notice, this is ignored in this class + "/ used by subclasses only + verticalSpace := ViewSpacing. + horizontalSpace := ViewSpacing. + mustRearrange := elementsChangeSize := false +! + +realize + mustRearrange ifTrue:[ + self setChildPositions + ]. + super realize +! + +setChildPositionsIfChanged + "set all of my child positions - this is usually delayed, + until the panel is actually shown (since we dont know, if more + elements are to be added) thus avoiding repositioning the elements + over and over. However, sometimes it is nescessary, to force positioning + the elements, for example, before querying the relative position of + an element (modalBoxes do so, to position the ok-button under the mouse + pointer)." + + mustRearrange ifTrue:[ + self setChildPositions + ]. + +! ! + +!PanelView methodsFor:'accessing'! + +addSubView:aView + "redefined to recompute layout when a subview is added" + + super addSubView:aView. + self addedView:aView +! + +addSubView:newView after:aView + "redefined to recompute layout when a subview is added" + + super addSubView:newView after:aView. + self addedView:aView +! + +elementsChangeSize:aBoolean + "tell the panel if elements are to change their size by themselfes + (for example, Lables or Buttons may do so if their contents changes). + Setting this flag will make the panel reorganize the elements whenever + any element changes its size." + + elementsChangeSize := aBoolean. + aBoolean ifTrue:[ + subViews notNil ifTrue:[ + subViews do:[:aView | + aView addDependent:self + ] + ] + ] +! + +addSubView:newView before:aView + "redefined to recompute layout when a subview is added" + + super addSubView:newView before:aView. + self addedView:aView +! + +verticalSpace:numberOfPixels + "set the vertical space between elements (in pixels). + The default is computed for 1mm spacing." + + verticalSpace ~= numberOfPixels ifTrue:[ + verticalSpace := numberOfPixels. + self layoutChanged + ] +! + +horizontalSpace:numberOfPixels + "set the horizontal space between elements on pixels (default is 1mm)" + + horizontalSpace ~= numberOfPixels ifTrue:[ + horizontalSpace := numberOfPixels. + self layoutChanged + ] +! + +space:numberOfPixels + "set the space between elements in pixels (default is 1mm) for both directions" + + (verticalSpace ~= numberOfPixels + or:[horizontalSpace ~= numberOfPixels]) ifTrue:[ + horizontalSpace := numberOfPixels. + verticalSpace := numberOfPixels. + self layoutChanged + ] +! ! +