1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Clock header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2008-09-16 10:49:08 +04:00
|
|
|
// Copyright 1998-2008 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.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
|
|
|
|
|
|
|
|
// values for type:
|
2008-09-21 12:00:32 +04: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 */
|
|
|
|
#define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 15:27:29 +04:00
|
|
|
// fabien: Please keep the horizontal formatting of both images in class desc,
|
|
|
|
// don't loose vert. space for nothing!
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
The time shown on the clock is not updated. To display the current time,
|
|
|
|
use Fl_Clock instead.
|
|
|
|
|
2008-10-15 15:27:29 +04:00
|
|
|
\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.gif
|
|
|
|
\htmlonly </TD> <TD> \endhtmlonly
|
|
|
|
\image html round_clock.gif
|
|
|
|
\htmlonly </TD> </TR> </table> \endhtmlonly
|
|
|
|
\image latex clock.eps "FL_SQUARE_CLOCK type" width=4cm
|
|
|
|
\image latex round_clock.eps "FL_ROUND_CLOCK type" width=4cm
|
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_;
|
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:
|
2002-08-14 20:49:38 +04:00
|
|
|
void draw();
|
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);
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
void value(ulong v); // set to this Unix time
|
2008-04-08 04:09:16 +04:00
|
|
|
|
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_;}
|
|
|
|
};
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Fl_Clock is provided for Forms compatibility.
|
|
|
|
It installs a 1-second timeout callback using Fl::add_timeout().
|
2008-10-15 15:27:29 +04:00
|
|
|
You can choose the rounded or square type of the the clock with type(), see below.
|
|
|
|
\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.gif
|
|
|
|
\htmlonly </TD> <TD> \endhtmlonly
|
|
|
|
\image html round_clock.gif
|
|
|
|
\htmlonly </TD> </TR> </table> \endhtmlonly
|
|
|
|
\image latex clock.eps "FL_SQUARE_CLOCK type" width=4cm
|
|
|
|
\image latex round_clock.eps "FL_ROUND_CLOCK type" width=4cm
|
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:
|
2002-08-14 20:49:38 +04:00
|
|
|
int handle(int);
|
2008-09-21 12:00:32 +04:00
|
|
|
/**
|
|
|
|
Undefined.
|
|
|
|
\todo Find Fl_Clock::update() implementation, if any, and document it.
|
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
void update();
|
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);
|
2008-04-08 04:09:16 +04:00
|
|
|
|
2008-09-16 10:49:08 +04:00
|
|
|
Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L);
|
2008-04-08 04:09:16 +04: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
|
|
|
|
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|