source: GTP/trunk/App/Demos/Geom/OgreStuff/include/CEGUI/CEGUIMouseCursor.h @ 1092

Revision 1092, 7.9 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

Line 
1/************************************************************************
2        filename:       CEGUIMouseCursor.h
3        created:        21/2/2004
4        author:         Paul D Turner
5       
6        purpose:        Defines interface for the MouseCursor class
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 _CEGUIMouseCursor_h_
27#define _CEGUIMouseCursor_h_
28
29#include "CEGUIBase.h"
30#include "CEGUIString.h"
31#include "CEGUISingleton.h"
32#include "CEGUIVector.h"
33#include "CEGUIRect.h"
34#include "CEGUIEventSet.h"
35#include "CEGUIInputEvent.h"
36
37
38#if defined(_MSC_VER)
39#       pragma warning(push)
40#       pragma warning(disable : 4275)
41#       pragma warning(disable : 4251)
42#endif
43
44
45// Start of CEGUI namespace section
46namespace CEGUI
47{
48
49/*!
50\brief
51        Enumeration of special values used for mouse cursor settings in Window objects.
52*/
53enum MouseCursorImage
54{               
55        BlankMouseCursor        = 0,            //!< No image should be displayed for the mouse cursor.
56        DefaultMouseCursor      = -1            //!< The default mouse cursor image should be displayed.
57};
58
59
60/*!
61\brief
62        Class that allows access to the GUI system mouse cursor.
63
64        The MouseCursor provides functionality to access the position and imagery of the mouse cursor / pointer
65*/
66class CEGUIEXPORT MouseCursor : public EventSet, public Singleton<MouseCursor>
67{
68public:
69        static const String EventNamespace;                             //!< Namespace for global events
70
71        /*************************************************************************
72                Event name constants
73        *************************************************************************/
74        // generated internally by MouseCursor
75        static const String EventImageChanged;                  //!< The cursor image of the widget has changed.
76
77
78        /*!
79        \brief
80                Constructor for MouseCursor objects
81        */
82        MouseCursor(void);
83
84
85        /*!
86        \brief
87                Destructor for MouseCursor objects
88        */
89        ~MouseCursor(void);
90
91
92        /*!
93        \brief
94                Return singleton MouseCursor object
95
96        \return
97                Singleton MouseCursor object
98        */
99        static  MouseCursor&    getSingleton(void);
100
101
102        /*!
103        \brief
104                Return pointer to singleton MouseCursor object
105
106        \return
107                Pointer to singleton MouseCursor object
108        */
109        static  MouseCursor*    getSingletonPtr(void);
110
111
112        /*!
113        \brief
114                Set the current mouse cursor image
115
116        \param imageset
117                String object holding the name of the Imageset that contains the desired Image.
118
119        \param image_name
120                String object holding the name of the desired Image on Imageset \a imageset.
121
122        \return
123                Nothing.
124
125        \exception UnknownObjectException       thrown if \a imageset is not known, or if \a imageset contains no Image named \a image_name.
126        */
127        void    setImage(const String& imageset, const String& image_name);
128
129
130        /*!
131        \brief
132                Set the current mouse cursor image
133        */
134        void    setImage(const Image* image);
135
136
137        /*!
138        \brief
139                Get the current mouse cursor image
140        \return
141                The current image used to draw mouse cursor.
142        */
143        const Image*    getImage(void) const    {return d_cursorImage;}
144
145
146        /*!
147        \brief
148                Makes the cursor draw itself
149
150        \return
151                Nothing
152        */
153        void    draw(void) const;
154
155
156        /*!
157        \brief
158                Set the current mouse cursor position
159
160        \param position
161                Point object describing the new location for the mouse.  This will be clipped to within the renderer screen area.
162        */
163        void    setPosition(const Point& position);
164
165
166        /*!
167        \brief
168                Offset the mouse cursor position by the deltas specified in \a offset.
169
170        \param offset
171                Point object which describes the amount to move the cursor in each axis.
172
173        \return
174                Nothing.
175        */
176        void    offsetPosition(const Point& offset);
177
178
179        /*!
180        \brief
181                Set the area that the mouse cursor is constrained to.
182
183        \param area
184                Pointer to a Rect object that describes the area of the display that the mouse is allowed to occupy.  The given area will be clipped to
185                the current Renderer screen area - it is never possible for the mouse to leave this area.  If this parameter is NULL, the
186                constraint is set to the size of the current Renderer screen area.
187
188        \return
189                Nothing.
190        */
191        void    setConstraintArea(const Rect* area);
192
193
194        /*!
195        \brief
196                Hides the mouse cursor.
197
198        \return
199                Nothing.
200        */
201        void    hide(void)              {d_visible = false;}
202
203
204        /*!
205        \brief
206                Shows the mouse cursor.
207
208        \return
209                Nothing.
210        */
211        void    show(void)              {d_visible = true;}
212
213
214        /*!
215        \brief
216                return whether the mouse cursor is visible.
217
218        \return
219                true if the mouse cursor is visible, false if the mouse cursor is hidden.
220        */
221        bool    isVisible(void) const   {return d_visible;}
222
223
224        /*!
225        \brief
226                Return the current mouse cursor position as a pixel offset from the top-left corner of the display.
227
228        \return
229                Point object describing the mouse cursor position in screen pixels.
230        */
231        Point   getPosition(void) const         {return Point(d_position.d_x, d_position.d_y);}
232
233
234        /*!
235        \brief
236                return the current constraint area of the mouse cursor.
237
238        \return
239                Rect object describing the active area that the mouse cursor is constrained to.
240        */
241        Rect    getConstraintArea(void) const           {return d_constraints;}
242
243
244        /*!
245        \brief
246                Return the current mouse cursor position as display resolution independant values.
247
248        \return
249                Point object describing the current mouse cursor position as resolution independant values that
250                range from 0.0f to 1.0f, where 0.0f represents the left-most and top-most positions, and 1.0f
251                represents the right-most and bottom-most positions.
252        */
253        Point   getDisplayIndependantPosition(void) const;
254
255
256protected:
257        /*************************************************************************
258                New event handlers
259        *************************************************************************/
260        /*!
261        \brief
262                event triggered internally when image of mouse cursor changes
263        */
264        virtual void    onImageChanged(MouseCursorEventArgs& e);
265
266
267        /*************************************************************************
268                Implementation Functions
269        *************************************************************************/
270        /*!
271        \brief
272                Add mouse cursor specific events
273        */
274        void    addMouseCursorEvents(void);
275
276
277private:
278        /*************************************************************************
279                Implementation Methods
280        *************************************************************************/
281        /*!
282        \brief
283                Checks the mouse cursor position is within the current 'constrain' Rect and adjusts as required.
284        */
285        void    constrainPosition(void);
286
287
288        /*************************************************************************
289                Implementation Data
290        *************************************************************************/
291        const Image*    d_cursorImage;          //!< Image that is currently set as the mouse cursor.
292        Vector3 d_position;                                     //!< Current location of the cursor
293        bool    d_visible;                                      //!< true if the cursor will be drawn, else false.
294        Rect    d_constraints;                          //!< Specifies the area (in screen pixels) that the mouse can move around in.
295};
296
297} // End of  CEGUI namespace section
298
299#if defined(_MSC_VER)
300#       pragma warning(pop)
301#endif
302
303#endif  // end of guard _CEGUIMouseCursor_h_
Note: See TracBrowser for help on using the repository browser.