CEGUISlider.h

00001 /************************************************************************
00002         filename:       CEGUISlider.h
00003         created:        13/4/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to base class for Slider widget
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #ifndef _CEGUISlider_h_
00027 #define _CEGUISlider_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "elements/CEGUISliderProperties.h"
00032 
00033 
00034 #if defined(_MSC_VER)
00035 #       pragma warning(push)
00036 #       pragma warning(disable : 4251)
00037 #endif
00038 
00039 
00040 // Start of CEGUI namespace section
00041 namespace CEGUI
00042 {
00043 
00051 class CEGUIEXPORT Slider : public Window
00052 {
00053 public:
00054         static const String EventNamespace;                             
00055 
00056 
00057         /*************************************************************************
00058                 Event name constants
00059         *************************************************************************/
00060         static const String EventValueChanged;          
00061         static const String EventThumbTrackStarted;     
00062         static const String EventThumbTrackEnded;               
00063 
00064 
00065         /*************************************************************************
00066                 Accessors
00067         *************************************************************************/
00075         float   getCurrentValue(void) const                     {return d_value;}
00076 
00077 
00085         float   getMaxValue(void) const                         {return d_maxValue;}
00086 
00087 
00098         float   getClickStep(void) const                {return d_step;}
00099 
00100 
00101         /*************************************************************************
00102                 Manipulators
00103         *************************************************************************/
00114         virtual void    initialise(void);
00115 
00116 
00127         void    setMaxValue(float maxVal);
00128 
00129 
00140         void    setCurrentValue(float value);
00141 
00142 
00156         void    setClickStep(float step)                {d_step = step;}
00157 
00158 
00159         /*************************************************************************
00160                 Construction / Destruction
00161         *************************************************************************/
00166         Slider(const String& type, const String& name);
00167 
00168 
00173         virtual ~Slider(void);
00174 
00175 
00176 protected:
00177         /*************************************************************************
00178                 Implementation Functions
00179         *************************************************************************/
00184         void    addSliderEvents(void);
00185 
00186 
00194         virtual Thumb*  createThumb(const String& name) const           = 0;
00195 
00196 
00201         virtual void    updateThumb(void)       = 0;
00202 
00203 
00211         virtual float   getValueFromThumb(void) const   = 0;
00212 
00213 
00227         virtual float   getAdjustDirectionFromPoint(const Point& pt) const      = 0;
00228 
00229 
00234         bool    handleThumbMoved(const EventArgs& e);
00235 
00236 
00241         bool    handleThumbTrackStarted(const EventArgs& e);
00242 
00243 
00248         bool    handleThumbTrackEnded(const EventArgs& e);
00249 
00250 
00261         virtual bool    testClassName_impl(const String& class_name) const
00262         {
00263                 if (class_name==(const utf8*)"Slider")  return true;
00264                 return Window::testClassName_impl(class_name);
00265         }
00266 
00267 
00268         /*************************************************************************
00269                 New event handlers for slider widget
00270         *************************************************************************/
00275         virtual void    onValueChanged(WindowEventArgs& e);
00276 
00277 
00282         virtual void    onThumbTrackStarted(WindowEventArgs& e);
00283 
00284 
00289         virtual void    onThumbTrackEnded(WindowEventArgs& e);
00290 
00291 
00292         /*************************************************************************
00293                 Overridden event handlers
00294         *************************************************************************/
00295         virtual void    onMouseButtonDown(MouseEventArgs& e);
00296         virtual void    onMouseWheel(MouseEventArgs& e);
00297 
00298 
00299         /*************************************************************************
00300                 Implementation Data
00301         *************************************************************************/
00302         float   d_value;                
00303         float   d_maxValue;             
00304         float   d_step;                 
00305 
00306         // Pointers to the controls that make up the slider
00307         Thumb*  d_thumb;                
00308 
00309 
00310 private:
00311         /*************************************************************************
00312                 Static Properties for this class
00313         *************************************************************************/
00314         static SliderProperties::CurrentValue   d_currentValueProperty;
00315         static SliderProperties::MaximumValue   d_maximumValueProperty;
00316         static SliderProperties::ClickStepSize  d_clickStepSizeProperty;
00317 
00318 
00319         /*************************************************************************
00320                 Private methods
00321         *************************************************************************/
00322         void    addSliderProperties(void);
00323 };
00324 
00325 } // End of  CEGUI namespace section
00326 
00327 #if defined(_MSC_VER)
00328 #       pragma warning(pop)
00329 #endif
00330 
00331 #endif  // end of guard _CEGUISlider_h_

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