Painting on GtkScrolledWindow or GtkEventBox
Posted
by ptomato
on Stack Overflow
See other posts from Stack Overflow
or by ptomato
Published on 2010-04-17T16:05:35Z
Indexed on
2010/04/24
18:43 UTC
Read the original article
Hit count: 182
Using GTK, I'm trying to overlay a "More" prompt (but it could just as well be any drawing object) in the corner of a GtkTextView
contained within a GtkScrolledWindow
. I draw the prompt in the handler for the expose
signal of the text view. It works, but when I scroll the window I get artifacts: the prompt is moved along with the contents of the text view and not erased.
In order to get rid of the artifacts I trigger a redraw after each scroll. This mostly works, but you can still see the prompt jumping up and down when you scroll quickly. Is there any way to prevent this? It would be nice if the prompt just "floated" on top of the text view.
I tried enclosing the scrolled window in a GtkEventBox
and painting the prompt on top of that, but that didn't work either; the scrollbars and text view always paint over the prompt, even when you set the event box's window to go in front of its children's windows.
UPDATE
If I connect the GtkEventBox
's expose callback with g_signal_connect_after()
, then it is called after the expose callbacks of the GtkScrolledWindow
and GtkTextView
. The text view still draws over the event box though. I think this is because the scrolling happens asynchronously. Anybody got any idea how I can prevent my drawing from being overwritten?
© Stack Overflow or respective owner