Drawing over child widgets without flashing

I’m working on a tool that has informational widgets above a set of drawings (done in a PaintDC).
See the screenshot at http://i.imgur.com/Y7g0hrM.png for an example.

Here’s the problem: I’d like the drawings on the DC to be above the widgets.

In the attached picture, that’s equivalent to putting the red line above the middle grey box.

I tried doing this with a ClientDC, but that produced unpleasant flashing (as it would first

do the main drawing routine, render it to screen, then add the line on top and update

the screen).

Is there a good way to do this, or am I out of luck?

Thanks,

Matt

mkeeter wrote:

I'm working on a tool that has informational widgets above a set of
drawings (done in a PaintDC).
See the screenshot at http://i.imgur.com/Y7g0hrM.png for an example.

Here's the problem: I'd like the drawings on the DC to be above the widgets.
In the attached picture, that's equivalent to putting the red line above
the middle grey box.

I tried doing this with a ClientDC, but that produced unpleasant
flashing (as it would first
do the main drawing routine, render it to screen, then add the line on
top and update
the screen).

Is there a good way to do this, or am I out of luck?

That's one of the main principles of UI toolkits using the concept of widgets/windows, that child widgets cover up anything drawn on their parent widget. Trying to make it work differently is like trying to swim upstream in a swift river. It might be possible but it's probably not worth the effort.

Usually when you see a UI like in your screenshot it is really just one window and each of the nodes are able to draw themselves on that window's canvas. That's more complex than child windows in some ways, like needing to deal with the mouse events differently, drawing everything instead of just setting a background color, using a statictext or textctrl widget, etc. On the other hand, it is much more flexible and gives you more freedom in what you can do with the UI. In addition to things stacking and drawing over the top of other objects like you are asking about, you can also do things like draw some elements partially transparent, have non-rectangular objects, etc. In addition, we have wx.lib.ogl and wx.lib.floatcanvas in the wxPython library that you can build upon if you want if they meet your needs.

···

--
Robin Dunn
Software Craftsman