What is the difference between a form and a morph?

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

What is the difference between a form and a morph?

Steve Quezadas
I usually like to go through the source code to answer my own question, but I can't tell by reading it.

[Morph], from what I understand, deals with manipulating graphics on smalltalk. But when I use ZnEasy to get a jpeg file, I notice that it returns a [Form] and not a [Morph] to display a jpeg. Spec2 also wants [Form] for displaying images rather than [Morph].

So what is the difference between a [Form] and a [Morph] since they both seem to deal with graphics?
Reply | Threaded
Open this post in threaded view
|

Re: What is the difference between a form and a morph?

K K Subbu
On 24/02/20 2:00 AM, Steve Quezadas wrote:
> [Morph], from what I understand, deals with manipulating graphics on
> smalltalk. But when I use ZnEasy to get a jpeg file, I notice that it
> returns a [Form] and not a [Morph] to display a jpeg. Spec2 also wants
> [Form] for displaying images rather than [Morph].
>
> So what is the difference between a [Form] and a [Morph] since they both
> seem to deal with graphics?

A Form is a rectangular of pixel. Essentially, a picture. You can create
a Morph around a form with:

   aForm asMorph openInHand.

A Morph is the basic unit of Morphic GUI - a live, direct editor of
objects. An excellent short tutorial about it is at:

http://stephane.ducasse.free.fr/freebooks/collectivenbluebook/morphic.final.pdf

HTH .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: What is the difference between a form and a morph?

Steve Quezadas
> A Form is a rectangular of pixel.
I don't understand. What is a "rectangular of a pixel"?

> You can create a Morph around a form with:
Don't you mean "convert  a [Form] to a [Morph] object"? What do you mean by "create a Morph around a form"?

On Sun, Feb 23, 2020 at 7:47 PM K K Subbu <[hidden email]> wrote:
On 24/02/20 2:00 AM, Steve Quezadas wrote:
> [Morph], from what I understand, deals with manipulating graphics on
> smalltalk. But when I use ZnEasy to get a jpeg file, I notice that it
> returns a [Form] and not a [Morph] to display a jpeg. Spec2 also wants
> [Form] for displaying images rather than [Morph].
>
> So what is the difference between a [Form] and a [Morph] since they both
> seem to deal with graphics?

A Form is a rectangular of pixel. Essentially, a picture. You can create
a Morph around a form with:

   aForm asMorph openInHand.

A Morph is the basic unit of Morphic GUI - a live, direct editor of
objects. An excellent short tutorial about it is at:

http://stephane.ducasse.free.fr/freebooks/collectivenbluebook/morphic.final.pdf

HTH .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: What is the difference between a form and a morph?

K K Subbu
On 24/02/20 10:37 AM, Steve Quezadas wrote:
>  > A Form is a rectangular of pixel.
> I don't understand. What is a "rectangular of a pixel"?

I meant rectangle of pixels. Sorry for the typo.

If you want to display a bitmap, you need to know its width x height x
depth. This is what a Form provides. See http://wiki.squeak.org/squeak/697

>  > You can create a Morph around a form with:
> Don't you mean "convert  a [Form] to a [Morph] object"? What do you mean
> by "create a Morph around a form"?

No, you don't convert the form. You need a tool to see/edit/interact
with this object which is what a morph allows you to do. See

   http://wiki.squeak.org/squeak/2305

See John Maloney's article for details on Morphic GUI.

HTH .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: What is the difference between a form and a morph?

Ben Coman
In reply to this post by Steve Quezadas
On Mon, 24 Feb 2020 at 04:31, Steve Quezadas <[hidden email]> wrote:
I usually like to go through the source code to answer my own question, but I can't tell by reading it.

[Morph], from what I understand, deals with manipulating graphics on smalltalk. But when I use ZnEasy to get a jpeg file, I notice that it returns a [Form] and not a [Morph] to display a jpeg. Spec2 also wants [Form] for displaying images rather than [Morph].

So what is the difference between a [Form] and a [Morph] since they both seem to deal with graphics?

I don't know the exact answer, but if you review method ImageMorph>>form 
you will see that the ImageMorph is a wrapper around a Form.

So some simple differences that may be inferred.
- Many morphs are not bitmaps.
- Morphs are GUI elements, i.e. interact with mouse and keyboard   
- Forms are not GUI elements
- Forms can be manipulated without displaying them.

In some other graphics system, an analogy could be putting an image on a button and asking "what is the difference between an 'image' and a 'button' ?"

wrt Spec2, Morph is one backend that Spec2 might use to display a Form,
or Spec2 might display the Form using a GTK widget. 

