'From etoys2.2 of 24 September 2007 [latest update: #1678] on 1 October 2007 at 3:39:21 pm'! "Change Set: graphPaperPickers-sw Date: 1 October 2007 Author: Scott Wallace TRAC 2870: Use appropriate color pickers for constructing graph paper, and position them appropriately"! !Morph methodsFor: 'e-toy support' stamp: 'sw 8/16/2007 23:49'! chosenColor: aColor "Temporarily remember a color in a property named chosenColor" self setProperty: #chosenColor toValue: aColor! ! !Morph methodsFor: 'e-toy support' stamp: 'sw 10/1/2007 15:38'! makeGraphPaper "Undertake interaction to define graph paper." | smallGrid backColor lineColor gridString | gridString := FillInTheBlank request: 'Enter grid size' translated initialAnswer: '16'. gridString isEmptyOrNil ifTrue: [^ self]. smallGrid := gridString asIntegerIfAllDigits. (smallGrid isNil or: [smallGrid = 0]) ifTrue: [^ self]. Utilities informUser: 'Choose a background color' translated during: [self changeColorTarget: self selector: #chosenColor: originalColor: Color yellow hand: ActiveHand showPalette: true]. backColor := self valueOfProperty: #chosenColor. Utilities informUser: 'Choose a line color' translated during: [self changeColorTarget: self selector: #chosenColor: originalColor: Color black hand: ActiveHand showPalette: true]. lineColor := self valueOfProperty: #chosenColor. self removeProperty: #chosenColor. self makeGraphPaperGrid: smallGrid background: backColor line: lineColor! ! !Morph methodsFor: 'meta-actions' stamp: 'sw 8/17/2007 00:22'! changeColorTarget: anObject selector: aSymbol originalColor: aColor hand: aHand showPalette: showPalette "Put up a color picker for changing some kind of color. May be modal or modeless, depending on #modalColorPickers setting" | c aRectangle | self flag: #arNote. "Simplify this due to anObject == self for almost all cases" c _ ColorPickerMorph new. c choseModalityFromPreference; sourceHand: aHand; target: anObject; selector: aSymbol; originalColor: aColor. showPalette ifFalse: [c initializeForJustCursor]. aRectangle := (anObject == ActiveWorld) ifTrue: [ActiveHand position extent: (20@20)] ifFalse: [anObject isMorph ifFalse: [Rectangle center: self position extent: (20@20)] ifTrue: [anObject fullBoundsInWorld]]. c putUpFor: anObject near: aRectangle! ! !String methodsFor: 'converting' stamp: 'sw 10/1/2007 15:37'! asIntegerIfAllDigits "If the receiver consists entirely of digits, answer the integer represented, else answer nil. Because of the all-digits requirement, a negative result is impossible." ^ self isAllDigits ifTrue: [self asNumber] ifFalse: [nil] " '123.4' asIntegerIfAllDigits '2345678901234' asIntegerIfAllDigits '-234' asIntegerIfAllDigits '02398' asIntegerIfAllDigits "! !