2011-10-18 19:59:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2010-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program 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; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
/**
|
|
|
|
* @file hotkeys_basic.cpp
|
2011-09-30 18:15:37 +00:00
|
|
|
* @brief Some functions to handle hotkeys in KiCad
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2007-09-06 11:52:26 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <hotkeys_basic.h>
|
|
|
|
#include <id.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <dialog_hotkeys_editor.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2009-04-06 18:54:57 +00:00
|
|
|
#include <wx/apptrait.h>
|
|
|
|
#include <wx/stdpaths.h>
|
2010-08-28 18:02:24 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2009-04-06 18:54:57 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
#define HOTKEYS_CONFIG_KEY wxT( "Keys" )
|
2007-08-20 11:33:45 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString g_CommonSectionTag( wxT( "[common]" ) );
|
|
|
|
wxString g_SchematicSectionTag( wxT( "[eeschema]" ) );
|
|
|
|
wxString g_LibEditSectionTag( wxT( "[libedit]" ) );
|
|
|
|
wxString g_BoardEditorSectionTag( wxT( "[pcbnew]" ) );
|
|
|
|
wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) );
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-08-20 11:33:45 +00:00
|
|
|
/* Class to handle hotkey commnands. hotkeys have a default value
|
2009-11-23 15:16:50 +00:00
|
|
|
* This class allows the real key code changed by user from a key code list
|
|
|
|
* file.
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2007-08-20 11:33:45 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2010-01-20 18:59:46 +00:00
|
|
|
m_KeyCode = keycode; // Key code (ascii value for ascii keys
|
|
|
|
// or wxWidgets code for function key
|
|
|
|
m_InfoMsg = infomsg; // info message.
|
|
|
|
m_Idcommand = idcommand; // internal id for the corresponding
|
|
|
|
// command (see hotkey_id_commnand list)
|
2009-11-23 15:16:50 +00:00
|
|
|
m_IdMenuEvent = idmenuevent; // id to call the corresponding event
|
2010-01-20 18:59:46 +00:00
|
|
|
// (if any) (see id.h)
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
m_KeyCode = base->m_KeyCode;
|
|
|
|
m_InfoMsg = base->m_InfoMsg;
|
|
|
|
m_Idcommand = base->m_Idcommand;
|
|
|
|
m_IdMenuEvent = base->m_IdMenuEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-26 20:46:04 +00:00
|
|
|
EDA_HOTKEY_CLIENT_DATA::~EDA_HOTKEY_CLIENT_DATA()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
/* class to handle the printable name and the keycode
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
|
|
|
struct hotkey_name_descr
|
|
|
|
{
|
2007-10-31 08:34:05 +00:00
|
|
|
const wxChar* m_Name;
|
2010-01-20 18:59:46 +00:00
|
|
|
int m_KeyCode;
|
2007-08-21 19:37:31 +00:00
|
|
|
};
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
/* table giving the hotkey name from the hotkey code, for special keys
|
|
|
|
* Note : when modifiers (ATL, SHIFT, CTRL) do not modify
|
|
|
|
* the code of the key, do need to enter the modified key code
|
|
|
|
* For instance wxT( "F1" ), WXK_F1 handle F1, AltF1, CtrlF1 ...
|
2010-08-29 16:36:52 +00:00
|
|
|
* Key names are:
|
|
|
|
* "Space","Ctrl+Space","Alt+Space" or
|
|
|
|
* "Alt+A","Ctrl+F1", ...
|
2010-08-28 18:02:24 +00:00
|
|
|
*/
|
2007-09-06 11:52:26 +00:00
|
|
|
static struct hotkey_name_descr s_Hotkey_Name_List[] =
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
{ wxT( "F1" ), WXK_F1 },
|
|
|
|
{ wxT( "F2" ), WXK_F2 },
|
|
|
|
{ wxT( "F3" ), WXK_F3 },
|
|
|
|
{ wxT( "F4" ), WXK_F4 },
|
|
|
|
{ wxT( "F5" ), WXK_F5 },
|
|
|
|
{ wxT( "F6" ), WXK_F6 },
|
|
|
|
{ wxT( "F7" ), WXK_F7 },
|
|
|
|
{ wxT( "F8" ), WXK_F8 },
|
|
|
|
{ wxT( "F9" ), WXK_F9 },
|
|
|
|
{ wxT( "F10" ), WXK_F10 },
|
|
|
|
{ wxT( "F11" ), WXK_F11 },
|
|
|
|
{ wxT( "F12" ), WXK_F12 },
|
|
|
|
|
|
|
|
{ wxT( "Esc" ), WXK_ESCAPE },
|
|
|
|
{ wxT( "Del" ), WXK_DELETE },
|
2010-08-29 16:36:52 +00:00
|
|
|
{ wxT( "Tab" ), WXK_TAB },
|
2010-08-28 18:02:24 +00:00
|
|
|
{ wxT( "BkSp" ), WXK_BACK },
|
|
|
|
{ wxT( "Ins" ), WXK_INSERT },
|
|
|
|
|
|
|
|
{ wxT( "Home" ), WXK_HOME },
|
|
|
|
{ wxT( "End" ), WXK_END },
|
|
|
|
{ wxT( "PgUp" ), WXK_PAGEUP },
|
|
|
|
{ wxT( "PgDn" ), WXK_PAGEDOWN },
|
|
|
|
|
|
|
|
{ wxT( "Up" ), WXK_UP },
|
|
|
|
{ wxT( "Down" ), WXK_DOWN },
|
|
|
|
{ wxT( "Left" ), WXK_LEFT },
|
|
|
|
{ wxT( "Right" ), WXK_RIGHT },
|
2010-01-20 18:59:46 +00:00
|
|
|
|
2010-08-29 16:36:52 +00:00
|
|
|
{ wxT( "Space" ), WXK_SPACE },
|
|
|
|
|
2010-01-20 18:59:46 +00:00
|
|
|
// Do not change this line: end of list
|
2010-08-28 18:02:24 +00:00
|
|
|
{ wxT( "" ), 0 }
|
2007-08-21 19:37:31 +00:00
|
|
|
};
|
|
|
|
|
2010-08-28 19:08:58 +00:00
|
|
|
#define MODIFIER_CTRL wxT( "Ctrl+" )
|
|
|
|
#define MODIFIER_ALT wxT( "Alt+" )
|
|
|
|
#define MODIFIER_SHIFT wxT( "Shift+" )
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnKeyNameFromKeyCode
|
2007-08-30 08:15:05 +00:00
|
|
|
* return the key name from the key code
|
2009-11-23 15:16:50 +00:00
|
|
|
* Only some wxWidgets key values are handled for function key ( see
|
|
|
|
* s_Hotkey_Name_List[] )
|
2010-02-16 10:42:57 +00:00
|
|
|
* @param aKeycode = key code (ascii value, or wxWidgets value for function keys)
|
2010-08-28 18:02:24 +00:00
|
|
|
* @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default)
|
2007-08-30 08:15:05 +00:00
|
|
|
* @return the key name in a wxString
|
|
|
|
*/
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
wxString keyname, modifier, fullkeyname;
|
|
|
|
int ii;
|
2010-08-28 18:02:24 +00:00
|
|
|
bool found = false;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
if( (aKeycode & GR_KB_CTRL) != 0 )
|
2010-08-28 19:08:58 +00:00
|
|
|
modifier << MODIFIER_CTRL;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
if( (aKeycode & GR_KB_ALT) != 0 )
|
2010-08-28 19:08:58 +00:00
|
|
|
modifier << MODIFIER_ALT;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
if( (aKeycode & GR_KB_SHIFT) != 0 )
|
2010-08-28 19:08:58 +00:00
|
|
|
modifier << MODIFIER_SHIFT;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
aKeycode &= ~( GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT );
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2010-08-29 16:36:52 +00:00
|
|
|
if( (aKeycode > ' ') && (aKeycode < 0x7F ) )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
found = true;
|
2011-09-01 12:54:34 +00:00
|
|
|
keyname.Append( (wxChar)aKeycode );
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( ii = 0; ; ii++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 ) // End of list
|
|
|
|
{
|
|
|
|
keyname = wxT( "<unknown>" );
|
|
|
|
break;
|
|
|
|
}
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode )
|
|
|
|
{
|
|
|
|
keyname = s_Hotkey_Name_List[ii].m_Name;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( aIsFound )
|
|
|
|
*aIsFound = found;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
fullkeyname = modifier + keyname;
|
|
|
|
return fullkeyname;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
2007-08-20 11:33:45 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
/*
|
|
|
|
* helper function use in AddHotkeyName to calculate an accelerator string
|
2011-09-29 16:49:40 +00:00
|
|
|
* In some menus, accelerators do not perform exactly the same action as
|
|
|
|
* the hotkey that perform a similar action.
|
2011-09-23 20:00:30 +00:00
|
|
|
* this is usually the case when this action uses the current mouse position
|
|
|
|
* for instance zoom action is ran from the F1 key or the Zoom menu.
|
|
|
|
* a zoom uses the mouse position from a hot key and not from the menu
|
|
|
|
* In this case, the accelerator if Shift+<hotkey>
|
2011-09-24 17:15:29 +00:00
|
|
|
* But for many keys, the Shift modifier is not usable, and the accelerator is Alt+<hotkey>
|
2011-09-23 20:00:30 +00:00
|
|
|
*/
|
|
|
|
static void AddModifierToKey( wxString& aFullKey, const wxString & aKey )
|
|
|
|
{
|
2011-09-24 17:15:29 +00:00
|
|
|
#if 0 // set to 0 for new behavior, 1 for old
|
2011-09-23 20:00:30 +00:00
|
|
|
aFullKey << wxT( " <" ) << aKey << wxT( ">" );
|
|
|
|
#else
|
2011-09-24 17:15:29 +00:00
|
|
|
if( (aKey.Length() == 1) && (aKey[0] >= 'A') && (aKey[0] <= 'Z'))
|
|
|
|
// We can use Shift+<key> as accelerator ans <key> for hot key
|
2011-09-23 20:00:30 +00:00
|
|
|
aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey;
|
2011-09-24 17:15:29 +00:00
|
|
|
else
|
|
|
|
// We must use Alt+<key> as accelerator ans <key> for hot key
|
|
|
|
aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey;
|
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
/* AddHotkeyName
|
2007-08-30 08:15:05 +00:00
|
|
|
* Add the key name from the Command id value ( m_Idcommand member value)
|
2010-12-20 17:44:25 +00:00
|
|
|
* aText = a wxString. returns aText + key name
|
2011-09-29 16:49:40 +00:00
|
|
|
* aList = pointer to a EDA_HOTKEY list of commands
|
2010-12-20 17:44:25 +00:00
|
|
|
* aCommandId = Command Id value
|
2011-09-23 20:00:30 +00:00
|
|
|
* aShortCutType = IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys)
|
|
|
|
* IS_ACCELERATOR to add <tab><Shift+keyname> (accelerators in menus, not hotkeys)
|
2011-09-29 16:49:40 +00:00
|
|
|
* IS_COMMENT to add <spaces><(keyname)> mainly in tool tips
|
2010-12-20 17:44:25 +00:00
|
|
|
* Return a wxString (aTest + key name) if key found or aText without modification
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList,
|
2011-09-23 20:00:30 +00:00
|
|
|
int aCommandId, HOTKEY_ACTION_TYPE aShortCutType )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString msg = aText;
|
2010-02-14 18:14:33 +00:00
|
|
|
wxString keyname;
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2010-02-14 18:14:33 +00:00
|
|
|
if( aList )
|
|
|
|
keyname = ReturnKeyNameFromCommandId( aList, aCommandId );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
if( !keyname.IsEmpty() )
|
2011-04-05 14:46:51 +00:00
|
|
|
{
|
2011-09-23 20:00:30 +00:00
|
|
|
switch( aShortCutType )
|
|
|
|
{
|
|
|
|
case IS_HOTKEY:
|
|
|
|
msg << wxT( "\t" ) << keyname;
|
|
|
|
break;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
case IS_ACCELERATOR:
|
|
|
|
AddModifierToKey( msg, keyname );
|
|
|
|
break;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
case IS_COMMENT:
|
|
|
|
msg << wxT( " (" ) << keyname << wxT( ")" );
|
|
|
|
break;
|
|
|
|
}
|
2011-04-05 14:46:51 +00:00
|
|
|
}
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
/* AddHotkeyName
|
2007-09-06 11:52:26 +00:00
|
|
|
* Add the key name from the Command id value ( m_Idcommand member value)
|
2010-12-20 17:44:25 +00:00
|
|
|
* aText = a wxString. returns aText + key name
|
2011-09-29 16:49:40 +00:00
|
|
|
* aList = pointer to a EDA_HOTKEY_CONFIG DescrList of commands
|
2010-12-20 17:44:25 +00:00
|
|
|
* aCommandId = Command Id value
|
2011-09-23 20:00:30 +00:00
|
|
|
* aShortCutType = IS_HOTKEY to add <tab><keyname> (active shortcuts in menus)
|
|
|
|
* IS_ACCELERATOR to add <tab><Shift+keyname> (active accelerators in menus)
|
|
|
|
* IS_COMMENT to add <spaces><(keyname)>
|
2010-12-20 17:44:25 +00:00
|
|
|
* Return a wxString (aText + key name) if key found or aText without modification
|
2007-09-06 11:52:26 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
wxString AddHotkeyName( const wxString& aText,
|
|
|
|
struct EDA_HOTKEY_CONFIG* aDescList,
|
|
|
|
int aCommandId,
|
|
|
|
HOTKEY_ACTION_TYPE aShortCutType )
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
wxString msg = aText;
|
|
|
|
wxString keyname;
|
|
|
|
EDA_HOTKEY** List;
|
2007-09-06 11:52:26 +00:00
|
|
|
|
2010-02-14 18:14:33 +00:00
|
|
|
if( aDescList )
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
2010-02-14 18:14:33 +00:00
|
|
|
for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
2010-02-14 18:14:33 +00:00
|
|
|
List = aDescList->m_HK_InfoList;
|
|
|
|
keyname = ReturnKeyNameFromCommandId( List, aCommandId );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-02-14 18:14:33 +00:00
|
|
|
if( !keyname.IsEmpty() )
|
|
|
|
{
|
2011-09-23 20:00:30 +00:00
|
|
|
switch( aShortCutType )
|
|
|
|
{
|
|
|
|
case IS_HOTKEY:
|
|
|
|
msg << wxT( "\t" ) << keyname;
|
|
|
|
break;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
case IS_ACCELERATOR:
|
|
|
|
AddModifierToKey( msg, keyname );
|
|
|
|
break;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
case IS_COMMENT:
|
|
|
|
msg << wxT( " (" ) << keyname << wxT( ")" );
|
|
|
|
break;
|
|
|
|
}
|
2010-02-14 18:14:33 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnKeyNameFromCommandId
|
2007-08-30 08:15:05 +00:00
|
|
|
* return the key name from the Command id value ( m_Idcommand member value)
|
2011-09-29 16:49:40 +00:00
|
|
|
* @param aList = pointer to a EDA_HOTKEY list of commands
|
2010-02-16 10:42:57 +00:00
|
|
|
* @param aCommandId = Command Id value
|
2007-08-30 08:15:05 +00:00
|
|
|
* @return the key name in a wxString
|
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
wxString keyname;
|
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
for( ; *aList != NULL; aList++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* hk_decr = *aList;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
if( hk_decr->m_Idcommand == aCommandId )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return keyname;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnKeyCodeFromKeyName
|
2007-08-30 08:15:05 +00:00
|
|
|
* return the key code from its key name
|
|
|
|
* Only some wxWidgets key values are handled for function key
|
2009-11-23 15:16:50 +00:00
|
|
|
* @param keyname = wxString key name to find in s_Hotkey_Name_List[],
|
2010-01-20 18:59:46 +00:00
|
|
|
* like F2 or space or an usual (ascii) char.
|
2007-08-30 08:15:05 +00:00
|
|
|
* @return the key code
|
|
|
|
*/
|
2010-08-29 16:36:52 +00:00
|
|
|
int ReturnKeyCodeFromKeyName( const wxString& keyname )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
int ii, keycode = 0;
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
// Search for modifiers: Ctrl+ Alt+ and Shift+
|
|
|
|
wxString key = keyname;
|
|
|
|
int modifier = 0;
|
|
|
|
while( 1 )
|
|
|
|
{
|
2010-08-28 19:08:58 +00:00
|
|
|
if( key.StartsWith( MODIFIER_CTRL ) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
modifier |= GR_KB_CTRL;
|
|
|
|
key.Remove( 0, 5 );
|
|
|
|
}
|
2010-08-28 19:08:58 +00:00
|
|
|
else if( key.StartsWith( MODIFIER_ALT ) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
modifier |= GR_KB_ALT;
|
|
|
|
key.Remove( 0, 4 );
|
|
|
|
}
|
2010-08-28 19:08:58 +00:00
|
|
|
else if( key.StartsWith( MODIFIER_SHIFT ) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
modifier |= GR_KB_SHIFT;
|
|
|
|
key.Remove( 0, 6 );
|
|
|
|
}
|
|
|
|
else
|
2011-09-01 12:54:34 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
break;
|
2011-09-01 12:54:34 +00:00
|
|
|
}
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
|
2010-08-29 16:36:52 +00:00
|
|
|
if( (key.length() == 1) && (key[0] > ' ') && (key[0] < 0x7F) )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
keycode = key[0];
|
|
|
|
keycode += modifier;
|
2010-08-29 16:36:52 +00:00
|
|
|
return keycode;
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
for( ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 ) // End of list reached
|
|
|
|
break;
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2010-08-29 16:36:52 +00:00
|
|
|
if( key.CmpNoCase( s_Hotkey_Name_List[ii].m_Name ) == 0 )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
keycode = s_Hotkey_Name_List[ii].m_KeyCode + modifier;
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return keycode;
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
/* DisplayHotkeyList
|
2007-08-30 08:15:05 +00:00
|
|
|
* Displays the current hotkey list
|
2011-09-29 16:49:40 +00:00
|
|
|
* aList = a EDA_HOTKEY_CONFIG list(Null terminated)
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
wxString keyname;
|
|
|
|
EDA_HOTKEY** List;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
wxString msg = wxT( "<html><body bgcolor=\"#E2E2E2\">" );
|
2011-09-09 19:30:59 +00:00
|
|
|
|
|
|
|
msg += wxT( "<H3>");
|
2011-09-10 17:48:35 +00:00
|
|
|
msg += _("Hotkeys List");
|
|
|
|
msg += wxT("</H3> <table cellpadding=\"0\">");
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-02-16 11:02:20 +00:00
|
|
|
for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-02-16 11:02:20 +00:00
|
|
|
List = aDescList->m_HK_InfoList;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
for( ; *List != NULL; List++ )
|
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* hk_decr = *List;
|
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) )
|
|
|
|
{
|
|
|
|
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
|
|
|
|
msg += wxT( "<tr><td>" ) + hk_decr->m_InfoMsg + wxT("</td>");
|
|
|
|
msg += wxT("<td><b> ") + keyname + wxT( "</b></td></tr>" );
|
|
|
|
}
|
2007-09-06 11:52:26 +00:00
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
|
2011-09-06 07:02:18 +00:00
|
|
|
msg += wxT("</table></html></body>");
|
|
|
|
DisplayHtmlInfoMessage( aFrame, _("Hotkeys List"), msg, wxSize(340, 750));
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function GetDescriptorFromHotkey
|
2011-09-29 16:49:40 +00:00
|
|
|
* Return a EDA_HOTKEY * pointer from a key code for OnHotKey() function
|
2010-02-16 11:02:20 +00:00
|
|
|
* @param aKey = key code (ascii value, or wxWidgets value for function keys
|
2011-09-29 16:49:40 +00:00
|
|
|
* @param aList = pointer to a EDA_HOTKEY list of commands
|
|
|
|
* @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2010-02-16 11:02:20 +00:00
|
|
|
for( ; *aList != NULL; aList++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* hk_decr = *aList;
|
|
|
|
|
2010-02-16 11:02:20 +00:00
|
|
|
if( hk_decr->m_KeyCode == aKey )
|
2007-09-22 14:31:20 +00:00
|
|
|
return hk_decr;
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
return NULL;
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function WriteHotkeyConfig
|
2010-08-28 18:02:24 +00:00
|
|
|
* Store the current hotkey list
|
|
|
|
* It is stored using the standard wxConfig mechanism or a file.
|
2007-08-30 08:15:05 +00:00
|
|
|
*
|
2010-08-28 18:02:24 +00:00
|
|
|
* @param aDescList = pointer to the current hotkey list.
|
2011-09-29 16:49:40 +00:00
|
|
|
* @param aFullFileName = a wxString pointer to a full file name.
|
2010-08-28 18:02:24 +00:00
|
|
|
* if NULL, use the standard wxConfig mechanism (default)
|
|
|
|
* the output format is: shortcut "key" "function"
|
|
|
|
* lines starting with # are comments
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
|
|
|
|
wxString* aFullFileName )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
wxString msg;
|
|
|
|
wxString keyname, infokey;
|
|
|
|
|
|
|
|
msg = wxT( "$hotkey list\n" );
|
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
/* Print the current hotkey list */
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY** List;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
if( aDescList->m_Comment )
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
msg += wxT( "# " );
|
|
|
|
msg += wxString( aDescList->m_Comment );
|
|
|
|
msg += wxT( "\n" );
|
2007-09-06 11:52:26 +00:00
|
|
|
}
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
msg += *aDescList->m_SectionTag;
|
|
|
|
msg += wxT( "\n" );
|
|
|
|
|
|
|
|
List = aDescList->m_HK_InfoList;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
for( ; *List != NULL; List++ )
|
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* hk_decr = *List;
|
2010-08-28 18:02:24 +00:00
|
|
|
msg += wxT( "shortcut " );
|
2007-09-06 11:52:26 +00:00
|
|
|
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
|
|
|
|
AddDelimiterString( keyname );
|
|
|
|
infokey = hk_decr->m_InfoMsg;
|
|
|
|
AddDelimiterString( infokey );
|
|
|
|
msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
msg += wxT( "$Endlist\n" );
|
|
|
|
|
|
|
|
if( aFullFileName )
|
|
|
|
{
|
|
|
|
FILE* file = wxFopen( *aFullFileName, wxT( "wt" ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( file )
|
2011-09-01 12:54:34 +00:00
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
fputs( TO_UTF8( msg ), file );
|
2011-09-01 12:54:34 +00:00
|
|
|
}
|
2010-08-28 18:02:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxConfig config( m_FrameName );
|
|
|
|
config.Write( HOTKEYS_CONFIG_KEY, msg );
|
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
return 1;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ReadHotkeyConfigFile
|
2010-12-14 15:56:30 +00:00
|
|
|
* Read an old configuration file (<file>.key) and fill the current hotkey list
|
2009-11-23 15:16:50 +00:00
|
|
|
* with hotkeys
|
2010-08-28 18:02:24 +00:00
|
|
|
* @param aFilename = file name to read.
|
|
|
|
* @param aDescList = current hotkey list descr. to initialise.
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename,
|
|
|
|
struct EDA_HOTKEY_CONFIG* aDescList )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
wxFile cfgfile( aFilename );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
/* get length */
|
|
|
|
cfgfile.SeekEnd();
|
|
|
|
wxFileOffset size = cfgfile.Tell();
|
|
|
|
cfgfile.Seek( 0 );
|
|
|
|
|
|
|
|
/* read data */
|
|
|
|
char* buffer = new char[size];
|
|
|
|
cfgfile.Read( buffer, size );
|
|
|
|
|
|
|
|
wxString data( buffer, wxConvUTF8 );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
/* parse */
|
|
|
|
ParseHotkeyConfig( data, aDescList );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
/* cleanup */
|
|
|
|
delete buffer;
|
|
|
|
cfgfile.Close();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
void ReadHotkeyConfig( const wxString& Appname, struct EDA_HOTKEY_CONFIG* aDescList )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
wxConfig config( Appname );
|
|
|
|
|
|
|
|
if( !config.HasEntry( HOTKEYS_CONFIG_KEY ) )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
// assume defaults are ok
|
|
|
|
return;
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString data;
|
|
|
|
config.Read( HOTKEYS_CONFIG_KEY, &data );
|
|
|
|
|
|
|
|
ParseHotkeyConfig( data, aDescList );
|
|
|
|
}
|
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
/* Function ReadHotkeyConfig
|
2010-08-28 18:02:24 +00:00
|
|
|
* Read configuration data and fill the current hotkey list with hotkeys
|
2011-09-29 16:49:40 +00:00
|
|
|
* aDescList is the current hotkey list descr. to initialize.
|
2010-08-28 18:02:24 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
int EDA_BASE_FRAME::ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
::ReadHotkeyConfig( m_FrameName, aDescList );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
/* Function ParseHotkeyConfig
|
2010-08-28 18:02:24 +00:00
|
|
|
* the input format is: shortcut "key" "function"
|
|
|
|
* lines starting by # are ignored (comments)
|
2010-12-20 17:44:25 +00:00
|
|
|
* lines like [xxx] are tags (example: [common] or [libedit] which identify sections
|
2010-08-28 18:02:24 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
void ParseHotkeyConfig( const wxString& data,
|
|
|
|
struct EDA_HOTKEY_CONFIG* aDescList )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
/* Read the config */
|
|
|
|
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY** CurrentHotkeyList = 0;
|
2010-08-28 18:02:24 +00:00
|
|
|
|
|
|
|
while( tokenizer.HasMoreTokens() )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString line = tokenizer.GetNextToken();
|
|
|
|
wxStringTokenizer lineTokenizer( line );
|
|
|
|
|
|
|
|
wxString line_type = lineTokenizer.GetNextToken();
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( line_type[0] == '#' ) //comment
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( line_type[0] == '[' ) // A tag is found. search infos in list
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
CurrentHotkeyList = 0;
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY_CONFIG* DList = aDescList;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
for( ; DList->m_HK_InfoList; DList++ )
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
if( *DList->m_SectionTag == line_type )
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
CurrentHotkeyList = DList->m_HK_InfoList;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( line_type == wxT( "$Endlist" ) )
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( line_type != wxT( "shortcut" ) )
|
|
|
|
continue;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
if( CurrentHotkeyList == NULL )
|
|
|
|
continue;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
/* Get the key name */
|
2010-08-28 18:02:24 +00:00
|
|
|
lineTokenizer.SetString( lineTokenizer.GetString(), L"\"\r\n\t ", wxTOKEN_STRTOK );
|
|
|
|
wxString keyname = lineTokenizer.GetNextToken();
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString remainder = lineTokenizer.GetString();
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* Get the command name */
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' );
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* search the hotkey in current hotkey list */
|
2011-09-29 16:49:40 +00:00
|
|
|
for( EDA_HOTKEY** List = CurrentHotkeyList; *List != NULL; List++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* hk_decr = *List;
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
if( hk_decr->m_InfoMsg == fctname )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
int code = ReturnKeyCodeFromKeyName( keyname );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
if( code )
|
|
|
|
hk_decr->m_KeyCode = code;
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ImportHotkeyConfigFromFile
|
2010-08-28 18:02:24 +00:00
|
|
|
* Prompt the user for an old hotkey file to read, and read it.
|
2011-09-29 16:49:40 +00:00
|
|
|
* @param aDescList = current hotkey list descr. to initialize.
|
2007-09-19 15:29:50 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDescList )
|
2007-09-19 15:29:50 +00:00
|
|
|
{
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
|
|
|
|
wxString mask = wxT( "*." ) + ext;
|
|
|
|
wxString path = wxGetCwd();
|
|
|
|
wxString filename;
|
|
|
|
|
|
|
|
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
|
|
|
|
path,
|
|
|
|
filename,
|
|
|
|
ext,
|
|
|
|
mask,
|
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
2011-11-07 18:04:19 +00:00
|
|
|
true );
|
2010-08-28 18:02:24 +00:00
|
|
|
|
|
|
|
if( filename.IsEmpty() )
|
|
|
|
return;
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
ReadHotkeyConfigFile( filename, aDescList );
|
|
|
|
}
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ExportHotkeyConfigToFile
|
2010-08-28 18:02:24 +00:00
|
|
|
* Prompt the user for an old hotkey file to read, and read it.
|
2011-09-29 16:49:40 +00:00
|
|
|
* @param aDescList = current hotkey list descr. to initialize.
|
2010-08-28 18:02:24 +00:00
|
|
|
*/
|
2011-09-29 16:49:40 +00:00
|
|
|
void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescList )
|
2010-08-28 18:02:24 +00:00
|
|
|
{
|
|
|
|
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
|
|
|
|
wxString mask = wxT( "*." ) + ext;
|
|
|
|
wxString path = wxGetCwd();
|
|
|
|
wxString filename;
|
|
|
|
|
2011-11-07 18:04:19 +00:00
|
|
|
filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),
|
2010-08-28 18:02:24 +00:00
|
|
|
path,
|
|
|
|
filename,
|
|
|
|
ext,
|
|
|
|
mask,
|
|
|
|
this,
|
2011-11-07 18:04:19 +00:00
|
|
|
wxFD_OPEN | wxFD_SAVE,
|
|
|
|
true );
|
2010-08-28 18:02:24 +00:00
|
|
|
|
|
|
|
if( filename.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
WriteHotkeyConfig( aDescList, &filename );
|
2007-09-19 15:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
/* add hotkey config options submenu to aMenu
|
2007-09-19 15:29:50 +00:00
|
|
|
*/
|
2010-01-18 12:37:53 +00:00
|
|
|
void AddHotkeyConfigMenu( wxMenu* aMenu )
|
2007-09-19 15:29:50 +00:00
|
|
|
{
|
2010-01-18 12:37:53 +00:00
|
|
|
if( aMenu == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-01-20 18:59:46 +00:00
|
|
|
wxMenu* HotkeySubmenu = new wxMenu();
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2010-01-18 12:37:53 +00:00
|
|
|
/* List existing hotkey menu*/
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( HotkeySubmenu,
|
|
|
|
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
|
2011-10-18 19:59:19 +00:00
|
|
|
_( "&List Current Keys" ),
|
2011-09-01 12:54:34 +00:00
|
|
|
_( "Displays the current hotkeys list and corresponding commands" ),
|
|
|
|
KiBitmap( info_xpm ) );
|
2007-11-14 16:02:19 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
/* Call hotkeys editor*/
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
|
2011-10-18 19:59:19 +00:00
|
|
|
_( "&Edit Hotkeys" ),
|
2011-09-01 12:54:34 +00:00
|
|
|
_( "Call the hotkeys editor" ),
|
|
|
|
KiBitmap( editor_xpm ) );
|
2010-08-28 18:02:24 +00:00
|
|
|
|
|
|
|
HotkeySubmenu->AppendSeparator();
|
|
|
|
|
|
|
|
/* create hotkey file to export current hotkeys config */
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
|
2011-10-18 19:59:19 +00:00
|
|
|
_( "E&xport Hotkeys" ),
|
|
|
|
_( "Create a hotkey configuration file to export the current hotkeys" ),
|
2011-09-01 12:54:34 +00:00
|
|
|
KiBitmap( save_setup_xpm ) );
|
2007-11-14 16:02:19 +00:00
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
/* Reload hotkey file */
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
|
2011-10-18 19:59:19 +00:00
|
|
|
_( "&Import Hotkeys" ),
|
2011-09-01 12:54:34 +00:00
|
|
|
_( "Load an existing hotkey configuration file" ),
|
|
|
|
KiBitmap( reload_xpm ) );
|
2009-10-27 13:48:24 +00:00
|
|
|
|
|
|
|
/* Append HotkeySubmenu to menu */
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( aMenu, HotkeySubmenu,
|
2011-10-18 19:59:19 +00:00
|
|
|
ID_PREFERENCES_HOTKEY_SUBMENU, _( "&Hotkeys" ),
|
2011-09-01 12:54:34 +00:00
|
|
|
_( "Hotkeys configuration and preferences" ),
|
|
|
|
KiBitmap( hotkeys_xpm ) );
|
2007-09-22 14:31:20 +00:00
|
|
|
}
|