--- a/GridBagLayoutView.st Fri May 30 14:25:12 2008 +0200
+++ b/GridBagLayoutView.st Fri May 30 14:25:19 2008 +0200
@@ -436,9 +436,9 @@
"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 subViews
+ r i k px py pixelsDiff weightDiff weight nextSize c
+ curX curY curWidth curHeight curRow curCol xMax yMax
|
MAX_INT_VAL := 9999999999.
@@ -458,66 +458,66 @@
"/ zero or negative widths and heights).
subViews do:[ :child |
- c := self constraints: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. ].
+ 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. ]].
- ].
+ "/ 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. ].
- ].
- ].
+ (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 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. ].
+ "/ 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).
+ c minWidth:(child preferredWidth).
+ c minHeight:(child preferredHeight).
- "/ 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 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.
- ].
- ].
+ "/ 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.
+ ].
+ ].
].
"/
@@ -540,85 +540,85 @@
yMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
subViews do:[ :child |
- c := self constraints:child.
+ c := self constraints:child.
- curX := c gridX.
- curY := c gridY.
- curWidth := c gridWidth.
- curHeight := c gridHeight.
+ 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. ].
- ].
- ].
+ "/ 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. ].
- ].
- ].
+ (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. ].
- ].
+ (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. ].
- ].
+ (curHeight <= 0) ifTrue:[
+ curHeight := curHeight + (r height) - curY.
+ (curHeight < 1) ifTrue:[ curHeight := 1. ].
+ ].
- px := curX + curWidth.
- py := curY + curHeight.
+ 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. ].
+ "/ 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 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.
- ].
- ].
+ "/ 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.
+ "/ Assign the new values to the gridbag slave */
+ c tempX:curX.
+ c tempY:curY.
+ c tempWidth:curWidth.
+ c tempHeight:curHeight.
].
"/
@@ -637,137 +637,137 @@
nextSize := MAX_INT_VAL.
i := 1. [ i ~~ MAX_INT_VAL ] whileTrue:[
- subViews do:[ :child |
- c := self constraints:child.
+ subViews do:[ :child |
+ c := self constraints:child.
- ((c tempWidth) == i) ifTrue:[
- px := (c tempX) + (c tempWidth).
+ ((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)) ].
+ "/
+ "/ 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)). ].
+ (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 |
+ 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).
- ].
+ 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.
+ "/ 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 := (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 |
+ (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.
- ].
- ].
+ 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).
+ ((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)) ].
+ "/
+ "/ 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)). ].
+ (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 |
+ 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).
- ].
+ 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.
+ "/ 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 := (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 |
+ (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.
+ 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
@@ -849,5 +849,5 @@
!GridBagLayoutView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/GridBagLayoutView.st,v 1.7 2007-10-09 08:43:53 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/GridBagLayoutView.st,v 1.8 2008-05-30 12:25:19 cg Exp $'
! !