how to draw using GtkDrawingAreaI program



I programed a simple application to test GtkDrawingArea
but it can never work. I wonder whether someone knows why.

int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *drawing_area;
    GtkWidget *vbox;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    vbox = gtk_hbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show (vbox);

    drawing_area = gtk_drawing_area_new ();
    gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 200, 200);
    gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

    gtk_widget_show (drawing_area);
    gtk_widget_show (window);

     gdk_draw_rectangle (drawing_area->window,

drawing_area->style->white_gc,
                                            TRUE,
                                            0, 0,

drawing_area->allocation.width,

drawing_area->allocation.height);


gdk_draw_line(drawing_area->window,drawing_area->style->black_gc,0,0,100,100);

     gtk_main ();

     return 0;
}







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