'From Squeakland 3.8.5976 of 25 August 2004 [latest update: #386] on 12 January 2005 at 4:16:22 pm'! "Change Set: SymbolTransFirstAttempt Date: 12 January 2005 Author: Yoshiki Ohshima Just a proof of concept of alternative way to translate the symbols and literal values."! RectangleMorph subclass: #TileMorph instanceVariableNames: 'type slotName literal operatorOrExpression actualObject downArrow upArrow suffixArrow typeColor lastArrowTick nArrowTicks operatorReadoutString possessive retractArrow vocabulary vocabularySymbol' classVariableNames: 'DownPicture RetractPicture SuffixArrowAllowance SuffixPicture UpArrowAllowance UpPicture UpdatingOperators' poolDictionaries: '' category: 'Morphic-Scripting Tiles'! !SelectionMenu class methodsFor: 'instance creation' stamp: 'yo 1/12/2005 14:52'! selectionsString: selectionsArray "Answer an instance of me whose labels and selections are identical." ^ self selectionsString: selectionsArray lines: nil! ! !SelectionMenu class methodsFor: 'instance creation' stamp: 'yo 1/12/2005 14:52'! selectionsString: selectionsArray lines: linesArray "Answer an instance of me whose labels and selections are identical." ^ self labelList: (selectionsArray) lines: linesArray selections: selectionsArray! ! !TileMorph methodsFor: 'mouse handling' stamp: 'yo 1/12/2005 15:01'! showOptions "The receiver is a tile that represents an operator; a click on the receiver's label will pop up a menu of alternative operator choices" | result menuChoices | menuChoices _ self options first collect: [:each | each asString translated]. result _ (SelectionMenu selectionsString: menuChoices) startUp. result _ self options first at: (menuChoices indexOf: result ifAbsent: [1]). result ifNotNil: [self value: result. self scriptEdited]! ! !SoundTile methodsFor: 'initialization' stamp: 'yo 1/12/2005 15:04'! initialize "Initialize the state of the receiver. Pick the croak sound if available, otherwise any sound." | soundChoices startingSoundName | super initialize. soundChoices _ SoundService default sampledSoundChoices. startingSoundName _ (soundChoices includes: 'croak') ifTrue: ['croak'] ifFalse: [[soundChoices anyOne] ifError: ['silence']]. self addArrows; setLiteral: startingSoundName. self labelMorph useSymbolFormat! ! !SymbolListTile methodsFor: 'player viewer' stamp: 'yo 1/12/2005 14:28'! updateLiteralLabel "Update the wording emblazoned on the tile, if needed. Copied down, for jimmying, unfortunately" | myLabel | (myLabel _ self labelMorph) ifNil: [^ self]. myLabel useSymbolFormat. myLabel acceptValue: literal asString. self changed.! ! !SymbolListTile methodsFor: 'user interface' stamp: 'yo 1/12/2005 14:38'! acceptNewLiteral: aLiteral "Accept the new literal" self labelMorph useSymbolFormat. self literal: aLiteral. self adjustHelpMessage. self acceptNewLiteral. "so tile scriptor can recompile if necessary" self labelMorph informTarget ! ! !SymbolListTile methodsFor: 'private' stamp: 'yo 1/12/2005 14:28'! line1: line1 "Emblazon the receiver with the requested label. If the receiver already has a label, make the new label be of the same class" super line1: line1. self labelMorph useSymbolFormat! ! !UpdatingStringMorph methodsFor: 'accessing' stamp: 'yo 1/12/2005 14:38'! valueFromContents "Return a new value from the current contents string." " | expression tilePadMorphOrNil asNumberBlock | asNumberBlock _ [:string | [string asNumber] on: Error do: []]. format = #string ifTrue: [^ contents]. (format = #default and: [self owner isKindOf: NumericReadoutTile]) ifTrue: [^ asNumberBlock value: contents]. tilePadMorphOrNil _ self ownerThatIsA: TilePadMorph. (tilePadMorphOrNil notNil and: [tilePadMorphOrNil type = #Number]) ifTrue: [^ asNumberBlock value: contents]. expression _ Vocabulary eToyVocabulary translationKeyFor: contents. expression isNil ifTrue: [expression _ contents]. ^ Compiler evaluate: expression " format = #symbol ifTrue: [^ lastValue]. format = #string ifTrue: [^ contents]. ^ Compiler evaluate: contents ! ! !UpdatingStringMorph methodsFor: 'formats' stamp: 'yo 1/12/2005 14:28'! useSymbolFormat format _ #symbol.! ! !UpdatingStringMorph methodsFor: 'target access' stamp: 'yo 1/12/2005 14:27'! acceptValueFromTarget: v "Accept a value from the target" self flag: #yo. "we may want to translate the v asString result." lastValue _ v. self format == #string ifTrue: [^ v asString]. self format == #symbol ifTrue: [^ v asString translated]. (format == #default and: [v isNumber]) ifTrue: [^ v printShowingDecimalPlaces: self decimalPlaces]. ^ v printString translated. ! !