Fl_Timer.H 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // "$Id: Fl_Timer.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
  3. //
  4. // Timer header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. /* \file
  19. Fl_Timer widget . */
  20. #ifndef Fl_Timer_H
  21. #define Fl_Timer_H
  22. #ifndef Fl_Widget_H
  23. #include "Fl_Widget.H"
  24. #endif
  25. // values for type():
  26. #define FL_NORMAL_TIMER 0
  27. #define FL_VALUE_TIMER 1
  28. #define FL_HIDDEN_TIMER 2
  29. /**
  30. This is provided only to emulate the Forms Timer widget. It works by
  31. making a timeout callback every 1/5 second. This is wasteful and
  32. inaccurate if you just want something to happen a fixed time in the
  33. future. You should directly call
  34. Fl::add_timeout() instead.
  35. */
  36. class FL_EXPORT Fl_Timer : public Fl_Widget {
  37. static void stepcb(void *);
  38. void step();
  39. char on, direction_;
  40. double delay, total;
  41. long lastsec,lastusec;
  42. protected:
  43. void draw();
  44. public:
  45. int handle(int);
  46. Fl_Timer(uchar t,int x,int y,int w,int h, const char *l);
  47. ~Fl_Timer();
  48. void value(double);
  49. /** See void Fl_Timer::value(double) */
  50. double value() const {return delay>0.0?delay:0.0;}
  51. /**
  52. Gets or sets the direction of the timer. If the direction is zero
  53. then the timer will count up, otherwise it will count down from the
  54. initial value().
  55. */
  56. char direction() const {return direction_;}
  57. /**
  58. Gets or sets the direction of the timer. If the direction is zero
  59. then the timer will count up, otherwise it will count down from the
  60. initial value().
  61. */
  62. void direction(char d) {direction_ = d;}
  63. /** Gets or sets whether the timer is suspended. */
  64. char suspended() const {return !on;}
  65. void suspended(char d);
  66. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Timer, Fl_Widget)
  67. };
  68. #endif
  69. //
  70. // End of "$Id: Fl_Timer.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
  71. //