5 |
* modify it under the terms of the GNU General Public License |
* modify it under the terms of the GNU General Public License |
6 |
* as published by the Free Software Foundation; either version 2 |
* as published by the Free Software Foundation; either version 2 |
7 |
* of the License, or (at your option) any later version. |
* of the License, or (at your option) any later version. |
8 |
* |
* |
9 |
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
33 |
class EventHandler { |
class EventHandler { |
34 |
public: |
public: |
35 |
virtual ~EventHandler() {} |
virtual ~EventHandler() {} |
36 |
|
|
37 |
/* Dispatch an event to the suitable virtual function. Returns |
/* Dispatch an event to the suitable virtual function. Returns |
38 |
true if event was handled. */ |
true if event was handled. */ |
39 |
bool dispatch_event (SDL_Event &e); |
bool dispatch_event (SDL_Event &e); |
41 |
/* |
/* |
42 |
** The following function can be overriden to receive |
** The following function can be overriden to receive |
43 |
** particular events. They should return true if the event |
** particular events. They should return true if the event |
44 |
** was handled. |
** was handled. |
45 |
*/ |
*/ |
46 |
virtual bool on_mousemotion (SDL_Event &e) { return false; } |
virtual bool on_mousemotion (SDL_Event &/*e*/) { return false; } |
47 |
virtual bool on_mousebutton (SDL_Event &e) { return false; } |
virtual bool on_mousebutton (SDL_Event &/*e*/) { return false; } |
48 |
virtual bool on_keydown (SDL_Event &e) { return false; } |
virtual bool on_keydown (SDL_Event &/*e*/) { return false; } |
49 |
virtual bool on_keyup (SDL_Event &e) { return false; } |
virtual bool on_keyup (SDL_Event &/*e*/) { return false; } |
50 |
virtual bool on_quit (SDL_Event &e) { return false; } |
virtual bool on_quit (SDL_Event &/*e*/) { return false; } |
51 |
|
|
52 |
/* The generic event handler; this method is called for events |
/* The generic event handler; this method is called for events |
53 |
that none of the specialized methods above decided to handle. */ |
that none of the specialized methods above decided to handle. */ |
54 |
virtual bool on_event (SDL_Event &e) { return false; } |
virtual bool on_event (SDL_Event &/*e*/) { return false; } |
55 |
}; |
}; |
56 |
|
|
57 |
class TempInputGrab { |
class TempInputGrab { |
58 |
public: |
public: |
59 |
TempInputGrab(SDL_GrabMode m) |
TempInputGrab(SDL_GrabMode m) |
60 |
: grabmode(SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
: grabmode(SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
61 |
{ |
{ |
62 |
SDL_WM_GrabInput(m); |
SDL_WM_GrabInput(m); |
63 |
} |
} |