Squeak Class Documentation category index | class index  
 
SketchEditorMorph
  category: Morphic-Support
  superclass: Morph
  subclasses:

Inst vars (converting to morphic events)
hostView -- SketchMorph we are working on.
stampForm -- Stamp is stored here.
canvasRectangle -- later use bounds
palette -- the PaintBox interface Morph
dirty -- not used
currentColor
ticksToDwell rotationCenter registrationPoint
newPicBlock -- do this after painting
action -- selector of painting action
paintingForm -- our copy
composite -- now paintArea origin. world relative. stop using it.
dimForm -- SketchMorph of the dimmed background. Opaque.
installed behind the editor morph.
buff
brush -- 1-bit Form of the brush,
paintingFormPen
formCanvas -- Aim it at paintingForm to allow it to draw ovals, rectangles, lines, etc.
picToComp dimToComp compToDisplay -- used to composite -- obsolete
picToBuff brushToBuff buffToBuff buffToPic
rotationButton scaleButton -- submorphs, handles to do these actions.
strokeOrigin -- During Pickup, origin of rect.
cumRot cumMag -- cumulative for multiple operations from same original
undoBuffer
lastEvent
currentNib -- 1 bit deep form.


For now, we do not carry the SketchMorph's registration point, rotation center, or ticksToDwell.

New -- using transform morphs to rotate the finished player. How get it rotated back and the rotationDegrees to be right? We cancel out rotationDegrees, so how remember it?

Registration point convention:
In a GraphicFrame, reg point is relative to this image's origin.
During painting, it is relative to canvasRectangle origin, and thus us absolute within the canvas. To convert back, subract newBox origin.

Be sure to convert back and forth correctly. In deliverPainting. initializeFromFrame:inView:

instance methods
  Nebraska support
  get:for:
getActionFor:
getBrushFor:
getColorFor:
getCursorFor:
getNibFor:
set:for:to:
valuesForHand:
valuesForHandIfPresent:

  access
  enclosingPasteUpMorph
forwardDirection
hostView
painting
palette
registrationPoint
registrationPoint:
rotationStyle
ticksToDwell
ticksToDwell:

  actions & preps
  clear
ellipse:
erase:
erasePrep:
fill:
flipHoriz:
flipVert:
forward:direction:
line:
notes
paint:
pickup:
pickupMouseUp:
polyEdit:
polyEditing
polyEditing:
polyFreeze
polyNew:
polygon:
rect:
render:
replaceOnly:
restoreRect:
rotateBy:
rotateDone:
rotateScalePrep:
scaleBy:
shiftConstrainPoint:
showDirType
stamp:
star:
toggleDirType:in:

  copying
  veryDeepFixupWith:
veryDeepInner:

  initialization
  initialize
initializeFor:inBounds:pasteUpMorph:
initializeFor:inBounds:pasteUpMorph:paintBoxPosition:

  morphic
  drawOn:
handlesMouseDown:
mouseDown:
mouseEnter:
mouseEnterDragging:
mouseLeave:
mouseLeaveDragging:
mouseMove:
mouseUp:

  palette handling
  cancelPainting:evt:
clearPainting:
dimTheWindow
paintBoxChanged:
paletteAttached:
paletteDetached:
savePainting:evt:
undoPainting:evt:

  start & finish
  addRotationScaleHandles
afterNewPicDo:ifNoBits:
cancel:
cancelOutOfPainting
deleteSelfAndSubordinates
deliverPainting:evt:
handlesMouseOver:
handlesMouseOverDragging:
prepareToPaint:
save:
setRotations:
undo:
verifyState:

class methods
  instance creation
  includeInNewMorphMenu

instance methods
  Nebraska support top  
 

get:for:


 

getActionFor:


 

getBrushFor:


 

getColorFor:


 

getCursorFor:


 

getNibFor:


 

set:for:to:


 

valuesForHand:


 

valuesForHandIfPresent:


  access top  
 

enclosingPasteUpMorph


 

forwardDirection

The direction object will go when issued a sent forward:. Up is
zero. Clockwise like a compass. From the arrow control.


 

hostView


 

painting


 

palette


 

registrationPoint


 

registrationPoint:


 

rotationStyle

Return the 'rotation style' of the receiver


 

ticksToDwell


 

ticksToDwell:


  actions & preps top  
 

clear

wipe out all the paint


 

ellipse:

Draw an ellipse from the center.


 

erase:

Pen is set up to draw transparent squares


 

erasePrep:

Transparent paint, square brush. Be careful not to let this be undone by asking palette for brush and color.


 

fill:

Find the area that is the same color as where you clicked. Fill it with
the current paint color.


 

flipHoriz:

Flip the image


 

flipVert:

Flip the image


 

forward:direction:

Move the forward direction arrow of this painting. When the user
says forward:, the object moves in the direction of the arrow. evt may be
an Event (from the user moving the arrow), or an initial number ofdegrees.


 

line:

Draw a line on the paintingForm using formCanvas aimed at it.


 

notes


Singleton costumes.
Registration points


 

paint:

While the mouse is down, lay down paint, but only within window bounds.
11/28/96 sw: no longer stop painting when pen strays out of window; once it comes back in, resume painting rather than waiting for a mouse up


 

pickup:

Grab a part of the picture (or screen) and store it in a known place. Note where we started. Use a rubberband rectangle to show what is being selected.


 

pickupMouseUp:

Grab a part of the picture (or screen) and store it in a known place. Like Copy on the Mac menu. Then switch to the stamp tool.


 

polyEdit:

Add handles and let user drag'em around


 

