Re: Call a function after showing something in a DrawingArea



Hi John!

John Cupitt schrieb:
On 1/3/06, Christoph Bersch <bersch uni-muenster de> wrote:
I want to write a program, that draws something in a DrawingArea, and calls a
function after _showing_ the changes in the DrawingArea:

1) call function draw_something()
2) show the changes
3) call a function measure()
4) return to step 1)

I would use a timeout. Set it to run every 20ms (or whatever interval
you want), and do something like:

static int number_of_ticks = 0;

my_timeout_callback( ...
{
  number_of_ticks += 1;
  if( number_of_ticks & 1 )
    // queue a redraw of our drawingarea
    gtk_widget_queue_draw( ..
  else
    measure();

  return( TRUE );
}

Great, this seems to work :-)

There's no guarantee that the draw will occur before the measure, but
it probably will for most reasonable machines. But of course that's
always true for X.

As long as it works for X, it's ok for me.

I thought, that a call of gtk_widget_draw() might be better than
gtk_widget_queue_draw_area(), as it draws immediately, although it is
deprecated.

So how could a call of gtk_widget_draw() be replaced in new code (I
don't fully understand the part belonging to this function in the
documentation). Could it be something like

gdk_window_invalidate_rect ();
gdk_window_process_updates ();
?

Thanks
Christoph




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