RE: drawing graphics


> Make a background pixmap the same size/depth
>       bgPixmap = gdk_pixmap_new(drawArea->window,
>                                 drawArea->allocation.width,
>                                 drawArea->allocation.height, -1);
> Set the background pixmap as the background of the drawing areas window
>       gdk_window_set_back_pixmap(drawArea->window, bgPixmap, 0);

I've tried this piece of code. I have added it immediately after the
construction of the drawing area, i.e.

    drawing_area = gtk_drawing_area_new ();
    gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area),
                           image_width, image_height);
    gtk_box_pack_start (GTK_BOX (main_vbox), drawing_area, TRUE, TRUE, 0);

    off_screen = gdk_pixmap_new (drawing_area->window,
    gdk_window_set_back_pixmap (drawing_area->window, off_screen, 0);

When I run the application, the following messages are printed:

Gdk-CRITICAL **: file gdkpixmap.c: line 62 (gdk_pixmap_new): assertion
`(window != NULL) || (depth != -1)' failed.

Gdk-CRITICAL **: file gdkwindow.c: line 1249 (gdk_window_set_back_pixmap):
assertion `window != NULL' failed.

Why? At which time is drawing_area->window initialised? Is it necessary to
show the app window before initialising the pixmap?

(sorry for the newbie questions... it's my very first GTK app)


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