polyEditing


 

polyEditing:


 

polyFreeze

A live polygon is on the painting. Draw it into the painting and
delete it.


 

polyNew:

Create a new polygon. Add it to the sketch, and let the user drag
its vertices around! Freeze it into the painting when the user chooses
another tool.


 

polygon:


 

rect:

While moving corner, just write on the canvas. When done, write
on the paintingForm


 

render:

Compose the damaged area again and store on the display. damageRect is relative to paintingForm origin. 3/19/97 tk


 

replaceOnly:

Paint replacing only one color! Call this each stroke. Also works for replacing all but one color.


 

restoreRect:

Restore the given rectangular area of the painting Form from the undo buffer.


 

rotateBy:

Left-right is rotation. 3/26/97 tk Slider at top of window. 4/3/97 tk


 

rotateDone:

MouseUp, snap box back to center.


 

rotateScalePrep:

Make a source that is the paintingForm. Work from that. 3/26/97 tk


 

scaleBy:

up-down is scale. 3/26/97 tk Now a slider on the right.


 

shiftConstrainPoint:

answer a point with x and y equal for shift-constrained drawing


 

showDirType

Display the proper symbol for this direction type. rotationStyle
is one of #(normal leftRight upDown none).


 

stamp:

plop one copy of the user's chosen Form down.


 

star:

Draw an star from the center.


 

toggleDirType:in:

Toggle from 'rotate' to 'to and fro' to 'up and down' to 'none'
for the kind of rotation the object does. An actor's rotationStyle is one
of #(normal leftRight upDown none).


  copying top  
 

veryDeepFixupWith:

If target and arguments fields were weakly copied, fix them here. If they were in the tree being copied, fix them up, otherwise point to the originals!!


 

veryDeepInner:

Copy all of my instance variables. Some need to be not copied at all, but shared. Warning!! Every instance variable defined in this class must be handled. We must also implement veryDeepFixupWith:. See DeepCopier class comment.


  initialization top  
 

initialize


 

initializeFor:inBounds:pasteUpMorph:


 

initializeFor:inBounds:pasteUpMorph:paintBoxPosition:

NB: if aPosition is nil, then it's assumed that the paintbox is obtained from a flap or some such, so do nothing special regarding a palette in this case. The palette needs already to be in the world for this to work.


  morphic top  
 

drawOn:

Put the painting on the display


 

handlesMouseDown:

Do I want to receive mouseDown events (mouseDown:, mouseMove:, mouseUp:)?


 

mouseDown:

Start a new stroke. Check if any palette setting have changed. 6/11/97 20:30 tk


 

mouseEnter:

Set the cursor. Reread colors if embedded editable polygon needs it.


 

mouseEnterDragging:

Test button state elsewhere if at all


 

mouseLeave:

Revert to the normal hand cursor.


 

mouseLeaveDragging:

Test button state elsewhere if at all


 

mouseMove:

In the middle of drawing a stroke. 6/11/97 19:51 tk


 

mouseUp:

Do nothing except those that work on mouseUp.


  palette handling top  
 

cancelPainting:evt:

Undo the operation after user issued #cancel in aPaintBoxMorph


 

clearPainting:

Clear the image after user issued #clear in aPaintBoxMorph


 

dimTheWindow

Updated to use TranslucentColor by kfr 10/5 00


 

paintBoxChanged:


 

paletteAttached:

A new palette has been attached to the receiver.
Don't know what to do here...


 

paletteDetached:

The palette has been detached to the receiver.
Don't know what to do here....


 

savePainting:evt:

Save the image after user issued #keep in aPaintBoxMorph


 

undoPainting:evt:

Undo the operation after user issued #undo in aPaintBoxMorph


  start & finish top  
 

addRotationScaleHandles

Rotation and scaling handles


 

afterNewPicDo:ifNoBits:

If the user said 'Save' at the end of drawing, do this block to save the picture.
goodBlock takes 2 args, the painted form and the bounding rectangle of its bits.
badBlock takes no args.


 

cancel:

Palette is telling us that the use wants to end the painting session.


 

cancelOutOfPainting


 

deleteSelfAndSubordinates

Delete the receiver and, if it has one, its subordinate dimForm


 

deliverPainting:evt:

Done painting. May come from resume, or from original call. Execute user's post painting instructions in the block. Always use this standard one. 4/21/97 tk


 

handlesMouseOver:

Do I want to receive mouseEnter: and mouseLeave: when the button is up and the hand is empty? The default response is false, except if you have added sensitivity to mouseEnter: or mouseLeave:, using the on:send:to: mechanism.


 

handlesMouseOverDragging:

Return true if I want to receive mouseEnterDragging: and mouseLeaveDragging: when the hand drags something over me (button up or button down), or when the mouse button is down but there is no mouseDown recipient. The default response is false, except if you have added sensitivity to mouseEnterLaden: or mouseLeaveLaden:, using the on:send:to: mechanism.


 

prepareToPaint:

Figure out what the current brush, fill, etc is. Return an action to take every mouseMove. Set up instance variable and pens. Prep for normal painting is inlined here. tk 6/14/97 21:11


 

save:

Palette is telling us that the use wants to end the painting session.


 

setRotations:

Tell the palette what number of rotations (or background) to show.


 

undo:

revert to a previous state.


 

verifyState:

We are sure we will make a mark now. Make sure the palette has not changed state while we were away. If so, end this action and start another one. 6/11/97 19:52 tk action, currentColor, brush


class methods
  instance creation top  
 

includeInNewMorphMenu

Not to be instantiated from the menu