New Border Style for a Morph - How?
Ned Konz
ned at bike-nomad.com
Sat Aug 14 18:35:12 UTC 2004
On Saturday 14 August 2004 11:07 am, Rick Zaccone wrote:
> After a long absence from Squeak, I'm finally back to using it again.
> It's good to be back and doing something other than Java or C++!
>
> 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!
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
> I tried other variations and I'm still not closer to understanding how
> this works.
>
> Am I on the wrong track with this? Would someone be kind enough to
> point me in the right direction? It doesn't seem like this should be
> very difficult, but I don't feel like I'm getting anywhere.
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.
--
Ned Konz
http://bike-nomad.com
More information about the Squeak-dev
mailing list
|