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  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00010  *
00011  *   Permission is hereby granted, free of charge, to any person obtaining
00012  *   a copy of this software and associated documentation files (the
00013  *   "Software"), to deal in the Software without restriction, including
00014  *   without limitation the rights to use, copy, modify, merge, publish,
00015  *   distribute, sublicense, and/or sell copies of the Software, and to
00016  *   permit persons to whom the Software is furnished to do so, subject to
00017  *   the following conditions:
00018  *
00019  *   The above copyright notice and this permission notice shall be
00020  *   included in all copies or substantial portions of the Software.
00021  *
00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00028  *   OTHER DEALINGS IN THE SOFTWARE.
00029  ***************************************************************************/
00030 #ifndef _CEGUISlider_h_
00031 #define _CEGUISlider_h_
00032 
00033 #include "CEGUIBase.h"
00034 #include "CEGUIWindow.h"
00035 #include "elements/CEGUISliderProperties.h"
00036 
00037 
00038 #if defined(_MSC_VER)
00039 #       pragma warning(push)
00040 #       pragma warning(disable : 4251)
00041 #endif
00042 
00043 
00044 // Start of CEGUI namespace section
00045 namespace CEGUI
00046 {
00047 
00052 class CEGUIEXPORT SliderWindowRenderer : public WindowRenderer
00053 {
00054 public:
00059     SliderWindowRenderer(const String& name);
00060 
00065     virtual void    updateThumb(void)   = 0;
00066 
00074     virtual float   getValueFromThumb(void) const   = 0;
00075 
00089     virtual float   getAdjustDirectionFromPoint(const Point& pt) const  = 0;
00090 };
00091 
00092 
00100 class CEGUIEXPORT Slider : public Window
00101 {
00102 public:
00103         static const String EventNamespace;                             
00104     static const String WidgetTypeName;             
00105 
00106         /*************************************************************************
00107                 Event name constants
00108         *************************************************************************/
00109         static const String EventValueChanged;          
00110         static const String EventThumbTrackStarted;     
00111         static const String EventThumbTrackEnded;               
00112 
00113     /*************************************************************************
00114         Child Widget name suffix constants
00115     *************************************************************************/
00116     static const String ThumbNameSuffix;            
00117 
00118         /*************************************************************************
00119                 Accessors
00120         *************************************************************************/
00128         float   getCurrentValue(void) const                     {return d_value;}
00129 
00130 
00138         float   getMaxValue(void) const                         {return d_maxValue;}
00139 
00140 
00151         float   getClickStep(void) const                {return d_step;}
00152 
00153 
00164     Thumb* getThumb() const;
00165 
00166 
00167         /*************************************************************************
00168                 Manipulators
00169         *************************************************************************/
00180         virtual void    initialiseComponents(void);
00181 
00182 
00193         void    setMaxValue(float maxVal);
00194 
00195 
00206         void    setCurrentValue(float value);
00207 
00208 
00222         void    setClickStep(float step)                {d_step = step;}
00223 
00224 
00225         /*************************************************************************
00226                 Construction / Destruction
00227         *************************************************************************/
00232         Slider(const String& type, const String& name);
00233 
00234 
00239         virtual ~Slider(void);
00240 
00241 
00242 protected:
00243         /*************************************************************************
00244                 Implementation Functions
00245         *************************************************************************/
00250         virtual void    updateThumb(void);
00251 
00252 
00260         virtual float   getValueFromThumb(void) const;
00261 
00262 
00276         virtual float   getAdjustDirectionFromPoint(const Point& pt) const;
00277 
00278 
00283     //virtual void    updateThumb_impl(void)   = 0;
00284 
00285 
00293     //virtual float   getValueFromThumb_impl(void) const   = 0;
00294 
00295 
00309     //virtual float   getAdjustDirectionFromPoint_impl(const Point& pt) const  = 0;
00310 
00315         bool    handleThumbMoved(const EventArgs& e);
00316 
00317 
00322         bool    handleThumbTrackStarted(const EventArgs& e);
00323 
00324 
00329         bool    handleThumbTrackEnded(const EventArgs& e);
00330 
00331 
00342         virtual bool    testClassName_impl(const String& class_name) const
00343         {
00344                 if (class_name=="Slider")       return true;
00345                 return Window::testClassName_impl(class_name);
00346         }
00347 
00348 
00349     // validate window renderer
00350     virtual bool validateWindowRenderer(const String& name) const
00351     {
00352         return (name == "Slider");
00353     }
00354 
00355 
00356         /*************************************************************************
00357                 New event handlers for slider widget
00358         *************************************************************************/
00363         virtual void    onValueChanged(WindowEventArgs& e);
00364 
00365 
00370         virtual void    onThumbTrackStarted(WindowEventArgs& e);
00371 
00372 
00377         virtual void    onThumbTrackEnded(WindowEventArgs& e);
00378 
00379 
00380         /*************************************************************************
00381                 Overridden event handlers
00382         *************************************************************************/
00383         virtual void    onMouseButtonDown(MouseEventArgs& e);
00384         virtual void    onMouseWheel(MouseEventArgs& e);
00385 
00386 
00387         /*************************************************************************
00388                 Implementation Data
00389         *************************************************************************/
00390         float   d_value;                
00391         float   d_maxValue;             
00392         float   d_step;                 
00393 
00394 private:
00395         /*************************************************************************
00396                 Static Properties for this class
00397         *************************************************************************/
00398         static SliderProperties::CurrentValue   d_currentValueProperty;
00399         static SliderProperties::MaximumValue   d_maximumValueProperty;
00400         static SliderProperties::ClickStepSize  d_clickStepSizeProperty;
00401 
00402 
00403         /*************************************************************************
00404                 Private methods
00405         *************************************************************************/
00406         void    addSliderProperties(void);
00407 };
00408 
00409 } // End of  CEGUI namespace section
00410 
00411 #if defined(_MSC_VER)
00412 #       pragma warning(pop)
00413 #endif
00414 
00415 #endif  // end of guard _CEGUISlider_h_

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