Re: Expose events

On Mon, 26 Apr 1999, K. M. Hawarden-Ogata wrote:

> Hi, I was wondering if someone could help me...
> I am writing a program that plots a graph and has various buttons that do
> things like read in data and plot a fitted curve to that data.
> My question is: Is there a nice way to force the drawing area widget to
> redraw after every event, i.e., after I click my "read in data" button, it
> automatically plots the data points on my drawing area.

you need to queue a redraw on the drawing area for such circumstances.
e.g. given you have something like

typedef struct 
  guint n_values;
  gdouble *values;
  GtkWidget *drawing_area;
} MyDrawData;

and a function to manipulate certain values:

my_draw_data_set_value (MyDrawData *dd,
                        guint       index,
                        gdouble     value)
  g_return_if_fail (dd != NULL);
  g_return_if_fail (index < dd->n_values);
  dd->values[index] = value;
  /* you need to: */
  if (dd->drawing_area)
    gtk_widget_queue_draw (dd->drawing_area);

so once you update a value either from a button click or anywhere
else in your program, you'd want to queue a redraw for the drawing area.
the nice thing about queued redraws is that if you modify multiple
values in a row, the queued redraws will get coalesced so that the
drawing area is only redrawn once in effect.

[btw, such questions are more on-topic on gtk-list or gtk-app-list,
 gtk-devel-list is meant for development regarding gtk itself]

> Thanks, Miranda


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