Crazy Eddies GUI System: CEGUISpinner.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 "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 {
    00052     class CEGUIEXPORT Spinner : public Window
    00053     {
    00054     public:
    00059         enum TextInputMode
    00060         {
    00061             FloatingPoint,
    00062             Integer,
    00063             Hexadecimal,
    00064             Octal
    00065         };
    00066
    00067         /*************************************************************************
    00068             Events system constants
    00069         *************************************************************************/
    00070         static const String WidgetTypeName;
    00071         static const String EventNamespace;
    00072
    00077         static const String EventValueChanged;
    00083         static const String EventStepChanged;
    00089         static const String EventMaximumValueChanged;
    00095         static const String EventMinimumValueChanged;
    00101         static const String EventTextInputModeChanged;
    00102
    00103         /*************************************************************************
    00104             Component widget name suffix strings
    00105         *************************************************************************/
    00106         static const String EditboxNameSuffix;
    00107         static const String IncreaseButtonNameSuffix;
    00108         static const String DecreaseButtonNameSuffix;
    00109
    00110         /*************************************************************************
    00111             Object Construction and Destruction
    00112         *************************************************************************/
    00117         Spinner(const String& type, const String& name);
    00118
    00123         virtual ~Spinner(void);
    00124
    00135         void initialiseComponents(void);
    00136
    00137
    00138         /*************************************************************************
    00139                 Accessors
    00140         *************************************************************************/
    00148         double getCurrentValue(void) const;
    00149
    00158         double getStepSize(void) const;
    00159
    00167         double getMaximumValue(void) const;
    00168
    00176         double getMinimumValue(void) const;
    00177
    00186         TextInputMode getTextInputMode(void) const;
    00187
    00188         /*************************************************************************
    00189                 Manipulators
    00190         *************************************************************************/
    00201         void setCurrentValue(double value);
    00202
    00214         void setStepSize(double step);
    00215
    00226         void setMaximumValue(double maxValue);
    00227
    00238         void setMinimumValue(double minVaue);
    00239
    00251         void setTextInputMode(TextInputMode mode);
    00252
    00253     protected:
    00254         /*************************************************************************
    00255                 Constants
    00256         *************************************************************************/
    00257         static const String FloatValidator;
    00258         static const String IntegerValidator;
    00259         static const String HexValidator;
    00260         static const String OctalValidator;
    00261
    00262         /*************************************************************************
    00263                 Protected Implementation Methods
    00264         *************************************************************************/
    00274         virtual double getValueFromText(void) const;
    00275
    00283         virtual String getTextFromValue(void) const;
    00284
    00285
    00296                 virtual bool    testClassName_impl(const String& class_name) const
    00297                 {
    00298                         if (class_name=="Spinner")      return true;
    00299                         return Window::testClassName_impl(class_name);
    00300                 }
    00301
    00313         PushButton* getIncreaseButton() const;
    00314
    00326         PushButton* getDecreaseButton() const;
    00327
    00338         Editbox* getEditbox() const;
    00339
    00340         /*************************************************************************
    00341                 Overrides for Event handler methods
    00342         *************************************************************************/
    00343         virtual void onFontChanged(WindowEventArgs& e);
    00344         virtual void onTextChanged(WindowEventArgs& e);
    00345         virtual void onActivated(ActivationEventArgs& e);
    00346
    00347         /*************************************************************************
    00348                 New Event handler methods
    00349         *************************************************************************/
    00360         virtual void onValueChanged(WindowEventArgs& e);
    00361
    00372         virtual void onStepChanged(WindowEventArgs& e);
    00373
    00384         virtual void onMaximumValueChanged(WindowEventArgs& e);
    00385
    00396         virtual void onMinimumValueChanged(WindowEventArgs& e);
    00397
    00408         virtual void onTextInputModeChanged(WindowEventArgs& e);
    00409
    00410         /*************************************************************************
    00411                 Internal event listener methods
    00412         *************************************************************************/
    00413         bool handleIncreaseButton(const EventArgs& e);
    00414         bool handleDecreaseButton(const EventArgs& e);
    00415         bool handleEditTextChange(const EventArgs& e);
    00416
    00417
    00418         /*************************************************************************
    00419                 Data Fields
    00420         *************************************************************************/
    00421         double   d_stepSize;
    00422         double   d_currentValue;
    00423         double   d_maxValue;
    00424         double   d_minValue;
    00425         TextInputMode   d_inputMode;
    00426
    00427     private:
    00428         /*************************************************************************
    00429                 Static properties for the Spinner widget
    00430         *************************************************************************/
    00431         static SpinnerProperties::CurrentValue  d_currentValueProperty;
    00432         static SpinnerProperties::StepSize      d_stepSizeProperty;
    00433         static SpinnerProperties::MaximumValue  d_maxValueProperty;
    00434         static SpinnerProperties::MinimumValue  d_minValueProperty;
    00435         static SpinnerProperties::TextInputMode d_textInputModeProperty;
    00436
    00437         /*************************************************************************
    00438                 Private Implementation Methods
    00439         *************************************************************************/
    00447         void    addSpinnerProperties(void);
    00448     };
    00449
    00450 } // End of  CEGUI namespace section
    00451
    00452 #if defined(_MSC_VER)
    00453 #       pragma warning(pop)
    00454 #endif
    00455
    00456 #endif  // end of guard _CEGUISpinner_h_