<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 7/11/2024 4:39 PM, Mark Volkmann via Cuis-dev wrote:
<blockquote
cite="mid:CAFfRWnUtVQ3AGDe32bQOTt8+oW3JOCgmZVORb5oHUdWf7Lodtw@mail.gmail.com"
type="cite">
<div dir="ltr">When creating a custom morph it's not clear to me
whether I should subclass PlacedMorph or BoxedMorph.
<div><br>
</div>
<div>I see that PlacedMorph doesn't hold the size of the morph,
but BoxedMorph does. BoxedMorph has the instance variable
extent and the accessors morphExtent and morphExtent:. I want
to be able to set the extent of my custom morph instances and
utilize that size informationĀ in my drawOn: method.</div>
<div><br>
<div>However, the drawOn: method in PlaceMorph uses a
VectorCanvas and BoxedMorph uses a HybridCanvas.
HybridCanvas doesn't have the
strokeWidth:color:fillColor:do: method and I want to use
that.</div>
<div><br>
</div>
<div>I could add my own extent instance variable to my
PlacedMorph subclass, but that feels wrong.</div>
<div><br>
</div>
<div>I need some advice on this.</div>
<div><br>
</div>
<div>
<div><span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div><font face="arial, helvetica,
sans-serif">R. Mark Volkmann</font></div>
<div><span style="font-size: 12.8px;"><font
face="arial, helvetica, sans-serif">Object
Computing, Inc.</font></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
BoxedMorph are a Hierarchy for morphs that are rectangle like, and
that occupy an area that can be specified as a Rectangle. This means
that, besides being of rectangular shape, sides are aligned with
local coordinate axes. Including rectangles with rounded corners and
such. The idea is that the 'extent' ivar is all that's needed to
establish our dimensions and shape.<br>
<br>
They are used, for example, for common widgets.<br>
<br>
If your morph is not in the shape of a rectangle, it is better to
make it a PlacedMorph. See `PlacedMorph subclasses`, and play with
instances of them in your Morphic World to see some of the things
that can be done.<br>
<br>
See #requiresVectorCanvas and #knowsOwnLocalBounds. You can redefine
#requiresVectorCanvas in a subclass of BoxedMorph if desired. But
see, in the other subclasses of PlacedMorph, the kind of freedom you
get when you can make #knowsOwnLocalBounds answer false.<br>
<br>
Finally, you can add whatever instance variable you need to any of
your classes. You're the master. Why would adding 'extent' to your
own PlacedMorph feel wrong, if that happens to be what you need /
want? Don't be shy. You're just playing.<br>
<br>
Happy explorations!<br>
<pre class="moz-signature" cols="72">--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich</pre>
</body>
</html>