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