Fl_Clock.H 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // "$Id: Fl_Clock.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
  3. //
  4. // Clock 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_Clock, Fl_Clock_Output widgets . */
  20. #ifndef Fl_Clock_H
  21. #define Fl_Clock_H
  22. #ifndef Fl_Widget_H
  23. #include "Fl_Widget.H"
  24. #endif
  25. // values for type:
  26. #define FL_SQUARE_CLOCK 0 /**< type() of Square Clock variant */
  27. #define FL_ROUND_CLOCK 1 /**< type() of Round Clock variant */
  28. #define FL_ANALOG_CLOCK FL_SQUARE_CLOCK /**< An analog clock is square */
  29. #define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */
  30. // fabien: Please keep the horizontal formatting of both images in class desc,
  31. // don't lose vert. space for nothing!
  32. /**
  33. \class Fl_Clock_Output
  34. \brief This widget can be used to display a program-supplied time.
  35. The time shown on the clock is not updated. To display the current time,
  36. use Fl_Clock instead.
  37. \htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
  38. <caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
  39. \image html clock.png
  40. \htmlonly </TD> <TD> \endhtmlonly
  41. \image html round_clock.png
  42. \htmlonly </TD> </TR> </table> \endhtmlonly
  43. \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
  44. \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
  45. */
  46. class FL_EXPORT Fl_Clock_Output : public Fl_Widget {
  47. int hour_, minute_, second_;
  48. ulong value_;
  49. void drawhands(Fl_Color,Fl_Color); // part of draw
  50. protected:
  51. void draw();
  52. void draw(int X, int Y, int W, int H);
  53. public:
  54. Fl_Clock_Output(int X, int Y, int W, int H, const char *L = 0);
  55. void value(ulong v); // set to this Unix time
  56. void value(int H, int m, int s);
  57. /**
  58. Returns the displayed time.
  59. Returns the time in seconds since the UNIX epoch (January 1, 1970).
  60. \see value(ulong)
  61. */
  62. ulong value() const {return value_;}
  63. /**
  64. Returns the displayed hour (0 to 23).
  65. \see value(), minute(), second()
  66. */
  67. int hour() const {return hour_;}
  68. /**
  69. Returns the displayed minute (0 to 59).
  70. \see value(), hour(), second()
  71. */
  72. int minute() const {return minute_;}
  73. /**
  74. Returns the displayed second (0 to 60, 60=leap second).
  75. \see value(), hour(), minute()
  76. */
  77. int second() const {return second_;}
  78. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Clock_Output, Fl_Widget)
  79. };
  80. // a Fl_Clock displays the current time always by using a timeout:
  81. /**
  82. \class Fl_Clock
  83. \brief This widget provides a round analog clock display.
  84. Fl_Clock is provided for Forms compatibility.
  85. It installs a 1-second timeout callback using Fl::add_timeout().
  86. You can choose the rounded or square type of the clock with type(), see below.
  87. \htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
  88. <caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
  89. \image html clock.png
  90. \htmlonly </TD> <TD> \endhtmlonly
  91. \image html round_clock.png
  92. \htmlonly </TD> </TR> </table> \endhtmlonly
  93. \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
  94. \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
  95. */
  96. class FL_EXPORT Fl_Clock : public Fl_Clock_Output {
  97. public:
  98. int handle(int);
  99. Fl_Clock(int X, int Y, int W, int H, const char *L = 0);
  100. Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L);
  101. ~Fl_Clock();
  102. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Clock, Fl_Clock_Output)
  103. };
  104. #endif
  105. //
  106. // End of "$Id: Fl_Clock.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
  107. //