Karl Ramberg uploaded a new version of Etoys to project Etoys: http://source.squeak.org/etoys/Etoys-kfr.12.mcz
==================== Summary ====================
Name: Etoys-kfr.12 Author: kfr Time: 29 May 2010, 1:57:17 pm UUID: b39ea6fc-84b9-f944-880d-2adcc2eac659 Ancestors: Etoys-Richo.11
Compute up/down arrow increments in NumberTiles from decimal places
=============== Diff against Etoys-Richo.11 ===============
Item was changed: ----- Method: Player>>arrowDeltaFor: (in category 'misc') ----- arrowDeltaFor: aGetSelector "Answer the arrowDelta to use in conjunction with a readout for aGetSelector, which will be of the form 'getXXX'"
+ (self slotInfoForGetter: aGetSelector) ifNotNilDo: [ :slotInfo | + ^slotInfo floatPrecision]. costume ifNotNil: [^ costume renderedMorph arrowDeltaFor: aGetSelector]. + ^ 1! - ^ 1 - - "For the future, possibly: If we want the SlotInformation for a user-defined slot to be able to specify a standard arrowDelta for that slot, we'd include something like the following... - | aSlotName slotInfo | - aSlotName _ Utilities inherentSelectorForGetter: aGetSelector. - (slotInfo _ self slotInfoAt: aSlotName ifAbsent: [nil]) ifNotNil: - [^ slotInfo arrowDelta]." - !
Item was added: + ----- Method: TileMorph>>decimalPlaces (in category 'mouse handling') ----- + decimalPlaces + "Answer the number of decimal places of the contained number" + + | readout | + (readout _ self findA: UpdatingStringMorph) ifNotNil: [^readout decimalPlaces ]. + ^0!
Item was changed: ----- Method: Player>>noteDecimalPlaces:forGetter: (in category 'misc') ----- noteDecimalPlaces: aNumber forGetter: aGetter "Note the given preference of decimal places for the given getter" + | slotInfo | + slotInfo _ self slotInfoAt: (Utilities inherentSelectorForGetter: aGetter). + slotInfo floatPrecision: (Utilities floatPrecisionForDecimalPlaces: aNumber). - costume noteDecimalPlaces: aNumber forGetter: aGetter!
Item was changed: ----- Method: TileMorph>>arrowDelta (in category 'mouse handling') ----- arrowDelta "Answer the amount by which a number I display should increase at a time"
+ | readout | + (readout _ self findA: UpdatingStringMorph) ifNotNil: [^readout floatPrecision ]. + ^1! - ^ self valueOfProperty: #arrowDelta ifAbsent: [1]!
Item was changed: ----- Method: Player>>setPrecisionFor: (in category 'slots-user') ----- setPrecisionFor: slotName "Set the precision for the given slot name"
| aList aMenu reply val aGetter places | aGetter := Utilities getterSelectorFor: slotName. + places := Utilities decimalPlacesForFloatPrecision: (self getPrecisionFor: slotName). - places := Utilities - decimalPlacesForFloatPrecision: (self defaultFloatPrecisionFor: aGetter). aList := #('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10'). aMenu := SelectionMenu labels: aList selections: (aList collect: [:m | m asNumber]). reply := aMenu startUpWithCaption: ('How many decimal places? (currently {1})' translated format: {places}). reply ifNotNil: [(self slotInfo includesKey: slotName) ifTrue: ["it's a user slot"
(self slotInfoAt: slotName) floatPrecision: (Utilities floatPrecisionForDecimalPlaces: reply). self class allInstancesDo: [:anInst | reply == 0 ifFalse: [((val := anInst instVarNamed: slotName asString) isInteger) ifTrue: [anInst instVarNamed: slotName asString put: val asFloat]]. anInst updateAllViewers]] ifFalse: ["it's specifying a preference for precision on a system-defined numeric slot"
self noteDecimalPlaces: reply forGetter: aGetter. self updateAllViewers]]!
Item was added: + ----- Method: Player>>getPrecisionFor: (in category 'slots-user') ----- + getPrecisionFor: slotName + "get the precision for the given slot name" + + | aGetter places precision | + precision _ 1. + (self slotInfo includesKey: slotName) + ifTrue: + ["it's a user slot" + precision _ (self slotInfoAt: slotName) floatPrecision] + ifFalse: + ["reference to system slots" + aGetter := Utilities getterSelectorFor: slotName. + self costume renderedMorph ifNotNilDo: [ :morph | + places _ morph decimalPlacesForGetter: aGetter. + precision _ Utilities floatPrecisionForDecimalPlaces: places ]]. + ^precision!
etoys-dev@lists.squeakfoundation.org