Algorithmic Solutions > LEDA > LEDA Guide > Windows and Panels > Timers


Each window has a timer clock that can be used to execute periodically a user-defined function. The function to be called and the time interval are specified in
  void W.start_timer(int msec, void (*func) window*));

The operation to stop the timer is

  void W.stop_timer();


The following example implements a simple digital clock demo program.

On the right you see a screenshot of the program.

Picture of Convex Hull

#include <LEDA/graphics/window.h>
#include <time.h>

using namespace leda;

void display_time(window* wp)
  window& W=*wp;

  //get the current time
  time_t clock; time(&clock);
  tm* T=localtime(&clock);

  //display it (centered in W)
  double x=(wp->xmax()-wp->xmin())/2;
  double y=(wp->ymax()-wp->ymin())/2;

  int th=T->tm_hour;int tm=T->tm_min; int ts=T->tm_sec;
  string s=string("%2d:%02d:%02d",th,tm,ts);

  wp->clear(); wp->draw_ctext(x,y,s);

int main()
  window W(125,50,"dclock");
  W.set_bg_color(grey1); W.set_font("T32");



  return 0;

See also:

Windows and Panels

Mouse Input

Drawing Operations

Manual Pages:

Manual Page Windows

Please send any suggestions, comments or questions to
© Copyright 2001-2003, Algorithmic Solutions Software GmbH