Crazy Eddies GUI System  0.6.2
CEGUISpinner.h
1 /***********************************************************************
2  filename: CEGUISpinner.h
3  created: 3/2/2005
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUISpinner_h_
29 #define _CEGUISpinner_h_
30 
31 #include "CEGUIBase.h"
32 #include "CEGUIWindow.h"
33 #include "elements/CEGUISpinnerProperties.h"
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 
41 // Start of CEGUI namespace section
42 namespace CEGUI
43 {
63  class CEGUIEXPORT Spinner : public Window
64  {
65  public:
71  {
75  Octal
76  };
77 
78  /*************************************************************************
79  Events system constants
80  *************************************************************************/
81  static const String WidgetTypeName;
82  static const String EventNamespace;
83  static const String EventValueChanged;
84  static const String EventStepChanged;
88 
89  /*************************************************************************
90  Component widget name suffix strings
91  *************************************************************************/
92  static const String EditboxNameSuffix;
95 
96  /*************************************************************************
97  Object Construction and Destruction
98  *************************************************************************/
103  Spinner(const String& type, const String& name);
104 
109  virtual ~Spinner(void);
110 
121  void initialiseComponents(void);
122 
123 
124  /*************************************************************************
125  Accessors
126  *************************************************************************/
134  float getCurrentValue(void) const;
135 
144  float getStepSize(void) const;
145 
153  float getMaximumValue(void) const;
154 
162  float getMinimumValue(void) const;
163 
172  TextInputMode getTextInputMode(void) const;
173 
174  /*************************************************************************
175  Manipulators
176  *************************************************************************/
187  void setCurrentValue(float value);
188 
200  void setStepSize(float step);
201 
212  void setMaximumValue(float maxValue);
213 
224  void setMinimumValue(float minVaue);
225 
237  void setTextInputMode(TextInputMode mode);
238 
239  protected:
240  /*************************************************************************
241  Constants
242  *************************************************************************/
243  static const String FloatValidator;
244  static const String IntegerValidator;
245  static const String HexValidator;
246  static const String OctalValidator;
247 
248  /*************************************************************************
249  Protected Implementation Methods
250  *************************************************************************/
260  virtual float getValueFromText(void) const;
261 
269  virtual String getTextFromValue(void) const;
270 
271 
282  virtual bool testClassName_impl(const String& class_name) const
283  {
284  if (class_name=="Spinner") return true;
285  return Window::testClassName_impl(class_name);
286  }
287 
299  PushButton* getIncreaseButton() const;
300 
312  PushButton* getDecreaseButton() const;
313 
324  Editbox* getEditbox() const;
325 
326  /*************************************************************************
327  Overrides for Event handler methods
328  *************************************************************************/
329  virtual void onFontChanged(WindowEventArgs& e);
330  virtual void onTextChanged(WindowEventArgs& e);
331  virtual void onActivated(ActivationEventArgs& e);
332 
333  /*************************************************************************
334  New Event handler methods
335  *************************************************************************/
346  virtual void onValueChanged(WindowEventArgs& e);
347 
358  virtual void onStepChanged(WindowEventArgs& e);
359 
370  virtual void onMaximumValueChanged(WindowEventArgs& e);
371 
382  virtual void onMinimumValueChanged(WindowEventArgs& e);
383 
394  virtual void onTextInputModeChanged(WindowEventArgs& e);
395 
396  /*************************************************************************
397  Internal event listener methods
398  *************************************************************************/
399  bool handleIncreaseButton(const EventArgs& e);
400  bool handleDecreaseButton(const EventArgs& e);
401  bool handleEditTextChange(const EventArgs& e);
402 
403 
404  /*************************************************************************
405  Data Fields
406  *************************************************************************/
407  float d_stepSize;
409  float d_maxValue;
410  float d_minValue;
412 
413  private:
414  /*************************************************************************
415  Static properties for the Spinner widget
416  *************************************************************************/
417  static SpinnerProperties::CurrentValue d_currentValueProperty;
418  static SpinnerProperties::StepSize d_stepSizeProperty;
419  static SpinnerProperties::MaximumValue d_maxValueProperty;
420  static SpinnerProperties::MinimumValue d_minValueProperty;
421  static SpinnerProperties::TextInputMode d_textInputModeProperty;
422 
423  /*************************************************************************
424  Private Implementation Methods
425  *************************************************************************/
433  void addSpinnerProperties(void);
434  };
435 
436 } // End of CEGUI namespace section
437 
438 #if defined(_MSC_VER)
439 # pragma warning(pop)
440 #endif
441 
442 #endif // end of guard _CEGUISpinner_h_