A while back I promised an example of using the wx.Overlay to assist
with drawing temporary things like rubber-band boxes over the top of
something else. I finally did that this morning and I've attached the
result. Basically instead of using the wx.INVERT or wx.XOR trick of
drawing a 2nd time to "erase" the rectangle, you can draw whatever you
want, in any colour you want, and you don't have to rely on a
side-effect of the logical op to make it work.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Attached is a similar example that uses wxGraphicsContext to get an
alpha-blended selection rect, and includes a hack to work around
flicker on MSW.
My understanding is that it doesn't. On Mac it is actually using an
overlay object provided by the platform, and the client DC is just used
to get the plumbing right. (So it is actually as if it was drawing on a
piece of transparent glass above the window, instead of on the window
itself.) On the other platforms the client dc is used directly to
implement a similar behavior.
>
> In any case, it's prettier and easier to use.
>
> > in any colour you want,
>
> This is still an issue -- if you don't know what colors may be on the
> screen, how do you make sure to get a contrasting color (at least
> without alpha, which, from your code, only appears to work on the Mac)?
Using a plain DC you can only use Alpha on the Mac, but as the other
Chris showed us you can use a wx.GraphicsContext (or a wx.GCDC) to get
alpha everywhere. (Although I'm seeing a crash currently on the Mac
when trying to use a GC with an Overlay, so I'll need to investigate
that...)
Hi Robin,Your sample code doesn't work when Double Buffering is turned on. Is there a workaround without turning double buffering off?
wx.BufferedPainDC