You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.2KB

  1. //
  2. // "$Id: Fl_Clock.H 7981 2010-12-08 23:53:04Z 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; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. /* \file
  28. Fl_Clock, Fl_Clock_Output widgets . */
  29. #ifndef Fl_Clock_H
  30. #define Fl_Clock_H
  31. #ifndef Fl_Widget_H
  32. #include "Fl_Widget.H"
  33. #endif
  34. // values for type:
  35. #define FL_SQUARE_CLOCK 0 /**< type() of Square Clock variant */
  36. #define FL_ROUND_CLOCK 1 /**< type() of Round Clock variant */
  37. #define FL_ANALOG_CLOCK FL_SQUARE_CLOCK /**< An analog clock is square */
  38. #define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */
  39. // fabien: Please keep the horizontal formatting of both images in class desc,
  40. // don't lose vert. space for nothing!
  41. /**
  42. \class Fl_Clock_Output
  43. \brief This widget can be used to display a program-supplied time.
  44. The time shown on the clock is not updated. To display the current time,
  45. use Fl_Clock instead.
  46. \htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
  47. <caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
  48. \image html clock.png
  49. \htmlonly </TD> <TD> \endhtmlonly
  50. \image html round_clock.png
  51. \htmlonly </TD> </TR> </table> \endhtmlonly
  52. \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
  53. \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
  54. */
  55. class FL_EXPORT Fl_Clock_Output : public Fl_Widget {
  56. int hour_, minute_, second_;
  57. ulong value_;
  58. void drawhands(Fl_Color,Fl_Color); // part of draw
  59. protected:
  60. void draw();
  61. void draw(int X, int Y, int W, int H);
  62. public:
  63. Fl_Clock_Output(int X, int Y, int W, int H, const char *L = 0);
  64. void value(ulong v); // set to this Unix time
  65. void value(int H, int m, int s);
  66. /**
  67. Returns the displayed time.
  68. Returns the time in seconds since the UNIX epoch (January 1, 1970).
  69. \see value(ulong)
  70. */
  71. ulong value() const {return value_;}
  72. /**
  73. Returns the displayed hour (0 to 23).
  74. \see value(), minute(), second()
  75. */
  76. int hour() const {return hour_;}
  77. /**
  78. Returns the displayed minute (0 to 59).
  79. \see value(), hour(), second()
  80. */
  81. int minute() const {return minute_;}
  82. /**
  83. Returns the displayed second (0 to 60, 60=leap second).
  84. \see value(), hour(), minute()
  85. */
  86. int second() const {return second_;}
  87. };
  88. // a Fl_Clock displays the current time always by using a timeout:
  89. /**
  90. \class Fl_Clock
  91. \brief This widget provides a round analog clock display.
  92. Fl_Clock is provided for Forms compatibility.
  93. It installs a 1-second timeout callback using Fl::add_timeout().
  94. You can choose the rounded or square type of the clock with type(), see below.
  95. \htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
  96. <caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
  97. \image html clock.png
  98. \htmlonly </TD> <TD> \endhtmlonly
  99. \image html round_clock.png
  100. \htmlonly </TD> </TR> </table> \endhtmlonly
  101. \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
  102. \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
  103. */
  104. class FL_EXPORT Fl_Clock : public Fl_Clock_Output {
  105. public:
  106. int handle(int);
  107. Fl_Clock(int X, int Y, int W, int H, const char *L = 0);
  108. Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L);
  109. ~Fl_Clock();
  110. };
  111. #endif
  112. //
  113. // End of "$Id: Fl_Clock.H 7981 2010-12-08 23:53:04Z greg.ercolano $".
  114. //