'From etoys2.1 of 6 September 2007 [latest update: #1640] on 14 September 2007 at 8:10:21 pm'! "Change Set: Repaint-close-tk Date: 14 September 2007 Author: Ted Kaehler If you repaint, and then go to another page of a BookMorph, the object will not be visible. This bullet-proofs the code that tries to close the paintBox when the user tosses a painting that is not present. I thought I fixed it so that the click on the 'next' button of the BookMorph would end painting, but this does not seem to work now."! !SketchMorph methodsFor: 'menu' stamp: 'tk 9/14/2007 20:03'! editDrawingIn: aPasteUpMorph forBackground: forBackground "Edit an existing sketch." | w bnds sketchEditor pal aPaintTab aWorld aPaintBox tfx oldRefPt newRefPt | self world assureNotPaintingElse: [^self]. oldRefPt := self referencePositionInWorld. w := aPasteUpMorph world. w prepareToPaint. w displayWorld. self visible: false. ActiveHand eventRecorders do: [:er | er rememberPaintBoxSettingsAtRecordingOutset]. sketchEditor := SketchEditorMorph new. bnds := sketchEditor findBounds: self in: aPasteUpMorph forBackground: forBackground. "it saves refPtOffset" forBackground ifTrue: [sketchEditor setProperty: #background toValue: true]. w addMorphFront: sketchEditor. sketchEditor initializeFor: self inBounds: bnds pasteUpMorph: aPasteUpMorph. sketchEditor afterNewPicDo: [:aForm :aRect | self visible: true. self form: aForm. newRefPt := (sketchEditor valueOfProperty: #refPtOffset) - (aRect origin - bnds origin). self rotationCenter: newRefPt asFloatPoint / aRect extent. "a fraction of extent of the final sketch form" self position: (self rotationCenter * self extent) negated. tfx := aPasteUpMorph transformFrom: aPasteUpMorph world. "may have moved" "align reference points (rotation centers) with original sketch" self topRendererOrSelf position: (tfx globalPointToLocal: (oldRefPt - (newRefPt * (self extent / originalForm extent)))). 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: [(aWorld := self world) ifNil: [aWorld := ActiveWorld]. (aPaintTab := aWorld paintingFlapTab) ifNotNil: [aPaintTab hideFlap] ifNil: [(aPaintBox := aWorld paintBox) ifNotNil: [aPaintBox delete]]]]! !