source: OGRE/trunk/ogrenew/Dependencies/include/CEGUI/elements/CEGUISlider.h @ 657

Revision 657, 9.2 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
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    Crazy Eddie's GUI System (http://www.cegui.org.uk)
10    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
11
12    This library is free software; you can redistribute it and/or
13    modify it under the terms of the GNU Lesser General Public
14    License as published by the Free Software Foundation; either
15    version 2.1 of the License, or (at your option) any later version.
16
17    This library is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    Lesser General Public License for more details.
21
22    You should have received a copy of the GNU Lesser General Public
23    License along with this library; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25*************************************************************************/
26#ifndef _CEGUISlider_h_
27#define _CEGUISlider_h_
28
29#include "CEGUIBase.h"
30#include "CEGUIWindow.h"
31#include "elements/CEGUISliderProperties.h"
32
33
34#if defined(_MSC_VER)
35#       pragma warning(push)
36#       pragma warning(disable : 4251)
37#endif
38
39
40// Start of CEGUI namespace section
41namespace CEGUI
42{
43
44/*!
45\brief
46        Base class for Slider widgets.
47
48        The slider widget has a default range of 0.0f - 1.0f.  This enables use of the slider value to scale
49        any value needed by way of a simple multiplication.
50*/
51class CEGUIEXPORT Slider : public Window
52{
53public:
54        static const String EventNamespace;                             //!< Namespace for global events
55
56
57        /*************************************************************************
58                Event name constants
59        *************************************************************************/
60        static const String EventValueChanged;          //!< Event fired when the slider value changes.
61        static const String EventThumbTrackStarted;     //!< Name of the event fired when the user begins dragging the thumb.
62        static const String EventThumbTrackEnded;               //!< Name of the event fired when the user releases the thumb.
63
64
65        /*************************************************************************
66                Accessors
67        *************************************************************************/
68        /*!
69        \brief
70                return the current slider value.
71
72        \return
73                float value equal to the sliders current value.
74        */
75        float   getCurrentValue(void) const                     {return d_value;}
76
77
78        /*!
79        \brief
80                return the maximum value set for this widget
81
82        \return
83                float value equal to the currently set maximum value for this slider.
84        */
85        float   getMaxValue(void) const                         {return d_maxValue;}
86
87
88        /*!
89        \brief
90                return the current click step setting for the slider.
91
92                The click step size is the amount the slider value will be adjusted when the widget
93                is clicked wither side of the slider thumb.
94
95        \return
96                float value representing the current click step setting.
97        */
98        float   getClickStep(void) const                {return d_step;}
99
100
101        /*************************************************************************
102                Manipulators
103        *************************************************************************/
104        /*!
105        \brief
106                Initialises the Window based object ready for use.
107
108        \note
109                This must be called for every window created.  Normally this is handled automatically by the WindowFactory for each Window type.
110
111        \return
112                Nothing
113        */
114        virtual void    initialise(void);
115
116
117        /*!
118        \brief
119                set the maximum value for the slider.  Note that the minimum value is fixed at 0.
120
121        \param maxVal
122                float value specifying the maximum value for this slider widget.
123
124        \return
125                Nothing.
126        */
127        void    setMaxValue(float maxVal);
128
129
130        /*!
131        \brief
132                set the current slider value.
133
134        \param value
135                float value specifying the new value for this slider widget.
136
137        \return
138                Nothing.
139        */
140        void    setCurrentValue(float value);
141
142
143        /*!
144        \brief
145                set the current click step setting for the slider.
146
147                The click step size is the amount the slider value will be adjusted when the widget
148                is clicked wither side of the slider thumb.
149
150        \param step
151                float value representing the click step setting to use.
152
153        \return
154                Nothing.
155        */
156        void    setClickStep(float step)                {d_step = step;}
157
158
159        /*************************************************************************
160                Construction / Destruction
161        *************************************************************************/
162        /*!
163        \brief
164                Slider base class constructor
165        */
166        Slider(const String& type, const String& name);
167
168
169        /*!
170        \brief
171                Slider base class destructor
172        */
173        virtual ~Slider(void);
174
175
176protected:
177        /*************************************************************************
178                Implementation Functions
179        *************************************************************************/
180        /*!
181        \brief
182                Add slider specific events
183        */
184        void    addSliderEvents(void);
185
186
187        /*!
188        \brief
189                create a Thumb based widget to use as the thumb for this slider.
190        */
191        virtual Thumb*  createThumb(void) const         = 0;
192
193
194        /*!
195        \brief
196                layout the slider component widgets
197        */
198        virtual void    layoutComponentWidgets(void)    = 0;
199
200
201        /*!
202        \brief
203                update the size and location of the thumb to properly represent the current state of the slider
204        */
205        virtual void    updateThumb(void)       = 0;
206
207
208        /*!
209        \brief
210                return value that best represents current slider value given the current location of the thumb.
211
212        \return
213                float value that, given the thumb widget position, best represents the current value for the slider.
214        */
215        virtual float   getValueFromThumb(void) const   = 0;
216
217
218        /*!
219        \brief
220                Given window location \a pt, return a value indicating what change should be
221                made to the slider.
222
223        \param pt
224                Point object describing a pixel position in window space.
225
226        \return
227                - -1 to indicate slider should be moved to a lower setting.
228                -  0 to indicate slider should not be moved.
229                - +1 to indicate slider should be moved to a higher setting.
230        */
231        virtual float   getAdjustDirectionFromPoint(const Point& pt) const      = 0;
232
233
234        /*!
235        \brief
236                handler function for when thumb moves.
237        */
238        bool    handleThumbMoved(const EventArgs& e);
239
240
241        /*!
242        \brief
243                handler function for when thumb tracking begins
244        */
245        bool    handleThumbTrackStarted(const EventArgs& e);
246
247
248        /*!
249        \brief
250                handler function for when thumb tracking begins
251        */
252        bool    handleThumbTrackEnded(const EventArgs& e);
253
254
255        /*!
256        \brief
257                Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
258
259        \param class_name
260                The class name that is to be checked.
261
262        \return
263                true if this window was inherited from \a class_name. false if not.
264        */
265        virtual bool    testClassName_impl(const String& class_name) const
266        {
267                if (class_name==(const utf8*)"Slider")  return true;
268                return Window::testClassName_impl(class_name);
269        }
270
271
272        /*************************************************************************
273                New event handlers for slider widget
274        *************************************************************************/
275        /*!
276        \brief
277                Handler triggered when the slider value changes
278        */
279        virtual void    onValueChanged(WindowEventArgs& e);
280
281
282        /*!
283        \brief
284                Handler triggered when the user begins to drag the slider thumb.
285        */
286        virtual void    onThumbTrackStarted(WindowEventArgs& e);
287
288
289        /*!
290        \brief
291                Handler triggered when the slider thumb is released
292        */
293        virtual void    onThumbTrackEnded(WindowEventArgs& e);
294
295
296        /*************************************************************************
297                Overridden event handlers
298        *************************************************************************/
299        virtual void    onMouseButtonDown(MouseEventArgs& e);
300        virtual void    onSized(WindowEventArgs& e);
301        virtual void    onMouseWheel(MouseEventArgs& e);
302
303
304        /*************************************************************************
305                Implementation Data
306        *************************************************************************/
307        float   d_value;                //!< current slider value
308        float   d_maxValue;             //!< slider maximum value (minimum is fixed at 0)
309        float   d_step;                 //!< amount to adjust slider by when clicked (and not dragged).
310
311        // Pointers to the controls that make up the slider
312        Thumb*  d_thumb;                //!< widget used to represent the 'thumb' of the slider.
313
314
315private:
316        /*************************************************************************
317                Static Properties for this class
318        *************************************************************************/
319        static SliderProperties::CurrentValue   d_currentValueProperty;
320        static SliderProperties::MaximumValue   d_maximumValueProperty;
321        static SliderProperties::ClickStepSize  d_clickStepSizeProperty;
322
323
324        /*************************************************************************
325                Private methods
326        *************************************************************************/
327        void    addSliderProperties(void);
328};
329
330} // End of  CEGUI namespace section
331
332#if defined(_MSC_VER)
333#       pragma warning(pop)
334#endif
335
336#endif  // end of guard _CEGUISlider_h_
Note: See TracBrowser for help on using the repository browser.