Re: [gtk-list] Re: Need help with gdk_draw_*
- From: Tim Janik <Tim Janik Hamburg Netsurf DE>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Need help with gdk_draw_*
- Date: Wed, 17 Dec 1997 05:46:46 +0100 (CET)
On Tue, 16 Dec 1997, Owen Taylor wrote:
> > #include <gtk/gtk.h>
> >
> > int main(int argc, char *argv[])
> > {
> > GtkWidget *mainwin;
> >
> > gtk_init(&argc, &argv);
> > mainwin=gtk_window_new(GTK_WINDOW_TOPLEVEL);
> > gtk_widget_show(mainwin);
> >
> > gdk_draw_rectangle(mainwin->window, mainwin->style->white_gc, TRUE,
> > 50, 50, 150, 150);
> >
> > gtk_main();
> > return 0;
> > }
>
> This is a sort of a classic problem. You can't draw on a window
> until is realized (the X window is created) and it is mapped
> (The window is drawn on the screen) The easiest way to do
> this is to do your drawing in an expose handler. (That way,
> it will also be redrawn if the window is hidden and then revealed)
>
> (Also, you should compile GTK with --enable-debug. You would get
> a warning that mainwin->window is NULL here)
uhm, no, since we are having a toplevel window here which is already
gtk_widget_show()en, there already exists an XLib struct (and it's
gdk_window() pointer) so we don't get a warning "window != NULL" here.
if you flush the output queue before the rectangle draw call, at the
point the gdk_draw_rectangle() call is made, the window will already
be realized and mapped, and therefore you can see the rectangle (though
only until the next expose).
>
> Regards,
> Owen
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
>
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]