|
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
|
00001 /********************************************************************************
00002 * *
00003 * Digital clock *
00004 * *
00005 *********************************************************************************
00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or *
00009 * modify it under the terms of the GNU Lesser General Public *
00010 * License as published by the Free Software Foundation; either *
00011 * version 2.1 of the License, or (at your option) any later version. *
00012 * *
00013 * This library is distributed in the hope that it will be useful, *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
00016 * Lesser General Public License for more details. *
00017 * *
00018 * You should have received a copy of the GNU Lesser General Public *
00019 * License along with this library; if not, write to the Free Software *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
00021 *********************************************************************************/
00022 #ifndef FXCLOCKBUTTON_H
00023 #define FXCLOCKBUTTON_H
00024
00025 #ifndef FXBUTTON_H
00026 #include <fox/FXButton.h>
00027 using namespace FX;
00028 #endif
00029 namespace FXEX {
00030
00031 /// ClockButton styles
00032 enum {
00033 CLOCKBUTTON_SECONDS = 0x10000000, /// show the 'seconds' value
00034 CLOCKBUTTON_SYMBOL = 0x20000000, /// show the am/pm symbol
00035 CLOCKBUTTON_24HOUR = 0x40000000, /// use 24 hour clock
00036 };
00037
00038 /**
00039 * A plain old digital clock - eg. for use in the status line of your app.
00040 * you can click on it to generate the appropriate FOX events.
00041 */
00042 class FXAPI FXClockButton : public FXButton {
00043 FXDECLARE(FXClockButton)
00044
00045 protected:
00046 FXString timeFormat;
00047
00048 protected:
00049 /// serialisation
00050 FXClockButton();
00051
00052 /// Set the time/date format to that defined by FXTime
00053 void setFormat();
00054
00055 public:
00056 enum {
00057 ID_CLOCK_UPDATE=FXButton::ID_LAST,
00058 ID_TOGGLE_SECONDS,
00059 ID_TOGGLE_HOURMODE,
00060 ID_TOGGLE_SYMBOL,
00061 ID_LAST
00062 };
00063
00064 public:
00065 long onClockTimeout(FXObject*,FXSelector,void*);
00066 long onCmdToggleSeconds(FXObject*,FXSelector,void*);
00067 long onUpdToggleSeconds(FXObject*,FXSelector,void*);
00068 long onCmdToggleHourMode(FXObject*,FXSelector,void*);
00069 long onUpdToggleHourMode(FXObject*,FXSelector,void*);
00070 long onCmdToggleSymbol(FXObject*,FXSelector,void*);
00071 long onUpdToggleSymbol(FXObject*,FXSelector,void*);
00072
00073 public:
00074 /// Make a new ClockButton
00075 FXClockButton(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,
00076 FXuint opts=BUTTON_TOOLBAR|FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT,
00077 FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,
00078 FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
00079
00080 /// create
00081 virtual void create();
00082
00083 /// get the current format, as defined by FXTime
00084 FXString getFormat() { return timeFormat; }
00085
00086 /// Show seconds
00087 void seconds(FXbool mode);
00088
00089 /// are we showing the seconds?
00090 FXbool seconds() { return (options&CLOCKBUTTON_SECONDS)!=0; }
00091
00092 /// set the time format to 24 hour time
00093 void hourMode(FXbool mode);
00094
00095 /// is the time set at 24 hour time
00096 FXbool hourMode() { return (options&CLOCKBUTTON_24HOUR)!=0; }
00097
00098 /// Show the AM/PM symbol
00099 void symbol(FXbool mode);
00100
00101 /// is the AM/PM symbol showing
00102 FXbool symbol() { return (options&CLOCKBUTTON_SYMBOL)!=0; }
00103
00104 /// save to stream
00105 virtual void save(FXStream& store) const;
00106
00107 /// load from stream
00108 virtual void load(FXStream& store);
00109
00110 /// destructor
00111 virtual ~FXClockButton();
00112 };
00113
00114 } // namespace FXEX
00115 #endif // FXCLOCKBUTTON_H