Re: How to draw points on the drawing area?



>First ignoring the PDU part. You draw to the drawing are with the gc_draw_*()
>functions in the exposure event callback. Here is the critical code 
>that you need to set up:
>
>
>    gboolean event_handler (GtkWidget *drawing_area,
>			    GdkEvent *event,
>			    gpointer client_data)
>    {
>      if (event->type == GDK_EXPOSE)
>	  draw_graphics((MyApp*)client_data);
>
>      return 1;
>    }

a few points here:

    * connecting to the "event" signal is wasteful. it means that
        your callback is executed for every single event on the
	widget. use the specific desired event if there is one,
	in this case "expose_event"

    * returning 1 is not correct. signal handlers return TRUE or
      FALSE. small point, perhaps, but ...

    * return TRUE by default from a callback connected to "event"
      is a bad idea. 

>About the PDU that you mentioned (though I have no idea what it is).
>Whenever you have data to read on that channel you should get a
>callback in which you read the data. You should then call draw_graphics()
>manually to update the display.

no, thats not right. you would call either gtk_widget_queue_draw(), or
use a GDK method such as gdk_window_invalidate_rect(). but the author
already knows this. i think his problem(s) arise from not grasping the
central role of the expose_event in GTK+ (a common problem).

--p



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