--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GridBagConstraints.st Tue Feb 03 19:13:26 1998 +0100
@@ -0,0 +1,503 @@
+Object subclass:#GridBagConstraints
+ instanceVariableNames:'insets gridX gridY gridWidth gridHeight weightX weightY anchor
+ fill ipadX ipadY tempX tempY tempWidth tempHeight minWidth
+ minHeight'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Support'
+!
+
+!GridBagConstraints class methodsFor:'documentation'!
+
+documentation
+"
+ The GridBagConstraints class holds the constraints for each child under control of the layouter
+ GridBagLayoutView. In addition to just be a placeholder for the constraints and some
+ temporary information during the layout process, the GridBagConstraints class also supports
+ the decoding and encoding its instance information from and into a literal array. This is
+ necessary in order to be used as a winSpec element.
+
+ For the valid values of each public instance variable see the documentation of the GridBagLayoutView.
+
+ [see also:]
+ GridBagLayoutView
+
+ [author:]
+ Andreas Vogel
+"
+!
+
+history
+ "Created: / 19.1.1998 / 13:31:29 / av"
+! !
+
+!GridBagConstraints class methodsFor:'instance creation'!
+
+new
+ "Create an initialized instance of myself."
+
+ ^ super new initialize
+
+ "Created: / 19.1.1998 / 13:37:27 / av"
+ "Modified: / 1.2.1998 / 13:09:17 / av"
+! !
+
+!GridBagConstraints methodsFor:'accessing'!
+
+anchor
+ "return the value of the instance variable 'anchor' (automatically generated)"
+
+ ^ anchor
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+anchor:something
+ "set the value of the instance variable 'anchor' (automatically generated)"
+
+ anchor := something.
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+fill
+ "return the value of the instance variable 'fill' (automatically generated)"
+
+ ^ fill
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+fill:something
+ "set the value of the instance variable 'fill' (automatically generated)"
+
+ fill := something.
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+gridHeight
+ "return the value of the instance variable 'gridHeight' (automatically generated)"
+
+ ^ gridHeight
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+gridHeight:something
+ "set the value of the instance variable 'gridHeight'"
+
+ | val |
+
+ ((val := something) == #REMAINDER)
+ ifTrue: [ val := 0. ]
+ ifFalse:[ (val == #RELATIVE) ifTrue:[ val := -1. ]].
+
+ gridHeight := val.
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+ "Modified: / 20.1.1998 / 22:10:17 / av"
+!
+
+gridWidth
+ "return the value of the instance variable 'gridWidth' (automatically generated)"
+
+ ^ gridWidth
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+gridWidth:something
+ "set the value of the instance variable 'gridWidth'"
+
+ | val |
+
+ ((val := something) == #REMAINDER)
+ ifTrue: [ val := 0. ]
+ ifFalse:[ (val == #RELATIVE) ifTrue:[ val := -1. ]].
+
+ gridWidth := val.
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+ "Modified: / 20.1.1998 / 22:08:53 / av"
+!
+
+gridX
+ "return the value of the instance variable 'gridX' (automatically generated)"
+
+ ^ gridX
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+gridX:something
+ "set the value of the instance variable 'gridX'"
+
+ (something == #RELATIVE) ifTrue:[ gridX := -1. ] ifFalse:[ gridX := something. ].
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+ "Modified: / 20.1.1998 / 22:12:40 / av"
+!
+
+gridY
+ "return the value of the instance variable 'gridY' (automatically generated)"
+
+ ^ gridY
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+gridY:something
+ "set the value of the instance variable 'gridY'"
+
+ (something == #RELATIVE) ifTrue:[ gridY := -1. ] ifFalse:[ gridY := something. ].
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+ "Modified: / 20.1.1998 / 22:45:48 / av"
+!
+
+insets
+ "return the value of the instance variable 'insets' (automatically generated)"
+
+ ^ insets
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+insets:something
+ "set the value of the instance variable 'insets' (automatically generated)"
+
+ insets := something.
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+ipadX
+ "return the value of the instance variable 'ipadX' (automatically generated)"
+
+ ^ ipadX
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+ipadX:something
+ "set the value of the instance variable 'ipadX' (automatically generated)"
+
+ ipadX := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+ipadY
+ "return the value of the instance variable 'ipadY' (automatically generated)"
+
+ ^ ipadY
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+ipadY:something
+ "set the value of the instance variable 'ipadY' (automatically generated)"
+
+ ipadY := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+minHeight
+ "return the value of the instance variable 'minHeight' (automatically generated)"
+
+ ^ minHeight
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+minHeight:something
+ "set the value of the instance variable 'minHeight' (automatically generated)"
+
+ minHeight := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+minWidth
+ "return the value of the instance variable 'minWidth' (automatically generated)"
+
+ ^ minWidth
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+minWidth:something
+ "set the value of the instance variable 'minWidth' (automatically generated)"
+
+ minWidth := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempHeight
+ "return the value of the instance variable 'tempHeight' (automatically generated)"
+
+ ^ tempHeight
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempHeight:something
+ "set the value of the instance variable 'tempHeight' (automatically generated)"
+
+ tempHeight := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempWidth
+ "return the value of the instance variable 'tempWidth' (automatically generated)"
+
+ ^ tempWidth
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempWidth:something
+ "set the value of the instance variable 'tempWidth' (automatically generated)"
+
+ tempWidth := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempX
+ "return the value of the instance variable 'tempX' (automatically generated)"
+
+ ^ tempX
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempX:something
+ "set the value of the instance variable 'tempX' (automatically generated)"
+
+ tempX := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempY
+ "return the value of the instance variable 'tempY' (automatically generated)"
+
+ ^ tempY
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+tempY:something
+ "set the value of the instance variable 'tempY' (automatically generated)"
+
+ tempY := something.
+
+ "Created: / 19.1.1998 / 19:58:21 / av"
+!
+
+weightX
+ "return the value of the instance variable 'weightX' (automatically generated)"
+
+ ^ weightX
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+weightX:something
+ "set the value of the instance variable 'weightX' (automatically generated)"
+
+ weightX := something.
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+weightY
+ "return the value of the instance variable 'weightY' (automatically generated)"
+
+ ^ weightY
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+!
+
+weightY:something
+ "set the value of the instance variable 'weightY' (automatically generated)"
+
+ weightY := something.
+
+ "Created: / 19.1.1998 / 19:58:20 / av"
+! !
+
+!GridBagConstraints methodsFor:'converting'!
+
+fromLiteralArrayEncoding:encoding
+ "Read my values from an encoding. The encoding is supposed to be of the form:
+ (GridBagConstraints
+ insets: (Insets left: 1 right: 1 top: 1 bottom: 1)
+ gridX: 1 gridY: 1 gridWidth: 1 gridHeight: 1
+ weightX: 1.0 weightY: 1.0 ipadX: 1 ipadY: 1 anchor: #CENTER fill: #BOTH
+ )
+ This is the reverse to literalArrayEncoding."
+
+ | stop sel |
+
+ self initialize.
+ insets := nil.
+ stop := encoding size.
+
+ 2 to:stop by:2 do:[ :i |
+ sel := encoding at:i.
+ (self respondsTo:sel) ifTrue:[
+ self perform:sel with:(encoding at:i+1)
+ ]
+ ].
+
+ insets notNil
+ ifTrue: [ insets := insets decodeAsLiteralArray ]
+ ifFalse: [ insets := Insets new ].
+
+ "
+ GridBagConstraints new fromLiteralArrayEncoding:#(GridBagConstraints
+ insets: #(Insets 96 97 98 99)
+ gridX: 101
+ )
+
+ #(#GridBagConstraints anchor: #CENTER fill: #BOTH) decodeAsLiteralArray
+ "
+
+ "Created: / 21.1.1998 / 20:10:26 / av"
+ "Modified: / 1.2.1998 / 13:14:03 / av"
+!
+
+fromLiteralArrayEncodingOld:encoding
+ "Read my values from an encoding. This is the reverse to literalArrayEncoding."
+
+ insets := encoding at:2.
+ gridX := encoding at:3.
+ gridY := encoding at:4.
+ gridWidth := encoding at:5.
+ gridHeight := encoding at:6.
+ weightX := encoding at:7.
+ weightY := encoding at:8.
+ ipadX := encoding at:9.
+ ipadY := encoding at:10.
+ anchor := encoding at:11.
+ fill := encoding at:12.
+
+ insets notNil ifTrue:[ insets := insets decodeAsLiteralArray ].
+
+ "
+ GridBagConstraints new fromLiteralArrayEncoding:#(#GridBagConstraints
+ #(Insets 50 60 70 80) 10 20 30 40 50.0 60.0 70 80 #CENTER #BOTH )
+
+ #(#GridBagConstraints
+ #(Insets 50 60 70 80) 10 20 30 40 50.0 60.0 70 80 #CENTER #BOTH ) decodeAsLiteralArray
+ "
+
+ "Created: / 21.1.1998 / 20:08:15 / av"
+ "Modified: / 1.2.1998 / 13:14:13 / av"
+!
+
+literalArrayEncoding
+ "Encode myself as an array, from which a copy of the receiver can be
+ reconstructed with #decodeAsLiteralArray."
+
+ | coll |
+
+ coll := OrderedCollection new.
+
+ coll add:#GridBagConstraints.
+ coll add:#'insets:' ; add:(insets literalArrayEncoding).
+ coll add:#'gridX:' ; add:gridX.
+ coll add:#'gridY:' ; add:gridY.
+ coll add:#'gridWidth:' ; add:gridWidth.
+ coll add:#'gridHeight:' ; add:gridHeight.
+ coll add:#'weightX:' ; add:weightX.
+ coll add:#'weightY:' ; add:weightY.
+ coll add:#'ipadX:' ; add:ipadX.
+ coll add:#'ipadY:' ; add:ipadY.
+ coll add:#'anchor:' ; add:anchor.
+ coll add:#'fill:' ; add:fill.
+
+ ^ coll asArray
+
+ "
+ GridBagConstraints new literalArrayEncoding
+ "
+
+ "Created: / 21.1.1998 / 20:13:48 / av"
+ "Modified: / 1.2.1998 / 13:14:56 / av"
+!
+
+literalArrayEncodingOld
+ "Encode myself as an array, from which a copy of the receiver can be
+ reconstructed with #decodeAsLiteralArray.
+ The encoding is:
+ (GridBagConstraints
+ #( Insets left right top bottom )
+ gridX gridY gridWidth gridHeight weightX weightY ipadX ipadY anchor fill
+ )
+ "
+
+ | coll |
+
+ coll := OrderedCollection new.
+
+ coll add: #GridBagConstraints.
+ coll add: (insets literalArrayEncoding).
+ coll add: gridX.
+ coll add: gridY.
+ coll add: gridWidth.
+ coll add: gridHeight.
+ coll add: weightX.
+ coll add: weightY.
+ coll add: ipadX.
+ coll add: ipadY.
+ coll add: anchor.
+ coll add: fill.
+
+ ^ coll asArray
+
+ "
+ GridBagConstraints new literalArrayEncoding
+ "
+
+ "Created: / 21.1.1998 / 20:13:33 / av"
+ "Modified: / 1.2.1998 / 13:14:49 / av"
+! !
+
+!GridBagConstraints methodsFor:'private'!
+
+initialize
+ "Set all non-temporary instance variables to default values.
+ Warning: no application should depend on this default settings and should always initilize
+ the constraints themselves."
+
+ gridX := -1.
+ gridY := -1.
+ gridWidth := 1.
+ gridHeight := 1.
+
+ weightX := 0.
+ weightY := 0.
+
+ anchor := #CENTER.
+ fill := #NONE.
+
+ ipadX := 0.
+ ipadY := 0.
+
+ insets := Insets new.
+
+ "Modified: / 1.2.1998 / 13:18:01 / av"
+! !
+
+!GridBagConstraints class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libwidg2/GridBagConstraints.st,v 1.1 1998-02-03 18:13:21 cg Exp $'
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GridBagLayoutInfo.st Tue Feb 03 19:13:26 1998 +0100
@@ -0,0 +1,185 @@
+Object subclass:#GridBagLayoutInfo
+ instanceVariableNames:'width height startX startY minWidth minHeight weightX weightY'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Support'
+!
+
+!GridBagLayoutInfo class methodsFor:'documentation'!
+
+documentation
+"
+ This is a helper class for the GridBagLayoutView and not usable for general purposes.
+
+ Instance variables:
+
+ int width, height number of cells horizontally, vertically
+ int startx, starty starting point for layout
+ int minWidth[] largest minWidth in each column
+ int minHeight[] largest minHeight in each row
+ double weightX[] largest weight in each column
+ double weightY[] largest weight in each row
+
+ [see also:]
+ GridBagLayoutView
+
+ [author:]
+ Andreas Vogel
+"
+!
+
+history
+ "Created: / 17.1.1998 / 14:26:04 / av"
+! !
+
+!GridBagLayoutInfo methodsFor:'accessing'!
+
+height
+ "return the value of the instance variable 'height' (automatically generated)"
+
+ ^ height
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+height:something
+ "set the value of the instance variable 'height' (automatically generated)"
+
+ height := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+minHeight
+ "return the value of the instance variable 'minHeight' (automatically generated)"
+
+ ^ minHeight
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+minHeight:something
+ "set the value of the instance variable 'minHeight' (automatically generated)"
+
+ minHeight := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+minWidth
+ "return the value of the instance variable 'minWidth' (automatically generated)"
+
+ ^ minWidth
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+minWidth:something
+ "set the value of the instance variable 'minWidth' (automatically generated)"
+
+ minWidth := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+startX
+ "return the value of the instance variable 'startX' (automatically generated)"
+
+ ^ startX
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+startX:something
+ "set the value of the instance variable 'startX' (automatically generated)"
+
+ startX := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+startY
+ "return the value of the instance variable 'startY' (automatically generated)"
+
+ ^ startY
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+startY:something
+ "set the value of the instance variable 'startY' (automatically generated)"
+
+ startY := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+weightX
+ "return the value of the instance variable 'weightX' (automatically generated)"
+
+ ^ weightX
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+weightX:something
+ "set the value of the instance variable 'weightX' (automatically generated)"
+
+ weightX := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+weightY
+ "return the value of the instance variable 'weightY' (automatically generated)"
+
+ ^ weightY
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+weightY:something
+ "set the value of the instance variable 'weightY' (automatically generated)"
+
+ weightY := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+width
+ "return the value of the instance variable 'width' (automatically generated)"
+
+ ^ width
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+!
+
+width:something
+ "set the value of the instance variable 'width' (automatically generated)"
+
+ width := something.
+
+ "Created: / 17.1.1998 / 14:32:39 / av"
+! !
+
+!GridBagLayoutInfo methodsFor:'initialization'!
+
+initialize
+
+ super initialize.
+
+ minWidth := IdentityDictionaryWithDefault newWithDefaultValue:0.
+ minHeight := IdentityDictionaryWithDefault newWithDefaultValue:0.
+
+ weightX := IdentityDictionaryWithDefault newWithDefaultValue:0.0.
+ weightY := IdentityDictionaryWithDefault newWithDefaultValue:0.0.
+
+ "Created: / 17.1.1998 / 14:32:30 / av"
+ "Modified: / 20.1.1998 / 16:50:16 / av"
+! !
+
+!GridBagLayoutInfo class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libwidg2/GridBagLayoutInfo.st,v 1.1 1998-02-03 18:13:22 cg Exp $'
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GridBagLayoutView.st Tue Feb 03 19:13:26 1998 +0100
@@ -0,0 +1,819 @@
+PanelView subclass:#GridBagLayoutView
+ instanceVariableNames:'columnWidths rowHeights columnWeights rowWeights layoutInfo'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Layout'
+!
+
+!GridBagLayoutView class methodsFor:'documentation'!
+
+documentation
+"
+GridBagLayout is a flexible layout manager that aligns components vertically and horizontally,
+without requiring that the components be the same size. Each GridBagLayout uses a dynamic rectangular
+grid of cells, with each component occupying one or more cells (called its display area).
+Each component managed by a GridBagLayout is associated with a GridBagConstraints instance that
+specifies how the component is laid out within its display area. How a GridBagLayout places a set of
+components depends on each component's GridBagConstraints and minimum size, as well as the preferred
+size of the components' container.
+
+To use a GridBagLayout effectively, you must customize one or more of its components' GridBagConstraints.
+You customize a GridBagConstraints object by setting one or more of its instance variables:
+
+ gridX
+ gridY
+ Specifies the cell at the upper left of the component's display area, where the
+ upper-left-most cell has address gridX=0, gridY=0. Use #RELATIVE (the default value)
+ to specify that the component be just placed just to the right of (for gridX)
+ or just below (for gridY) the component that was added to the container just before
+ this component was added.
+
+ gridWidth
+ gridHeight
+ Specifies the number of cells in a row (for gridWidth) or column (for gridHeight)
+ in the component's display area. The default value is 1. Use #REMAINDER to specify
+ that the component be the last one in its row (for gridWidth) or column (for gridHeight).
+ Use #RELATIVE to specify that the component be the next to last one in its row
+ (for gridWidth) or column (for gridHeight).
+
+ fill
+ Used when the component's display area is larger than the component's requested size
+ to determine whether (and how) to resize the component.
+ Valid values are
+ #NONE
+ (the default),
+ #HORIZONTAL
+ (make the component wide enough to fill its display area
+ horizontally, but don't change its height),
+ #VERTICAL
+ (make the component tall enough to fill its display area
+ vertically, but don't change its width), and
+ #BOTH
+ (make the component fill its display area entirely).
+
+ ipadX
+ ipadY
+ Specifies the internal padding: how much to add to the minimum size of the component.
+ The width of the component will be at least its minimum width plus ipadX*2 pixels
+ (since the padding applies to both sides of the component). Similarly, the height of
+ the component will be at least the minimum height plus ipadY*2 pixels.
+
+ insets
+ Specifies the external padding of the component -- the minimum amount of space between
+ the component and the edges of its display area.
+
+ anchor
+ Used when the component is smaller than its display area to determine where (within the area)
+ to place the component.
+ Valid values are
+ #CENTER (the default),
+ #NORTH,
+ #NORTHEAST,
+ #EAST,
+ #SOUTHEAST,
+ #SOUTH,
+ #SOUTHWEST,
+ #WEST,
+ #NORTHWEST.
+
+ weightX
+ weightY
+ Used to determine how to distribute space; this is important for specifying resizing
+ behavior. Unless you specify a weight for at least one component in a row (weightX)
+ and column (weightY), all the components clump together in the center of their container.
+ This is because when the weight is zero (the default), the GridBagLayout puts any extra
+ space between its grid of cells and the edges of the container.
+
+
+ [see also:]
+ GridBagConstraints
+ GridBagLayoutInfo
+ Insets
+
+ [author:]
+ Andreas Vogel
+"
+!
+
+examples
+"
+ This example is taken from the java source and should produce the same layout. Check the file
+ Grid*.gif in the java distribution.
+
+ [exBegin]
+ | v p c |
+ c := #(
+ #( fill: #BOTH weightX: 1.0 )
+ #( fill: #BOTH weightX: 1.0 )
+ #( fill: #BOTH weightX: 1.0 )
+ #( fill: #BOTH weightX: 1.0 gridWidth: #REMAINDER )
+ #( fill: #BOTH gridWidth: #REMAINDER )
+ #( fill: #BOTH gridWidth: #RELATIVE )
+ #( fill: #BOTH gridWidth: #REMAINDER )
+ #( fill: #BOTH weightY: 1.0 gridHeight: 2 )
+ #( fill: #BOTH gridWidth: #REMAINDER )
+ #( fill: #BOTH gridWidth: #REMAINDER )
+ ).
+ v := StandardSystemView new. v label:'GridBagLayoutView: Example 1'.
+ p := GridBagLayoutView in:v. p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+ 1 to: c size do:[ :i | | b |
+ b := Button label:('Button ',(i displayString)) in:p.
+ b objectAttributeAt:#GridBagConstraints put:((#(GridBagConstraints) , (c at:i)) decodeAsLiteralArray).
+ ].
+ v extent:(p preferredExtent). v open.
+ [exEnd]
+
+
+ [exBegin]
+ | v p c |
+ c := #(
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 gridWidth: #REMAINDER )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #RELATIVE )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH weightY: 1.0 gridHeight: 2 )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )
+ #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )
+ ).
+ v := StandardSystemView new. v label:'GridBagLayoutView: Example 2'.
+ p := GridBagLayoutView in:v. p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+ 1 to: c size do:[ :i | | b |
+ b := Button label:('Button ',(i displayString)) in:p.
+ b objectAttributeAt:#GridBagConstraints put:((#(GridBagConstraints) , (c at:i)) decodeAsLiteralArray).
+ ].
+ v extent:(p preferredExtent). v open.
+ [exEnd]
+
+
+
+"
+!
+
+history
+ "Created: / 20.1.1998 / 00:08:17 / av"
+! !
+
+!GridBagLayoutView class methodsFor:'instance creation'!
+
+new
+ "Create a new instance of my class and do explizit initialization of it."
+
+ ^ super new initialize
+
+ "Created: / 19.1.1998 / 13:53:11 / av"
+ "Modified: / 1.2.1998 / 13:02:59 / av"
+! !
+
+!GridBagLayoutView methodsFor:'layout'!
+
+setChildPositions
+ "(re)compute position of every child whenever childs are added or my size has changed"
+
+ self arrangeGrid.
+
+ "Modified: / 1.2.1998 / 12:52:22 / av"
+! !
+
+!GridBagLayoutView methodsFor:'private'!
+
+adjustForGravity:c in:r
+
+ | diffx diffy add |
+
+ r setLeft: ((r left) + (c insets left)).
+ r width: ((r width) - ((c insets left) + (c insets right))).
+ r setTop: ((r top) + (c insets top)).
+ r height: ((r height) - ((c insets top) + (c insets bottom))).
+
+ diffx := 0.
+ (((c fill) ~~ #HORIZONTAL and:[(c fill) ~~ #BOTH]) and:[(r width) > (add := (c minWidth) + (c ipadX))]) ifTrue:[
+ diffx := (r width) - add.
+ r width:add.
+ ].
+
+ diffy := 0.
+ (((c fill) ~~ #VERTICAL and:[(c fill) ~~ #BOTH]) and:[(r height) > (add := (c minHeight) + (c ipadY))]) ifTrue:[
+ diffy := (r height) - add.
+ r height:add.
+ ].
+
+ ((c anchor) == #CENTER) ifTrue:[
+ r setLeft:((r left) + (diffx / 2)).
+ r setTop:((r top) + (diffy / 2)).
+ ].
+ ((c anchor) == #NORTH) ifTrue:[
+ r setLeft:((r left) + (diffx / 2)).
+ ].
+ ((c anchor) == #NORTHEAST) ifTrue:[
+ r setLeft:((r left) + diffx).
+ ].
+ ((c anchor) == #EAST) ifTrue:[
+ r setLeft:((r left) + diffx).
+ r setTop:((r top) + (diffy / 2)).
+ ].
+ ((c anchor) == #SOUTHEAST) ifTrue:[
+ r setLeft:((r left) + diffx).
+ r setTop:((r top) + diffy).
+ ].
+ ((c anchor) == #SOUTH) ifTrue:[
+ r setLeft:((r left) + (diffx / 2)).
+ r setTop:((r top) + diffy).
+ ].
+ ((c anchor) == #SOUTHWEST) ifTrue:[
+ r setTop:((r top) + diffy).
+ ].
+ ((c anchor) == #WEST) ifTrue:[
+ r setTop:((r top) + (diffy / 2)).
+ ].
+ ((c anchor) == #NORTHWEST) ifTrue:[
+ ].
+
+ r setLeft: ((r left) asInteger).
+ r setTop: ((r top) asInteger).
+ r width: ((r width) asInteger).
+ r height: ((r height) asInteger).
+
+ ^ r
+
+ "Modified: / 22.1.1998 / 09:50:01 / av"
+!
+
+arrangeGrid
+ " Lay out the grid."
+
+ | insets subViews info ext d r c diffw diffh weight |
+
+ insets := Insets new.
+
+ "/ If the parent has no slaves anymore, then don't do anything
+ "/ at all: just leave the parent's size as-is.
+ (((subViews := self subViews) size) == 0) ifTrue:[^ self].
+
+ extentChanged ifTrue:[
+ ext := self computeExtent.
+ width := ext x.
+ height := ext y.
+ ].
+
+ "/ Pass #1: scan all the slaves to figure out the total amount
+ "/ of space needed.
+
+ info := self getLayoutInfo:#PREFERRED_SIZE.
+ d := self getMinSize:info.
+
+ ((width < (d width)) or:[(height < (d height))]) ifTrue:[
+ info := self getLayoutInfo:#MINIMUM_SIZE.
+ d := self getMinSize:info.
+ ].
+
+ layoutInfo := info.
+ r := Rectangle origin:0@0 extent:((d width) @ (d height)).
+
+ "/ If the current dimensions of the window don't match the desired
+ "/ dimensions, then adjust the minWidth and minHeight arrays
+ "/ according to the weights.
+
+ diffw := width - (r width).
+ (diffw ~~ 0) ifTrue:[
+ weight := 0.0.
+ 0 to:((info width) - 1) do:[ :i |
+ weight := weight + ((info weightX) at:(i + 1)).
+ ].
+ (weight > 0.0) ifTrue:[
+ 0 to:((info width) - 1) do:[ :i |
+ | dx |
+ dx := ((diffw * ((info weightX) at:(i + 1))) / weight) asInteger.
+ (info minWidth) at:(i + 1) put:(((info minWidth) at:(i + 1)) + dx).
+ r width:((r width) + dx).
+ (((info minWidth) at:(i + 1)) < 0) ifTrue:[
+ r width:((r width) - ((info minWidth) at:(i + 1))).
+ (info minWidth) at:(i + 1) put:0.
+ ].
+ ].
+ ].
+ diffw := width - (r width).
+ ] ifFalse:[
+ diffw := 0.
+ ].
+
+ diffh := height - (r height).
+ (diffh ~~ 0) ifTrue:[
+ weight := 0.0.
+ 0 to:((info height) - 1) do:[ :i |
+ weight := weight + ((info weightY) at:(i + 1)).
+ ].
+ (weight > 0.0) ifTrue:[
+ 0 to:((info height) - 1) do:[ :i |
+ | dy |
+ dy := ((diffh * ((info weightY) at:(i + 1))) / weight) asInteger.
+ (info minHeight) at:(i + 1) put:(((info minHeight) at:(i + 1)) + dy).
+ r height:((r height) + dy).
+ (((info minHeight) at:(i + 1)) < 0) ifTrue:[
+ r height:((r height) - ((info minHeight) at:(i + 1))).
+ (info minHeight) at:(i + 1) put:0.
+ ].
+ ].
+ ].
+ diffh := height - (r height).
+ ] ifFalse:[
+ diffh := 0.
+ ].
+
+ "/ Now do the actual layout of the slaves using the layout information
+ "/ that has been collected.
+
+ info startX:(((diffw / 2) + (insets left)) asInteger).
+ info startY:(((diffh / 2) + (insets top)) asInteger).
+
+ subViews do:[ :child |
+ c := self constraints:child.
+
+ r setLeft:(info startX).
+ 0 to:((c tempX) - 1) do:[ :i | r setLeft:((r left) + ((info minWidth) at:(i + 1))). ].
+
+ r setTop:(info startY).
+ 0 to:((c tempY) - 1) do:[ :i | r setTop:((r top) + ((info minHeight) at:(i + 1))). ].
+
+ r width:0.
+ (c tempX) to:((c tempX) + (c tempWidth) - 1) do:[ :i |
+ r width:((r width) + ((info minWidth) at:(i + 1))).
+ ].
+
+ r height:0.
+ (c tempY) to:((c tempY) + (c tempHeight) - 1) do:[ :i |
+ r height:((r height) + ((info minHeight) at:(i + 1))).
+ ].
+
+ self adjustForGravity:c in:r.
+
+ "/ If the window is too small to be interesting then
+ "/ unmap it. Otherwise configure it and then make sure
+ "/ its mapped.
+
+ (((r width) <= 0) or:[(r height) <= 0]) ifTrue:[
+ child origin:(0@0) ; width:0 height:0.
+ ] ifFalse:[
+ child origin:((r left) @ (r top)).
+ child width:(r width).
+ child height:(r height).
+ ].
+ ].
+
+ "Modified: / 1.2.1998 / 12:53:37 / av"
+!
+
+constraints:anObject
+ " Get the GridBag constraints for an object. As a fallback create new constraints for objects
+ which don't have any constraints yet."
+
+ | c |
+
+ c := anObject objectAttributeAt:#GridBagConstraints.
+ c isNil ifTrue:[
+ anObject objectAttributeAt:#GridBagConstraints put:(c := GridBagConstraints new)
+ ].
+ ^ c.
+
+ "Created: / 21.1.1998 / 00:24:34 / av"
+ "Modified: / 1.2.1998 / 12:55:23 / av"
+!
+
+getLayoutInfo:which
+ "return a good extent, one that makes subviews fit"
+
+ |
+ MAX_INT_VAL subViews
+ r i k px py pixelsDiff weightDiff weight nextSize c
+ curX curY curWidth curHeight curRow curCol xMax yMax
+ |
+
+ MAX_INT_VAL := 9999999999.
+ subViews := (self subViews).
+
+ r := GridBagLayoutInfo new.
+ r width:0.
+ r height:0.
+
+ xMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
+ yMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
+ curRow := curCol := -1.
+
+ "/ Pass #1
+ "/
+ "/ Figure out the dimensions of the layout grid (use a value of 1 for
+ "/ zero or negative widths and heights).
+
+ subViews do:[ :child |
+ c := self constraints:child.
+
+ curX := c gridX.
+ curY := c gridY.
+ ((curWidth := c gridWidth) <= 0) ifTrue:[ curWidth := 1. ].
+ ((curHeight := c gridHeight) <= 0) ifTrue:[ curHeight := 1. ].
+
+ "/ If x or y is negative, then use relative positioning:
+ ((curX < 0) and:[ curY < 0 ])
+ ifTrue:[
+ (curRow >= 0)
+ ifTrue: [ curY := curRow. ]
+ ifFalse:[ (curCol >= 0) ifTrue:[ curX := curCol. ] ifFalse: [ curY := 0. ]].
+ ].
+
+ (curX < 0)
+ ifTrue:[
+ px := 0.
+ curY to:(curY + curHeight - 1) do: [ :i |
+ px := px max:(xMax at:(i + 1)).
+ ].
+ ((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ].
+ ]
+ ifFalse:[
+ (curY < 0) ifTrue:[
+ py := 0.
+ curX to: (curX + curWidth - 1) do: [ :i |
+ py := py max: (yMax at:(i + 1)).
+ ].
+ ((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ].
+ ].
+ ].
+
+ "/ Adjust the grid width and height
+ px := curX + curWidth. [ (r width) < px ] whileTrue:[ r width:((r width) + 1). ].
+ py := curY + curHeight. [ (r height) < py ] whileTrue:[ r height:((r height) + 1). ].
+
+ "/ Adjust the xMax and yMax arrays
+ curX to:(curX + curWidth - 1) do:[ :i | yMax at:(i + 1) put:py. ].
+ curY to:(curY + curHeight - 1) do:[ :i | xMax at:(i + 1) put:px. ].
+
+ c minWidth:(child preferredExtent x).
+ c minHeight:(child preferredExtent y).
+
+ "/ Zero width and height must mean that this is the last item (or
+ "/ else something is wrong).
+ (((c gridHeight) == 0) and:[ (c gridWidth) == 0 ]) ifTrue:[
+ curRow := curCol := -1.
+ ].
+
+ "/ Zero width starts a new row
+ (((c gridHeight) == 0) and:[ curRow < 0 ])
+ ifTrue:[
+ curCol := curX + curWidth.
+ ]
+ ifFalse:[
+ ((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[
+ curRow := curY + curHeight.
+ ].
+ ].
+ ].
+
+ "/
+ "/ Apply minimum row/column dimensions
+ "/
+ ((r width) < (columnWidths size)) ifTrue:[ r width:(columnWidths size). ].
+ ((r height) < (rowHeights size)) ifTrue:[ r height:(rowHeights size). ].
+
+ "/
+ "/ Pass #2
+ "/
+ "/ Negative values for gridX are filled in with the current x value.
+ "/ Negative values for gridY are filled in with the current y value.
+ "/ Negative or zero values for gridWidth and gridHeight end the current
+ "/ row or column, respectively.
+ "/
+
+ curRow := curCol := -1.
+ xMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
+ yMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
+
+ subViews do:[ :child |
+ c := self constraints:child.
+
+ curX := c gridX.
+ curY := c gridY.
+ curWidth := c gridWidth.
+ curHeight := c gridHeight.
+
+ "/ If x or y is negative, then use relative positioning:
+ ((curX < 0) and:[ curY < 0 ])
+ ifTrue:[
+ (curRow >= 0)
+ ifTrue: [ curY := curRow. ]
+ ifFalse:[ (curCol >= 0)
+ ifTrue: [ curX := curCol. ]
+ ifFalse: [ curY := 0. ].
+ ].
+ ].
+
+ (curX < 0)
+ ifTrue:[
+ (curHeight <= 0) ifTrue:[
+ curHeight := curHeight + (r height) - curY.
+ (curHeight < 1) ifTrue:[ curHeight := 1. ].
+ ].
+ px := 0.
+ curY to:(curY + curHeight - 1) do: [ :i | px := px max:(xMax at:(i + 1)). ].
+ ((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ].
+ ]
+ ifFalse:[
+ (curY < 0) ifTrue:[
+ (curWidth <= 0) ifTrue:[
+ curWidth := curWidth + (r width) - curX.
+ (curWidth < 1) ifTrue:[ curWidth := 1. ].
+ ].
+ py := 0.
+ curX to:(curX + curWidth - 1) do: [ :i | py := py max:(yMax at:(i + 1)). ].
+ ((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ].
+ ].
+ ].
+
+ (curWidth <= 0) ifTrue:[
+ curWidth := curWidth + (r width) - curX.
+ (curWidth < 1) ifTrue:[ curWidth := 1. ].
+ ].
+
+ (curHeight <= 0) ifTrue:[
+ curHeight := curHeight + (r height) - curY.
+ (curHeight < 1) ifTrue:[ curHeight := 1. ].
+ ].
+
+ px := curX + curWidth.
+ py := curY + curHeight.
+
+ "/ Adjust the xMax and yMax arrays
+ curX to: (curX + curWidth - 1) do:[ :i | yMax at:(i + 1) put:py. ].
+ curY to: (curY + curHeight - 1) do:[ :i | xMax at:(i + 1) put:px. ].
+
+ "/ Zero width and height must mean that this is the last item (or
+ "/ else something is wrong).
+ ((c gridHeight) == 0 and:[ (c gridWidth) == 0 ]) ifTrue:[
+ curRow := curCol := -1.
+ ].
+
+ "/ Zero width starts a new row
+ ((c gridHeight) == 0 and:[ curRow < 0 ])
+ ifTrue:[
+ curCol := curX + curWidth.
+ ]
+ ifFalse:[
+ ((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[
+ curRow := curY + curHeight.
+ ].
+ ].
+
+ "/ Assign the new values to the gridbag slave */
+ c tempX:curX.
+ c tempY:curY.
+ c tempWidth:curWidth.
+ c tempHeight:curHeight.
+ ].
+
+ "/
+ "/ Apply minimum row/column dimensions and weights
+ "/
+ r minWidth: (columnWidths copy).
+ r minHeight: (rowHeights copy).
+ r weightX: (columnWeights copy).
+ r weightY: (rowWeights copy).
+
+ "/
+ "/ Pass #3
+ "/
+ "/ Distribute the minimun widths and weights:
+ "/
+ nextSize := MAX_INT_VAL.
+
+ i := 1. [ i ~~ MAX_INT_VAL ] whileTrue:[
+ subViews do:[ :child |
+ c := self constraints:child.
+
+ ((c tempWidth) == i) ifTrue:[
+ px := (c tempX) + (c tempWidth).
+
+ "/
+ "/ Figure out if we should use this slaves weight. If the weight
+ "/ is less than the total weight spanned by the width of the cell,
+ "/ then discard the weight. Otherwise split the difference
+ "/ according to the existing weights.
+ "/
+ weightDiff := (c weightX) asFloat.
+ (c tempX) to:(px - 1) do:[ :k | weightDiff := weightDiff - ((r weightX) at:(k + 1)) ].
+
+ (weightDiff > 0.0) ifTrue:[
+ weight := 0.0.
+ (c tempX) to:(px - 1) do:[ :k | weight := weight + ((r weightX) at:(k + 1)). ].
+
+ k := c tempX.
+ [ (weight > 0.0) and:[k < px] ] whileTrue:[
+ | wt dx |
+
+ wt := ((r weightX) at:(k + 1)) asFloat.
+ dx := (wt * weightDiff) / weight.
+ wt at:(k + 1) put:(wt + dx).
+ weightDiff := weightDiff - dx.
+ weight := weight - wt.
+ ].
+ (r weightX) at:(px - 1 + 1) put:(((r weightX) at:(px - 1 + 1)) + weightDiff).
+ ].
+
+ "/ Calculate the minWidth array values.
+ "/ First, figure out how wide the current slave needs to be.
+ "/ Then, see if it will fit within the current minWidth values.
+ "/ If it will not fit, add the difference according to the
+ "/ weightX array.
+
+ pixelsDiff := (c minWidth) + (c ipadX) + (c insets left) + (c insets right).
+ (c tempX) to:(px - 1) do:[ :k |
+ pixelsDiff := pixelsDiff - ((r minWidth) at:(k + 1)).
+ ].
+
+ (pixelsDiff > 0) ifTrue:[
+ weight := 0.0.
+ (c tempX) to:(px - 1) do:[ :k | weight := weight + ((r weightX) at:(k + 1)). ].
+ k := c tempX.
+ [ (weight > 0.0) and:[k < px] ] whileTrue:[
+ | wt dx |
+
+ wt := ((r weightX) at:(k + 1)) asFloat.
+ dx := ((wt * pixelsDiff) / weight) asInteger.
+ (r minWidth) at:(k + 1) put:(((r minWidth) at:(k + 1)) + dx).
+ pixelsDiff := pixelsDiff - dx.
+ weight := weight - wt.
+ ].
+ (r minWidth) at:(px - 1 + 1) put:(((r minWidth) at:(px - 1 + 1)) + pixelsDiff).
+ ].
+ ] ifFalse:[
+ (((c tempWidth) > i) and:[ (c tempWidth) < nextSize ]) ifTrue:[
+ nextSize := c tempWidth.
+ ].
+ ].
+
+ "///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ ((c tempHeight) == i) ifTrue:[
+ py := (c tempY) + (c tempHeight).
+
+ "/
+ "/ Figure out if we should use this slaves weight. If the weight
+ "/ is less than the total weight spanned by the width of the cell,
+ "/ then discard the weight. Otherwise split the difference
+ "/ according to the existing weights.
+ "/
+ weightDiff := (c weightY) asFloat.
+ (c tempY) to:(py - 1) do:[ :k | weightDiff := weightDiff - ((r weightY) at:(k + 1)) ].
+
+ (weightDiff > 0.0) ifTrue:[
+ weight := 0.0.
+ (c tempY) to:(py - 1) do:[ :k | weight := weight + ((r weightY) at:(k + 1)). ].
+
+ k := c tempY.
+ [ (weight > 0.0) and:[k < py] ] whileTrue:[
+ | wt dy |
+
+ wt := ((r weightY) at:(k + 1)) asFloat.
+ dy := (wt * weightDiff) / weight.
+ wt at:(k + 1) put:(wt + dy).
+ weightDiff := weightDiff - dy.
+ weight := weight - wt.
+ ].
+ (r weightY) at:(py - 1 + 1) put:(((r weightY) at:(py - 1 + 1)) + weightDiff).
+ ].
+
+ "/ Calculate the minWidth array values.
+ "/ First, figure out how wide the current slave needs to be.
+ "/ Then, see if it will fit within the current minWidth values.
+ "/ If it will not fit, add the difference according to the
+ "/ weightX array.
+
+ pixelsDiff := (c minHeight) + (c ipadY) + (c insets top) + (c insets bottom).
+ (c tempY) to:(py - 1) do:[ :k |
+ pixelsDiff := pixelsDiff - ((r minHeight) at:(k + 1)).
+ ].
+
+ (pixelsDiff > 0) ifTrue:[
+ weight := 0.0.
+ (c tempY) to:(py - 1) do:[ :k |
+ weight := weight + ((r weightY) at:(k + 1)).
+ ].
+ k := c tempY.
+ [ (weight > 0.0) and:[k < py] ] whileTrue:[
+ | wt dy |
+
+ wt := ((r weightY) at:(k + 1)) asFloat.
+ dy := ((wt * pixelsDiff) / weight) asInteger.
+ (r minHeight) at:(k + 1) put:(((r minHeight) at:(k + 1)) + dy).
+ pixelsDiff := pixelsDiff - dy.
+ weight := weight - wt.
+ ].
+ (r minHeight) at:(py - 1 + 1) put:(((r minHeight) at:(py - 1 + 1)) + pixelsDiff).
+ ].
+ ] ifFalse:[
+ (((c tempHeight) > i) and:[ (c tempHeight) < nextSize ]) ifTrue:[
+ nextSize := c tempHeight.
+ ].
+ ].
+ ].
+ i := nextSize.
+ nextSize := MAX_INT_VAL.
+ ].
+
+ ^ r
+
+ "Modified: / 29.3.1997 / 11:06:45 / cg"
+ "Created: / 19.1.1998 / 17:24:26 / av"
+ "Modified: / 21.1.1998 / 18:40:38 / av"
+!
+
+getMinSize:info
+ "Figure out the minimum size of the master based on the information from getLayoutInfo. The
+ result will be returned as a rectangle with width and height set to the minimum size."
+
+ | d insets t |
+
+ insets := Insets new.
+
+ d := Rectangle origin:0@0 extent:0@0.
+
+ t := 0.
+ 1 to:(info width) do:[ :i | t := t + ((info minWidth) at:i). ].
+ d width:(t + (insets left) + (insets right)).
+
+ t := 0.
+ 1 to:(info height) do:[ :i | t := t + ((info minHeight) at:i). ].
+ d height:(t + (insets top) + (insets bottom)).
+
+ ^ d
+
+ "Modified: / 1.2.1998 / 12:59:00 / av"
+!
+
+initialize
+ "Initialize the instance. Mainly set our instance variables to required values."
+
+ super initialize.
+
+ columnWidths := IdentityDictionaryWithDefault newWithDefaultValue:0.
+ rowHeights := IdentityDictionaryWithDefault newWithDefaultValue:0.
+
+ columnWeights := IdentityDictionaryWithDefault newWithDefaultValue:0.0.
+ rowWeights := IdentityDictionaryWithDefault newWithDefaultValue:0.0.
+
+ layoutInfo := nil.
+
+ "Created: / 19.1.1998 / 13:53:59 / av"
+ "Modified: / 1.2.1998 / 12:57:05 / av"
+!
+
+minimumLayoutSize
+ "Return our minimum layout size. The width and height of the returned rectangle gives the minimum
+ layout size."
+
+ | info |
+
+ info := self getLayoutInfo:#MINIMUM_SIZE.
+ ^ self getMinSize:info
+
+ "Created: / 19.1.1998 / 17:25:01 / av"
+ "Modified: / 1.2.1998 / 12:59:38 / av"
+!
+
+preferredLayoutSize
+ "Return our preffered layout size. The width and height of the returned rectangle gives the
+ preferred layout size."
+
+ | info |
+
+ info := self getLayoutInfo:#PREFFERED_SIZE.
+ ^ self getMinSize:info
+
+ "Created: / 19.1.1998 / 17:23:37 / av"
+ "Modified: / 1.2.1998 / 13:00:04 / av"
+! !
+
+!GridBagLayoutView methodsFor:'queries'!
+
+preferredExtent
+ "Return a good extent, one that makes subviews fit. Return the the preferred extent as a point
+ where x and y represents the width and height of the extent."
+
+ | d |
+
+ "/ If I have an explicit preferredExtent ..
+ preferredExtent notNil ifTrue:[ ^ preferredExtent ].
+
+ (self subViews) isNil ifTrue:[ ^ super preferredExtent. ].
+
+ d := self preferredLayoutSize.
+ ^ (d width) @ (d height).
+
+ "Created: / 17.1.1998 / 00:11:46 / av"
+ "Modified: / 1.2.1998 / 13:01:46 / av"
+! !
+
+!GridBagLayoutView class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libwidg2/GridBagLayoutView.st,v 1.1 1998-02-03 18:13:23 cg Exp $'
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GridBagLayoutViewSpec.st Tue Feb 03 19:13:26 1998 +0100
@@ -0,0 +1,110 @@
+PanelViewSpec subclass:#GridBagLayoutViewSpec
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-Support-UI-Specs'
+!
+
+!GridBagLayoutViewSpec class methodsFor:'documentation'!
+
+documentation
+"
+ This is the specification class for the GridBagLayoutView.
+
+ [see also:]
+ GridBagLayoutView
+ GridBagConstraints
+ GridBagLayoutInfo
+
+ [author:]
+ Andreas Vogel
+"
+!
+
+history
+ "Created: / 22.1.1998 / 00:24:53 / av"
+! !
+
+!GridBagLayoutViewSpec class methodsFor:'interface - painter'!
+
+addBindingsTo:env for:anInstance channel:aChannel
+
+ super addBindingsTo:env for:anInstance channel:aChannel.
+
+"/ env at:#horizontalLayoutList
+"/ put:#(
+"/ #left
+"/ #leftSpace
+"/ #fixLeft
+"/ #fixLeftSpace
+"/ #right
+"/ #rightSpace
+"/ #center
+"/ #spread
+"/ #spreadSpace
+"/ #fit
+"/ #fitSpace
+"/ #leftFit
+"/ #leftSpaceFit
+"/ #rightFit
+"/ #rightSpaceFit
+"/
+"/ #leftMax
+"/ #leftSpaceMax
+"/ #rightMax
+"/ #rightSpaceMax
+"/ #centerMax
+"/ #spreadMax
+"/ #spreadSpaceMax
+"/ ) asValue.
+"/
+"/ env at:#verticalLayoutList
+"/ put:#(
+"/ #top
+"/ #topSpace
+"/ #center
+"/ #bottom
+"/ #bottomSpace
+"/ #fit
+"/ #fitSpace
+"/ #topMax
+"/ #topSpaceMax
+"/ #bottomMax
+"/ #bottomSpaceMax
+"/ #centerMax
+"/ ) asValue.
+
+ "Created: / 22.1.1998 / 00:26:00 / av"
+ "Modified: / 22.1.1998 / 00:49:40 / av"
+! !
+
+!GridBagLayoutViewSpec methodsFor:'building'!
+
+buildViewWithLayoutFor:aBuilder in:aView
+ | v |
+
+ v := super buildViewWithLayoutFor:aBuilder in:aView.
+
+ "/ Now, after all children exists, decode the GridBagLayoutConstraints and store the created object
+ "/
+ (v subViews) do:[ :sv |
+ | slot constraints |
+
+ slot := #GridBagConstraints.
+ constraints := sv objectAttributeAt:slot.
+ constraints notNil ifTrue:[
+ sv objectAttributeAt:slot put:(constraints decodeAsLiteralArray)
+ ].
+ ].
+
+ ^ v
+
+ "Created: / 22.1.1998 / 22:04:35 / av"
+ "Modified: / 25.1.1998 / 00:05:13 / av"
+! !
+
+!GridBagLayoutViewSpec class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libwidg2/Attic/GridBagLayoutViewSpec.st,v 1.1 1998-02-03 18:13:24 cg Exp $'
+! !
--- a/Make.proto Tue Feb 03 18:50:47 1998 +0100
+++ b/Make.proto Tue Feb 03 19:13:26 1998 +0100
@@ -1,4 +1,4 @@
-# $Header: /cvs/stx/stx/libwidg2/Make.proto,v 1.66 1997-09-20 22:55:46 cg Exp $
+# $Header: /cvs/stx/stx/libwidg2/Make.proto,v 1.67 1998-02-03 18:13:26 cg Exp $
#
# -------------- no need to change anything below ----------
@@ -130,6 +130,9 @@
ComboListV.$(O): ComboListV.st $(STCHDR) ../include/Object.H ../include/ComboView.H
FNmEdtFld.$(O): FNmEdtFld.st $(STCHDR) ../include/Object.H
FNmEntrBox.$(O): FNmEntrBox.st $(STCHDR) ../include/Object.H
+GridBagConstraints.$(O): GridBagConstraints.st $(STCHDR) ../include/Object.H
+GridBagLayoutInfo.$(O): GridBagLayoutInfo.st $(STCHDR) ../include/Object.H
+GridBagLayoutView.$(O): GridBagLayoutView.st $(STCHDR) ../include/Object.H
HScale.$(O): HScale.st $(STCHDR) ../include/Object.H
HSlider.$(O): HSlider.st $(STCHDR) ../include/Object.H
HStepSlider.$(O): HStepSlider.st $(STCHDR) ../include/Object.H