links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Last updated at 11:45 pm UTC on 8 October 2017
The class BorderedMorph is a subclass of the class Morph, with these additional instance variables:

  BorderedMorh new borderStyle: (BorderStyle inset width: 2); openInWorld.

Direct subclasses (2006, update for later versions):

Question: How to change a morphs border style? Rick Zaccone August 14, 2004 I am trying to create a RectangleMorph that has a special border. I would like (say) the top and bottom edges to be black and the left and right edges to be white. In general, opposite edges should be the same color. A simple border is sufficient. It doesn't need to be beveled. It seems that I need to create a subclass of BorderStyle to do this.

Before charging ahead to do this, I tried to understand how the existing styles work. I used
MessageTally tallySends: [RectangleMorph new openInWorld]
Wow! Lots of stuff going on, and I never see the border being drawn! I tried other variations and I'm still not closer to understanding how this works.

Answer: Ned Konz The problem with that is that you won't see the actual drawing. Try this instead:
r := RectangleMorph new openInWorld.
MessageTally tallySends: [ r drawOn: World assuredCanvas ].
or more succinctly:
r := RectangleMorph new openInWorld.
MessageTally tallySendsTo: r borderStyle 
             inBlock: [r drawOn: World assuredCanvas] 
             showTree: true
What you'll see is (simplified):
1 RectangleMorph(Morph)>>drawOn:
  |1 FormCanvas(Canvas)>>fillRectangle:fillStyle:borderStyle:
  |  |1 SimpleBorder>>frameRectangle:on:
  |  |  |1 =FormCanvas>>frameAndFillRectangle:fi...Color:bottomRightColor:
  |  |  |1 FormCanvas(Canvas)>>fillRectangle:color:
That is, a BorderedMorph tells the Canvas to frame and fill itself, and that behavior is delegated to the morph's borderStyle.