00001 00002 /* 00003 ----------------------------------------------------------------------------- 00004 This source file is part of OGRE 00005 (Object-oriented Graphics Rendering Engine) 00006 For the latest info, see http://www.ogre3d.org/ 00007 00008 Copyright © 2000-2002 The OGRE Team 00009 Also see acknowledgements in Readme.html 00010 00011 This program is free software you can redistribute it and/or modify it under 00012 the terms of the GNU Lesser General Public License as published by the Free Software 00013 Foundation either version 2 of the License, or (at your option) any later 00014 version. 00015 00016 This program is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS 00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License along with 00021 this program if not, write to the Free Software Foundation, Inc., 59 Temple 00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00023 http://www.gnu.org/copyleft/lesser.txt. 00024 ----------------------------------------------------------------------------- 00025 */ 00026 #include "OgreStableHeaders.h" 00027 00028 #include "OgreMouseEvent.h" 00029 #include "OgreEventListeners.h" 00030 #include "OgreMouseTarget.h" // HACK move higher 00031 #include "OgreEventMulticaster.h" 00032 00033 00034 00035 namespace Ogre { 00036 00037 00038 MouseTarget::MouseTarget() 00039 { 00040 mMouseListener = 0; 00041 mMouseWithin = false; 00042 00043 } 00044 //----------------------------------------------------------------------- 00045 00046 void MouseTarget::processMouseEvent(MouseEvent* e) 00047 { 00048 MouseListener* listener = mMouseListener; 00049 if (listener != NULL) 00050 { 00051 int id = e->getID(); 00052 switch(id) 00053 { 00054 case MouseEvent::ME_MOUSE_PRESSED: 00055 listener->mousePressed(e); 00056 break; 00057 case MouseEvent::ME_MOUSE_RELEASED: 00058 listener->mouseReleased(e); 00059 break; 00060 case MouseEvent::ME_MOUSE_CLICKED: 00061 listener->mouseClicked(e); 00062 break; 00063 case MouseEvent::ME_MOUSE_EXITED: 00064 mMouseWithin = false; 00065 listener->mouseExited(e); 00066 break; 00067 case MouseEvent::ME_MOUSE_ENTERED: 00068 mMouseWithin = true; 00069 listener->mouseEntered(e); 00070 break; 00071 case MouseEvent::ME_MOUSE_DRAGENTERED: 00072 mMouseWithin = true; 00073 listener->mouseDragEntered(e); 00074 break; 00075 case MouseEvent::ME_MOUSE_DRAGEXITED: 00076 mMouseWithin = false; 00077 listener->mouseDragExited(e); 00078 break; 00079 case MouseEvent::ME_MOUSE_DRAGDROPPED: 00080 listener->mouseDragDropped(e); 00081 break; 00082 } 00083 } 00084 } 00085 00086 void MouseTarget::addMouseListener(MouseListener* l) 00087 { 00088 if (l == NULL) 00089 { 00090 return; 00091 } 00092 mMouseListener = EventMulticaster::add(mMouseListener,l); 00093 } 00094 00095 void MouseTarget::removeMouseListener(MouseListener* l) 00096 { 00097 if (l == NULL) 00098 { 00099 return; 00100 } 00101 mMouseListener = EventMulticaster::remove(mMouseListener,l); 00102 } 00103 00104 //----------------------------------------------------------------------- 00105 bool MouseTarget::isMouseWithin() const 00106 { 00107 return mMouseWithin; 00108 } 00109 } 00110
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:19 2004