CEGUISpinner.h

00001 /************************************************************************
00002     filename:   CEGUISpinner.h
00003     created:    3/2/2005
00004     author:             Paul D Turner
00005 *************************************************************************/
00006 /*************************************************************************
00007     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00008     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00009 
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Lesser General Public
00012     License as published by the Free Software Foundation; either
00013     version 2.1 of the License, or (at your option) any later version.
00014 
00015     This library is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018     Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public
00021     License along with this library; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 *************************************************************************/
00024 #ifndef _CEGUISpinner_h_
00025 #define _CEGUISpinner_h_
00026 
00027 #include "CEGUIBase.h"
00028 #include "CEGUIWindow.h"
00029 #include "elements/CEGUISpinnerProperties.h"
00030 
00031 #if defined(_MSC_VER)
00032 #       pragma warning(push)
00033 #       pragma warning(disable : 4251)
00034 #endif
00035 
00036 
00037 // Start of CEGUI namespace section
00038 namespace CEGUI
00039 {
00048     class CEGUIEXPORT Spinner : public Window
00049     {
00050     public:
00055         enum TextInputMode
00056         {
00057             FloatingPoint,  
00058             Integer,        
00059             Hexadecimal,    
00060             Octal           
00061         };
00062 
00063         /*************************************************************************
00064             Events system constants
00065         *************************************************************************/
00066         static const String EventNamespace;                 
00067         static const String EventValueChanged;              
00068         static const String EventStepChanged;               
00069         static const String EventMaximumValueChanged;       
00070         static const String EventMinimumValueChanged;       
00071         static const String EventTextInputModeChanged;      
00072 
00073         /*************************************************************************
00074             Object Construction and Destruction
00075         *************************************************************************/
00080         Spinner(const String& type, const String& name);
00081 
00086         virtual ~Spinner(void);
00087 
00098         void initialise(void);
00099 
00100 
00101         /*************************************************************************
00102                 Accessors
00103         *************************************************************************/
00111         float getCurrentValue(void) const;
00112 
00121         float getStepSize(void) const;
00122 
00130         float getMaximumValue(void) const;
00131 
00139         float getMinimumValue(void) const;
00140 
00149         TextInputMode getTextInputMode(void) const;
00150 
00151         /*************************************************************************
00152                 Manipulators
00153         *************************************************************************/
00164         void setCurrentValue(float value);
00165 
00177         void setStepSize(float step);
00178 
00189         void setMaximumValue(float maxValue);
00190 
00201         void setMinimumValue(float minVaue);
00202 
00214         void setTextInputMode(TextInputMode mode);
00215 
00216     protected:
00217         /*************************************************************************
00218                 Constants
00219         *************************************************************************/
00220         static const String FloatValidator;      
00221         static const String IntegerValidator;    
00222         static const String HexValidator;        
00223         static const String OctalValidator;      
00224 
00225         /*************************************************************************
00226                 Protected Implementation Methods
00227         *************************************************************************/
00235         void addSpinnerEvents(void);
00236 
00246         virtual float getValueFromText(void) const;
00247 
00255         virtual String getTextFromValue(void) const;
00256 
00257 
00268                 virtual bool    testClassName_impl(const String& class_name) const
00269                 {
00270                         if (class_name==(const utf8*)"Spinner") return true;
00271                         return Window::testClassName_impl(class_name);
00272                 }
00273 
00274 
00275         /*************************************************************************
00276                 Abstract Implementation methods
00277         *************************************************************************/
00286         virtual PushButton* createIncreaseButton(const String& name) const = 0;
00287 
00296         virtual PushButton* createDecreaseButton(const String& name) const = 0;
00297 
00306         virtual Editbox* createEditbox(const String& name) const = 0;
00307 
00308         /*************************************************************************
00309                 Overrides for Event handler methods
00310         *************************************************************************/
00311         virtual void onFontChanged(WindowEventArgs& e);
00312         virtual void onTextChanged(WindowEventArgs& e);
00313         virtual void onActivated(ActivationEventArgs& e);
00314 
00315         /*************************************************************************
00316                 New Event handler methods
00317         *************************************************************************/
00328         virtual void onValueChanged(WindowEventArgs& e);
00329 
00340         virtual void onStepChanged(WindowEventArgs& e);
00341 
00352         virtual void onMaximumValueChanged(WindowEventArgs& e);
00353 
00364         virtual void onMinimumValueChanged(WindowEventArgs& e);
00365 
00376         virtual void onTextInputModeChanged(WindowEventArgs& e);
00377 
00378         /*************************************************************************
00379                 Internal event listener methods
00380         *************************************************************************/
00381         bool handleIncreaseButton(const EventArgs& e);
00382         bool handleDecreaseButton(const EventArgs& e);
00383         bool handleEditTextChange(const EventArgs& e);
00384 
00385 
00386         /*************************************************************************
00387                 Data Fields
00388         *************************************************************************/
00389         PushButton* d_increaseButton;   
00390         PushButton* d_decreaseButton;   
00391         Editbox*    d_editbox;          
00392 
00393         float   d_stepSize;     
00394         float   d_currentValue; 
00395         float   d_maxValue;     
00396         float   d_minValue;     
00397         TextInputMode   d_inputMode;    
00398 
00399     private:
00400         /*************************************************************************
00401                 Static properties for the Spinner widget
00402         *************************************************************************/
00403         static SpinnerProperties::CurrentValue  d_currentValueProperty;
00404         static SpinnerProperties::StepSize      d_stepSizeProperty;
00405         static SpinnerProperties::MaximumValue  d_maxValueProperty;
00406         static SpinnerProperties::MinimumValue  d_minValueProperty;
00407         static SpinnerProperties::TextInputMode d_textInputModeProperty;
00408 
00409         /*************************************************************************
00410                 Private Implementation Methods
00411         *************************************************************************/
00419         void    addSpinnerProperties(void);
00420     };
00421 
00422 } // End of  CEGUI namespace section
00423 
00424 
00425 #endif  // end of guard _CEGUISpinner_h_

Generated on Sat Nov 26 10:09:55 2005 for Crazy Eddies GUI System by  doxygen 1.4.5