cheers -ben
Reply | Threaded
Open this post in threaded view
|

Re: What is the difference between a form and a morph?

Steve Quezadas
Ben,

I checked, [Form] is inherited from class [DisplayMedium]. So in
smalltalk, the inheritence pattern is:
Object -> DisplayObject -> DisplayMedium -> Form

The inheritence pattern of ImageMorph is:
Object -> Morph -> ImageMorph

One does not inherit the other and is not a wrapper, at least in Pharo8

On Sun, Feb 23, 2020 at 10:11 PM Ben Coman <[hidden email]> wrote:
On Mon, 24 Feb 2020 at 04:31, Steve Quezadas <[hidden email]> wrote:
I usually like to go through the source code to answer my own question, but I can't tell by reading it.

[Morph], from what I understand, deals with manipulating graphics on smalltalk. But when I use ZnEasy to get a jpeg file, I notice that it returns a [Form] and not a [Morph] to display a jpeg. Spec2 also wants [Form] for displaying images rather than [Morph].

So what is the difference between a [Form] and a [Morph] since they both seem to deal with graphics?

I don't know the exact answer, but if you review method ImageMorph>>form 
you will see that the ImageMorph is a wrapper around a Form.

So some simple differences that may be inferred.
- Many morphs are not bitmaps.
- Morphs are GUI elements, i.e. interact with mouse and keyboard   
- Forms are not GUI elements
- Forms can be manipulated without displaying them.

In some other graphics system, an analogy could be putting an image on a button and asking "what is the difference between an 'image' and a 'button' ?"

wrt Spec2, Morph is one backend that Spec2 might use to display a Form,
or Spec2 might display the Form using a GTK widget. 

cheers -ben
Reply | Threaded
Open this post in threaded view
|

Re: What is the difference between a form and a morph?

Markus Stumptner
Normally, there should not be an inheritance relationship between wrapper and wrappee, but I agree that describing Morphs as wrappers around Forms seems to miss the point. The notion of wrapper usually implies that there is little modification to the protocol of the wrappee, a wrapper should not need a lot of code. But Morphs are a completely different level of the architecture, with a large and complex protocol that's very different from Forms. So let's start again.

Forms are images (implemented as rectangular pixel arrays, as stated).

Morphs are the objects that describe how the graphical interface works, they control displaying (for which they use Forms), handling of user input (mouse clicks, dragging etc) and above all the internal structure of the interface (for example the different regions that make up a window on the screen are Morphs). Note that the user display side of the Pharo interface is handled by class DisplayScreen, which is a subclass of Form.  So the Morphs in the user interface display themselves by inserting their Forms in the proper places on the Form that is the internal representation of the screen.

So, as Subbu said, you don't convert Morphs to Forms, they serve different purposes.  Morphs (some Morphs) have instance variables that allow them to refer to the Form that they use for displaying.  Hope that helps a bit.

I note that all of this (plus some more) you can essentially get from the class comments of the two.

Markus

On 25/2/20 12:22 pm, Steve Quezadas wrote:
Ben,

I checked, [Form] is inherited from class [DisplayMedium]. So in
smalltalk, the inheritence pattern is:
Object -> DisplayObject -> DisplayMedium -> Form

The inheritence pattern of ImageMorph is:
Object -> Morph -> ImageMorph

One does not inherit the other and is not a wrapper, at least in Pharo8

On Sun, Feb 23, 2020 at 10:11 PM Ben Coman <[hidden email]> wrote:
On Mon, 24 Feb 2020 at 04:31, Steve Quezadas <[hidden email]> wrote:
I usually like to go through the source code to answer my own question, but I can't tell by reading it.

[Morph], from what I understand, deals with manipulating graphics on smalltalk. But when I use ZnEasy to get a jpeg file, I notice that it returns a [Form] and not a [Morph] to display a jpeg. Spec2 also wants [Form] for displaying images rather than [Morph].

So what is the difference between a [Form] and a [Morph] since they both seem to deal with graphics?

I don't know the exact answer, but if you review method ImageMorph>>form 
you will see that the ImageMorph is a wrapper around a Form.

So some simple differences that may be inferred.
- Many morphs are not bitmaps.
- Morphs are GUI elements, i.e. interact with mouse and keyboard   
- Forms are not GUI elements
- Forms can be manipulated without displaying them.

In some other graphics system, an analogy could be putting an image on a button and asking "what is the difference between an 'image' and a 'button' ?"

wrt Spec2, Morph is one backend that Spec2 might use to display a Form,
or Spec2 might display the Form using a GTK widget. 

cheers -ben