A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-bp.173.mcz ==================== Summary ==================== Name: Graphics-bp.173 Author: bp Time: 1 January 2011, 4:46:21.309 pm UUID: ea1ef361-c184-465d-bd42-8f50a5f87416 Ancestors: Graphics-mtf.172 - moved LayoutFrame from Morphic-Layout to Graphics-Primitives because it is not specific to Morphic, i.e. it has no references to it and is perfectly usable - and used - by MVC only UIs. This also fixes PackageDependencyTest>>#testSUnitGUI. This version should be loaded before Morphic-bp.505. =============== 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@0 extent: 0@0]. + offsets := offsetsOrNil ifNil: [0@0 extent: 0@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! |
Free forum by Nabble | Edit this page |