CEGUISpinner.h

00001 /***********************************************************************
00002     filename:   CEGUISpinner.h
00003     created:    3/2/2005
00004     author:             Paul D Turner
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUISpinner_h_
00029 #define _CEGUISpinner_h_
00030 
00031 #include "CEGUIBase.h"
00032 #include "CEGUIWindow.h"
00033 #include "elements/CEGUISpinnerProperties.h"
00034 
00035 #if defined(_MSC_VER)
00036 #       pragma warning(push)
00037 #       pragma warning(disable : 4251)
00038 #endif
00039 
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00063     class CEGUIEXPORT Spinner : public Window
00064     {
00065     public:
00070         enum TextInputMode
00071         {
00072             FloatingPoint,  
00073             Integer,        
00074             Hexadecimal,    
00075             Octal           
00076         };
00077 
00078         /*************************************************************************
00079             Events system constants
00080         *************************************************************************/
00081         static const String WidgetTypeName;                 
00082         static const String EventNamespace;                 
00083         static const String EventValueChanged;              
00084         static const String EventStepChanged;               
00085         static const String EventMaximumValueChanged;       
00086         static const String EventMinimumValueChanged;       
00087         static const String EventTextInputModeChanged;      
00088 
00089         /*************************************************************************
00090             Component widget name suffix strings
00091         *************************************************************************/
00092         static const String EditboxNameSuffix;          
00093         static const String IncreaseButtonNameSuffix;   
00094         static const String DecreaseButtonNameSuffix;   
00095 
00096         /*************************************************************************
00097             Object Construction and Destruction
00098         *************************************************************************/
00103         Spinner(const String& type, const String& name);
00104 
00109         virtual ~Spinner(void);
00110 
00121         void initialiseComponents(void);
00122 
00123 
00124         /*************************************************************************
00125                 Accessors
00126         *************************************************************************/
00134         float getCurrentValue(void) const;
00135 
00144         float getStepSize(void) const;
00145 
00153         float getMaximumValue(void) const;
00154 
00162         float getMinimumValue(void) const;
00163 
00172         TextInputMode getTextInputMode(void) const;
00173 
00174         /*************************************************************************
00175                 Manipulators
00176         *************************************************************************/
00187         void setCurrentValue(float value);
00188 
00200         void setStepSize(float step);
00201 
00212         void setMaximumValue(float maxValue);
00213 
00224         void setMinimumValue(float minVaue);
00225 
00237         void setTextInputMode(TextInputMode mode);
00238 
00239     protected:
00240         /*************************************************************************
00241                 Constants
00242         *************************************************************************/
00243         static const String FloatValidator;      
00244         static const String IntegerValidator;    
00245         static const String HexValidator;        
00246         static const String OctalValidator;      
00247 
00248         /*************************************************************************
00249                 Protected Implementation Methods
00250         *************************************************************************/
00260         virtual float getValueFromText(void) const;
00261 
00269         virtual String getTextFromValue(void) const;
00270 
00271 
00282                 virtual bool    testClassName_impl(const String& class_name) const
00283                 {
00284                         if (class_name=="Spinner")      return true;
00285                         return Window::testClassName_impl(class_name);
00286                 }
00287 
00299         PushButton* getIncreaseButton() const;
00300 
00312         PushButton* getDecreaseButton() const;
00313 
00324         Editbox* getEditbox() const;
00325 
00326         /*************************************************************************
00327                 Overrides for Event handler methods
00328         *************************************************************************/
00329         virtual void onFontChanged(WindowEventArgs& e);
00330         virtual void onTextChanged(WindowEventArgs& e);
00331         virtual void onActivated(ActivationEventArgs& e);
00332 
00333         /*************************************************************************
00334                 New Event handler methods
00335         *************************************************************************/
00346         virtual void onValueChanged(WindowEventArgs& e);
00347 
00358         virtual void onStepChanged(WindowEventArgs& e);
00359 
00370         virtual void onMaximumValueChanged(WindowEventArgs& e);
00371 
00382         virtual void onMinimumValueChanged(WindowEventArgs& e);
00383 
00394         virtual void onTextInputModeChanged(WindowEventArgs& e);
00395 
00396         /*************************************************************************
00397                 Internal event listener methods
00398         *************************************************************************/
00399         bool handleIncreaseButton(const EventArgs& e);
00400         bool handleDecreaseButton(const EventArgs& e);
00401         bool handleEditTextChange(const EventArgs& e);
00402 
00403 
00404         /*************************************************************************
00405                 Data Fields
00406         *************************************************************************/
00407         float   d_stepSize;     
00408         float   d_currentValue; 
00409         float   d_maxValue;     
00410         float   d_minValue;     
00411         TextInputMode   d_inputMode;    
00412 
00413     private:
00414         /*************************************************************************
00415                 Static properties for the Spinner widget
00416         *************************************************************************/
00417         static SpinnerProperties::CurrentValue  d_currentValueProperty;
00418         static SpinnerProperties::StepSize      d_stepSizeProperty;
00419         static SpinnerProperties::MaximumValue  d_maxValueProperty;
00420         static SpinnerProperties::MinimumValue  d_minValueProperty;
00421         static SpinnerProperties::TextInputMode d_textInputModeProperty;
00422 
00423         /*************************************************************************
00424                 Private Implementation Methods
00425         *************************************************************************/
00433         void    addSpinnerProperties(void);
00434     };
00435 
00436 } // End of  CEGUI namespace section
00437 
00438 #if defined(_MSC_VER)
00439 #       pragma warning(pop)
00440 #endif
00441 
00442 #endif  // end of guard _CEGUISpinner_h_

Generated on Sat Jun 28 14:35:44 2008 for Crazy Eddies GUI System by  doxygen 1.5.4