Relationship between Morph and Canvas

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Relationship between Morph and Canvas

nacho
Hi,
I've been digging and inspecting all the classes related to Morphic. But there's something that I don't happen to figure out.
Morph has a method
drawOn: aCanvas
        aCanvas fillRectangle: self bounds fillStyle: self fillStyle borderStyle: self borderStyle


Which if it's not overridden by a subclass of Morph makes it possible to still instantiate a Morph -the classic blue rectangle.

Now aCanvas is obviously an instance of FormCanvas or some other subclasses of Canvas.
But the question is, where does Morph create such instance of FormCanvas?
How does this work? I'm getting all wrong?
I read the documentation available but I can't grasp it from what I have read.
Thanks in advance for your help
best
Nacho
Nacho Smalltalker apprentice. Buenos Aires, Argentina.
Reply | Threaded
Open this post in threaded view
|

Re: Relationship between Morph and Canvas

Sean P. DeNigris
Administrator
nacho wrote
But the question is, where does Morph create such instance of FormCanvas?
#drawOn: -> senders incl. WorldState>>#drawWorld:submorphs:invalidAreasOn: -> senders incl. WorldState>>#drawWorld:submorphs:invalidAreasOn:, whose implementation sends #assuredCanvas... hmm that sounds interesting -> implementors incl. WorldState>>#assuredCanvas... et voilà
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Relationship between Morph and Canvas

Nicolai Hess
In reply to this post by nacho
Hi Nacho,

2015-02-06 22:32 GMT+01:00 nacho <[hidden email]>:
Hi,
I've been digging and inspecting all the classes related to Morphic. But
there's something that I don't happen to figure out.
Morph has a method
drawOn: aCanvas
        aCanvas fillRectangle: self bounds fillStyle: self fillStyle
borderStyle: self borderStyle


Which if it's not overridden by a subclass of Morph makes it possible to
still instantiate a Morph -the classic blue rectangle.

Now aCanvas is obviously an instance of FormCanvas or some other subclasses
of Canvas.
But the question is, where does Morph create such instance of FormCanvas?

The Morph does not care where this Canvas come from *

The WorldMorph (a PasteUpMorph) has a "WorldState" instance variable and this
world state controlls the update cycle. During this update it
creates THE canvas from the DisplayScreen (this is now a FormCanvas for the DisplayScreen(Form)).
Now it calls drawOn:canvas for all Morph(and submorphs) of the WorldMorph.
(With some more or less complex computations for clipping resp. updating only the changed areas).
 
How does this work? I'm getting all wrong?
look at:
WorldMorph>>#displayWorld
WorldState>>#displayWorld:submorphs:
 
I read the documentation available but I can't grasp it from what I have
read.


* you can create your own Form and Canvas instance and call drawOn: for a Morph with that canvas:

|f canvas |
f:=Form extent:300@300 depth:32.
canvas := f getCanvas.
EllipseMorph new extent:300@300;drawOn:canvas.
f display

 
Thanks in advance for your help
best
Nacho




-----
Nacho
Smalltalker apprentice.
Buenos Aires, Argentina.
--
View this message in context: http://forum.world.st/Relationship-between-Morph-and-Canvas-tp4804251.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.