Re: [gtk-list] how to draw using GtkDrawingAreaI program



Perhaps you missed this post by Havoc Pennington:
>You need to draw when you receive expose events, rather than immediately.
>Read the "scribble" example in the GTK+ Tutorial for details.
>
>Havoc

You can't reliably draw into a drawing
area until you know it is visible on the screen - an expose
event informs you that your drawing area is ready (you'll
also get exposes when your drawing area needs to be
updated).  You would need to select the expose_event
with gtk_widget_set_events() for the drawing area, and
then attach a handler to the expose_event to do
the drawing.
  Of course, if you are just trying to tinker with a drawing
area to see how it works, you could just put a "Draw" Button
in your app.  If you've done all your shows in the right order,
the implication would be that if the "Draw" Button (or
menu item, whatever) is visible, so is the drawing area.

Donna
----- Original Message -----
From: Jiang XU <jiang.xu@echostar.com>
To: <gtk-list@redhat.com>
Sent: Monday, August 30, 1999 12:45 PM
Subject: [gtk-list] 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;
> }
>
>
>
>
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
/dev/null
>
>
>



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