Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
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:
57  SliderWindowRenderer(const String& name);
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 
333  bool handleThumbTrackStarted(const EventArgs& e);
334 
335 
340  bool handleThumbTrackEnded(const EventArgs& e);
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 
360  virtual void onThumbTrackStarted(WindowEventArgs& e);
361 
362 
367  virtual void onThumbTrackEnded(WindowEventArgs& e);
368 
369 
370  /*************************************************************************
371  Overridden event handlers
372  *************************************************************************/
373  virtual void onMouseButtonDown(MouseEventArgs& e);
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_