Re: gtk+2 drawing on top of widgets



Dennis Bjorklund <db zigo dhs org> writes:
> I have a window with some widgets inside and I would like to draw on top
> of these widgets.

There is basically no supported way to do this - no one has thought
about how it would work at all. So don't be surprised if it's
impossible or difficult - but maybe you can figure out some hack. ;-)
 
> So I tried to turn of double buffer for the window and tried to
> get the old bahviour by calling first
> 
>  gdk_window_begin_paint_region (event->window, event->region);
>

The docs for this function may help, and also check out the source
code to gtk_main_do_event() to see when GTK calls it automatically.
  
> If someone have some other suggestion on how to paint over the widgets can
> work please tell me. Can I know that the expose of the window is "the
> last" thing that is done so that drawing will go on top of the children
> inside the window?

You may want to try g_signal_connect_after() to run your expose
handler _after_ the default handlers.

One problem you have is that exposes are per-window, and won't include
subwindow-obscured areas; you need the union of exposes for a window
and all its subwindows. So you might want to use GdkRegion to maintain
a damage region that is the union of exposes received on a toplevel
window and all subwindows; then run an idle handler at lower priority
than GDK_PRIORITY_REDRAW (GDK_PRIORITY_REDRAW + 10 perhaps), and do
your drawing in that idle handler for the damaged region. Might work.

You still have the problem that widgets can legitimately draw with no
expose event involved, though GTK 2 normally does not do so, I can't
think of an example.

Havoc



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]