Crazy Eddies GUI System  0.7.1
CEGUISlider.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 "../CEGUIBase.h"
34 #include "../CEGUIWindow.h"
35 #include "CEGUISliderProperties.h"
36 
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 
44 // Start of CEGUI namespace section
45 namespace CEGUI
46 {
47 
52 class CEGUIEXPORT SliderWindowRenderer : public WindowRenderer
53 {
54 public:
59  SliderWindowRenderer(const String& name);
60 
65  virtual void updateThumb(void) = 0;
66 
74  virtual float getValueFromThumb(void) const = 0;
75 
89  virtual float getAdjustDirectionFromPoint(const Point& pt) const = 0;
90 };
91 
92 
100 class CEGUIEXPORT Slider : public Window
101 {
102 public:
103  static const String EventNamespace;
104  static const String WidgetTypeName;
105 
106  /*************************************************************************
107  Event name constants
108  *************************************************************************/
109  static const String EventValueChanged;
112 
113  /*************************************************************************
114  Child Widget name suffix constants
115  *************************************************************************/
116  static const String ThumbNameSuffix;
117 
118  /*************************************************************************
119  Accessors
120  *************************************************************************/
128  float getCurrentValue(void) const {return d_value;}
129 
130 
138  float getMaxValue(void) const {return d_maxValue;}
139 
140 
151  float getClickStep(void) const {return d_step;}
152 
153 
164  Thumb* getThumb() const;
165 
166 
167  /*************************************************************************
168  Manipulators
169  *************************************************************************/
180  virtual void initialiseComponents(void);
181 
182 
193  void setMaxValue(float maxVal);
194 
195 
206  void setCurrentValue(float value);
207 
208 
222  void setClickStep(float step) {d_step = step;}
223 
224 
225  /*************************************************************************
226  Construction / Destruction
227  *************************************************************************/
232  Slider(const String& type, const String& name);
233 
234 
239  virtual ~Slider(void);
240 
241 
242 protected:
243  /*************************************************************************
244  Implementation Functions
245  *************************************************************************/
250  virtual void updateThumb(void);
251 
252 
260  virtual float getValueFromThumb(void) const;
261 
262 
276  virtual float getAdjustDirectionFromPoint(const Point& pt) const;
277 
278 
283  //virtual void updateThumb_impl(void) = 0;
284 
285 
293  //virtual float getValueFromThumb_impl(void) const = 0;
294 
295 
309  //virtual float getAdjustDirectionFromPoint_impl(const Point& pt) const = 0;
310 
315  bool handleThumbMoved(const EventArgs& e);
316 
317 
322  bool handleThumbTrackStarted(const EventArgs& e);
323 
324 
329  bool handleThumbTrackEnded(const EventArgs& e);
330 
331 
342  virtual bool testClassName_impl(const String& class_name) const
343  {
344  if (class_name=="Slider") return true;
345  return Window::testClassName_impl(class_name);
346  }
347 
348 
349  // validate window renderer
350  virtual bool validateWindowRenderer(const String& name) const
351  {
352  return (name == "Slider");
353  }
354 
355 
356  /*************************************************************************
357  New event handlers for slider widget
358  *************************************************************************/
363  virtual void onValueChanged(WindowEventArgs& e);
364 
365 
370  virtual void onThumbTrackStarted(WindowEventArgs& e);
371 
372 
377  virtual void onThumbTrackEnded(WindowEventArgs& e);
378 
379 
380  /*************************************************************************
381  Overridden event handlers
382  *************************************************************************/
383  virtual void onMouseButtonDown(MouseEventArgs& e);
384  virtual void onMouseWheel(MouseEventArgs& e);
385 
386 
387  /*************************************************************************
388  Implementation Data
389  *************************************************************************/
390  float d_value;
391  float d_maxValue;
392  float d_step;
393 
394 private:
395  /*************************************************************************
396  Static Properties for this class
397  *************************************************************************/
398  static SliderProperties::CurrentValue d_currentValueProperty;
399  static SliderProperties::MaximumValue d_maximumValueProperty;
400  static SliderProperties::ClickStepSize d_clickStepSizeProperty;
401 
402 
403  /*************************************************************************
404  Private methods
405  *************************************************************************/
406  void addSliderProperties(void);
407 };
408 
409 } // End of CEGUI namespace section
410 
411 #if defined(_MSC_VER)
412 # pragma warning(pop)
413 #endif
414 
415 #endif // end of guard _CEGUISlider_h_