Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/Slider.h
1 /***********************************************************************
2  filename: CEGUISlider.h
3  created: 13/4/2004
4  author: Paul D Turner
5 
6  purpose: Interface to base class for Slider widget
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUISlider_h_
31 #define _CEGUISlider_h_
32 
33 #include "../Base.h"
34 #include "../Window.h"
35 
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
46 
51 class CEGUIEXPORT SliderWindowRenderer : public WindowRenderer
52 {
53 public:
58  SliderWindowRenderer(const String& name);
59 
64  virtual void updateThumb(void) = 0;
65 
73  virtual float getValueFromThumb(void) const = 0;
74 
88  virtual float getAdjustDirectionFromPoint(const Vector2f& pt) const = 0;
89 };
90 
91 
99 class CEGUIEXPORT Slider : public Window
100 {
101 public:
102  static const String EventNamespace;
103  static const String WidgetTypeName;
104 
105  /*************************************************************************
106  Event name constants
107  *************************************************************************/
112  static const String EventValueChanged;
124 
125  /*************************************************************************
126  Child Widget name suffix constants
127  *************************************************************************/
128  static const String ThumbName;
129 
130  /*************************************************************************
131  Accessors
132  *************************************************************************/
140  float getCurrentValue(void) const {return d_value;}
141 
142 
150  float getMaxValue(void) const {return d_maxValue;}
151 
152 
163  float getClickStep(void) const {return d_step;}
164 
165 
176  Thumb* getThumb() const;
177 
178 
179  /*************************************************************************
180  Manipulators
181  *************************************************************************/
192  virtual void initialiseComponents(void);
193 
194 
205  void setMaxValue(float maxVal);
206 
207 
218  void setCurrentValue(float value);
219 
220 
234  void setClickStep(float step) {d_step = step;}
235 
236 
237  /*************************************************************************
238  Construction / Destruction
239  *************************************************************************/
244  Slider(const String& type, const String& name);
245 
246 
251  virtual ~Slider(void);
252 
253 
254 protected:
255  /*************************************************************************
256  Implementation Functions
257  *************************************************************************/
262  virtual void updateThumb(void);
263 
264 
272  virtual float getValueFromThumb(void) const;
273 
274 
288  virtual float getAdjustDirectionFromPoint(const Vector2f& pt) const;
289 
290 
295  //virtual void updateThumb_impl(void) = 0;
296 
297 
305  //virtual float getValueFromThumb_impl(void) const = 0;
306 
307 
321  //virtual float getAdjustDirectionFromPoint_impl(const Point& pt) const = 0;
322 
327  bool handleThumbMoved(const EventArgs& e);
328 
329 
334  bool handleThumbTrackStarted(const EventArgs& e);
335 
336 
341  bool handleThumbTrackEnded(const EventArgs& e);
342 
343  // validate window renderer
344  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
345 
346 
347  /*************************************************************************
348  New event handlers for slider widget
349  *************************************************************************/
354  virtual void onValueChanged(WindowEventArgs& e);
355 
356 
361  virtual void onThumbTrackStarted(WindowEventArgs& e);
362 
363 
368  virtual void onThumbTrackEnded(WindowEventArgs& e);
369 
370 
371  /*************************************************************************
372  Overridden event handlers
373  *************************************************************************/
374  virtual void onMouseButtonDown(MouseEventArgs& e);
375  virtual void onMouseWheel(MouseEventArgs& e);
376 
377 
378  /*************************************************************************
379  Implementation Data
380  *************************************************************************/
381  float d_value;
382  float d_maxValue;
383  float d_step;
384 
385 private:
386 
387  /*************************************************************************
388  Private methods
389  *************************************************************************/
390  void addSliderProperties(void);
391 };
392 
393 } // End of CEGUI namespace section
394 
395 #if defined(_MSC_VER)
396 # pragma warning(pop)
397 #endif
398 
399 #endif // end of guard _CEGUISlider_h_