00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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 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 void EventListener::event( const Event &e ){
00095 if( functor_mask & (1<<(e.type)) ){
00096 holder[e.type]( e );
00097 }
00098 }
00099
00100
00101 };
00102 };
00103