[Cuis-dev] suggestion for BoxMorph class comment
Mark Volkmann
r.mark.volkmann at gmail.com
Thu Dec 19 16:56:03 PST 2024
I've been thinking a lot about the distinctions between subclassing from
Morph, PlacedMorph, and BoxMorph. To me it seems like the following are the
primary distinctions.
Subclasses of `Morph`:
- do not have a specified "extent" (size)
- use the coordinate system of their owner (such as a `WorldMorph`)
For example, if the owner is scaled by a factor of 2 then this will be
also.
- use a `VectorCanvas`
- if the `drawOn:` method is not overridden, it will fill the morph with a
blue rectangle
that is centered at origin, has a width of 150, and a height of 140
Subclasses of `PlacedMorph`
- do not have a specified "extent" (size)
- use their own local coordinate system
- can be dragged to a new location
- use a `VectorCanvas`
- inherits the `drawOn:` method defined in its superclass `Morph`
Subclasses of `BoxMorph`:
- have an "extent" (size) specified by their `defaultExtent` method which
defaults to `50 at 40`
- use a `HybridCanvas` by default, but will use a `VectorCanvas`
if their `requiresVectorCanvas` method returns `true`
- if the `drawOn:` method is not overridden, it will fill the morph with a
light green rectangle
- automatically clips its contents to its extent
(major difference between this class and the previous two!)
While there is nothing wrong with the class comment for `BoxMorph`, I think
it would be good to emphasize that what you choose to draw inside it
doesn't need to be "rectangular". It seems that the important thing to know
is that whatever you draw will be CLIPPED to a rectangle whose size is
specified by what is returned from the `defaultExtent` method.
The warning about when we should not subclass from BoxMorph could say that
we should not do that unless we are okay with the clipping that it provides.
--
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20241219/a37f5115/attachment.htm>
More information about the Cuis-dev
mailing list