source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreMouseEvent.h @ 1812

Revision 1812, 9.9 KB checked in by gumbau, 18 years ago (diff)
RevLine 
[1812]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General  License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General  License for more details.
18
19You should have received a copy of the GNU Lesser General  License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25/***************************************************************************
26OgreMouseEvent.h  - 
27 * An event which indicates that a mouse action occurred in a MouseTarget (e.g. MouseTarget).
28 * This event is used both for mouse events (click, enter, exit) and mouse
29 * motion events (moves and drags).
30 * <P>
31 * This low-level event is generated by a MouseTarget object for:
32 * <ul>
33 * <li>Mouse Events
34 *     <ul>
35 *     <li>a mouse button is pressed
36 *     <li>a mouse button is released
37 *     <li>a mouse button is clicked (pressed and released)
38 *     <li>the mouse cursor enters a MouseTarget
39 *     <li>the mouse cursor exits a MouseTarget
40 *     </ul>
41 * <li> Mouse Motion Events
42 *     <ul>
43 *     <li>the mouse is moved
44 *     <li>the mouse is dragged
45 *     </ul>
46 * </ul>
47 * <P>
48 * A MouseEvent object is passed to every MouseListener
49 * object which registered to receive
50 * the "interesting" mouse events using MouseTarget's
51 * <code>addMouseListener</code> method.
52 *
53 * A MouseEvent object is also passed to every MouseMotionListener
54 * object which registered to receive
55 * mouse motion events using the MouseTarget's addMouseMotionListener
56 * method
57 *
58 * When a mouse button is clicked, events are generated and sent to the
59 * registered MouseListeners, with the button mask set in the modifier field.
60 * For example, if the first mouse button is pressed, events are sent in the
61 * following order:
62 * <PRE>
63 *    MOUSE_PRESSED:  BUTTON1_MASK
64 *    MOUSE_RELEASED: BUTTON1_MASK
65 *    MOUSE_CLICKED:  BUTTON1_MASK
66 * </PRE>
67 * When multiple mouse buttons are pressed, each press, release, and click
68 * results in a separate event. The button mask in the modifier field reflects
69 * only the button that changed state, not the current state of all buttons.
70 * <P>
71 * For example, if the user presses button 1 followed by button 2 and
72 * releases them in the same order, the following sequence of events is
73 * generated:
74 * <PRE>
75 *    MOUSE_PRESSED:  BUTTON1_MASK
76 *    MOUSE_PRESSED:  BUTTON2_MASK
77 *    MOUSE_RELEASED: BUTTON1_MASK
78 *    MOUSE_CLICKED:  BUTTON1_MASK
79 *    MOUSE_RELEASED: BUTTON2_MASK
80 *    MOUSE_CLICKED:  BUTTON2_MASK
81 * </PRE>
82 * If button2 is released first, the MOUSE_RELEASED/MOUSE_CLICKED pair
83 * for BUTTON2_MASK arrives first, followed by the pair for BUTTON1_MASK.
84 *
85-------------------
86begin                : Dec 03 2002
87copyright            : (C) 2002 by Kenny Sabir
88email                : kenny@sparksuit.com
89***************************************************************************/
90#ifndef __MouseEvent_H__
91#define __MouseEvent_H__
92
93#include "OgrePrerequisites.h"
94#include "OgreInputEvent.h"
95
96namespace Ogre {
97
98/** An event which indicates that a mouse action occurred in a MouseTarget (e.g. MouseTarget).
99@remarks
100 * This event is used both for mouse events (click, enter, exit) and mouse
101 * motion events (moves and drags).
102 * <P>
103 * This low-level event is generated by a MouseTarget object for:
104 * <ul>
105 * <li>Mouse Events
106 *     <ul>
107 *     <li>a mouse button is pressed
108 *     <li>a mouse button is released
109 *     <li>a mouse button is clicked (pressed and released)
110 *     <li>the mouse cursor enters a MouseTarget
111 *     <li>the mouse cursor exits a MouseTarget
112 *     </ul>
113 * <li> Mouse Motion Events
114 *     <ul>
115 *     <li>the mouse is moved
116 *     <li>the mouse is dragged
117 *     </ul>
118 * </ul>
119 * <P>
120 * A MouseEvent object is passed to every MouseListener
121 * object which registered to receive
122 * the "interesting" mouse events using MouseTarget's
123 * <code>addMouseListener</code> method.
124 *
125 * A MouseEvent object is also passed to every MouseMotionListener
126 * object which registered to receive
127 * mouse motion events using the MouseTarget's addMouseMotionListener
128 * method
129 *
130 * When a mouse button is clicked, events are generated and sent to the
131 * registered MouseListeners, with the button mask set in the modifier field.
132 * For example, if the first mouse button is pressed, events are sent in the
133 * following order:
134 * <PRE>
135 *    MOUSE_PRESSED:  BUTTON1_MASK
136 *    MOUSE_RELEASED: BUTTON1_MASK
137 *    MOUSE_CLICKED:  BUTTON1_MASK
138 * </PRE>
139 * When multiple mouse buttons are pressed, each press, release, and click
140 * results in a separate event. The button mask in the modifier field reflects
141 * only the button that changed state, not the current state of all buttons.
142 * <P>
143 * For example, if the user presses button 1 followed by button 2 and
144 * releases them in the same order, the following sequence of events is
145 * generated:
146 * <PRE>
147 *    MOUSE_PRESSED:  BUTTON1_MASK
148 *    MOUSE_PRESSED:  BUTTON2_MASK
149 *    MOUSE_RELEASED: BUTTON1_MASK
150 *    MOUSE_CLICKED:  BUTTON1_MASK
151 *    MOUSE_RELEASED: BUTTON2_MASK
152 *    MOUSE_CLICKED:  BUTTON2_MASK
153 * </PRE>
154 * If button2 is released first, the MOUSE_RELEASED/MOUSE_CLICKED pair
155 * for BUTTON2_MASK arrives first, followed by the pair for BUTTON1_MASK.
156 *
157 */
158    class _OgreExport MouseEvent : public InputEvent
159    {
160    protected:
161                /**
162                 * The mouse events x coordinate.
163                 * The x value is relative to the MouseTarget
164                 * that fired the event.
165                 */
166                Real mX;
167                /**
168                 * The mouse events y coordinate.
169                 * The y value is relative to the MouseTarget
170                 * that fired the event.
171                 */
172                Real mY;
173
174                /**
175                 * The mouse events z coordinate.
176                 * The z value is relative to the MouseTarget
177                 * that fired the event.
178                 */
179                Real mZ;
180
181
182        Real mRelX;
183        Real mRelY;
184        Real mRelZ;
185
186                /**
187                 * Which button was pressed
188                 */
189
190                int mButtonID;
191                /**
192                 * not implemented yet
193                 */
194                int mClickCount;
195
196
197
198
199        public:
200
201                enum
202                {
203                        ME_FIRST_EVENT = 500,
204                        ME_LAST_EVENT = 510
205                };
206
207                enum
208                {
209                        ME_MOUSE_CLICKED        = ME_FIRST_EVENT,
210                        ME_MOUSE_PRESSED,
211                        ME_MOUSE_RELEASED,
212                        ME_MOUSE_MOVED,
213                        ME_MOUSE_ENTERED,
214                        ME_MOUSE_EXITED,
215                        ME_MOUSE_DRAGGED,
216
217      ME_MOUSE_DRAGENTERED,
218      ME_MOUSE_DRAGEXITED,
219      ME_MOUSE_DRAGMOVED,
220      ME_MOUSE_DRAGDROPPED
221                };
222
223                /**
224                 * Constructs a MouseEvent object with the specified source MouseTarget,
225                 * type, modifiers, coordinates, and click count.
226                 *
227                 * @param source       the MouseTarget that originated the event
228                 * @param id           the integer that identifies the event
229                 * @param when         a long int that gives the time the event occurred
230                 * @param modifiers    the modifier keys down during event
231                 *                     (shift, ctrl, alt, meta)
232                 * @param x            the horizontal x coordinate for the mouse location
233                 * @param y            the vertical y coordinate for the mouse location
234                 * @param clickCount   the number of mouse clicks associated with event
235                 */
236                MouseEvent(PositionTarget* source, int id, int whichButton, Real when, int modifiers,
237                        Real x, Real y, Real z, int clickCount);
238
239        MouseEvent(PositionTarget* source, int id, int whichButton, Real when, int modifiers,
240                        Real x, Real y, Real z, Real relx, Real rely, Real relz, int clickCount);
241               
242         /**
243                 * Return the number of mouse clicks associated with this event.
244                 *
245                 * @return integer value for the number of clicks - NOT IMPLEMENTED
246                 */
247                 int getClickCount();
248
249                /**
250                 * Returns the horizontal x position of the event relative to the
251                 * source MouseTarget.
252                 *
253                 * @return x  an integer indicating horizontal position relative to
254                 *            the MouseTarget
255                 */
256                 Real getX() const;
257
258                /**
259                 * Returns the vertical y position of the event relative to the
260                 * source MouseTarget.
261                 *
262                 * @return y  an integer indicating vertical position relative to
263                 *            the MouseTarget
264                 */
265                 Real getY() const;
266
267                /**
268                 * Returns the scrollwheel z position of the event relative to the
269                 * source MouseTarget.
270                 *
271                 * @return y  an integer indicating scrollwheel position relative to
272                 *            the MouseTarget
273                 */
274                 Real getZ() const;
275
276         /** get relative X cursor movement */
277         Real getRelX() const {return mRelX;}
278         
279         /** get relative Y cursor movement */
280         Real getRelY() const {return mRelY;}
281         
282         /** get relative Z cursor movement */
283         Real getRelZ() const {return mRelZ;}
284
285                /**
286                 * Returns a parameter string identifying this event.
287                 * This method is useful for event-logging and for debugging.
288                 *
289                 * @return a string identifying the event and its attributes
290                 */
291                 String paramString() const;
292
293                /**
294                 * Translates the event's coordinates to a new position
295                 * by adding specified x (horizontal) and y (veritcal) offsets.
296                 *
297                 * @param x the horizontal x value to add to the current x coordinate position
298                 * @param y the vertical y value to add to the current y coordinate position
299                 */
300                 void translatePoint(Real x, Real y);
301
302                 /** return the ID of the button */
303                 int getButtonID() const;
304    };
305
306
307}
308
309
310#endif
311
Note: See TracBrowser for help on using the repository browser.