'From etoys2.1 of 26 July 2007 [latest update: #1646] on 14 September 2007 at 5:05:24 pm'! "Change Set: nonPlayerViewer-sw Date: 14 September 2007 Author: Scott Wallace A few fixes to breathe a little life back into the 'Direct Viewer' -- i.e. a Viewer for a non-player object."! !CategoryViewer methodsFor: 'categories' stamp: 'sw 9/14/2007 10:45'! chooseCategory "The mouse went down on my category-list control; pop up a list of category choices" | aList aMenu reply aLinePosition lineList special | Cursor wait showWhile: [ aList _ (scriptedPlayer categoriesForViewer: self) asOrderedCollection. special := {ScriptingSystem nameForScriptsCategory. ScriptingSystem nameForInstanceVariablesCategory}. aList removeAllFoundIn: special. aList := special, aList. aLinePosition _ aList indexOf: #miscellaneous ifAbsent: [nil]. aList _ aList collect: [:aCatSymbol | self currentVocabulary categoryWordingAt: aCatSymbol]. lineList _ aLinePosition ifNil: [#(2)] ifNotNil: [Array with: 2 with: aLinePosition]. aMenu _ CustomMenu labels: aList lines: lineList selections: aList. reply _ aMenu startUpWithCaption: 'category' translated. reply ifNil: [^ self]. self chooseCategoryWhoseTranslatedWordingIs: reply asSymbol ]! ! !CategoryViewer methodsFor: 'support' stamp: 'sw 9/14/2007 16:58'! isSpecialPatchCase: aPlayer and: cmd "Boolean - Kedama hook - answer whether the player and command provided represent a 'special patch case'." aPlayer isPlayerLike ifFalse: [^ false]. ((aPlayer costume renderedMorph class = KedamaMorph) and: [cmd = #addToPatchDisplayList:]) ifTrue: [ ^ true. ]. (aPlayer costume renderedMorph class = KedamaPatchMorph) ifTrue: [ (#(#redComponentInto: #greenComponentInto: #blueComponentInto: #redComponentFrom: #greenComponentFrom: #blueComponentFrom:) includes: cmd) ifTrue: [ ^ true. ]. ]. (aPlayer costume renderedMorph class = KedamaTurtleMorph) ifTrue: [ (#(#colorFromPatch: #colorToPatch:) includes: cmd) ifTrue: [ ^ true. ]. ]. ^ false. ! ! !CategoryViewer methodsFor: 'support' stamp: 'sw 9/14/2007 16:59'! isSpecialPatchReceiver: aPlayer and: cmd "Boolean - Kedama hook - answer whether it's true both that the object provided is a Player whose costume is a KedamaPatchMorph AND that the command provided is one of six special Component commands such as #greenComponentFrom: " ^ aPlayer isPlayerLike and: [aPlayer costume renderedMorph class = KedamaPatchMorph] and: [ (#(#redComponentInto: #greenComponentInto: #blueComponentInto: #redComponentFrom: #greenComponentFrom: #blueComponentFrom:) includes: cmd)]. ! ! !PhraseTileMorph methodsFor: 'dropping/grabbing' stamp: 'sw 9/14/2007 16:59'! morphToDropInPasteUp: aPasteUp "Answer the morph to drop in aPasteUp, given that the receiver is the putative droppee" | actualObject itsSelector aScriptor pos aWatcher op | ((actualObject _ self actualObject) isNil or: [actualObject isPlayerLike not] or: [actualObject costume isInWorld not]) ifTrue: [^ ScriptingTileHolder around: self]. self isCommand ifFalse: "Can't expand to a scriptor, but maybe launch a watcher..." [^ (Preferences dropProducesWatcher and: [(#(unknown command) includes: self resultType) not] and: [(op _ self operatorTile operatorOrExpression) notNil] and: [op numArgs = 0] and: [(Vocabulary gettersForbiddenFromWatchers includes: op) not]) ifTrue: [aWatcher _ WatcherWrapper new fancyForPlayer: self associatedPlayer getter: op. aWatcher position: self position] ifFalse: [ScriptingTileHolder around: self]]. self justGrabbedFromViewer ifFalse: [^ ScriptingTileHolder around: self]. actualObject assureUniClass. itsSelector _ self userScriptSelector. pos _ self position. aScriptor _ itsSelector isEmptyOrNil ifFalse: [actualObject scriptEditorFor: itsSelector] ifTrue: ["It's a system-defined selector; construct an anonymous scriptor around it" actualObject newScriptorAround: self]. aScriptor ifNil:[^ ScriptingTileHolder around: self]. (self hasOwner: aScriptor) ifTrue:[ aScriptor fullBounds. "force layout" aScriptor position: pos - self position. ] ifFalse:[ aScriptor position: self position. ]. (aScriptor valueOfProperty: #needsLayoutFixed) ifNotNil: [ aScriptor removeProperty: #needsLayoutFixed. aScriptor fixLayout ]. ^ aScriptor! ! !PhraseTileMorph methodsFor: 'miscellaneous' stamp: 'sw 9/14/2007 11:03'! try "Evaluate the given phrase once" | aPlayer | (userScriptSelector notNil and: [userScriptSelector numArgs = 0]) ifTrue: [aPlayer _ self objectViewed player. aPlayer triggerScript: userScriptSelector] ifFalse: [[Compiler evaluate: self codeString for: self associatedPlayer logged: false] ifError: [self inform: 'evaluation error' translated]]! ! !PhraseTileMorph methodsFor: 'kedama' stamp: 'sw 9/14/2007 16:59'! replacePlayerWith: aPlayer "Kedama hook." | tile patch | aPlayer isPlayerLike ifFalse: [^ self]. aPlayer isPrototypeTurtlePlayer ifTrue: [ tile _ self firstMorphBearingKedamaPlayer. tile ifNil: [^ self]. (tile isMemberOf: TileMorph) ifFalse: [^ self]. tile type = #objRef ifFalse: [^ self]. tile referToSimilarObject: aPlayer. patch _ aPlayer costume renderedMorph kedamaWorld defaultPatch player. ] ifFalse: [ (aPlayer costume renderedMorph isMemberOf: KedamaPatchMorph) ifTrue: [ patch _ aPlayer. ] ifFalse: [^ self]. ]. self allMorphsDo: [:e | ((e isMemberOf: UpdatingStringMorph) or: [e isMemberOf: UpdatingRectangleMorph]) ifTrue: [ e target isPlayerLike ifTrue: [ e target costume renderedMorph class = aPlayer costume renderedMorph class ifTrue: [ e target: aPlayer ]. ]. ]. (e isMemberOf: KedamaPatchTile) ifTrue: [ e usePatch: patch. ]. ].! ! !StandardViewer methodsFor: 'initialization' stamp: 'sw 9/14/2007 16:59'! initializeFor: aPlayer barHeight: anInteger includeDismissButton: aBoolean showCategories: categoryInfo "Initialize the receiver to be a look inside the given Player. The categoryInfo, if present, describes which categories should be present in it, in which order" scriptedPlayer _ aPlayer. self listDirection: #topToBottom; hResizing: #shrinkWrap; vResizing: #shrinkWrap; layoutInset: 3; cellInset: 3; borderWidth: 1. self color: ScriptingSystem baseColor. self borderColor: ScriptingSystem borderColor. self addHeaderMorphWithBarHeight: anInteger includeDismissButton: aBoolean. categoryInfo isEmptyOrNil ifFalse: "Reincarnating an pre-existing list" [categoryInfo do: [:aCat | self addCategoryViewerFor: aCat]] ifTrue: "starting fresh" [self addSearchPane. self addCategoryViewer. self addCategoryViewer. (self categoriesCurrentlyShowing includes: ScriptingSystem nameForInstanceVariablesCategory translated) ifTrue: [self addCategoryViewer]. (self categoriesCurrentlyShowing includes: ScriptingSystem nameForScriptsCategory translated) ifTrue: [self addCategoryViewer]. (scriptedPlayer isPlayerLike and: [scriptedPlayer costume isMemberOf: KedamaMorph])ifTrue: [self addCategoryViewer]] ! ! !TextMorph methodsFor: 'private' stamp: 'sw 9/14/2007 11:01'! releaseParagraphReally "a slight kludge so subclasses can have a bit more control over whether the paragraph really gets released. important for GeeMail since the selection needs to be accessible even if the hand is outside me" "Paragraph instantiation is lazy -- it will be created only when needed" self releaseEditor. paragraph ifNotNil: [paragraph _ nil]. container ifNotNil: [container isMorph ifTrue: [container releaseCachedState]]! !