Crazy Eddies GUI System: CEGUISlider.h Source File

Crazy Eddies GUI System 0.7.6

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

- File List

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 "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         *************************************************************************/
    00113         static const String EventValueChanged;
    00119         static const String EventThumbTrackStarted;
    00124         static const String EventThumbTrackEnded;
    00125
    00126     /*************************************************************************
    00127         Child Widget name suffix constants
    00128     *************************************************************************/
    00129     static const String ThumbNameSuffix;
    00130
    00131         /*************************************************************************
    00132                 Accessors
    00133         *************************************************************************/
    00141         float   getCurrentValue(void) const                     {return d_value;}
    00142
    00143
    00151         float   getMaxValue(void) const                         {return d_maxValue;}
    00152
    00153
    00164         float   getClickStep(void) const                {return d_step;}
    00165
    00166
    00177     Thumb* getThumb() const;
    00178
    00179
    00180         /*************************************************************************
    00181                 Manipulators
    00182         *************************************************************************/
    00193         virtual void    initialiseComponents(void);
    00194
    00195
    00206         void    setMaxValue(float maxVal);
    00207
    00208
    00219         void    setCurrentValue(float value);
    00220
    00221
    00235         void    setClickStep(float step)                {d_step = step;}
    00236
    00237
    00238         /*************************************************************************
    00239                 Construction / Destruction
    00240         *************************************************************************/
    00245         Slider(const String& type, const String& name);
    00246
    00247
    00252         virtual ~Slider(void);
    00253
    00254
    00255 protected:
    00256         /*************************************************************************
    00257                 Implementation Functions
    00258         *************************************************************************/
    00263         virtual void    updateThumb(void);
    00264
    00265
    00273         virtual float   getValueFromThumb(void) const;
    00274
    00275
    00289         virtual float   getAdjustDirectionFromPoint(const Point& pt) const;
    00290
    00291
    00296     //virtual void    updateThumb_impl(void)   = 0;
    00297
    00298
    00306     //virtual float   getValueFromThumb_impl(void) const   = 0;
    00307
    00308
    00322     //virtual float   getAdjustDirectionFromPoint_impl(const Point& pt) const  = 0;
    00323
    00328         bool    handleThumbMoved(const EventArgs& e);
    00329
    00330
    00335         bool    handleThumbTrackStarted(const EventArgs& e);
    00336
    00337
    00342         bool    handleThumbTrackEnded(const EventArgs& e);
    00343
    00344
    00355         virtual bool    testClassName_impl(const String& class_name) const
    00356         {
    00357                 if (class_name=="Slider")       return true;
    00358                 return Window::testClassName_impl(class_name);
    00359         }
    00360
    00361
    00362     // validate window renderer
    00363     virtual bool validateWindowRenderer(const String& name) const
    00364     {
    00365         return (name == "Slider");
    00366     }
    00367
    00368
    00369         /*************************************************************************
    00370                 New event handlers for slider widget
    00371         *************************************************************************/
    00376         virtual void    onValueChanged(WindowEventArgs& e);
    00377
    00378
    00383         virtual void    onThumbTrackStarted(WindowEventArgs& e);
    00384
    00385
    00390         virtual void    onThumbTrackEnded(WindowEventArgs& e);
    00391
    00392
    00393         /*************************************************************************
    00394                 Overridden event handlers
    00395         *************************************************************************/
    00396         virtual void    onMouseButtonDown(MouseEventArgs& e);
    00397         virtual void    onMouseWheel(MouseEventArgs& e);
    00398
    00399
    00400         /*************************************************************************
    00401                 Implementation Data
    00402         *************************************************************************/
    00403         float   d_value;
    00404         float   d_maxValue;
    00405         float   d_step;
    00406
    00407 private:
    00408         /*************************************************************************
    00409                 Static Properties for this class
    00410         *************************************************************************/
    00411         static SliderProperties::CurrentValue   d_currentValueProperty;
    00412         static SliderProperties::MaximumValue   d_maximumValueProperty;
    00413         static SliderProperties::ClickStepSize  d_clickStepSizeProperty;
    00414
    00415
    00416         /*************************************************************************
    00417                 Private methods
    00418         *************************************************************************/
    00419         void    addSliderProperties(void);
    00420 };
    00421
    00422 } // End of  CEGUI namespace section
    00423
    00424 #if defined(_MSC_VER)
    00425 #       pragma warning(pop)
    00426 #endif
    00427
    00428 #endif  // end of guard _CEGUISlider_h_