[squeak-dev] The Trunk: Graphics-cmm.174.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jan 8 21:49:53 UTC 2011
Chris Muller uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-cmm.174.mcz
==================== Summary ====================
Name: Graphics-cmm.174
Author: cmm
Time: 8 January 2011, 3:49:19.775 pm
UUID: f55656ad-b923-452a-81a5-426ad37dbd43
Ancestors: Graphics-bp.173
Merged Graphics-bp.173 without dropping the postscript.
=============== Diff against Graphics-mtf.172 ===============
Item was added:
+ Object subclass: #LayoutFrame
+ instanceVariableNames: 'leftFraction leftOffset topFraction topOffset rightFraction rightOffset bottomFraction bottomOffset'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Graphics-Primitives'!
+
+ !LayoutFrame commentStamp: '<historical>' prior: 0!
+ I define a frame for positioning some morph in a proportional layout.
+
+ Instance variables:
+ leftFraction
+ topFraction
+ rightFraction
+ bottomFraction <Float> The fractional distance (between 0 and 1) to place the morph in its owner's bounds
+ leftOffset
+ topOffset
+ rightOffset
+ bottomOffset <Integer> Fixed pixel offset to apply after fractional positioning (e.g., "10 pixel right of the center of the owner")!
Item was added:
+ ----- Method: LayoutFrame class>>classVersion (in category 'accessing') -----
+ classVersion
+ ^1 "changed treatment of bottomOffset and rightOffset"
+ !
Item was added:
+ ----- Method: LayoutFrame class>>fractions: (in category 'instance creation') -----
+ fractions: fractionsOrNil
+ ^self fractions: fractionsOrNil offsets: nil!
Item was added:
+ ----- Method: LayoutFrame class>>fractions:offsets: (in category 'instance creation') -----
+ fractions: fractionsOrNil offsets: offsetsOrNil
+
+ | fractions offsets |
+
+ fractions := fractionsOrNil ifNil: [0 at 0 extent: 0 at 0].
+ offsets := offsetsOrNil ifNil: [0 at 0 extent: 0 at 0].
+ ^self new
+ topFraction: fractions top offset: offsets top;
+ leftFraction: fractions left offset: offsets left;
+ bottomFraction: fractions bottom offset: offsets bottom;
+ rightFraction: fractions right offset: offsets right
+ !
Item was added:
+ ----- Method: LayoutFrame class>>offsets: (in category 'instance creation') -----
+ offsets: offsetsOrNil
+ ^self fractions: nil offsets: offsetsOrNil!
Item was added:
+ ----- Method: LayoutFrame>>bottomFraction (in category 'accessing') -----
+ bottomFraction
+ ^bottomFraction!
Item was added:
+ ----- Method: LayoutFrame>>bottomFraction: (in category 'accessing') -----
+ bottomFraction: aNumber
+ bottomFraction := aNumber!
Item was added:
+ ----- Method: LayoutFrame>>bottomFraction:offset: (in category 'accessing') -----
+ bottomFraction: aNumber offset: anInteger
+
+ bottomFraction := aNumber.
+ bottomOffset := anInteger!
Item was added:
+ ----- Method: LayoutFrame>>bottomOffset (in category 'accessing') -----
+ bottomOffset
+ ^bottomOffset!
Item was added:
+ ----- Method: LayoutFrame>>bottomOffset: (in category 'accessing') -----
+ bottomOffset: anInteger
+ bottomOffset := anInteger!
Item was added:
+ ----- Method: LayoutFrame>>convertToCurrentVersion:refStream: (in category 'objects from disk') -----
+ convertToCurrentVersion: varDict refStream: smartRefStrm
+ | className oldClassVersion |
+
+ "JW 2/1/2001"
+ "Since class version isn't passed in varDict, look it up through smartRefSrm."
+ className := varDict at: #ClassName.
+ oldClassVersion := (smartRefStrm structures at: className) first.
+ (oldClassVersion = 0) ifTrue: [ self negateBottomRightOffsets ].
+ ^super convertToCurrentVersion: varDict refStream: smartRefStrm.
+ !
Item was added:
+ ----- Method: LayoutFrame>>layout:in: (in category 'layout') -----
+ layout: oldBounds in: newBounds
+ "Return the proportional rectangle insetting the given bounds"
+ | left right top bottom |
+ leftFraction ifNotNil:[
+ left := newBounds left + (newBounds width * leftFraction).
+ leftOffset ifNotNil:[left := left + leftOffset]].
+ rightFraction ifNotNil:[
+ right := newBounds right - (newBounds width * (1.0 - rightFraction)).
+ rightOffset ifNotNil:[right := right + rightOffset]].
+ topFraction ifNotNil:[
+ top := newBounds top + (newBounds height * topFraction).
+ topOffset ifNotNil:[top := top + topOffset]].
+ bottomFraction ifNotNil:[
+ bottom := newBounds bottom - (newBounds height * (1.0 - bottomFraction)).
+ bottomOffset ifNotNil:[bottom := bottom + bottomOffset]].
+ left ifNil:[ right
+ ifNil:[left := oldBounds left. right := oldBounds right]
+ ifNotNil:[left := right - oldBounds width]].
+ right ifNil:[right := left + oldBounds width].
+ top ifNil:[ bottom
+ ifNil:[top := oldBounds top. bottom := oldBounds bottom]
+ ifNotNil:[top := bottom - oldBounds height]].
+ bottom ifNil:[bottom := top + oldBounds height].
+ ^(left rounded @ top rounded) corner: (right rounded @ bottom rounded)!
Item was added:
+ ----- Method: LayoutFrame>>leftFraction (in category 'accessing') -----
+ leftFraction
+ ^leftFraction!
Item was added:
+ ----- Method: LayoutFrame>>leftFraction: (in category 'accessing') -----
+ leftFraction: aNumber
+ leftFraction := aNumber!
Item was added:
+ ----- Method: LayoutFrame>>leftFraction:offset: (in category 'accessing') -----
+ leftFraction: aNumber offset: anInteger
+
+ leftFraction := aNumber.
+ leftOffset := anInteger!
Item was added:
+ ----- Method: LayoutFrame>>leftOffset (in category 'accessing') -----
+ leftOffset
+ ^leftOffset!
Item was added:
+ ----- Method: LayoutFrame>>leftOffset: (in category 'accessing') -----
+ leftOffset: anInteger
+ leftOffset := anInteger!
Item was added:
+ ----- Method: LayoutFrame>>minExtentFrom: (in category 'layout') -----
+ minExtentFrom: minExtent
+ "Return the minimal extent the given bounds can be represented in"
+ | width height left right top bottom |
+ left := leftFraction ifNil: [0.0].
+ right := rightFraction ifNil: [1.0].
+ width := left = right
+ ifTrue: [0]
+ ifFalse: [minExtent x / (right - left)].
+ top := topFraction ifNil: [0.0].
+ bottom := bottomFraction ifNil: [1.0].
+ height := bottom = top
+ ifTrue: [0]
+ ifFalse: [minExtent y / (bottom - top)].
+ leftOffset ifNotNil:[width := width + leftOffset].
+ rightOffset ifNotNil:[width := width + rightOffset].
+ topOffset ifNotNil:[height := height + topOffset].
+ bottomOffset ifNotNil:[height := height + bottomOffset].
+ ^width truncated @ height truncated!
Item was added:
+ ----- Method: LayoutFrame>>negateBottomRightOffsets (in category 'objects from disk') -----
+ negateBottomRightOffsets
+
+ bottomOffset ifNotNil: [ bottomOffset := bottomOffset negated ].
+ rightOffset ifNotNil: [ rightOffset := rightOffset negated ].
+
+ !
Item was added:
+ ----- Method: LayoutFrame>>rightFraction (in category 'accessing') -----
+ rightFraction
+ ^rightFraction!
Item was added:
+ ----- Method: LayoutFrame>>rightFraction: (in category 'accessing') -----
+ rightFraction: aNumber
+ rightFraction := aNumber!
Item was added:
+ ----- Method: LayoutFrame>>rightFraction:offset: (in category 'accessing') -----
+ rightFraction: aNumber offset: anInteger
+
+ rightFraction := aNumber.
+ rightOffset := anInteger!
Item was added:
+ ----- Method: LayoutFrame>>rightOffset (in category 'accessing') -----
+ rightOffset
+ ^rightOffset!
Item was added:
+ ----- Method: LayoutFrame>>rightOffset: (in category 'accessing') -----
+ rightOffset: anInteger
+ rightOffset := anInteger!
Item was added:
+ ----- Method: LayoutFrame>>topFraction (in category 'accessing') -----
+ topFraction
+ ^topFraction!
Item was added:
+ ----- Method: LayoutFrame>>topFraction: (in category 'accessing') -----
+ topFraction: aNumber
+ topFraction := aNumber!
Item was added:
+ ----- Method: LayoutFrame>>topFraction:offset: (in category 'accessing') -----
+ topFraction: aNumber offset: anInteger
+
+ topFraction := aNumber.
+ topOffset := anInteger!
Item was added:
+ ----- Method: LayoutFrame>>topOffset (in category 'accessing') -----
+ topOffset
+ ^topOffset!
Item was added:
+ ----- Method: LayoutFrame>>topOffset: (in category 'accessing') -----
+ topOffset: anInteger
+ topOffset := anInteger!
More information about the Squeak-dev
mailing list
|