Christopher Barker wrote:
> Paul McNett wrote:
>> This must be really simple, as I've been doing really cool things
>> with floatcanvas with no troubles so far - great library!
> 
> Thanks -- but in this case, you didn't miss anything.
> 
>> How do I specify that a rectangle is *not* to be scaled?
> 
> An unscaled rectangle is not a current part of the standard FloatCanvas
> objects.
> 
>> I'm trying to make a legend of sorts, where most of the drawing is 
>> scalable. Because text isn't scaled by default, I get what I want for
>>  the text by merely specifying font size. But how do I draw a box
>> around this legend and *not* have the box scale with the rest of the
>> drawing?
> 
> This is a missing piece. You're going to need to make a new DrawObject.
> There are few options:
> 
> 1) make an UnscaledRectangle. (or add a flag the existing rectangle --
> in fact, I regret not doing things that way in the first place. IN fact, 
> we really should have all object have a "Scaled" flag). This
> would be easy -- just change Rectangle._Draw() to use self.WH, rather
> than the scaled one computed. Note: this will get trickier of you want
> to be able to choose what corner of the rectangle is fixed -- like you
> can with text.

This was easy, indeed. I just subclassed Rectangle, and wrote an 
overridden _Draw() method that uses self.WH instead of the calculation.


> 2) Make an UnScaledTextBox -- the ScaledTextBox provides a way to put a
> box around the text, with spacers, etc. and UnScaled version is clearly
> needed.

I didn't try this, but the TextBox seems nicer than the Text object so I 
probably should have.

> 3) Maybe you can get away with just changing the BackgroundColor or your
>   Text Object?

Bingo. This is all I really need right now so I scrubbed the 
UnscaledRectangle class.


> If you run into problems, post here. If any case, please post your
> solution here, and we can put it into the distribution.

I think you could make a mixin class to add the unscaled feature, fairly 
easily. So code could look like:

o = fc.AddUnscaledRectangle(...)


Paul

_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to