00001 /* 00002 * $Id: MouseEvent.cpp,v 1.6 2002/08/07 15:55:42 virtualcasino Exp $ 00003 */ 00004 #include<MouseEvent.h> 00005 #include<SDL/SDL.h> 00006 00007 extern SDL_Event globalEvent; 00008 namespace clawsoft{ 00009 00010 MouseEvent::MouseEvent(){ 00011 Event::setClassName("MouseEvent"); 00012 } 00013 00014 bool MouseEvent::inFocus(Rect r){ 00015 int x, y; 00016 /*x = globalEvent.motion.x; 00017 y = globalEvent.motion.y;*/ 00018 SDL_GetMouseState(&x, &y); 00019 if(r.getLeft() <= x && r.getRight() >= x){ 00020 if(r.getTop() <= y && r.getBottom() >= y){ 00021 return true; 00022 } 00023 } 00024 return false; 00025 } 00026 00027 bool MouseEvent::leftPressed(){ 00028 if(globalEvent.button.button == SDL_BUTTON_LEFT || 00029 globalEvent.button.state == SDL_PRESSED) 00030 return true; 00031 return false; 00032 } 00033 00034 bool MouseEvent::rightPressed(){ 00035 if(globalEvent.button.button == SDL_BUTTON_RIGHT || 00036 globalEvent.button.state == SDL_PRESSED) 00037 return true; 00038 return false; 00039 } 00040 00041 bool MouseEvent::middlePressed(){ 00042 if(globalEvent.button.button == SDL_BUTTON_MIDDLE || 00043 globalEvent.button.state == SDL_PRESSED) 00044 return true; 00045 return false; 00046 } 00047 00048 void MouseEvent::getStatus(int *x, int *y, int *b){ 00049 /* *x = globalEvent.motion.x; 00050 *y = globalEvent.motion.y;*/ 00051 *b = SDL_GetMouseState(x, y); 00052 } 00053 00054 }
Powered by: