OpenTTD: src/hotkeys.h Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

hotkeys.h
Go to the documentation of this file.
1 /* $Id: hotkeys.h 25669 2013-08-05 20:36:28Z michi_cc $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
9
12 #ifndef HOTKEYS_H
13 #define HOTKEYS_H
14
15 #include "core/smallvec_type.hpp"
16 #include "gfx_type.h"
17 #include "window_type.h"
18 #include "string_type.h"
19
24 struct Hotkey {
25 Hotkey(uint16 default_keycode, const char *name, int num);
26 Hotkey(const uint16 *default_keycodes, const char *name, int num);
27
28 void AddKeycode(uint16 keycode);
29
30 const char *name;
31 int num;
32 SmallVector<uint16, 1> keycodes;
33 };
34
35 #define HOTKEY_LIST_END Hotkey((uint16)0, NULL, -1)
36
37 struct IniFile;
38
42 struct HotkeyList {
43 typedef EventState (*GlobalHotkeyHandlerFunc)(int hotkey);
44
45 HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler = NULL);
46 ~HotkeyList();
47
48 void Load(IniFile *ini);
49 void Save(IniFile *ini) const;
50
51 int CheckMatch(uint16 keycode, bool global_only = false) const;
52
53 GlobalHotkeyHandlerFunc global_hotkey_handler;
54 private:
55 const char *ini_group;
56 Hotkey *items;
57
62 HotkeyList(const HotkeyList &other);
63 };
64
65 bool IsQuitKey(uint16 keycode);
66
67 void LoadHotkeysFromConfig();
68 void SaveHotkeysToConfig();
69
70
71 void HandleGlobalHotkeys(WChar key, uint16 keycode);
72
73 #endif /* HOTKEYS_H */