Control: Change controls to use new callback infrastrucure.
[gemrb.git] / gemrb / core / EventMgr.h
blob7b98b8fddef2c255319903e936a3d8897165de94
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /**
22 * @file EventMgr.h
23 * Declares EventMgr, class distributing events from input devices to GUI windows
24 * @author The GemRB Project
28 #ifndef EVENTMGR_H
29 #define EVENTMGR_H
31 #include "exports.h"
33 #include "Control.h"
34 #include "WindowMgr.h"
36 #include <vector>
38 #define GEM_LEFT 0x81
39 #define GEM_RIGHT 0x82
40 #define GEM_UP 0x83
41 #define GEM_DOWN 0x84
42 #define GEM_DELETE 0x85
43 #define GEM_RETURN 0x86
44 #define GEM_BACKSP 0x87
45 #define GEM_TAB 0x88
46 #define GEM_ALT 0x89
47 #define GEM_HOME 0x8a
48 #define GEM_END 0x8b
49 #define GEM_ESCAPE 0x8c
50 #define GEM_PGUP 0x8d
51 #define GEM_PGDOWN 0x8e
52 #define GEM_GRAB 0x8f
55 #define GEM_MOD_SHIFT 1
56 #define GEM_MOD_CTRL 2
57 #define GEM_MOD_ALT 4
59 #define GEM_MOUSEOUT 128
61 // Mouse buttons
62 #define GEM_MB_ACTION 1
63 #define GEM_MB_MENU 4
64 #define GEM_MB_SCRLUP 8
65 #define GEM_MB_SCRLDOWN 16
67 #define GEM_MB_NORMAL 255
68 #define GEM_MB_DOUBLECLICK 256
70 #define GEM_RK_DOUBLESPEED 1
71 #define GEM_RK_DISABLE 2
72 #define GEM_RK_QUADRUPLESPEED 4
74 /**
75 * @class EventMgr
76 * Class distributing events from input devices to GUI windows.
77 * The events are pumped into instance of this class from a Video driver plugin
80 class GEM_EXPORT EventMgr {
81 private:
82 std::vector< Window*> windows;
83 std::vector< int> topwin;
85 unsigned short dc_x, dc_y;
86 unsigned long dc_time, dc_delay;
87 unsigned long rk_delay, rk_flags;
88 public:
89 EventMgr(void);
90 ~EventMgr(void);
91 /** Adds a Window to the Event Manager */
92 void AddWindow(Window* win);
93 /** Removes a Window from the Event chain */
94 //void DelWindow(unsigned short WindowID, const char *WindowPack);
95 void DelWindow(Window* win);
96 /** Frees and Removes all the Windows in the Array */
97 void Clear();
98 /** Call this to change the cursor (moving over windows will change it back) */
99 void RefreshCursor(int idx);
100 /** BroadCast Mouse Move Event */
101 void MouseMove(unsigned short x, unsigned short y);
102 /** BroadCast Mouse Move Event */
103 void MouseDown(unsigned short x, unsigned short y, unsigned short Button,
104 unsigned short Mod);
105 /** BroadCast Mouse Move Event */
106 void MouseUp(unsigned short x, unsigned short y, unsigned short Button,
107 unsigned short Mod);
108 /** BroadCast Mouse Idle Event */
109 void MouseIdle(unsigned long time);
110 /** BroadCast Key Press Event */
111 void KeyPress(unsigned char Key, unsigned short Mod);
112 /** BroadCast Key Release Event */
113 void KeyRelease(unsigned char Key, unsigned short Mod);
114 /** Special Ket Press Event */
115 void OnSpecialKeyPress(unsigned char Key);
116 /** Sets focus to the control of the window */
117 void SetFocused(Window *win, Control *ctrl);
118 /** Sets mouse event focus to the control of the window */
119 void SetMouseFocused(Window *win, Control *ctrl);
120 /** Sets the maximum accepted doubleclick delay */
121 void SetDCDelay(unsigned long t);
122 void SetRKDelay(unsigned long t);
123 unsigned long GetRKDelay();
124 unsigned long SetRKFlags(unsigned long arg, unsigned int op);
126 /** Mask of which Mouse Buttons are pressed */
127 unsigned char MButtons;
128 private:
129 /** Last Window focused */
130 Window* last_win_focused;
131 /** Last Window mouse event focused */
132 Window* last_win_mousefocused;
133 /** Last Window under Mouse Pointer*/
134 Window* last_win_over;
135 /** Sets a Window on the Top of the Window Queue */
136 void SetDefaultFocus(Window *win);
137 void SetOnTop(int Index);
138 bool ClickMatch(unsigned short x, unsigned short y, unsigned long thisTime);
141 #endif // ! EVENTMGR_H