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

EventListener.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: EventListener.cpp,v 1.4 2002/01/11 14:35:03 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/PhysicalComponents/EventListener.h"
00026 #include "Teddy/PhysicalComponents/Area.h"
00027 #include "Teddy/PhysicalComponents/ActionButton.h"
00028 #include "Teddy/MixIn/Named.h"
00029 #include "Teddy/SysSupport/Messages.h"
00030 #include "Teddy/SysSupport/StdIO.h"
00031 using namespace Teddy::MixIn;
00032 using namespace Teddy::Signals;
00033 using namespace Teddy::SysSupport;
00034 
00035 
00036 namespace Teddy              {
00037 namespace PhysicalComponents {
00038 
00039 
00040 const int Event::Event_ID                  =  0;
00041 const int Event::WindowEvent_ID            =  1;
00042 const int Event::WindowFocusActiveEvent_ID =  2;
00043 const int Event::WindowPopupOpenEvent_ID   =  3;
00044 const int Event::WindowPopupCloseEvent_ID  =  4;
00045 const int Event::WindowMoveEvent_ID        =  5;
00046 const int Event::WindowSizeEventEvent_ID   =  6;
00047 const int Event::WindowToFrontEvent_ID     =  7;
00048 const int Event::WindowToBackEvent_ID      =  8;
00049 const int Event::WindowSplitUpdateEvent_ID =  9;
00050 const int Event::MouseButtonDownEvent_ID   = 10;
00051 const int Event::MouseButtonUpEvent_ID     = 11;
00052 const int Event::MouseMotionEvent_ID       = 12;
00053 const int Event::MouseDragEvent_ID         = 13;
00054 const int Event::MouseHoldDragEvent_ID     = 14;
00055 const int Event::KeyEvent_ID               = 15;
00056 const int Event::KeyDownEvent_ID           = 16;
00057 const int Event::KeyUpEvent_ID             = 17;
00058 const int Event::JoyEvent_ID               = 18;
00059 const int Event::JoyButtonEvent_ID         = 19;
00060 const int Event::JoyAxisEvent_ID           = 20;
00061 const int Event::JoyHatEvent_ID            = 21;
00062 const int Event::JoyBallEvent_ID           = 22;
00063 
00064 
00065 EventListener::EventListener(){
00066     functor_mask = anon_mask = 0;
00067 }
00068 
00069 
00070 EventListener::~EventListener(){
00071 }
00072 
00073 
00074 void EventListener::bind( int type, Functor1<bool,const Event &> *f ){
00075     functor_mask |= (1<<(type));
00076     holder[type].functor = f;
00077 }
00078 
00079 
00080 /*virtual*/ bool EventListener::doesEvent( int type ){
00081     return ( functor_mask & 1<<(type)) != 0;
00082 }
00083 
00084 
00085 void EventListener::enableEvent( int type ){
00086     functor_mask |= (1<<(type));
00087 }
00088 
00089 void EventListener::disableEvent( int type ){
00090     functor_mask &= ~(1<<(type));
00091 }
00092 
00093 
00094 /*virtual*/ void EventListener::event( const Event &e ){
00095     if( functor_mask & (1<<(e.type)) ){
00096         holder[e.type]( e );
00097     }
00098 }
00099 
00100 
00101 };  //  namespace PhysicalComponents
00102 };  //  namespace Teddy
00103