1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Clock header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2017-05-15 17:26:02 +03:00
|
|
|
// Copyright 1998-2017 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// 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:
|
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/COPYING.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// Please see the following page on how to report bugs and issues:
|
2005-04-16 04:13:17 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/bugs.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Clock, Fl_Clock_Output widgets . */
|
2008-04-08 04:09:16 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_Clock_H
|
|
|
|
#define Fl_Clock_H
|
|
|
|
|
|
|
|
#ifndef Fl_Widget_H
|
|
|
|
#include "Fl_Widget.H"
|
|
|
|
#endif
|
|
|
|
|
2017-05-15 17:26:02 +03:00
|
|
|
// Values for type():
|
|
|
|
// Please change doxygen documentation below (class Fl_Clock_Output)
|
|
|
|
// accordingly as well when changing the following type values:
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
#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 */
|
2008-09-21 12:00:32 +04:00
|
|
|
#define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
// fabien: Please keep the horizontal formatting of both images in class desc,
|
2017-05-15 17:26:02 +03:00
|
|
|
// don't lose vertical space for nothing!
|
2008-10-15 15:27:29 +04:00
|
|
|
|
2008-04-08 04:09:16 +04:00
|
|
|
/**
|
2008-09-16 10:49:08 +04:00
|
|
|
\class Fl_Clock_Output
|
|
|
|
\brief This widget can be used to display a program-supplied time.
|
2017-05-15 17:26:02 +03:00
|
|
|
|
2008-09-16 10:49:08 +04:00
|
|
|
The time shown on the clock is not updated. To display the current time,
|
|
|
|
use Fl_Clock instead.
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
\htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
|
2008-10-15 15:27:29 +04:00
|
|
|
<caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
|
2020-07-01 19:03:10 +03:00
|
|
|
\image html clock.png
|
2008-10-15 15:27:29 +04:00
|
|
|
\htmlonly </TD> <TD> \endhtmlonly
|
2020-07-01 19:03:10 +03:00
|
|
|
\image html round_clock.png
|
2008-10-15 15:27:29 +04:00
|
|
|
\htmlonly </TD> </TR> </table> \endhtmlonly
|
2010-12-09 02:53:04 +03:00
|
|
|
\image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
|
|
|
|
\image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
|
2017-05-15 17:26:02 +03:00
|
|
|
|
|
|
|
Values for clock type() (\#include \<FL/Clock.H\>):
|
|
|
|
|
|
|
|
\code
|
2020-07-01 19:03:10 +03:00
|
|
|
#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
|
2017-05-15 17:26:02 +03:00
|
|
|
\endcode
|
|
|
|
|
2008-04-08 04:09:16 +04:00
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
class FL_EXPORT Fl_Clock_Output : public Fl_Widget {
|
1998-10-06 22:21:25 +04:00
|
|
|
int hour_, minute_, second_;
|
|
|
|
ulong value_;
|
2017-05-15 18:30:52 +03:00
|
|
|
int shadow_; // draw shadows of hands
|
2002-08-14 20:49:38 +04:00
|
|
|
void drawhands(Fl_Color,Fl_Color); // part of draw
|
1998-10-06 22:21:25 +04:00
|
|
|
protected:
|
2022-12-30 21:14:36 +03:00
|
|
|
void draw() FL_OVERRIDE;
|
2008-09-21 12:00:32 +04:00
|
|
|
void draw(int X, int Y, int W, int H);
|
1998-10-06 22:21:25 +04:00
|
|
|
public:
|
2008-04-08 04:09:16 +04:00
|
|
|
|
2008-09-16 10:49:08 +04:00
|
|
|
Fl_Clock_Output(int X, int Y, int W, int H, const char *L = 0);
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
void value(ulong v); // set to this Unix time
|
|
|
|
|
2008-09-16 10:49:08 +04:00
|
|
|
void value(int H, int m, int s);
|
|
|
|
|
2008-04-08 04:09:16 +04:00
|
|
|
/**
|
2008-09-16 10:49:08 +04:00
|
|
|
Returns the displayed time.
|
|
|
|
Returns the time in seconds since the UNIX epoch (January 1, 1970).
|
|
|
|
\see value(ulong)
|
2008-04-08 04:09:16 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
ulong value() const {return value_;}
|
2008-04-08 04:09:16 +04:00
|
|
|
|
|
|
|
/**
|
2008-09-16 10:49:08 +04:00
|
|
|
Returns the displayed hour (0 to 23).
|
|
|
|
\see value(), minute(), second()
|
2008-04-08 04:09:16 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int hour() const {return hour_;}
|
2008-04-08 04:09:16 +04:00
|
|
|
|
|
|
|
/**
|
2008-09-16 10:49:08 +04:00
|
|
|
Returns the displayed minute (0 to 59).
|
|
|
|
\see value(), hour(), second()
|
2008-04-08 04:09:16 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int minute() const {return minute_;}
|
2008-04-08 04:09:16 +04:00
|
|
|
|
|
|
|
/**
|
2008-09-16 10:49:08 +04:00
|
|
|
Returns the displayed second (0 to 60, 60=leap second).
|
|
|
|
\see value(), hour(), minute()
|
2008-04-08 04:09:16 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int second() const {return second_;}
|
2017-05-15 18:30:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the shadow drawing mode of the hands.
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
\returns shadow drawing mode of the hands
|
|
|
|
\retval 0 no shadows
|
|
|
|
\retval 1 draw shadows of hands (default)
|
2017-05-15 18:30:52 +03:00
|
|
|
*/
|
|
|
|
int shadow() const {return shadow_;}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the shadow drawing mode of the hands.
|
|
|
|
|
2017-05-15 18:35:30 +03:00
|
|
|
Enables (1) or disables (0) drawing the hands with shadows.
|
2017-05-15 18:30:52 +03:00
|
|
|
|
|
|
|
Values except 0 and 1 are reserved for future extensions and
|
|
|
|
yield undefined behavior.
|
|
|
|
|
|
|
|
The default is to draw the shadows (1).
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
\param[in] mode 1 = shadows (default), 0 = no shadows
|
2017-05-15 18:30:52 +03:00
|
|
|
*/
|
|
|
|
void shadow(int mode) { shadow_ = mode ? 1 : 0; }
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
1999-01-13 18:45:50 +03:00
|
|
|
// a Fl_Clock displays the current time always by using a timeout:
|
|
|
|
|
2008-04-08 04:09:16 +04:00
|
|
|
/**
|
2008-09-16 10:49:08 +04:00
|
|
|
\class Fl_Clock
|
|
|
|
\brief This widget provides a round analog clock display.
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
Fl_Clock is provided for Forms compatibility.
|
2008-09-16 10:49:08 +04:00
|
|
|
It installs a 1-second timeout callback using Fl::add_timeout().
|
2017-05-15 17:26:02 +03:00
|
|
|
You can choose the rounded or square type of the clock with type().
|
|
|
|
Please see Fl_Clock_Output widget for applicable values.
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
\htmlonly <BR> <table align=CENTER border=1 cellpadding=5 >
|
2008-10-15 15:27:29 +04:00
|
|
|
<caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly
|
2020-07-01 19:03:10 +03:00
|
|
|
\image html clock.png
|
2008-10-15 15:27:29 +04:00
|
|
|
\htmlonly </TD> <TD> \endhtmlonly
|
2020-07-01 19:03:10 +03:00
|
|
|
\image html round_clock.png
|
2008-10-15 15:27:29 +04:00
|
|
|
\htmlonly </TD> </TR> </table> \endhtmlonly
|
2020-07-01 19:03:10 +03:00
|
|
|
\image latex clock.png "FL_SQUARE_CLOCK type" width=4cm
|
2010-12-09 02:53:04 +03:00
|
|
|
\image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm
|
2017-05-15 17:26:02 +03:00
|
|
|
|
|
|
|
\see class Fl_Clock_Output
|
2008-04-08 04:09:16 +04:00
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
class FL_EXPORT Fl_Clock : public Fl_Clock_Output {
|
1999-01-13 18:45:50 +03:00
|
|
|
public:
|
2022-12-30 21:14:36 +03:00
|
|
|
int handle(int) FL_OVERRIDE;
|
2008-04-08 04:09:16 +04:00
|
|
|
|
2008-09-16 10:49:08 +04:00
|
|
|
Fl_Clock(int X, int Y, int W, int H, const char *L = 0);
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2008-09-16 10:49:08 +04:00
|
|
|
Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L);
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
~Fl_Clock();
|
1999-01-13 18:45:50 +03:00
|
|
|
};
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|