'From Squeak3.1alpha [latest update: #''Squeak3.1alpha'' of 28 February 2001 update 3939] on 20 April 2001 at 9:58:31 pm'! "Change Set: menuIconInViewer-sw Date: 20 April 2001 Author: Scott Wallace Use the classic Smalltalk 'menu' icon as the icon inviting a user click to bring up a menu (a) in the viewer header (b) on every content row of a viewer. Also, viewer rows for which a menu is not useful no longer show a menu icon. Also, as a debugging aid and to assist in getting preexisting viewers to feel the new look, adds a new item 'relaunch this Viewer' to a viewer's main menu."! !CategoryViewer methodsFor: 'entries' stamp: 'sw 4/20/2001 18:16'! infoButtonFor: aScriptOrSlotSymbol "Answer a fully-formed morph that will serve as the 'info button' alongside an entry corresponding to the given slot or script symbol. If no such button is appropriate, answer a transparent graphic that fills the same space." | aButton elementType | elementType _ scriptedPlayer elementTypeFor: aScriptOrSlotSymbol. elementType == #systemScript ifTrue: ["Fill the space with sweet nothing, since there is no meaningful menu to offer". aButton _ RectangleMorph new beTransparent extent: (17@20). aButton borderWidth: 0. ^ aButton]. aButton _ IconicButton new labelGraphic: Cursor menu. aButton target: scriptedPlayer; actionSelector: #infoFor:inViewer:; arguments: (Array with: aScriptOrSlotSymbol with: self); color: Color transparent; borderWidth: 0; shedSelvedge; actWhen: #buttonDown. aButton setBalloonText: 'Press here to get a menu'. ^ aButton! ! !Player methodsFor: 'misc' stamp: 'sw 4/20/2001 21:13'! offerViewerMenuFor: aViewer event: evt "Put up the Viewer menu on behalf of the receiver." | aMenu aWorld | aWorld _ aViewer world. aMenu _ MenuMorph new defaultTarget: self. costumes ifNotNil: [(costumes size > 1 or: [costumes size == 1 and: [costumes first ~~ costume renderedMorph]]) ifTrue: [aMenu add: 'forget other costumes' target: self selector: #forgetOtherCostumes]]. aMenu addLine. aMenu add: 'add a new instance variable' target: self action: #addInstanceVariable. aMenu add: 'add a new script' target: aViewer action: #newPermanentScript. aMenu addLine. aMenu add: 'expunge empty scripts' target: self action: #expungeEmptyScripts. aMenu add: 'browse etoy vocabulary' target: self action: #browseEToyVocabulary. Preferences universalTiles ifTrue: [aMenu add: 'choose vocabulary...' target: aViewer action: #chooseVocabulary]. "aMenu add: 'searching protocol browser' target: self action: #openSearchingProtocolBrowser." aMenu addLine. aMenu add: 'tile representing me' action: #tearOffTileForSelf. aMenu add: 'reveal me' target: self selector: #revealPlayerIn: argument: aWorld. aMenu add: 'grab me' target: self selector: #grabPlayerIn: argument: aWorld. aMenu addLine. aMenu add: 'inspect morph' target: costume selector: #inspect. aMenu add: 'inspect player' target: self selector: #inspect. self belongsToUniClass ifTrue: [aMenu add: 'browse class' target: self action: #browsePlayerClass. aMenu add: 'inspect class' target: self class action: #inspect]. aMenu add: 'relaunch this Viewer' target: aViewer action: #relaunchViewer. aMenu popUpEvent: evt in: aWorld ! ! !StandardViewer methodsFor: 'user interface' stamp: 'sw 4/20/2001 21:22'! relaunchViewer "Launch a new viewer to replace the receiver." self presenter updateViewer: self forceToShow: nil! ! !StandardViewer methodsFor: 'initialization' stamp: 'sw 4/20/2001 14:23'! addHeaderMorphWithBarHeight: anInteger includeDismissButton: aBoolean "Add the header morph to the receiver, using anInteger as a guide for its height, and if aBoolean is true, include a dismiss buton for it" | header aFont aButton aTextMorph nail wrpr costs headWrapper | header _ AlignmentMorph newRow color: self color muchLighter; wrapCentering: #center; cellPositioning: #leftCenter. aFont _ Preferences standardButtonFont. aBoolean ifTrue: [header addMorph: (aButton _ SimpleButtonMorph new label: 'O' font: aFont). aButton target: self; color: Color tan; actionSelector: #dismiss; setBalloonText: 'remove this entire Viewer from the screen don''t worry -- nothing will be lost!!.'. header addTransparentSpacerOfSize: 4@1]. aButton _ IconicButton new borderWidth: 0; labelGraphic: (ScriptingSystem formAtKey: #AddCategoryViewer); color: Color transparent; actWhen: #buttonDown; target: self; actionSelector: #addCategoryViewer; setBalloonText: 'click here to add another category pane'; shedSelvedge. header addMorphBack: aButton. header addTransparentSpacerOfSize: 4@1. costs _ scriptedPlayer costumes. costs ifNotNil: [(costs size > 1 or: [costs size = 1 and: [costs first ~~ scriptedPlayer costume]]) ifTrue: [header addUpDownArrowsFor: self. (wrpr _ header submorphs last) submorphs second setBalloonText: 'switch to previous costume'. wrpr submorphs first setBalloonText: 'switch to next costume']]. (self hasProperty: #noInteriorThumbnail) ifFalse: [nail _ ThumbnailMorph new objectToView: scriptedPlayer viewSelector: #costume] ifTrue: [nail _ ImageMorph new image: Cursor menu]. nail on: #mouseDown send: #offerViewerMenuForEvt:morph: to: scriptedPlayer. header addMorphBack: nail. nail setBalloonText: 'click here to get a menu that will allow you to add an instance variable,, tear off a tile, etc..'. (self hasProperty: #noInteriorThumbnail) ifFalse: [nail borderWidth: 3; borderColor: #raised]. header addTransparentSpacerOfSize: 5@5. " aButton _ SimpleButtonMorph new target: self; actionSelector: #newEmptyScript; label: 'S' font: (aFont _ StrikeFont familyName: #ComicBold size: 16); color: Color transparent; borderWidth: 0; actWhen: #buttonDown. aButton setBalloonText: 'drag from here to create a new script for this object'. header addMorphBack: aButton. header addTransparentSpacerOfSize: 8@5. aButton _ SimpleButtonMorph new target: scriptedPlayer; actionSelector: #addInstanceVariable; label: 'I' font: aFont; color: Color transparent; borderWidth: 0; actWhen: #buttonUp. aButton setBalloonText: 'click here to add an instance variable to this object.'. header addMorphBack: aButton. header addTransparentSpacerOfSize: 5@5." self viewsMorph ifTrue: [scriptedPlayer costume assureExternalName]. aTextMorph _ UpdatingStringMorph new useStringFormat; target: scriptedPlayer; getSelector: #nameForViewer; setNameTo: 'name'; font: ScriptingSystem fontForNameEditingInScriptor. self viewsMorph ifTrue: [aTextMorph putSelector: #setName:. aTextMorph setProperty: #okToTextEdit toValue: true]. aTextMorph step. header addMorphBack: aTextMorph. aTextMorph setBalloonText: 'Click here to edit the player''s name.'. header beSticky. anInteger > 0 ifTrue: [headWrapper _ AlignmentMorph newColumn color: self color. headWrapper addTransparentSpacerOfSize: (0 @ anInteger). headWrapper addMorphBack: header. self addMorph: headWrapper] ifFalse: [self addMorph: header]! !