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 "OgreMouseTarget.h" 00029 00030 #include "OgreMouseEvent.h" 00031 #include "OgreEventListeners.h" 00032 #include "OgreEventMulticaster.h" 00033 00034 00035 00036 namespace Ogre { 00037 00038 00039 MouseTarget::MouseTarget() 00040 { 00041 mMouseListener = 0; 00042 mMouseWithin = false; 00043 00044 } 00045 //----------------------------------------------------------------------- 00046 00047 void MouseTarget::processMouseEvent(MouseEvent* e) 00048 { 00049 MouseListener* listener = mMouseListener; 00050 if (listener != NULL) 00051 { 00052 int id = e->getID(); 00053 switch(id) 00054 { 00055 case MouseEvent::ME_MOUSE_PRESSED: 00056 listener->mousePressed(e); 00057 break; 00058 case MouseEvent::ME_MOUSE_RELEASED: 00059 listener->mouseReleased(e); 00060 break; 00061 case MouseEvent::ME_MOUSE_CLICKED: 00062 listener->mouseClicked(e); 00063 break; 00064 case MouseEvent::ME_MOUSE_EXITED: 00065 mMouseWithin = false; 00066 listener->mouseExited(e); 00067 break; 00068 case MouseEvent::ME_MOUSE_ENTERED: 00069 mMouseWithin = true; 00070 listener->mouseEntered(e); 00071 break; 00072 case MouseEvent::ME_MOUSE_DRAGENTERED: 00073 mMouseWithin = true; 00074 listener->mouseDragEntered(e); 00075 break; 00076 case MouseEvent::ME_MOUSE_DRAGEXITED: 00077 mMouseWithin = false; 00078 listener->mouseDragExited(e); 00079 break; 00080 case MouseEvent::ME_MOUSE_DRAGDROPPED: 00081 listener->mouseDragDropped(e); 00082 break; 00083 } 00084 } 00085 } 00086 00087 void MouseTarget::addMouseListener(MouseListener* l) 00088 { 00089 if (l == NULL) 00090 { 00091 return; 00092 } 00093 mMouseListener = EventMulticaster::add(mMouseListener,l); 00094 } 00095 00096 void MouseTarget::removeMouseListener(MouseListener* l) 00097 { 00098 if (l == NULL) 00099 { 00100 return; 00101 } 00102 mMouseListener = EventMulticaster::remove(mMouseListener,l); 00103 } 00104 00105 //----------------------------------------------------------------------- 00106 bool MouseTarget::isMouseWithin() const 00107 { 00108 return mMouseWithin; 00109 } 00110 } 00111
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:35 2004