Crazy Eddie's GUI System  ${CEGUI_VERSION}
Minesweeper_Timer.h
1 /***********************************************************************
2  created: 08/08/2006
3  author: Olivier Delannoy
4 
5  purpose: Interface to timer window
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _Minesweeper_Timer_h_
30 #define _Minesweeper_Timer_h_
31 
32 #include "CEGUI/Window.h"
33 #include "CEGUI/WindowFactory.h"
34 #include "CEGUI/Property.h"
35 
36 namespace TimerProperties
37 {
49 class Delay : public CEGUI::Property
50 {
51 public:
52  Delay() : Property("Delay", "Property to get/set the current delay used by the timer. Value is a float.", "0.000000") {}
53  CEGUI::String get(const CEGUI::PropertyReceiver* receiver) const;
54  void set(CEGUI::PropertyReceiver* receiver, const CEGUI::String& value);
55  CEGUI::Property* clone() const;
56 };
57 
58 }
59 
73 class Timer : public CEGUI::Window
74 {
75 public:
76  /*************************************************************************
77  Constants
78  *************************************************************************/
79  // type name for this widget
83 
84 
85 
86  /*************************************************************************
87  Construction and Destruction
88  *************************************************************************/
93  Timer(const CEGUI::String& type, const CEGUI::String& name);
98  virtual ~Timer(void) {}
99 
103  void start();
107  void stop();
111  bool isStarted() const;
116  void setDelay(float delay);
117 
118  float getDelay() const;
119 
120 protected:
121  virtual void updateSelf(float elapsed);
122 
123 private:
124  static TimerProperties::Delay d_delayProperty;
125  float d_delay;
126  float d_currentValue;
127  bool d_started;
128  void addTimerProperties(void);
129 };
130 
132 {
133 public:
136  { return new Timer(d_type, name); }
138  { delete window;}
139 };
140 
141 TimerFactory& getTimerFactory();
142 
143 #endif // end of guard _CEGUIGUISheet_h_
static const CEGUI::String EventNamespace
Store the event namespace related to the timer.
Definition: Minesweeper_Timer.h:81
void set(CEGUI::PropertyReceiver *receiver, const CEGUI::String &value)
Sets the value of the property.
Definition: Minesweeper_Timer.cpp:37
virtual void updateSelf(float elapsed)
Perform actual update processing for this Window.
Definition: Minesweeper_Timer.cpp:95
virtual ~Timer(void)
Destructor for Timer windows.
Definition: Minesweeper_Timer.h:98
static const CEGUI::String EventTimerAlarm
The name of the event generated by this widget.
Definition: Minesweeper_Timer.h:82
Definition: Minesweeper_Timer.cpp:31
Definition: Minesweeper_Timer.h:131
Dummy base class to ensure correct casting of receivers.
Definition: cegui/include/CEGUI/Property.h:45
void start()
start the timer in order to generate alarm event
Definition: Minesweeper_Timer.cpp:73
Timer(const CEGUI::String &type, const CEGUI::String &name)
Constructor for Timer windows.
Definition: Minesweeper_Timer.cpp:61
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: cegui/include/CEGUI/Window.h:149
String d_type
String holding the type of object created by this factory.
Definition: cegui/include/CEGUI/WindowFactory.h:167
void destroyWindow(CEGUI::Window *window)
Destroys the given Window object.
Definition: Minesweeper_Timer.h:137
CEGUI::Window * createWindow(const CEGUI::String &name)
Create a new Window object of whatever type this WindowFactory produces.
Definition: Minesweeper_Timer.h:135
An abstract class that defines the interface to access object properties by name. ...
Definition: cegui/include/CEGUI/Property.h:60
Property to access the delay between two alarm.
Definition: Minesweeper_Timer.h:49
Abstract class that defines the required interface for all WindowFactory objects. ...
Definition: cegui/include/CEGUI/WindowFactory.h:115
static const CEGUI::String WidgetTypeName
The unique typename of this widget.
Definition: Minesweeper_Timer.h:80
Property(const String &name, const String &help, const String &defaultValue="", bool writesXML=true, const String &dataType="Unknown", const String &origin="Unknown")
Creates a new Property object.
Definition: cegui/include/CEGUI/Property.h:91
Window class intended to be used as a timer.
Definition: Minesweeper_Timer.h:73
void stop()
stop generating alarm event
Definition: Minesweeper_Timer.cpp:77
bool isStarted() const
Check wether the timer is started or not.
Definition: Minesweeper_Timer.cpp:81
void setDelay(float delay)
Set the delay between to event generation in seconds.
Definition: Minesweeper_Timer.cpp:85
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62