00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 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 Public 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 Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 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 /*************************************************************************** 00026 OgreEventProcessor.h - 00027 The EventProcessor controls getting events, storing them in a queue, and 00028 dispatching events. 00029 It contains an InputDevice which creates InputEvents. The events are then 00030 stored FIFO in the EventQueue. 00031 00032 The EventProcessor is a frame listener, so each frame, it empties the entire 00033 queue to the list of dispatchers. 00034 00035 Each dispatcher corresponds to a registered TargetManager. 00036 00037 The TargetManagers need to be registered with the Processor before initialise is called. 00038 00039 After intialise is called, the Processor will start processing events once startProcessingEvents is called. 00040 00041 The Processor acts like a default EventTarget, so it can process events that no dispatcher consumes. 00042 You can listen default actions to the processor by e.g. 00043 mProcessor->addMouseListener(defaultMouseMovement); 00044 00045 WARNING: The event objects are created in InputReader when they are submitted to the queue 00046 , yet destroyed in the Event Processor when they are taken off the queue. 00047 Deleting objects in different locations to where they are created is usually undesirable, however, 00048 since the Processor, queue and InputReader are tightly coupled (only the Processor is visible to the outside) 00049 this can be an exception. 00050 The reason for this is for performance... The alternative, is to do 2 more event copies when sending events to the queue, 00051 so the queue manages creating (copying the event from the inputReader) and deleting objects once popped - however 00052 this would require the events to be copied twice.. So I have avoided this by having the same event object passed around 00053 and not copied. 00054 ------------------- 00055 begin : Nov 19 2002 00056 copyright : (C) 2002 by Kenny Sabir 00057 email : kenny@sparksuit.com 00058 ***************************************************************************/ 00059 00060 #ifndef __EventProcessor_H__ 00061 #define __EventProcessor_H__ 00062 00063 #include "OgrePrerequisites.h" 00064 #include "OgreSingleton.h" 00065 #include "OgreFrameListener.h" 00066 #include "OgreMouseTarget.h" 00067 #include "OgreActionTarget.h" 00068 #include "OgreMouseMotionTarget.h" 00069 00070 namespace Ogre { 00089 class _OgreExport EventProcessor : public FrameListener, public MouseTarget, public MouseMotionTarget, public Singleton<EventProcessor> 00090 { 00091 protected: 00092 EventQueue* mEventQueue; 00097 void cleanup(); 00098 InputReader* mInputDevice; 00099 typedef std::vector<EventDispatcher*> DispatcherList; 00100 DispatcherList mDispatcherList; 00101 00102 public: 00103 EventProcessor(); 00104 virtual ~EventProcessor(); 00105 00110 void startProcessingEvents(); 00111 00116 void stopProcessingEvents(); 00117 00123 void initialise(RenderWindow* ren); 00124 00129 void processEvent(InputEvent* e); 00130 00135 void addCursorMoveListener(MouseMotionListener* c); 00136 00141 void removeCursorMoveListener(MouseMotionListener* c); 00142 00148 void addTargetManager(TargetManager* targetManager); 00149 00155 bool frameStarted(const FrameEvent& evt); 00156 00157 // PositionTarget methods 00161 Real getTop() const; 00162 00166 Real getLeft() const; 00167 00171 PositionTarget* getPositionTargetParent() ; 00172 00188 static EventProcessor& getSingleton(void); 00189 00190 }; 00191 00192 00193 00194 } 00195 00196 00197 #endif //__EventProcessor_H__
Copyright © 2002 by The OGRE Team