'From Squeak3.1alpha of 5 February 2001 [latest update: #3578] on 12 February 2001 at 10:29:49 pm'! "Change Set: specialTiles-sw Date: 12 February 2001 Author: Scott Wallace Addresses some difficulties involving the various unaffiliated special tiles such as random-number-tiles which became impaired after the advent of generic layouts. After this update, the special tiles found on the final page of the Standard Parts Bin will now again be of the correct size, and the Random-number tile will again be capable of being picked up and dropped down. Also, the three most frequently-needed special tiles -- namely, the random, button-down, and button-up tiles, can now be obtained from the main menu of any ScriptEditorMorph."! !Presenter methodsFor: 'palette & parts bin' stamp: 'sw 2/12/2001 22:02'! systemQueryPhraseWithActionString: anActionString labelled: aLabel "Answer a SystemQueryPhrase with the given action string and label" | aTile aPhrase | aPhrase _ SystemQueryPhrase new. aTile _ BooleanTile new. aTile setExpression: anActionString label: aLabel. aPhrase addMorph: aTile. aPhrase enforceTileColorPolicy. ^ aPhrase! ! !Presenter methodsFor: 'palette & parts bin' stamp: 'sw 2/12/2001 21:31'! tilesPagesForPartsBin "Answer a list of pages holding tiles for the Parts Bin. At present, there is only one page" | aPage bools aTile aPhrase | aPage _ self newPageForStandardPartsBin padding: 30. aPage cellInset: 10 @ 10; listSpacing: #equal. bools _ self booleanTiles. aPage addMorphBack: bools first markAsPartsDonor. aPage addMorphBack: bools last markAsPartsDonor. aPage addMorphBack: self arithmeticTiles first markAsPartsDonor. aPage addMorphBack: RandomNumberTile new markAsPartsDonor. #(('(Sensor anyButtonPressed)' 'button down?') ('(Sensor noButtonPressed)' 'button up?') "('(Sensor keyboardPressed)' 'key hit?') sucker doesn't work for some reason") do: [:pair | aPhrase _ SystemQueryPhrase new. aTile _ BooleanTile new. aTile setExpression: pair first label: pair second. aPhrase addMorph: aTile. aPage addMorphBack: aPhrase]. aPage enforceTileColorPolicy. aPage replaceTallSubmorphsByThumbnails. ^ OrderedCollection with: aPage "room to grow"! ! !Presenter methodsFor: 'tile support' stamp: 'sw 2/12/2001 21:30'! phraseForReceiver: rcvr op: op arg: arg resultType: resultType "Answer a PhraseTileMorph affiliated with the given receiver, initialized to hold the given operator, argument, and result type" | m argTile rcvrTile | arg == nil ifTrue: [m _ PhraseTileMorph new setOperator: op type: resultType rcvrType: (self typeForConstant: rcvr)] ifFalse: [m _ PhraseTileMorph new setOperator: op type: resultType rcvrType: (self typeForConstant: rcvr) argType: (self typeForConstant: arg). argTile _ self constantTile: arg. argTile position: m lastSubmorph position. m lastSubmorph addMorph: argTile]. rcvrTile _ self constantTile: rcvr. " TilePadMorph makeReceiverColorOfResultType ifTrue: [rcvrTile color: m color]." rcvrTile position: m firstSubmorph position. m firstSubmorph addMorph: rcvrTile. m vResizing: #shrinkWrap. ^ m! ! !RandomNumberTile methodsFor: 'initialization' stamp: 'sw 2/12/2001 21:00'! initialize "Initialize the receiver fully, including adding all its relevant submorphs" | m1 m2 | super initialize. self vResizing: #shrinkWrap. self typeColor: (ScriptingSystem colorForType: #number). self addArrows. m1 _ StringMorph contents: 'random' font: ScriptingSystem fontForTiles. self addMorph: m1. m2 _ UpdatingStringMorph contents: '180' font: ScriptingSystem fontForTiles. m2 target: self; getSelector: #literal; putSelector: #literal:. m2 position: m1 topRight. self addMorphBack: m2. literal _ 180. self updateLiteralLabel! ! !RandomNumberTile methodsFor: 'as yet unclassified' stamp: 'sw 2/12/2001 21:41'! handlesMouseDown: evt "Answer whether the receiver would handle the mouseDown represented by evt" ^ self inPartsBin ifTrue: [false] ifFalse: [super handlesMouseDown: evt]! ! !ScriptEditorMorph methodsFor: 'other' stamp: 'sw 2/12/2001 21:59'! handUserButtonDownTile "Hand the user a button-down tile, presumably to drop in the script" self currentHand attachMorph: (self presenter systemQueryPhraseWithActionString: '(Sensor anyButtonPressed)' labelled: 'button down?') ! ! !ScriptEditorMorph methodsFor: 'other' stamp: 'sw 2/12/2001 22:07'! handUserButtonUpTile "Hand the user a button-up tile, presumably to drop in the script" self currentHand attachMorph: (self presenter systemQueryPhraseWithActionString: '(Sensor noButtonPressed)' labelled: 'button up?') ! ! !ScriptEditorMorph methodsFor: 'other' stamp: 'sw 2/12/2001 21:50'! handUserRandomTile "Hand the user a random-number tile, presumably to drop in the script" self currentHand attachMorph: RandomNumberTile new markAsPartsDonor makeAllTilesGreen ! ! !ScriptEditorMorph methodsFor: 'other' stamp: 'sw 2/12/2001 22:24'! offerScriptorMenu "Put up a menu in response to the user's clicking in the menu-request area of the scriptor's heaer" | aMenu count | self modernize. aMenu _ MenuMorph new defaultTarget: self. aMenu addTitle: scriptName asString. count _ self savedTileVersionsCount. self showingMethodPane ifFalse: "currently showing tiles" [aMenu add: 'show code textually' action: #showSourceInScriptor. count > 0 ifTrue: [aMenu add: 'revert to tile version...' action: #revertScriptVersion]. aMenu add: 'save this version' action: #saveScriptVersion] ifTrue: "current showing textual source" [count >= 1 ifTrue: [aMenu add: 'revert to tile version' action: #revertToTileVersion]. aMenu add: 'make tiles from this code' action: #recreateTileVersion]. Preferences noviceMode ifFalse: ["just for now, not for kids" aMenu add: 'use new universal tiles' action: #useNewTiles]. aMenu addList: #( - ('destroy this script' destroyScript) ('rename this script' renameScript) ('button to fire this script' tearOfButtonToFireScript) ('edit balloon help for this script' editMethodDescription) - ('fires per tick...' chooseFrequency) ('explain status alternatives' explainStatusAlternatives) - ('hand me a tile for self' tileForSelf) ('hand me a "random number" tile' handUserRandomTile) ('hand me a "button down?" tile' handUserButtonDownTile) ('hand me a "button up?" tile' handUserButtonUpTile) ). aMenu popUpInWorld: self currentWorld. " ('add parameter to this script' addParameter)" ! ! !SystemQueryPhrase methodsFor: 'initialization' stamp: 'sw 2/12/2001 21:30'! initialize "Initialize the receiver. In this case we primarily seek to undo the damage done by inherited implementors of #initialize" super initialize. self removeAllMorphs. resultType _ #boolean. self vResizing: #shrinkWrap! ! "Postscript:" ScriptingSystem resetStandardPartsBin. !