Another, maybe more elegant way is to add a pattern like:
canvas withFillStyle: aStyle do: aBlock.
and inside a block use calls like: canvas fillRect: aRect. canvas fillPolygon: aPoly etc
On 22/03/2008, Igor Stasenko siguctua@gmail.com wrote:
On 21/03/2008, Gary Chambers gazzaguru2@btinternet.com wrote:
P.S. Just rectangular fills as a proof of concept for the moment.
-----Original Message----- From: ui-bounces@lists.squeakfoundation.org
[mailto:ui-bounces@lists.squeakfoundation.org]On Behalf Of Gary Chambers Sent: 21 March 2008 5:59 PM To: Squeak's User Interface
Subject: RE: [UI] A small change... for a start
Pinesoft-Widgets-gvc.302 on SqueakMap. Nebraska not included in changes (may do a separate package for that if there is interest).
Added CompositeFillStyle. Canvas double-dispatches to the fillstyle/color/infiniteForm. Should allow more complex fills through subclassing(like pieced together from forms for a button, top-left image, top image etc.).
Have fun!
It looks double-dispatch needed from a BaloonEngine, not from Canvas. A fillStyle needs method #registerFillWith: engine.
So, it will dispatch back to BalloonEngine with messages like:
^ engine registerSolidFill: self. "For single color fill"
^ engine registerGradientFill: self "For gradient fill"
^ engine registerBitmapFill: self "For bitmap fill"
And BaloonEngine>>registerFill: aFill should look like: ^ aFill registerFillWith: self.
Otherwise we need to extend canvas protocol with methods:
#fillRectangle:color: #fillRectangle:gradient: #fillRectangle:bitmap:
I don't like that there is need in additional checking for fill type later, after canvas receives #fillRectangle:basicFillStyle: i think it would be better to be precise after dispatch, what basic fill type should be used.
Gary
-- Best regards, Igor Stasenko AKA sig.