KiCad PCB EDA Suite
hotkeys_basic.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef HOTKEYS_BASIC_H
25 #define HOTKEYS_BASIC_H
26 
27 #include <map>
28 #include <common.h>
29 
30 #define DEFAULT_HOTKEY_FILENAME_EXT wxT( "hotkeys" )
31 #define EESCHEMA_HOTKEY_NAME wxT( "Eeschema" )
32 #define PCBNEW_HOTKEY_NAME wxT( "PcbNew" )
33 
34 // A define to allow translation of Hot Key message Info in hotkey help menu
35 // We do not want to use the _( x ) usual macro from wxWidgets, which calls wxGetTranslation(),
36 // because the English string is used in key file configuration
37 // The translated string is used only when displaying the help window.
38 // Therefore translation tools have to use the "_" and the "_HKI" prefix to extract
39 // strings to translate
40 #include <i18n_utility.h> // _HKI definition
41 
42 class TOOL_ACTION;
43 class TOOL_MANAGER;
44 class EDA_BASE_FRAME;
45 
46 
47 /*
48  * Keep these out of the ASCII range, and out of the WXK range
49  */
50 #define PSEUDO_WXK_CLICK 400
51 #define PSEUDO_WXK_DBLCLICK 401
52 #define PSEUDO_WXK_WHEEL 402
53 
58 int KeyCodeFromKeyName( const wxString& keyname );
59 
66 wxString KeyNameFromKeyCode( int aKeycode, bool * aIsFound = nullptr );
67 
77 {
80 };
81 
89 wxString AddHotkeyName( const wxString& aText, int aHotKey,
90  HOTKEY_ACTION_TYPE aStyle = IS_HOTKEY);
91 
99 void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, TOOL_MANAGER* aToolMgr );
100 
107 void ReadHotKeyConfig( wxString aFileName, std::map<std::string, int>& aHotKeys );
108 
113 int WriteHotKeyConfig( const std::map<std::string, TOOL_ACTION*>& aActionMap );
114 
123 int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string, int>& aMap );
124 
131 int ReadLegacyHotkeyConfig( const wxString& aAppname, std::map<std::string, int>& aMap );
132 
133 #endif // HOTKEYS_BASIC_H
int ReadLegacyHotkeyConfigFile(const wxString &aFilename, std::map< std::string, int > &aMap)
Function ReadLegacyHotkeyConfigFile Read hotkey configuration for a given app, possibly before the fr...
int WriteHotKeyConfig(const std::map< std::string, TOOL_ACTION * > &aActionMap)
Function WriteHotKeyConfig Updates the hotkeys config file with the hotkeys from the given actions ma...
wxString AddHotkeyName(const wxString &aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle=IS_HOTKEY)
AddHotkeyName.
int ReadLegacyHotkeyConfig(const wxString &aAppname, std::map< std::string, int > &aMap)
Function ReadLegacyHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys...
TOOL_MANAGER.
Definition: tool_manager.h:51
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound=nullptr)
Function KeyNameFromKeyCode return the user-friendly key name (ie: "Ctrl+M") from the key code.
Some functions to handle hotkeys in KiCad.
int KeyCodeFromKeyName(const wxString &keyname)
Function KeyCodeFromKeyName return the key code from its user-friendly key name (ie: "Ctrl+M")
The base frame for deriving all KiCad main window classes.
TOOL_ACTION.
Definition: tool_action.h:46
void ReadHotKeyConfig(wxString aFileName, std::map< std::string, int > &aHotKeys)
Function ReadotKeyConfig Reads a hotkey config file into a map.
The common library.
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, TOOL_MANAGER *aToolMgr)
Function DisplayHotkeyList Displays the current hotkey list.
HOTKEY_ACTION_TYPE
An helper enum for AddHotkeyName function In menus we can add a hot key, or an accelerator ,...
Definition: hotkeys_basic.h:76