Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
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
43namespace CEGUI
44{
45
50class CEGUIEXPORT SliderWindowRenderer : public WindowRenderer
51{
52public:
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
98class CEGUIEXPORT Slider : public Window
99{
100public:
101 static const String EventNamespace;
102 static const String WidgetTypeName;
103
104 /*************************************************************************
105 Event name constants
106 *************************************************************************/
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
253protected:
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
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 *************************************************************************/
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;
382 float d_step;
383
384private:
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_
Base class used as the argument to all subscribers Event object.
Definition EventArgs.h:51
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition InputEvent.h:281
Base class for ItemEntry window renderer objects.
Definition widgets/Slider.h:51
virtual void updateThumb(void)=0
update the size and location of the thumb to properly represent the current state of the slider
virtual float getValueFromThumb(void) const =0
return value that best represents current slider value given the current location of the thumb.
SliderWindowRenderer(const String &name)
Constructor.
virtual float getAdjustDirectionFromPoint(const Vector2f &pt) const =0
Given window location pt, return a value indicating what change should be made to the slider.
Base class for Slider widgets.
Definition widgets/Slider.h:99
virtual void updateThumb(void)
update the size and location of the thumb to properly represent the current state of the slider
float getMaxValue(void) const
return the maximum value set for this widget
Definition widgets/Slider.h:149
static const String ThumbName
Widget name for the thumb component.
Definition widgets/Slider.h:127
bool handleThumbMoved(const EventArgs &e)
update the size and location of the thumb to properly represent the current state of the slider
bool handleThumbTrackEnded(const EventArgs &e)
handler function for when thumb tracking begins
virtual float getAdjustDirectionFromPoint(const Vector2f &pt) const
Given window location pt, return a value indicating what change should be made to the slider.
virtual void initialiseComponents(void)
Initialises the Window based object ready for use.
Slider(const String &type, const String &name)
Slider base class constructor.
virtual ~Slider(void)
Slider base class destructor.
static const String WidgetTypeName
Window factory name.
Definition widgets/Slider.h:102
static const String EventNamespace
Namespace for global events.
Definition widgets/Slider.h:101
virtual void onThumbTrackEnded(WindowEventArgs &e)
Handler triggered when the slider thumb is released.
static const String EventValueChanged
Definition widgets/Slider.h:111
static const String EventThumbTrackEnded
Definition widgets/Slider.h:122
float d_maxValue
slider maximum value (minimum is fixed at 0)
Definition widgets/Slider.h:381
float getClickStep(void) const
return the current click step setting for the slider.
Definition widgets/Slider.h:162
virtual void onThumbTrackStarted(WindowEventArgs &e)
Handler triggered when the user begins to drag the slider thumb.
virtual float getValueFromThumb(void) const
return value that best represents current slider value given the current location of the thumb.
float d_step
amount to adjust slider by when clicked (and not dragged).
Definition widgets/Slider.h:382
void setClickStep(float step)
set the current click step setting for the slider.
Definition widgets/Slider.h:233
virtual bool validateWindowRenderer(const WindowRenderer *renderer) const
Function used in checking if a WindowRenderer is valid for this window.
Thumb * getThumb() const
Return a pointer to the Thumb component widget for this Slider.
void setMaxValue(float maxVal)
set the maximum value for the slider. Note that the minimum value is fixed at 0.
bool handleThumbTrackStarted(const EventArgs &e)
handler function for when thumb tracking begins
virtual void onValueChanged(WindowEventArgs &e)
Handler triggered when the slider value changes.
float getCurrentValue(void) const
return the current slider value.
Definition widgets/Slider.h:139
static const String EventThumbTrackStarted
Definition widgets/Slider.h:117
virtual void onMouseWheel(MouseEventArgs &e)
Handler called when the mouse wheel (z-axis) position changes within this window's area.
float d_value
current slider value
Definition widgets/Slider.h:380
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
void setCurrentValue(float value)
set the current slider value.
String class used within the GUI system.
Definition String.h:64
Base class for Thumb widget.
Definition Thumb.h:56
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition InputEvent.h:252
Base-class for the assignable WindowRenderer object.
Definition WindowRenderer.h:52
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1