view include/EventHandler.h @ 7:104dff305563

Added App::on_InputFocus and app::on_InputBlur to make sure the program does not receive mouse clicks when not in foreground. Added option in CmakeLists.txt to support compiling for gprof.
author Eris Caffee <discordia@eldalin.com>
date Mon, 15 Nov 2010 21:55:46 -0600
parents d691ce98f406
children bdfe3327f4ce
line source
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Fracter - A simple Mandelbrot Set viewer.
4 //
5 // Copyright (C) 2010 Sarah Eris Horsley Caffee
6 //
7 // This file is part of Fracter.
8 //
9 // Fracter is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 //
22 //
23 // EventHandler.h
24 // EventHandler class definition. This is a virtual class that is meant to be
25 // an interface implemented by an application class. It does, though, provide
26 // default implementations of it's methods so that unused events can be quietly
27 // ignored.
28 //
29 ////////////////////////////////////////////////////////////////////////////////
31 #ifndef EVENTHANDLER_H
32 #define EVENTHANDLER_H
34 #include "SDL.h"
36 class EventHandler
37 {
38 public:
40 EventHandler();
41 virtual ~EventHandler() = 0;
43 virtual void on_Event(SDL_Event * event);
45 // Active events
46 virtual void on_MouseFocus();
47 virtual void on_MouseBlur();
48 virtual void on_InputFocus();
49 virtual void on_InputBlur();
50 virtual void on_Minimize();
51 virtual void on_Restore();
54 // Keyboard events
55 virtual void on_KeyDown(SDL_KeyboardEvent key);
56 virtual void on_KeyUp(SDL_KeyboardEvent key);
58 // Mouse events
59 virtual void on_MouseMove(SDL_MouseMotionEvent motion);
60 virtual void on_LButtonDown(SDL_MouseButtonEvent button);
61 virtual void on_LButtonUp(SDL_MouseButtonEvent button);
62 virtual void on_RButtonDown(SDL_MouseButtonEvent button);
63 virtual void on_RButtonUp(SDL_MouseButtonEvent button);
64 virtual void on_MButtonDown(SDL_MouseButtonEvent button);
65 virtual void on_MButtonUp(SDL_MouseButtonEvent button);
66 virtual void on_MouseWheelDown(SDL_MouseButtonEvent motion);
67 virtual void on_MouseWheelUp(SDL_MouseButtonEvent motion);
69 // Joystick events
70 virtual void on_JoyAxis(SDL_JoyAxisEvent jaxis);
71 virtual void on_JoyButtonDown(SDL_JoyButtonEvent jbutton);
72 virtual void on_JoyButtonUp(SDL_JoyButtonEvent jbutton);
73 virtual void on_JoyHat(SDL_JoyHatEvent jhat);
74 virtual void on_JoyBall(SDL_JoyBallEvent jball);
76 // Misc events
77 virtual void on_Resize(SDL_ResizeEvent resize);
78 virtual void on_Expose();
79 virtual void on_Quit();
80 virtual void on_User(SDL_UserEvent user);
81 virtual void on_SysWM(SDL_SysWMEvent syswm);
83 };
85 #endif