Crazy Eddie's GUI System  0.8.4
Slider.h
00001 /***********************************************************************
00002         created:        13/4/2004
00003         author:         Paul D Turner
00004         
00005         purpose:        Interface to base class for Slider widget
00006 *************************************************************************/
00007 /***************************************************************************
00008  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00009  *
00010  *   Permission is hereby granted, free of charge, to any person obtaining
00011  *   a copy of this software and associated documentation files (the
00012  *   "Software"), to deal in the Software without restriction, including
00013  *   without limitation the rights to use, copy, modify, merge, publish,
00014  *   distribute, sublicense, and/or sell copies of the Software, and to
00015  *   permit persons to whom the Software is furnished to do so, subject to
00016  *   the following conditions:
00017  *
00018  *   The above copyright notice and this permission notice shall be
00019  *   included in all copies or substantial portions of the Software.
00020  *
00021  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00025  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00026  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027  *   OTHER DEALINGS IN THE SOFTWARE.
00028  ***************************************************************************/
00029 #ifndef _CEGUISlider_h_
00030 #define _CEGUISlider_h_
00031 
00032 #include "../Base.h"
00033 #include "../Window.h"
00034 
00035 
00036 #if defined(_MSC_VER)
00037 #       pragma warning(push)
00038 #       pragma warning(disable : 4251)
00039 #endif
00040 
00041 
00042 // Start of CEGUI namespace section
00043 namespace CEGUI
00044 {
00045 
00050 class CEGUIEXPORT SliderWindowRenderer : public WindowRenderer
00051 {
00052 public:
00057     SliderWindowRenderer(const String& name);
00058 
00063     virtual void    updateThumb(void)   = 0;
00064 
00072     virtual float   getValueFromThumb(void) const   = 0;
00073 
00087     virtual float   getAdjustDirectionFromPoint(const Vector2f& pt) const  = 0;
00088 };
00089 
00090 
00098 class CEGUIEXPORT Slider : public Window
00099 {
00100 public:
00101         static const String EventNamespace;                             
00102     static const String WidgetTypeName;             
00103 
00104         /*************************************************************************
00105                 Event name constants
00106         *************************************************************************/
00111         static const String EventValueChanged;
00117         static const String EventThumbTrackStarted;
00122         static const String EventThumbTrackEnded;
00123 
00124     /*************************************************************************
00125         Child Widget name suffix constants
00126     *************************************************************************/
00127     static const String ThumbName;            
00128 
00129         /*************************************************************************
00130                 Accessors
00131         *************************************************************************/
00139         float   getCurrentValue(void) const                     {return d_value;}
00140 
00141 
00149         float   getMaxValue(void) const                         {return d_maxValue;}
00150 
00151 
00162         float   getClickStep(void) const                {return d_step;}
00163 
00164 
00175     Thumb* getThumb() const;
00176 
00177 
00178         /*************************************************************************
00179                 Manipulators
00180         *************************************************************************/
00191         virtual void    initialiseComponents(void);
00192 
00193 
00204         void    setMaxValue(float maxVal);
00205 
00206 
00217         void    setCurrentValue(float value);
00218 
00219 
00233         void    setClickStep(float step)                {d_step = step;}
00234 
00235 
00236         /*************************************************************************
00237                 Construction / Destruction
00238         *************************************************************************/
00243         Slider(const String& type, const String& name);
00244 
00245 
00250         virtual ~Slider(void);
00251 
00252 
00253 protected:
00254         /*************************************************************************
00255                 Implementation Functions
00256         *************************************************************************/
00261         virtual void    updateThumb(void);
00262 
00263 
00271         virtual float   getValueFromThumb(void) const;
00272 
00273 
00287         virtual float   getAdjustDirectionFromPoint(const Vector2f& pt) const;
00288 
00289 
00294     //virtual void    updateThumb_impl(void)   = 0;
00295 
00296 
00304     //virtual float   getValueFromThumb_impl(void) const   = 0;
00305 
00306 
00320     //virtual float   getAdjustDirectionFromPoint_impl(const Point& pt) const  = 0;
00321 
00326         bool    handleThumbMoved(const EventArgs& e);
00327 
00328 
00333         bool    handleThumbTrackStarted(const EventArgs& e);
00334 
00335 
00340         bool    handleThumbTrackEnded(const EventArgs& e);
00341 
00342     // validate window renderer
00343         virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
00344 
00345 
00346         /*************************************************************************
00347                 New event handlers for slider widget
00348         *************************************************************************/
00353         virtual void    onValueChanged(WindowEventArgs& e);
00354 
00355 
00360         virtual void    onThumbTrackStarted(WindowEventArgs& e);
00361 
00362 
00367         virtual void    onThumbTrackEnded(WindowEventArgs& e);
00368 
00369 
00370         /*************************************************************************
00371                 Overridden event handlers
00372         *************************************************************************/
00373         virtual void    onMouseButtonDown(MouseEventArgs& e);
00374         virtual void    onMouseWheel(MouseEventArgs& e);
00375 
00376 
00377         /*************************************************************************
00378                 Implementation Data
00379         *************************************************************************/
00380         float   d_value;                
00381         float   d_maxValue;             
00382         float   d_step;                 
00383 
00384 private:
00385 
00386         /*************************************************************************
00387                 Private methods
00388         *************************************************************************/
00389         void    addSliderProperties(void);
00390 };
00391 
00392 } // End of  CEGUI namespace section
00393 
00394 #if defined(_MSC_VER)
00395 #       pragma warning(pop)
00396 #endif
00397 
00398 #endif  // end of guard _CEGUISlider_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends