Re: [gtk-list] Re: Need help with gdk_draw_*
- From: Owen Taylor <owt1 cornell edu>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Need help with gdk_draw_*
- Date: Wed, 17 Dec 1997 17:47:29 -0500
"Yoav Cohen-Sivan" <ycs@netvision.net.il> writes:
> I thought it was something along these lines. But, from the tutorial, I
> got the impression that gtk_widget_show() already does the realizing and
> mapping, as stated in another e-mail by Tim Janik. This is why I put the
> call to gdk_draw after the call to gtk_widget_show(). From what you say I
> gather that gtk_widget_show() doesn't do the realizing and mapping, rather
> the call to gtk_main().
No, gdk_show() does do that for toplevels. But the X server won't
know about it until you enter the event loop unless you add a gdk_flush().
> I tried Tim Janik's suggestion of adding a gdk_flush() right after the
> gdk_draw but it didn't help. Only after I set up the expose_event handler
> and drew from there did everything work.
Try moving the gdk_flush() before the gdk_draw. Then it will work.
The window has to be mapped before you can draw on it, and that's
what the gdk_flush() forces.
> To strengthen the claim that gtk_widget_show() already realizes the
> window, I tried moving the call to gdk_draw to _before_ gtk_widget_show()
> and sure enough I got the expected 'window == NULL' error message.
Yes, this is the correct interpretation.
> To conclude, I simply don't understand what I am doing wrong.
> gtk_widget_show() realizes and maps the widget, I even flush the output
> queue with gdk_flush() and still it doesn't work, _but_ implement the
> drawing as an expose_event handler and everything is fine - this seems to
> be a bug. Are you suggesting that there is no way to draw on Gtk widgets
> from outside an expose_event handler?
No, I'm just suggesting that that is usually the best way to
organize things, since you have to be prepared to draw everything
there anyways.
Sometimes it is useful to draw from other event handlers when what
you are drawing is inherently ephemeral - for instance the Paned
widgets do this to do the rubber banding.
And also in many cases when the contents of the widget change you
will want to redraw without an actual expose event. If you do
all your drawing in the expose handler, you can force it to
be called with gtk_widget_draw() (at least for drawing area widgets.
Some other widgets have separate "draw" handlers)
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]