refevent.cpp

Aller à la documentation de ce fichier.
00001 #include "refevent.h"
00002 
00003 RefEvent::RefEvent(SDL_Event &evnt, void (ptrCallback)(SDL_Event*),unsigned long prior,long execcounter)
00004     :execCounter(execcounter)
00005     ,priority(prior)
00006     ,event(evnt)
00007     ,callback(ptrCallback)
00008 
00009 {
00010     //ctor
00011 }
00012 
00013 RefEvent::~RefEvent()
00014 {
00015     //dtor
00016 }
00017 
00018 // TODO (Bérenger#1#): trouver le moyen de supprimer un gestionnaire tombé à 0.
00019 bool RefEvent::testEvent(SDL_Event *evnt)
00020 {
00021     if(event.type==evnt->type && execCounter)
00022     {
00023         switch(event.type)
00024         {
00025             case SDL_ACTIVEEVENT:
00026                 if(event.active.gain==evnt->active.gain && event.active.state==evnt->active.state)
00027                 {
00028                     if(execCounter!=-1)
00029                         execCounter--;
00030                     this->callback(evnt);
00031                     return true;
00032                 }
00033                 break;
00034             case SDL_KEYDOWN:
00035             case SDL_KEYUP:
00036                 if(event.key.state==evnt->key.state && memcmp(&(event.key.keysym),&(evnt->key.keysym),sizeof(SDL_keysym)))
00037                 {
00038                     if(execCounter!=-1)
00039                         execCounter--;
00040                     this->callback(evnt);
00041                     return true;
00042                 }
00043                 break;
00044             case SDL_JOYBUTTONUP:
00045                 if(event.jbutton.which==evnt->jbutton.which && event.jbutton.button==evnt->jbutton.button && event.jbutton.state==evnt->jbutton.state)
00046                 {
00047                     if(execCounter!=-1)
00048                         execCounter--;
00049                     this->callback(evnt);
00050                     return true;
00051                 }
00052                 break;
00053             case SDL_VIDEORESIZE:
00054                 if(event.resize.w==evnt->resize.w && event.resize.h==evnt->resize.h)
00055                 {
00056                     if(execCounter!=-1)
00057                         execCounter--;
00058                     this->callback(evnt);
00059                     return true;
00060                 }
00061                 break;
00062             case SDL_MOUSEMOTION:
00063             case SDL_MOUSEBUTTONDOWN:
00064             case SDL_MOUSEBUTTONUP:
00065             case SDL_JOYAXISMOTION:
00066             case SDL_JOYBALLMOTION:
00067             case SDL_JOYHATMOTION:
00068             case SDL_JOYBUTTONDOWN:
00069             case SDL_VIDEOEXPOSE:
00070             case SDL_QUIT:
00071             case SDL_USEREVENT:
00072             case SDL_SYSWMEVENT:
00073                 this->callback(evnt);
00074                 return true;
00075                 break;
00076             default:
00077                 logErr((char*)__FILE__,__LINE__,(char*)"Evènement inconnu");
00078                 return false;
00079         }
00080     }
00081     return false;
00082 }

Généré le Sun Nov 15 16:53:06 2009 pour PFen par  doxygen 1.6.1