-
Notifications
You must be signed in to change notification settings - Fork 261
/
Fl_Clock.H
163 lines (128 loc) · 4.8 KB
/
Fl_Clock.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//
// Clock header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2017 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
/* \file
Fl_Clock, Fl_Clock_Output widgets . */
#ifndef Fl_Clock_H
#define Fl_Clock_H
#ifndef Fl_Widget_H
#include "Fl_Widget.H"
#endif
// Values for type():
// Please change doxygen documentation below (class Fl_Clock_Output)
// accordingly as well when changing the following type values:
#define FL_SQUARE_CLOCK 0 /**< type() of Square Clock variant */
#define FL_ROUND_CLOCK 1 /**< type() of Round Clock variant */
#define FL_ANALOG_CLOCK FL_SQUARE_CLOCK /**< An analog clock is square */
#define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */
// fabien: Please keep the horizontal formatting of both images in class desc,
// don't lose vertical space for nothing!
/**
\class Fl_Clock_Output
\brief This widget can be used to display a program-supplied time.
The time shown on the clock is not updated. To display the current time,
use Fl_Clock instead.
\htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
<caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
\image html clock.png
\htmlonly </TD> <TD> \endhtmlonly
\image html round_clock.png
\htmlonly </TD> </TR> </table> \endhtmlonly
\image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
\image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
Values for clock type() (\#include \<FL/Clock.H\>):
\code
#define FL_SQUARE_CLOCK 0 // Square Clock variant
#define FL_ROUND_CLOCK 1 // Round Clock variant
#define FL_ANALOG_CLOCK FL_SQUARE_CLOCK // An analog clock is square
#define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK // Not yet implemented
\endcode
*/
class FL_EXPORT Fl_Clock_Output : public Fl_Widget {
int hour_, minute_, second_;
ulong value_;
int shadow_; // draw shadows of hands
void drawhands(Fl_Color,Fl_Color); // part of draw
protected:
void draw() FL_OVERRIDE;
void draw(int X, int Y, int W, int H);
public:
Fl_Clock_Output(int X, int Y, int W, int H, const char *L = 0);
void value(ulong v); // set to this Unix time
void value(int H, int m, int s);
/**
Returns the displayed time.
Returns the time in seconds since the UNIX epoch (January 1, 1970).
\see value(ulong)
*/
ulong value() const {return value_;}
/**
Returns the displayed hour (0 to 23).
\see value(), minute(), second()
*/
int hour() const {return hour_;}
/**
Returns the displayed minute (0 to 59).
\see value(), hour(), second()
*/
int minute() const {return minute_;}
/**
Returns the displayed second (0 to 60, 60=leap second).
\see value(), hour(), minute()
*/
int second() const {return second_;}
/**
Returns the shadow drawing mode of the hands.
\returns shadow drawing mode of the hands
\retval 0 no shadows
\retval 1 draw shadows of hands (default)
*/
int shadow() const {return shadow_;}
/**
Sets the shadow drawing mode of the hands.
Enables (1) or disables (0) drawing the hands with shadows.
Values except 0 and 1 are reserved for future extensions and
yield undefined behavior.
The default is to draw the shadows (1).
\param[in] mode 1 = shadows (default), 0 = no shadows
*/
void shadow(int mode) { shadow_ = mode ? 1 : 0; }
};
// a Fl_Clock displays the current time always by using a timeout:
/**
\class Fl_Clock
\brief This widget provides a round analog clock display.
Fl_Clock is provided for Forms compatibility.
It installs a 1-second timeout callback using Fl::add_timeout().
You can choose the rounded or square type of the clock with type().
Please see Fl_Clock_Output widget for applicable values.
\htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
<caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
\image html clock.png
\htmlonly </TD> <TD> \endhtmlonly
\image html round_clock.png
\htmlonly </TD> </TR> </table> \endhtmlonly
\image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
\image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
\see class Fl_Clock_Output
*/
class FL_EXPORT Fl_Clock : public Fl_Clock_Output {
public:
int handle(int) FL_OVERRIDE;
Fl_Clock(int X, int Y, int W, int H, const char *L = 0);
Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L);
~Fl_Clock();
};
#endif