1 |
|
---|
2 | /*
|
---|
3 | -----------------------------------------------------------------------------
|
---|
4 | This source file is part of OGRE
|
---|
5 | (Object-oriented Graphics Rendering Engine)
|
---|
6 | For the latest info, see http://www.ogre3d.org/
|
---|
7 |
|
---|
8 | Copyright (c) 2000-2005 The OGRE Team
|
---|
9 | Also see acknowledgements in Readme.html
|
---|
10 |
|
---|
11 | This program is free software you can redistribute it and/or modify it under
|
---|
12 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
13 | Foundation either version 2 of the License, or (at your option) any later
|
---|
14 | version.
|
---|
15 |
|
---|
16 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
17 | ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
18 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
21 | this program if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
23 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
24 | -----------------------------------------------------------------------------
|
---|
25 | */
|
---|
26 | #include "OgreStableHeaders.h"
|
---|
27 |
|
---|
28 | #include "OgreMouseMotionTarget.h"
|
---|
29 | #include "OgreMouseEvent.h"
|
---|
30 | #include "OgreEventListeners.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | namespace Ogre {
|
---|
34 |
|
---|
35 | //-----------------------------------------------------------------------
|
---|
36 | void MouseMotionTarget::processMouseMotionEvent(MouseEvent* e)
|
---|
37 | {
|
---|
38 | // Remove all marked listeners
|
---|
39 | std::set<MouseMotionListener*>::iterator i;
|
---|
40 | for (i = mRemovedListeners.begin(); i != mRemovedListeners.end(); i++)
|
---|
41 | {
|
---|
42 | mMouseMotionListeners.erase(*i);
|
---|
43 | }
|
---|
44 | mRemovedListeners.clear();
|
---|
45 |
|
---|
46 | // Tell all listeners
|
---|
47 | for (i= mMouseMotionListeners.begin(); i != mMouseMotionListeners.end(); i++)
|
---|
48 | {
|
---|
49 | MouseMotionListener* listener = *i;
|
---|
50 | if (listener != 0)
|
---|
51 | {
|
---|
52 | int id = e->getID();
|
---|
53 | switch(id)
|
---|
54 | {
|
---|
55 | case MouseEvent::ME_MOUSE_MOVED:
|
---|
56 | listener->mouseMoved(e);
|
---|
57 | break;
|
---|
58 | case MouseEvent::ME_MOUSE_DRAGGED:
|
---|
59 | listener->mouseDragged(e);
|
---|
60 | break;
|
---|
61 | case MouseEvent::ME_MOUSE_DRAGMOVED:
|
---|
62 | listener->mouseDragMoved(e);
|
---|
63 | break;
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | void MouseMotionTarget::addMouseMotionListener(MouseMotionListener* l)
|
---|
70 | {
|
---|
71 | mMouseMotionListeners.insert(l);
|
---|
72 | }
|
---|
73 |
|
---|
74 | void MouseMotionTarget::removeMouseMotionListener(MouseMotionListener* l)
|
---|
75 | {
|
---|
76 | mRemovedListeners.insert(l);
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|