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

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

added ogre dependencies and patched ogre sources

Line 
1/************************************************************************
2        filename:       CEGUIThumb.h
3        created:        25/4/2004
4        author:         Paul D Turner
5       
6        purpose:        Interface for a 'Thumb' widget.  Intended to be used as
7                                part of other widgets such as scrollers and sliders.
8*************************************************************************/
9/*************************************************************************
10    Crazy Eddie's GUI System (http://www.cegui.org.uk)
11    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
12
13    This library is free software; you can redistribute it and/or
14    modify it under the terms of the GNU Lesser General Public
15    License as published by the Free Software Foundation; either
16    version 2.1 of the License, or (at your option) any later version.
17
18    This library is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21    Lesser General Public License for more details.
22
23    You should have received a copy of the GNU Lesser General Public
24    License along with this library; if not, write to the Free Software
25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26*************************************************************************/
27#ifndef _CEGUIThumb_h_
28#define _CEGUIThumb_h_
29
30#include "CEGUIPushButton.h"
31#include "elements/CEGUIThumbProperties.h"
32#include <utility>
33
34
35#if defined(_MSC_VER)
36#       pragma warning(push)
37#       pragma warning(disable : 4251)
38#endif
39
40
41// Start of CEGUI namespace section
42namespace CEGUI
43{
44
45/*!
46\brief
47        Base class for Thumb widget.
48       
49        The thumb widget is used to compose other widgets (like sliders and scroll bars).  You would
50        not normally need to use this widget directly unless you are making a new widget of some type.
51*/
52class CEGUIEXPORT Thumb : public PushButton
53{
54public:
55        static const String EventNamespace;                             //!< Namespace for global events
56
57
58        /*************************************************************************
59                Event name constants
60        *************************************************************************/
61        // generated internally by Window
62        static const String EventThumbPositionChanged;          //!< The position of the thumb widget has changed.
63        static const String EventThumbTrackStarted;                     //!< Name of the event fired when the user begins dragging the thumb.
64        static const String EventThumbTrackEnded;                               //!< Name of the event fired when the user releases the thumb.
65
66
67        /*************************************************************************
68                Accessor Functions
69        *************************************************************************/
70        /*!
71        \brief
72                return whether hot-tracking is enabled or not.
73
74        \return
75                true if hot-tracking is enabled.  false if hot-tracking is disabled.
76        */
77        bool    isHotTracked(void) const                        {return d_hotTrack;}
78
79        /*!
80        \brief
81                return whether the thumb is movable on the vertical axis.
82
83        \return
84                true if the thumb is movable along the vertical axis.
85                false if the thumb is fixed on the vertical axis.
86        */
87        bool    isVertFree(void) const                          {return d_vertFree;}
88
89        /*!
90        \brief
91                return whether the thumb is movable on the horizontal axis.
92
93        \return
94                true if the thumb is movable along the horizontal axis.
95                false if the thumb is fixed on the horizontal axis.
96        */
97        bool    isHorzFree(void) const                          {return d_horzFree;}
98
99
100        /*!
101        \brief
102                Return a std::pair that describes the current range set for the vertical movement.
103
104        \return
105                a std::pair describing the current vertical range.  The first element is the minimum value,
106                the second element is the maximum value.
107        */
108        std::pair<float, float> getVertRange(void) const;
109
110
111        /*!
112        \brief
113                Return a std::pair that describes the current range set for the horizontal movement.
114
115        \return
116                a std::pair describing the current horizontal range.  The first element is the minimum value,
117                the second element is the maximum value.
118        */
119        std::pair<float, float> getHorzRange(void) const;
120
121
122        /*************************************************************************
123                Manipulator Functions
124        *************************************************************************/
125        /*!
126        \brief
127                set whether the thumb uses hot-tracking.
128
129        \param setting
130                true to enable hot-tracking.  false to disable hot-tracking.
131
132        \return
133                Nothing.
134        */
135        void    setHotTracked(bool setting)                             {d_hotTrack = setting;}
136
137
138        /*!
139        \brief
140                set whether thumb is movable on the vertical axis.
141
142        \param setting
143                true to allow movement of thumb along the vertical axis.  false to fix thumb on the vertical axis.
144
145        \return
146                nothing.
147        */
148        void    setVertFree(bool setting)                                               {d_vertFree = setting;}
149
150
151        /*!
152        \brief
153                set whether thumb is movable on the horizontal axis.
154
155        \param setting
156                true to allow movement of thumb along the horizontal axis.  false to fix thumb on the horizontal axis.
157
158        \return
159                nothing.
160        */
161        void    setHorzFree(bool setting)                                               {d_horzFree = setting;}
162       
163
164        /*!
165        \brief
166                set the movement range of the thumb for the vertical axis.
167
168                The values specified here are relative to the parent window for the thumb, and are specified in whichever
169                metrics mode is active for the widget.
170
171        \param min
172                the minimum setting for the thumb on the vertical axis.
173
174        \param max
175                the maximum setting for the thumb on the vertical axis.
176
177        \return
178                Nothing.
179        */
180        void    setVertRange(float min, float max);
181
182
183        /*!
184        \brief
185                set the movement range of the thumb for the horizontal axis.
186
187                The values specified here are relative to the parent window for the thumb, and are specified in whichever
188                metrics mode is active for the widget.
189
190        \param min
191                the minimum setting for the thumb on the horizontal axis.
192
193        \param max
194                the maximum setting for the thumb on the horizontal axis.
195
196        \return
197                Nothing.
198        */
199        void    setHorzRange(float min, float max);
200
201
202        /*************************************************************************
203                Construction / Destruction
204        *************************************************************************/
205        /*!
206        \brief
207                Constructor for Thumb objects
208        */
209        Thumb(const String& type, const String& name);
210
211
212        /*!
213        \brief
214                Destructor for Thumb objects
215        */
216        virtual ~Thumb(void);
217
218
219protected:
220        /*************************************************************************
221                Implementation Functions
222        *************************************************************************/
223        /*!
224        \brief
225                Add thumb specific events
226        */
227        void    addThumbEvents(void);
228
229
230        /*!
231        \brief
232                Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
233
234        \param class_name
235                The class name that is to be checked.
236
237        \return
238                true if this window was inherited from \a class_name. false if not.
239        */
240        virtual bool    testClassName_impl(const String& class_name) const
241        {
242                if (class_name==(const utf8*)"Thumb")   return true;
243                return PushButton::testClassName_impl(class_name);
244        }
245
246
247        /*************************************************************************
248                New Thumb Events
249        *************************************************************************/
250        /*!
251        \brief
252                event triggered internally when the position of the thumb
253        */
254        virtual void    onThumbPositionChanged(WindowEventArgs& e);
255
256
257        /*!
258        \brief
259                Handler triggered when the user begins to drag the thumb.
260        */
261        virtual void    onThumbTrackStarted(WindowEventArgs& e);
262
263
264        /*!
265        \brief
266                Handler triggered when the thumb is released
267        */
268        virtual void    onThumbTrackEnded(WindowEventArgs& e);
269
270
271
272        /*************************************************************************
273                Overridden event handling routines
274        *************************************************************************/
275        virtual void    onMouseMove(MouseEventArgs& e);
276        virtual void    onMouseButtonDown(MouseEventArgs& e);
277        virtual void    onCaptureLost(WindowEventArgs& e);
278
279
280        /*************************************************************************
281                Implementation Data
282        *************************************************************************/
283        // general settings
284        bool    d_hotTrack;                                     //!< true if events are to be sent real-time, else just when thumb is released
285        bool    d_vertFree;                                     //!< true if thumb is movable vertically
286        bool    d_horzFree;                                     //!< true if thumb is movable horizontally
287
288        // operational limits
289        float   d_vertMin, d_vertMax;           //!< vertical range
290        float   d_horzMin, d_horzMax;           //!< horizontal range
291
292        // internal state
293        bool    d_beingDragged;                         //!< true if thumb is being dragged
294        Point   d_dragPoint;                            //!< point where we are being dragged at.
295
296
297private:
298        /*************************************************************************
299                Static Properties for this class
300        *************************************************************************/
301        static ThumbProperties::HotTracked      d_hotTrackedProperty;
302        static ThumbProperties::VertFree        d_vertFreeProperty;
303        static ThumbProperties::HorzFree        d_horzFreeProperty;
304        static ThumbProperties::VertRange       d_vertRangeProperty;
305        static ThumbProperties::HorzRange       d_horzRangeProperty;
306
307
308        /*************************************************************************
309                Private methods
310        *************************************************************************/
311        void    addThumbProperties(void);
312};
313
314} // End of  CEGUI namespace section
315
316#if defined(_MSC_VER)
317#       pragma warning(pop)
318#endif
319
320#endif  // end of guard _CEGUIThumb_h_
Note: See TracBrowser for help on using the repository browser.