(svn r27953) -Cleanup: Adjust other languages for r27952
[openttd.git] / src / hotkeys.h
blob25a489b3f3aced7c8ea231128cc867993bfceeac
1 /* $Id$ */
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 */
10 /** @file hotkeys.h %Hotkey related functions. */
12 #ifndef HOTKEYS_H
13 #define HOTKEYS_H
15 #include "core/smallvec_type.hpp"
16 #include "gfx_type.h"
17 #include "window_type.h"
18 #include "string_type.h"
20 /**
21 * All data for a single hotkey. The name (for saving/loading a configfile),
22 * a list of keycodes and a number to help identifying this hotkey.
24 struct Hotkey {
25 Hotkey(uint16 default_keycode, const char *name, int num);
26 Hotkey(const uint16 *default_keycodes, const char *name, int num);
28 void AddKeycode(uint16 keycode);
30 const char *name;
31 int num;
32 SmallVector<uint16, 1> keycodes;
35 #define HOTKEY_LIST_END Hotkey((uint16)0, NULL, -1)
37 struct IniFile;
39 /**
40 * List of hotkeys for a window.
42 struct HotkeyList {
43 typedef EventState (*GlobalHotkeyHandlerFunc)(int hotkey);
45 HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler = NULL);
46 ~HotkeyList();
48 void Load(IniFile *ini);
49 void Save(IniFile *ini) const;
51 int CheckMatch(uint16 keycode, bool global_only = false) const;
53 GlobalHotkeyHandlerFunc global_hotkey_handler;
54 private:
55 const char *ini_group;
56 Hotkey *items;
58 /**
59 * Dummy private copy constructor to prevent compilers from
60 * copying the structure, which fails due to _hotkey_lists.
62 HotkeyList(const HotkeyList &other);
65 bool IsQuitKey(uint16 keycode);
67 void LoadHotkeysFromConfig();
68 void SaveHotkeysToConfig();
71 void HandleGlobalHotkeys(WChar key, uint16 keycode);
73 #endif /* HOTKEYS_H */