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