Re: [gtk-list] gdk drawing funks



Well, I am trying to do the same. What I found out is that a drawing_area
does not have a window of its own, so canvas->window stays 0x0 until the
main window is realized, i.e. after the gtk_widget_show(topwin).
This gets rid of the error, but it does not show the rectangle as expected.
If I draw on topwin_>window, I can see the rectangle flashing by. It does not
stay. Anyone?

>>>>> "Stefan" == Stefan Ottosson <ottosson@canit.se> writes:

    Stefan> hi, I'm trying to make use of gdks drawing funktions.  All
    Stefan> I want to do is draw a rectangle on the toplevel window.

    Stefan> Here's what I tried to do, this generates a "drawable !=
    Stefan> null" message..

    Stefan> int main(int argc, char **argv) { GtkWidget *topwin;
    Stefan> GtkWidget *canvas;

    Stefan> gtk_init(&argc, &argv);

    Stefan> topwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    Stefan> canvas = gtk_drawing_area_new();
    Stefan> gtk_drawing_area_size(GTK_DRAWING_AREA(canvas), 200, 200);
    Stefan> gtk_widget_show(canvas);

    Stefan> gtk_container_add(GTK_CONTAINER(topwin), canvas);

    Stefan> gdk_draw_rectangle(canvas->window,
    Stefan> canvas->style->black_gc, TRUE, 10, 10, 80, 50);

    Stefan> gtk_widget_show(topwin);

    Stefan> gtk_main(); }

    Stefan> -- To unsubscribe: mail -s unsubscribe
    Stefan> gtk-list-request@redhat.com < /dev/null


-- 

R. A. Hogendoorn                                       E-mail: hogend@nlr.nl
Informatics Division                                   Tel. +31-527-24-8367 
Please note the changed extension -------------------------------------^^^^
National Aerospace Laboratory, The Netherlands         Fax. +31-527-24-8210 



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