<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    It looks ok to me, except for the missing $] at the end of #drawOn:<br>
    <br>
    Cheers,<br>
    <br>
    On 7/11/2024 8:50 PM, Mark Volkmann via Cuis-dev wrote:
    <blockquote
cite="mid:CAFfRWnVy-rROcSNB3nP3p652Pzy2t8TwZcpa_JwbWLXeQfp3QA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div dir="ltr">On Thu, Jul 11, 2024 at 5:51 PM Juan Vuletich
          <<a moz-do-not-send="true" href="mailto:juan@cuis.st">juan@cuis.st</a>>
          wrote:<br>
        </div>
        <div class="gmail_quote">
          <blockquote class="gmail_quote" style="margin: 0px 0px 0px
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">
            <div bgcolor="#ffffff"> On 7/11/2024 4:39 PM, Mark Volkmann
              via Cuis-dev wrote:
              <blockquote 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">
                          <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>
              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!</div>
          </blockquote>
          <div><br>
          </div>
          <div>Thanks Juan! I suppose the reason I thought that adding
            an `extent` instance variable to my class was suspect is
            that I would get that automatically if I subclass BoxedMorph
            instead of PlacedMorph.</div>
          <div><br>
          </div>
          <div>Here is my latest code that subclasses PlacedMorph and
            does add an `extent` instance variable. I'm curious if
            anyone sees anything suspect in this code.</div>
          <div><br>
          </div>
          <div><font face="monospace">PlacedMorph subclass: #CanvasDemo<br>
                  instanceVariableNames: 'extent'<br>
                  classVariableNames: ''<br>
                  poolDictionaries: ''<br>
                  category: 'Volkmann'<br>
            </font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">extent<br>
                  ^ extent<br>
            </font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">extent: aPoint<br>
                  extent := aPoint<br>
            </font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">initialize<br>
                  super initialize.<br>
                  extent := 100 @ 100<br>
            </font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">drawOn: aCanvas<br>
                  | x1 x2 y1 y2 |<br>
            </font><span style="font-family: monospace;">   <span
                class="gmail-Apple-converted-space"> </span></span><font
              face="monospace">x1 := 0.<br>
            </font><span style="font-family: monospace;">   <span
                class="gmail-Apple-converted-space"> </span></span><font
              face="monospace">y1 := 0.<br>
            </font><span style="font-family: monospace;">   <span
                class="gmail-Apple-converted-space"> </span></span><font
              face="monospace">x2 := extent x.<br>
            </font><span style="font-family: monospace;">   <span
                class="gmail-Apple-converted-space"> </span></span><font
              face="monospace">y2 := extent y.<br>
            </font><span style="font-family: monospace;">   <span
                class="gmail-Apple-converted-space"> </span></span><font
              face="monospace">aCanvas strokeWidth: 10 color: Color red
              fillColor: Color green do: [<br>
            </font><span style="font-family: monospace;">   <span
                class="gmail-Apple-converted-space"> </span></span><span
              style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;">aCanvas</span></div>
          <div><span style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;"> 
               </span><span class="gmail-Apple-converted-space"
              style="font-family: monospace;"> </span><span
              style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;">moveTo:
              x1 @ y1;</span></div>
          <div><span style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;"> 
               </span><span class="gmail-Apple-converted-space"
              style="font-family: monospace;"> </span><span
              style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><font face="monospace">lineTo: x2 @
              y2;<br>
            </font><span style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;"> 
               </span><span class="gmail-Apple-converted-space"
              style="font-family: monospace;"> </span><span
              style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><font face="monospace">lineTo: x2 @
              y1;<br>
            </font><span style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;"> 
               </span><span class="gmail-Apple-converted-space"
              style="font-family: monospace;"> </span><span
              style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><font face="monospace">lineTo: x1 @
              y1;<br>
            </font><span style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;"> 
               </span><span class="gmail-Apple-converted-space"
              style="font-family: monospace;"> </span><span
              style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><font face="monospace">lineTo: x1 @
              y2;<br>
            </font><span style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><span style="font-family: monospace;"> 
               </span><span class="gmail-Apple-converted-space"
              style="font-family: monospace;"> </span><span
              style="font-family: monospace;">   </span><span
              class="gmail-Apple-converted-space" style="font-family:
              monospace;"> </span><font face="monospace">lineTo: x2 @ y2<br>
              <br>
            </font></div>
          <div><font face="arial, sans-serif">Here's an example of using
              this class:</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">cd := CanvasDemo new extent:
              300@400.<br>
              cd openInHand.</font></div>
        </div>
        <div><br>
        </div>
        <span class="gmail_signature_prefix">-- </span><br>
        <div dir="ltr" class="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>
    </blockquote>
    <br>
    <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>