'From Squeak3.5 of ''11 April 2003'' [latest update: #5180] on 31 May 2003 at 12:45 pm'! !PasteUpMorph methodsFor: 'world menu' stamp: 'sumim 5/27/2003 01:19'! makeNewDrawing: evt at: aPoint "make a new drawing, triggered by the given event, with the painting area centered around the given point" | w newSketch newPlayer sketchEditor aPaintBox aPalette tfx whereToPresent rect ownerBeforeHack aPaintTab aWorld | w _ self world. w assureNotPaintingElse: [^ self]. rect _ self paintingBoundsAround: aPoint. aPalette _ self standardPalette. aPalette ifNotNil: [aPalette showNoPalette; layoutChanged]. w prepareToPaint. newSketch _ self drawingClass new player: (newPlayer _ UnscriptedPlayer newUserInstance). newPlayer costume: newSketch. newSketch nominalForm: (Form extent: rect extent depth: w assuredCanvas depth). newSketch bounds: rect. sketchEditor _ SketchEditorMorph new. w addMorphFront: sketchEditor. sketchEditor initializeFor: newSketch inBounds: rect pasteUpMorph: self. (aPaintTab _ (aWorld _ self world) paintingFlapTab) ifNotNil: [aPaintTab referent comeToFront] ifNil: [(aPaintBox _ aWorld paintBox) ifNotNil:[aPaintBox comeToFront]]. sketchEditor afterNewPicDo: [:aForm :aRect | whereToPresent _ self presenter. newSketch form: aForm. tfx _ self transformFrom: w. newSketch position: (tfx globalPointToLocal: aRect origin). newSketch rotationStyle: sketchEditor rotationStyle. newSketch forwardDirection: sketchEditor forwardDirection. ownerBeforeHack _ newSketch owner. "about to break the invariant!!!!" newSketch privateOwner: self. "temp for halo access" newPlayer setHeading: sketchEditor forwardDirection. (aPaintTab _ (aWorld _ self world) paintingFlapTab) ifNotNil:[aPaintTab hideFlap] ifNil:[(aPaintBox _ aWorld paintBox) ifNotNil:[aPaintBox delete]]. "Includes newSketch rotationDegrees: sketchEditor forwardDirection." newSketch privateOwner: ownerBeforeHack. "probably nil, but let's be certain" self addMorphFront: newPlayer costume. w startSteppingSubmorphsOf: newSketch. whereToPresent drawingJustCompleted: newSketch] ifNoBits:[ (aPaintTab _ (aWorld _ self world) paintingFlapTab) ifNotNil:[aPaintTab hideFlap] ifNil:[(aPaintBox _ aWorld paintBox) ifNotNil:[aPaintBox delete]]. aPalette ifNotNil: [aPalette showNoPalette].]! ! !SketchMorph methodsFor: 'menu' stamp: 'sumim 5/27/2003 01:16'! editDrawingIn: aPasteUpMorph forBackground: forBackground | w bnds sketchEditor pal aPaintTab aWorld aPaintBox tfx | self world assureNotPaintingElse: [^ self]. w _ aPasteUpMorph world. w prepareToPaint. w displayWorld. self visible: false. forBackground ifTrue: [bnds _ aPasteUpMorph boundsInWorld] ifFalse: [bnds _ (self boundsInWorld expandBy: (60 @ 60)). bnds _ (aPasteUpMorph paintingBoundsAround: bnds center) merge: bnds]. sketchEditor _ SketchEditorMorph new. forBackground ifTrue: [sketchEditor setProperty: #background toValue: true]. w addMorphFront: sketchEditor. sketchEditor initializeFor: self inBounds: bnds pasteUpMorph: aPasteUpMorph. (aPaintTab _ (aWorld _ self world) paintingFlapTab) ifNotNil: [aPaintTab referent comeToFront] ifNil:[(aPaintBox _ aWorld paintBox) ifNotNil: [aPaintBox comeToFront]]. sketchEditor afterNewPicDo: [:aForm :aRect | self visible: true. self form: aForm. tfx _ aPasteUpMorph transformFrom: aPasteUpMorph world. self topRendererOrSelf position: (tfx globalPointToLocal: aRect origin). self rotationStyle: sketchEditor rotationStyle. self forwardDirection: sketchEditor forwardDirection. (aPaintTab _ (aWorld _ self world) paintingFlapTab) ifNotNil:[aPaintTab hideFlap] ifNil:[(aPaintBox _ aWorld paintBox) ifNotNil:[aPaintBox delete]]. self presenter drawingJustCompleted: self. forBackground ifTrue: [self goBehind]] "shouldn't be necessary" ifNoBits: ["If no bits drawn. Must keep old pic. Can't have no picture" self visible: true. aWorld _ self currentWorld. "sometimes by now I'm no longer in a world myself, but we still need to get ahold of the world so that we can deal with the palette" ((pal _ aPasteUpMorph standardPalette) notNil and: [pal isInWorld]) ifTrue: [(aPaintBox _ aWorld paintBox) ifNotNil: [aPaintBox delete]. pal viewMorph: self] ifFalse:[ (aPaintTab _ (aWorld _ self world) paintingFlapTab) ifNotNil:[aPaintTab hideFlap] ifNil:[(aPaintBox _ aWorld paintBox) ifNotNil:[aPaintBox delete]]]]! !