Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreMouseEvent.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General  License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General  License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General  License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #include "OgreStableHeaders.h"
00026 
00027 #include "OgreString.h"
00028 #include "OgreMouseEvent.h"
00029 #include "OgreStringConverter.h"
00030 #include "OgrePositionTarget.h"
00031 
00032 namespace Ogre {
00033 
00034     MouseEvent::MouseEvent(PositionTarget* source, int id, int whichButton, Real when, int modifiers,
00035         Real x, Real y, Real z, int clickCount) :
00036         InputEvent(source, id, when, modifiers),
00037         mX(x),mY(y),mZ(z),
00038         mRelX(0), mRelY(0), mRelZ(0),
00039         mButtonID(whichButton),
00040         mClickCount(clickCount)
00041     {
00042     } 
00043 
00044     MouseEvent::MouseEvent(PositionTarget* source, int id, int whichButton, Real when, int modifiers,
00045         Real x, Real y, Real z,
00046         Real relx, Real rely, Real relz,
00047         int clickCount) :
00048         InputEvent(source, id, when, modifiers),
00049         mX(x), mY(y), mZ(z),
00050         mRelX(relx), mRelY(rely), mRelZ(relz),
00051         mButtonID(whichButton),
00052         mClickCount(clickCount)
00053     {
00054     } 
00055 
00056 
00062      int MouseEvent::getClickCount() {
00063         return mClickCount;
00064     }
00065 
00073      Real MouseEvent::getX() const {
00074         return mX;
00075     }
00083      Real MouseEvent::getY() const {
00084         return mY;
00085     }
00086 
00094      Real MouseEvent::getZ() const {
00095         return mZ;
00096     }
00097      int MouseEvent::getButtonID() const
00098      {
00099          return mButtonID;
00100 
00101      }
00102 
00109      String MouseEvent::paramString() const {
00110         String typeStr;
00111         switch(mId) {
00112           case ME_MOUSE_PRESSED:
00113               typeStr = "MOUSE_PRESSED";
00114               break;
00115           case ME_MOUSE_RELEASED:
00116               typeStr = "MOUSE_RELEASED";
00117               break;
00118           case ME_MOUSE_CLICKED:
00119               typeStr = "MOUSE_CLICKED";
00120               break;
00121           case ME_MOUSE_ENTERED:
00122               typeStr = "MOUSE_ENTERED";
00123               break;
00124           case ME_MOUSE_EXITED:
00125               typeStr = "MOUSE_EXITED";
00126               break;
00127           case ME_MOUSE_MOVED:
00128               typeStr = "MOUSE_MOVED";
00129               break;
00130           case ME_MOUSE_DRAGGED:
00131               typeStr = "MOUSE_DRAGGED";
00132               break;
00133           case ME_MOUSE_DRAGENTERED:
00134               typeStr = "MOUSE_DRAGENTERED";
00135               break;
00136           case ME_MOUSE_DRAGEXITED:
00137               typeStr = "MOUSE_DRAGEXITED";
00138               break;
00139           case ME_MOUSE_DRAGDROPPED:
00140               typeStr = "MOUSE_DRAGDROPPED";
00141               break;
00142           case ME_MOUSE_DRAGMOVED:
00143               typeStr = "MOUSE_DRAGMOVED";
00144               break;
00145           default:
00146               typeStr = "unknown type";
00147         }
00148         return typeStr + ",("+StringConverter::toString(mX)+","+StringConverter::toString(mY)+")"+ ",mods="+StringConverter::toString(getModifiers())+ 
00149                ",clickCount="+StringConverter::toString(mClickCount);
00150     }
00151 
00159      void MouseEvent::translatePoint(Real x, Real y) {
00160         mX += x;
00161         mY += y;
00162     }
00163 
00164 }
00165 

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:35 2004