source: OGRE/trunk/ogrenew/OgreMain/src/OgreMouseEvent.cpp @ 692

Revision 692, 4.7 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

Line 
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#include "OgreStableHeaders.h"
26
27#include "OgreString.h"
28#include "OgreMouseEvent.h"
29#include "OgreStringConverter.h"
30#include "OgrePositionTarget.h"
31
32namespace Ogre {
33
34        MouseEvent::MouseEvent(PositionTarget* source, int id, int whichButton, Real when, int modifiers,
35                Real x, Real y, Real z, int clickCount) :
36                InputEvent(source, id, when, modifiers),
37                mX(x),mY(y),mZ(z),
38        mRelX(0), mRelY(0), mRelZ(0),
39                mButtonID(whichButton),
40                mClickCount(clickCount)
41        {
42        }
43
44    MouseEvent::MouseEvent(PositionTarget* source, int id, int whichButton, Real when, int modifiers,
45                Real x, Real y, Real z,
46        Real relx, Real rely, Real relz,
47        int clickCount) :
48                InputEvent(source, id, when, modifiers),
49                mX(x), mY(y), mZ(z),
50        mRelX(relx), mRelY(rely), mRelZ(relz),
51                mButtonID(whichButton),
52                mClickCount(clickCount)
53        {
54        }
55
56
57        /**
58         * Return the number of mouse clicks associated with this event.
59         *
60         * @return integer value for the number of clicks
61         */
62         int MouseEvent::getClickCount() {
63                return mClickCount;
64        }
65
66        /**
67         * Returns the horizontal x position of the event relative to the
68         * source GuiElement.
69         *
70         * @return x  an integer indicating horizontal position relative to
71         *            the GuiElement
72         */
73         Real MouseEvent::getX() const {
74                return mX;
75        }
76        /**
77         * Returns the vertical y position of the event relative to the
78         * source GuiElement.
79         *
80         * @return y  an integer indicating vertical position relative to
81         *            the GuiElement
82         */
83         Real MouseEvent::getY() const {
84                return mY;
85        }
86
87        /**
88         * Returns the vertical y position of the event relative to the
89         * source GuiElement.
90         *
91         * @return y  an integer indicating vertical position relative to
92         *            the GuiElement
93         */
94         Real MouseEvent::getZ() const {
95                return mZ;
96        }
97         int MouseEvent::getButtonID() const
98         {
99                 return mButtonID;
100
101         }
102
103        /**
104         * Returns a parameter string identifying this event.
105         * This method is useful for event-logging and for debugging.
106         *
107         * @return a string identifying the event and its attributes
108         */
109         String MouseEvent::paramString() const {
110                String typeStr;
111                switch(mId) {
112                  case ME_MOUSE_PRESSED:
113                          typeStr = "MOUSE_PRESSED";
114                          break;
115                  case ME_MOUSE_RELEASED:
116                          typeStr = "MOUSE_RELEASED";
117                          break;
118                  case ME_MOUSE_CLICKED:
119                          typeStr = "MOUSE_CLICKED";
120                          break;
121                  case ME_MOUSE_ENTERED:
122                          typeStr = "MOUSE_ENTERED";
123                          break;
124                  case ME_MOUSE_EXITED:
125                          typeStr = "MOUSE_EXITED";
126                          break;
127                  case ME_MOUSE_MOVED:
128                          typeStr = "MOUSE_MOVED";
129                          break;
130                  case ME_MOUSE_DRAGGED:
131                          typeStr = "MOUSE_DRAGGED";
132                          break;
133                  case ME_MOUSE_DRAGENTERED:
134                          typeStr = "MOUSE_DRAGENTERED";
135                          break;
136                  case ME_MOUSE_DRAGEXITED:
137                          typeStr = "MOUSE_DRAGEXITED";
138                          break;
139                  case ME_MOUSE_DRAGDROPPED:
140                          typeStr = "MOUSE_DRAGDROPPED";
141                          break;
142                  case ME_MOUSE_DRAGMOVED:
143                          typeStr = "MOUSE_DRAGMOVED";
144                          break;
145                  default:
146                          typeStr = "unknown type";
147                }
148                return typeStr + ",("+StringConverter::toString(mX)+","+StringConverter::toString(mY)+")"+ ",mods="+StringConverter::toString(getModifiers())+
149                           ",clickCount="+StringConverter::toString(mClickCount);
150        }
151
152        /**
153         * Translates the event's coordinates to a new position
154         * by adding specified x (horizontal) and y (veritcal) offsets.
155         *
156         * @param x the horizontal x value to add to the current x coordinate position
157         * @param y the vertical y value to add to the current y coordinate position
158         */
159         void MouseEvent::translatePoint(Real x, Real y) {
160                mX += x;
161                mY += y;
162        }
163
164}
165
Note: See TracBrowser for help on using the repository browser.