Crazy Eddie's GUI System  0.8.7
widgets/Slider.h
1 /***********************************************************************
2  created: 13/4/2004
3  author: Paul D Turner
4 
5  purpose: Interface to base class for Slider widget
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUISlider_h_
30 #define _CEGUISlider_h_
31 
32 #include "../Base.h"
33 #include "../Window.h"
34 
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
50 class CEGUIEXPORT SliderWindowRenderer : public WindowRenderer
51 {
52 public:
58 
63  virtual void updateThumb(void) = 0;
64 
72  virtual float getValueFromThumb(void) const = 0;
73 
87  virtual float getAdjustDirectionFromPoint(const Vector2f& pt) const = 0;
88 };
89 
90 
98 class CEGUIEXPORT Slider : public Window
99 {
100 public:
101  static const String EventNamespace;
102  static const String WidgetTypeName;
103 
104  /*************************************************************************
105  Event name constants
106  *************************************************************************/
111  static const String EventValueChanged;
123 
124  /*************************************************************************
125  Child Widget name suffix constants
126  *************************************************************************/
127  static const String ThumbName;
128 
129  /*************************************************************************
130  Accessors
131  *************************************************************************/
139  float getCurrentValue(void) const {return d_value;}
140 
141 
149  float getMaxValue(void) const {return d_maxValue;}
150 
151 
162  float getClickStep(void) const {return d_step;}
163 
164 
175  Thumb* getThumb() const;
176 
177 
178  /*************************************************************************
179  Manipulators
180  *************************************************************************/
191  virtual void initialiseComponents(void);
192 
193 
204  void setMaxValue(float maxVal);
205 
206 
217  void setCurrentValue(float value);
218 
219 
233  void setClickStep(float step) {d_step = step;}
234 
235 
236  /*************************************************************************
237  Construction / Destruction
238  *************************************************************************/
243  Slider(const String& type, const String& name);
244 
245 
250  virtual ~Slider(void);
251 
252 
253 protected:
254  /*************************************************************************
255  Implementation Functions
256  *************************************************************************/
261  virtual void updateThumb(void);
262 
263 
271  virtual float getValueFromThumb(void) const;
272 
273 
287  virtual float getAdjustDirectionFromPoint(const Vector2f& pt) const;
288 
289 
294  //virtual void updateThumb_impl(void) = 0;
295 
296 
304  //virtual float getValueFromThumb_impl(void) const = 0;
305 
306 
320  //virtual float getAdjustDirectionFromPoint_impl(const Point& pt) const = 0;
321 
326  bool handleThumbMoved(const EventArgs& e);
327 
328 
334 
335 
341 
342  // validate window renderer
343  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
344 
345 
346  /*************************************************************************
347  New event handlers for slider widget
348  *************************************************************************/
353  virtual void onValueChanged(WindowEventArgs& e);
354 
355 
361 
362 
368 
369 
370  /*************************************************************************
371  Overridden event handlers
372  *************************************************************************/
374  virtual void onMouseWheel(MouseEventArgs& e);
375 
376 
377  /*************************************************************************
378  Implementation Data
379  *************************************************************************/
380  float d_value;
381  float d_maxValue;
382  float d_step;
383 
384 private:
385 
386  /*************************************************************************
387  Private methods
388  *************************************************************************/
389  void addSliderProperties(void);
390 };
391 
392 } // End of CEGUI namespace section
393 
394 #if defined(_MSC_VER)
395 # pragma warning(pop)
396 #endif
397 
398 #endif // end of guard _CEGUISlider_h_
CEGUI::Slider::d_step
float d_step
amount to adjust slider by when clicked (and not dragged).
Definition: widgets/Slider.h:382
CEGUI::Slider::validateWindowRenderer
virtual bool validateWindowRenderer(const WindowRenderer *renderer) const
Function used in checking if a WindowRenderer is valid for this window.
CEGUI::Slider::getThumb
Thumb * getThumb() const
Return a pointer to the Thumb component widget for this Slider.
CEGUI::Slider::getMaxValue
float getMaxValue(void) const
return the maximum value set for this widget
Definition: widgets/Slider.h:149
CEGUI::Slider::onMouseWheel
virtual void onMouseWheel(MouseEventArgs &e)
Handler called when the mouse wheel (z-axis) position changes within this window's area.
CEGUI::Slider::setMaxValue
void setMaxValue(float maxVal)
set the maximum value for the slider. Note that the minimum value is fixed at 0.
CEGUI::Slider::updateThumb
virtual void updateThumb(void)
update the size and location of the thumb to properly represent the current state of the slider
CEGUI::Slider::setCurrentValue
void setCurrentValue(float value)
set the current slider value.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Slider::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: widgets/Slider.h:101
CEGUI::Slider::d_value
float d_value
current slider value
Definition: widgets/Slider.h:380
CEGUI::MouseEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition: InputEvent.h:281
CEGUI::Slider::onValueChanged
virtual void onValueChanged(WindowEventArgs &e)
Handler triggered when the slider value changes.
CEGUI::Vector2< float >
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
CEGUI::Slider::handleThumbTrackEnded
bool handleThumbTrackEnded(const EventArgs &e)
handler function for when thumb tracking begins
CEGUI::Slider::handleThumbTrackStarted
bool handleThumbTrackStarted(const EventArgs &e)
handler function for when thumb tracking begins
CEGUI::Slider::EventThumbTrackStarted
static const String EventThumbTrackStarted
Definition: widgets/Slider.h:117
CEGUI::SliderWindowRenderer::SliderWindowRenderer
SliderWindowRenderer(const String &name)
Constructor.
CEGUI::SliderWindowRenderer::updateThumb
virtual void updateThumb(void)=0
update the size and location of the thumb to properly represent the current state of the slider
CEGUI::Slider::EventValueChanged
static const String EventValueChanged
Definition: widgets/Slider.h:111
CEGUI::Slider::WidgetTypeName
static const String WidgetTypeName
Window factory name.
Definition: widgets/Slider.h:102
CEGUI::Thumb
Base class for Thumb widget.
Definition: Thumb.h:56
CEGUI::SliderWindowRenderer
Base class for ItemEntry window renderer objects.
Definition: widgets/Slider.h:51
CEGUI::SliderWindowRenderer::getAdjustDirectionFromPoint
virtual float getAdjustDirectionFromPoint(const Vector2f &pt) const =0
Given window location pt, return a value indicating what change should be made to the slider.
CEGUI::Slider::initialiseComponents
virtual void initialiseComponents(void)
Initialises the Window based object ready for use.
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::Slider::getValueFromThumb
virtual float getValueFromThumb(void) const
return value that best represents current slider value given the current location of the thumb.
CEGUI::Slider
Base class for Slider widgets.
Definition: widgets/Slider.h:99
CEGUI::WindowRenderer
Base-class for the assignable WindowRenderer object.
Definition: WindowRenderer.h:52
CEGUI::Slider::getCurrentValue
float getCurrentValue(void) const
return the current slider value.
Definition: widgets/Slider.h:139
CEGUI::Slider::~Slider
virtual ~Slider(void)
Slider base class destructor.
CEGUI::Slider::ThumbName
static const String ThumbName
Widget name for the thumb component.
Definition: widgets/Slider.h:127
CEGUI::Slider::setClickStep
void setClickStep(float step)
set the current click step setting for the slider.
Definition: widgets/Slider.h:233
CEGUI::Slider::Slider
Slider(const String &type, const String &name)
Slider base class constructor.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::SliderWindowRenderer::getValueFromThumb
virtual float getValueFromThumb(void) const =0
return value that best represents current slider value given the current location of the thumb.
CEGUI::Slider::onMouseButtonDown
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
CEGUI::Slider::getAdjustDirectionFromPoint
virtual float getAdjustDirectionFromPoint(const Vector2f &pt) const
Given window location pt, return a value indicating what change should be made to the slider.
CEGUI::Slider::getClickStep
float getClickStep(void) const
return the current click step setting for the slider.
Definition: widgets/Slider.h:162
CEGUI::Slider::onThumbTrackStarted
virtual void onThumbTrackStarted(WindowEventArgs &e)
Handler triggered when the user begins to drag the slider thumb.
CEGUI::Slider::EventThumbTrackEnded
static const String EventThumbTrackEnded
Definition: widgets/Slider.h:122
CEGUI::Slider::d_maxValue
float d_maxValue
slider maximum value (minimum is fixed at 0)
Definition: widgets/Slider.h:381
CEGUI::EventArgs
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
CEGUI::Slider::handleThumbMoved
bool handleThumbMoved(const EventArgs &e)
update the size and location of the thumb to properly represent the current state of the slider
CEGUI::Slider::onThumbTrackEnded
virtual void onThumbTrackEnded(WindowEventArgs &e)
Handler triggered when the slider thumb is released.