2007-08-30 08:15:05 +00:00
|
|
|
/*********************/
|
|
|
|
/* hotkeys_basic.cpp */
|
|
|
|
/*********************/
|
2007-08-20 11:33:45 +00:00
|
|
|
|
|
|
|
/* Some functions to handle hotkeys in kicad
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2007-09-06 11:52:26 +00:00
|
|
|
|
2007-08-20 11:33:45 +00:00
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-08-20 11:33:45 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "hotkeys_basic.h"
|
2007-08-21 19:37:31 +00:00
|
|
|
#include "macros.h"
|
2007-09-19 15:29:50 +00:00
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
#include "gestfich.h"
|
|
|
|
#include "wxstruct.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>
|
|
|
|
|
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
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* 0 = files are in Home directory (usefull under unix)
|
|
|
|
* 1 = kicad/template ( usefull only under windows )
|
|
|
|
* 2 ... = unused
|
|
|
|
*/
|
|
|
|
int g_ConfigFileLocationChoice;
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
Ki_HotkeyInfo::Ki_HotkeyInfo( 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
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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-01-20 18:59:46 +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 },
|
|
|
|
{ wxT( "Tab" ), '\t' },
|
|
|
|
{ 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 },
|
|
|
|
|
|
|
|
{ wxT( "space" ), ' ' },
|
|
|
|
{ wxT( "?" ), '?' },
|
|
|
|
{ wxT( "!" ), '!' },
|
2010-02-25 17:08:28 +00:00
|
|
|
{ wxT( ";" ), ';' },
|
2010-01-20 18:59:46 +00:00
|
|
|
{ wxT( ":" ), ':' },
|
2010-02-25 17:08:28 +00:00
|
|
|
{ wxT( "." ), '.' },
|
2010-01-20 18:59:46 +00:00
|
|
|
{ wxT( "," ), ',' },
|
|
|
|
{ wxT( "*" ), '*' },
|
|
|
|
{ wxT( "+" ), '+' },
|
2010-02-25 17:08:28 +00:00
|
|
|
{ wxT( "=" ), '=' },
|
2010-01-20 18:59:46 +00:00
|
|
|
{ wxT( "-" ), '-' },
|
|
|
|
{ wxT( "%%" ), '%' },
|
2010-02-25 17:08:28 +00:00
|
|
|
{ wxT( "[" ), '[' },
|
|
|
|
{ wxT( "]" ), ']' },
|
|
|
|
{ wxT( "'" ), '\'' },
|
|
|
|
{ wxT( "`" ), '`' },
|
|
|
|
{ wxT( "/" ), '/' },
|
|
|
|
{ wxT( "\\" ), '\\' },
|
|
|
|
{ wxT( "0" ), '0' },
|
|
|
|
{ wxT( "1" ), '1' },
|
|
|
|
{ wxT( "2" ), '2' },
|
|
|
|
{ wxT( "3" ), '3' },
|
|
|
|
{ wxT( "4" ), '4' },
|
|
|
|
{ wxT( "5" ), '5' },
|
|
|
|
{ wxT( "6" ), '6' },
|
|
|
|
{ wxT( "7" ), '7' },
|
|
|
|
{ wxT( "8" ), '8' },
|
|
|
|
{ wxT( "9" ), '9' },
|
2010-01-20 18:59:46 +00:00
|
|
|
{ wxT( "A" ), 'A' },
|
|
|
|
{ wxT( "B" ), 'B' },
|
|
|
|
{ wxT( "C" ), 'C' },
|
|
|
|
{ wxT( "D" ), 'D' },
|
|
|
|
{ wxT( "E" ), 'E' },
|
|
|
|
{ wxT( "F" ), 'F' },
|
|
|
|
{ wxT( "G" ), 'G' },
|
|
|
|
{ wxT( "H" ), 'H' },
|
|
|
|
{ wxT( "I" ), 'I' },
|
|
|
|
{ wxT( "J" ), 'J' },
|
|
|
|
{ wxT( "K" ), 'K' },
|
|
|
|
{ wxT( "L" ), 'L' },
|
|
|
|
{ wxT( "M" ), 'M' },
|
|
|
|
{ wxT( "N" ), 'N' },
|
|
|
|
{ wxT( "O" ), 'O' },
|
|
|
|
{ wxT( "P" ), 'P' },
|
|
|
|
{ wxT( "Q" ), 'Q' },
|
|
|
|
{ wxT( "R" ), 'R' },
|
|
|
|
{ wxT( "S" ), 'S' },
|
|
|
|
{ wxT( "T" ), 'T' },
|
|
|
|
{ wxT( "U" ), 'U' },
|
|
|
|
{ wxT( "V" ), 'V' },
|
|
|
|
{ wxT( "W" ), 'W' },
|
|
|
|
{ wxT( "X" ), 'X' },
|
|
|
|
{ wxT( "Y" ), 'Y' },
|
|
|
|
{ wxT( "Z" ), 'Z' },
|
|
|
|
|
|
|
|
{ wxT( "Ctrl++" ), GR_KB_CTRL + '+' },
|
|
|
|
{ wxT( "Ctrl+-" ), GR_KB_CTRL + '-' },
|
|
|
|
|
|
|
|
{ wxT( "Ctrl+A" ), GR_KB_CTRL + 'A' },
|
|
|
|
{ wxT( "Ctrl+B" ), GR_KB_CTRL + 'B' },
|
|
|
|
{ wxT( "Ctrl+C" ), GR_KB_CTRL + 'C' },
|
|
|
|
{ wxT( "Ctrl+D" ), GR_KB_CTRL + 'D' },
|
|
|
|
{ wxT( "Ctrl+E" ), GR_KB_CTRL + 'E' },
|
|
|
|
{ wxT( "Ctrl+F" ), GR_KB_CTRL + 'F' },
|
|
|
|
{ wxT( "Ctrl+G" ), GR_KB_CTRL + 'G' },
|
|
|
|
{ wxT( "Ctrl+H" ), GR_KB_CTRL + 'H' },
|
|
|
|
{ wxT( "Ctrl+I" ), GR_KB_CTRL + 'I' },
|
|
|
|
{ wxT( "Ctrl+J" ), GR_KB_CTRL + 'J' },
|
|
|
|
{ wxT( "Ctrl+K" ), GR_KB_CTRL + 'K' },
|
|
|
|
{ wxT( "Ctrl+L" ), GR_KB_CTRL + 'L' },
|
|
|
|
{ wxT( "Ctrl+M" ), GR_KB_CTRL + 'M' },
|
|
|
|
{ wxT( "Ctrl+N" ), GR_KB_CTRL + 'N' },
|
|
|
|
{ wxT( "Ctrl+O" ), GR_KB_CTRL + 'O' },
|
|
|
|
{ wxT( "Ctrl+P" ), GR_KB_CTRL + 'P' },
|
|
|
|
{ wxT( "Ctrl+Q" ), GR_KB_CTRL + 'Q' },
|
|
|
|
{ wxT( "Ctrl+R" ), GR_KB_CTRL + 'R' },
|
|
|
|
{ wxT( "Ctrl+S" ), GR_KB_CTRL + 'S' },
|
|
|
|
{ wxT( "Ctrl+T" ), GR_KB_CTRL + 'T' },
|
|
|
|
{ wxT( "Ctrl+U" ), GR_KB_CTRL + 'U' },
|
|
|
|
{ wxT( "Ctrl+V" ), GR_KB_CTRL + 'V' },
|
|
|
|
{ wxT( "Ctrl+W" ), GR_KB_CTRL + 'W' },
|
|
|
|
{ wxT( "Ctrl+X" ), GR_KB_CTRL + 'X' },
|
|
|
|
{ wxT( "Ctrl+Y" ), GR_KB_CTRL + 'Y' },
|
|
|
|
{ wxT( "Ctrl+Z" ), GR_KB_CTRL + 'Z' },
|
|
|
|
|
|
|
|
{ wxT( "Shift+Ctrl++" ), GR_KB_SHIFT + GR_KB_CTRL + '+' },
|
|
|
|
{ wxT( "Shift+Ctrl+-" ), GR_KB_SHIFT + GR_KB_CTRL + '-' },
|
|
|
|
|
|
|
|
{ wxT( "Shift+Ctrl+A" ), GR_KB_SHIFT + GR_KB_CTRL + 'A' },
|
|
|
|
{ wxT( "Shift+Ctrl+B" ), GR_KB_SHIFT + GR_KB_CTRL + 'B' },
|
|
|
|
{ wxT( "Shift+Ctrl+C" ), GR_KB_SHIFT + GR_KB_CTRL + 'C' },
|
|
|
|
{ wxT( "Shift+Ctrl+D" ), GR_KB_SHIFT + GR_KB_CTRL + 'D' },
|
|
|
|
{ wxT( "Shift+Ctrl+E" ), GR_KB_SHIFT + GR_KB_CTRL + 'E' },
|
|
|
|
{ wxT( "Shift+Ctrl+F" ), GR_KB_SHIFT + GR_KB_CTRL + 'F' },
|
|
|
|
{ wxT( "Shift+Ctrl+G" ), GR_KB_SHIFT + GR_KB_CTRL + 'G' },
|
|
|
|
{ wxT( "Shift+Ctrl+H" ), GR_KB_SHIFT + GR_KB_CTRL + 'H' },
|
|
|
|
{ wxT( "Shift+Ctrl+I" ), GR_KB_SHIFT + GR_KB_CTRL + 'I' },
|
|
|
|
{ wxT( "Shift+Ctrl+J" ), GR_KB_SHIFT + GR_KB_CTRL + 'J' },
|
|
|
|
{ wxT( "Shift+Ctrl+K" ), GR_KB_SHIFT + GR_KB_CTRL + 'K' },
|
|
|
|
{ wxT( "Shift+Ctrl+L" ), GR_KB_SHIFT + GR_KB_CTRL + 'L' },
|
|
|
|
{ wxT( "Shift+Ctrl+M" ), GR_KB_SHIFT + GR_KB_CTRL + 'M' },
|
|
|
|
{ wxT( "Shift+Ctrl+N" ), GR_KB_SHIFT + GR_KB_CTRL + 'N' },
|
|
|
|
{ wxT( "Shift+Ctrl+O" ), GR_KB_SHIFT + GR_KB_CTRL + 'O' },
|
|
|
|
{ wxT( "Shift+Ctrl+P" ), GR_KB_SHIFT + GR_KB_CTRL + 'P' },
|
|
|
|
{ wxT( "Shift+Ctrl+Q" ), GR_KB_SHIFT + GR_KB_CTRL + 'Q' },
|
|
|
|
{ wxT( "Shift+Ctrl+R" ), GR_KB_SHIFT + GR_KB_CTRL + 'R' },
|
|
|
|
{ wxT( "Shift+Ctrl+S" ), GR_KB_SHIFT + GR_KB_CTRL + 'S' },
|
|
|
|
{ wxT( "Shift+Ctrl+T" ), GR_KB_SHIFT + GR_KB_CTRL + 'T' },
|
|
|
|
{ wxT( "Shift+Ctrl+U" ), GR_KB_SHIFT + GR_KB_CTRL + 'U' },
|
|
|
|
{ wxT( "Shift+Ctrl+V" ), GR_KB_SHIFT + GR_KB_CTRL + 'V' },
|
|
|
|
{ wxT( "Shift+Ctrl+W" ), GR_KB_SHIFT + GR_KB_CTRL + 'W' },
|
|
|
|
{ wxT( "Shift+Ctrl+X" ), GR_KB_SHIFT + GR_KB_CTRL + 'X' },
|
|
|
|
{ wxT( "Shift+Ctrl+Y" ), GR_KB_SHIFT + GR_KB_CTRL + 'Y' },
|
|
|
|
{ wxT( "Shift+Ctrl+Z" ), GR_KB_SHIFT + GR_KB_CTRL + 'Z' },
|
|
|
|
|
|
|
|
// Do not change this line: end of list
|
|
|
|
{ wxT( "" ), 0 }
|
2007-08-21 19:37:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-01-19 20:43:44 +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)
|
2007-08-30 08:15:05 +00:00
|
|
|
* @return the key name in a wxString
|
|
|
|
*/
|
2010-02-16 10:42:57 +00:00
|
|
|
wxString ReturnKeyNameFromKeyCode( int aKeycode )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
wxString keyname, modifier, fullkeyname;
|
|
|
|
int ii;
|
|
|
|
|
2010-02-16 10:42:57 +00:00
|
|
|
if( (aKeycode & GR_KB_CTRL) != 0 )
|
2010-01-20 18:59:46 +00:00
|
|
|
modifier << wxT( "Ctrl+" );
|
2010-02-16 10:42:57 +00:00
|
|
|
if( (aKeycode & GR_KB_ALT) != 0 )
|
2010-01-20 18:59:46 +00:00
|
|
|
modifier << wxT( "Alt+" );
|
2010-02-16 10:42:57 +00:00
|
|
|
if( (aKeycode & GR_KB_SHIFT) != 0 )
|
2010-01-20 18:59:46 +00:00
|
|
|
modifier << wxT( "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 );
|
2007-08-30 08:15:05 +00:00
|
|
|
for( ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )
|
|
|
|
{
|
|
|
|
keyname = wxT( "<unknown>" );
|
|
|
|
break;
|
|
|
|
}
|
2010-02-16 10:42:57 +00:00
|
|
|
if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
keyname = s_Hotkey_Name_List[ii].m_Name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
/** function AddHotkeyName
|
2007-08-30 08:15:05 +00:00
|
|
|
* Add the key name from the Command id value ( m_Idcommand member value)
|
2010-02-16 10:42:57 +00:00
|
|
|
* @param aText = a wxString. returns aText + key name
|
|
|
|
* @param aList = pointer to a Ki_HotkeyInfo list of commands
|
|
|
|
* @param aCommandId = Command Id value
|
|
|
|
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
|
|
|
|
* = false to add <spaces><(keyname)>
|
|
|
|
* @return a wxString (aTest + key name) if key found or aText without modification
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2010-02-14 18:14:33 +00:00
|
|
|
wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
|
2010-02-16 10:42:57 +00:00
|
|
|
int aCommandId , bool aIsShortCut )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2010-02-14 18:14:33 +00:00
|
|
|
wxString msg = aText;
|
|
|
|
wxString keyname;
|
|
|
|
if( aList )
|
|
|
|
keyname = ReturnKeyNameFromCommandId( aList, aCommandId );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
if( !keyname.IsEmpty() )
|
2010-02-16 10:42:57 +00:00
|
|
|
{
|
|
|
|
if ( aIsShortCut )
|
|
|
|
msg << wxT( "\t" ) << keyname;
|
|
|
|
else
|
|
|
|
msg << wxT( " <" ) << keyname << wxT(">");
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
/** function AddHotkeyName
|
2007-09-06 11:52:26 +00:00
|
|
|
* Add the key name from the Command id value ( m_Idcommand member value)
|
2010-02-16 10:42:57 +00:00
|
|
|
* @param aText = a wxString. returns aText + key name
|
|
|
|
* @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands
|
|
|
|
* @param aCommandId = Command Id value
|
|
|
|
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
|
|
|
|
* = false to add <spaces><(keyname)>
|
|
|
|
* @return a wxString (aTest + key name) if key found or aText without modification
|
2007-09-06 11:52:26 +00:00
|
|
|
*/
|
2010-02-14 18:14:33 +00:00
|
|
|
wxString AddHotkeyName( const wxString& aText,
|
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* aDescList,
|
2010-02-16 10:42:57 +00:00
|
|
|
int aCommandId,
|
|
|
|
bool aIsShortCut )
|
2007-09-06 11:52:26 +00:00
|
|
|
{
|
2010-02-14 18:14:33 +00:00
|
|
|
wxString msg = aText;
|
2007-09-06 11:52:26 +00:00
|
|
|
wxString keyname;
|
|
|
|
Ki_HotkeyInfo** List;
|
|
|
|
|
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 );
|
|
|
|
if( !keyname.IsEmpty() )
|
|
|
|
{
|
2010-02-16 10:42:57 +00:00
|
|
|
if ( aIsShortCut )
|
|
|
|
msg << wxT( "\t" ) << keyname;
|
|
|
|
else
|
|
|
|
msg << wxT( " <" ) << keyname << wxT(">");
|
2010-02-14 18:14:33 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-19 20:43:44 +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)
|
2010-02-16 10:42:57 +00:00
|
|
|
* @param aList = pointer to a Ki_HotkeyInfo list of commands
|
|
|
|
* @param aCommandId = Command Id value
|
2007-08-30 08:15:05 +00:00
|
|
|
* @return the key name in a wxString
|
|
|
|
*/
|
2010-02-16 10:42:57 +00:00
|
|
|
wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** 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
|
|
|
{
|
2010-02-16 10:42:57 +00:00
|
|
|
Ki_HotkeyInfo* hk_decr = *aList;
|
|
|
|
if( hk_decr->m_Idcommand == aCommandId )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return keyname;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-19 20:43:44 +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
|
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
static 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;
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
if( keyname.CmpNoCase( s_Hotkey_Name_List[ii].m_Name ) == 0 )
|
|
|
|
{
|
|
|
|
keycode = s_Hotkey_Name_List[ii].m_KeyCode;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return keycode;
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
/** function DisplayHotkeyList
|
2007-08-30 08:15:05 +00:00
|
|
|
* Displays the current hotkey list
|
2010-02-16 11:02:20 +00:00
|
|
|
* @param aFrame = current active frame
|
|
|
|
* @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor list
|
2010-01-20 18:59:46 +00:00
|
|
|
*(Null terminated)
|
2007-08-30 08:15:05 +00:00
|
|
|
* @return none
|
|
|
|
*/
|
2010-02-16 11:02:20 +00:00
|
|
|
void DisplayHotkeyList( WinEDA_DrawFrame* aFrame,
|
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
|
2007-08-20 11:33:45 +00:00
|
|
|
{
|
2007-09-06 11:52:26 +00:00
|
|
|
wxString keyname;
|
|
|
|
Ki_HotkeyInfo** List;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
wxString msg = _( "Current hotkey list:\n\n" );
|
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;
|
2007-09-06 11:52:26 +00:00
|
|
|
for( ; *List != NULL; List++ )
|
|
|
|
{
|
|
|
|
Ki_HotkeyInfo* hk_decr = *List;
|
|
|
|
msg += _( "key " );
|
|
|
|
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
|
2010-01-20 18:59:46 +00:00
|
|
|
msg += keyname + wxT( ": " ) + hk_decr->m_InfoMsg + wxT( "\n" );
|
2007-09-06 11:52:26 +00:00
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
|
2010-02-16 11:02:20 +00:00
|
|
|
DisplayInfoMessage( aFrame, msg );
|
2007-08-20 11:33:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2010-01-19 20:43:44 +00:00
|
|
|
/** function GetDescriptorFromHotkey
|
2007-09-22 14:31:20 +00:00
|
|
|
* Return a Ki_HotkeyInfo * pointer fron 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
|
|
|
|
* @param aList = pointer to a Ki_HotkeyInfo list of commands
|
2009-11-23 15:16:50 +00:00
|
|
|
* @return the corresponding Ki_HotkeyInfo pointer from the Ki_HotkeyInfo List
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2010-02-16 11:02:20 +00:00
|
|
|
Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** 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
|
|
|
{
|
2010-02-16 11:02:20 +00:00
|
|
|
Ki_HotkeyInfo* hk_decr = *aList;
|
|
|
|
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
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
/*
|
|
|
|
* Create a configuration file (*.key) from the current hotkey list
|
2009-11-23 15:16:50 +00:00
|
|
|
* @param Filename = default full file name to create. If void, A filename
|
2010-01-20 18:59:46 +00:00
|
|
|
* will be asked
|
2007-08-21 19:37:31 +00:00
|
|
|
* @param List = pointer to the current hotkey list.
|
|
|
|
* the ouput format is: shortcut "key" "function"
|
2007-09-19 15:29:50 +00:00
|
|
|
* lines starting with # are comments
|
2007-08-30 08:15:05 +00:00
|
|
|
*
|
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
int WinEDA_BasicFrame::WriteHotkeyConfigFile(
|
|
|
|
const wxString& Filename,
|
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* DescList,
|
|
|
|
bool verbose )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
wxString FullFilename = Filename;
|
|
|
|
FILE* cfgfile;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( FullFilename.IsEmpty() || verbose )
|
|
|
|
{
|
|
|
|
wxString Mask, Path, Ext;
|
|
|
|
Ext = DEFAULT_HOTKEY_FILENAME_EXT;
|
2009-06-19 20:13:22 +00:00
|
|
|
Mask = wxT( "*." ) + Ext;
|
2007-09-19 15:29:50 +00:00
|
|
|
Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
2009-02-21 15:12:26 +00:00
|
|
|
FullFilename = EDA_FileSelector( _( "Save Hotkey Configuration File:" ),
|
2009-11-23 15:16:50 +00:00
|
|
|
Path,
|
|
|
|
FullFilename,
|
|
|
|
Ext,
|
|
|
|
Mask,
|
2007-08-30 08:15:05 +00:00
|
|
|
this,
|
|
|
|
wxFD_SAVE,
|
2009-11-23 15:16:50 +00:00
|
|
|
TRUE );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
2009-11-23 15:16:50 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
if( FullFilename.IsEmpty() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cfgfile = wxFopen( FullFilename, wxT( "wt" ) );
|
|
|
|
|
|
|
|
if( cfgfile == NULL )
|
|
|
|
{
|
|
|
|
if( verbose )
|
|
|
|
{
|
|
|
|
msg = _( "Unable to create " ) + FullFilename;
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString keyname, infokey;
|
|
|
|
|
|
|
|
msg = wxT( "$hotkey list\n" );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
/* print the allowed keys, for info
|
|
|
|
*/
|
|
|
|
msg = wxT( "# " ); msg += _( "Allowed keys:\n" );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
|
2007-08-30 08:15:05 +00:00
|
|
|
msg.Empty();
|
|
|
|
for( int ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )
|
|
|
|
break;;
|
|
|
|
if( msg.IsEmpty() )
|
|
|
|
msg = wxT( "# " );
|
|
|
|
else
|
|
|
|
msg += wxT( ", " );
|
|
|
|
msg += s_Hotkey_Name_List[ii].m_Name;
|
|
|
|
if( msg.Len() > 60 )
|
|
|
|
{
|
|
|
|
msg += wxT( "\n" );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
|
2007-08-30 08:15:05 +00:00
|
|
|
msg.Empty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
/* print the last line of the info section */
|
2007-08-30 08:15:05 +00:00
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
msg += wxT( "\n" );
|
|
|
|
msg += wxT( "#\n#\n" );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
/* Print the current hotkey list */
|
|
|
|
Ki_HotkeyInfo** List;
|
|
|
|
for( ; DescList->m_HK_InfoList != NULL; DescList++ )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2007-09-06 11:52:26 +00:00
|
|
|
if( DescList->m_Comment )
|
|
|
|
{
|
|
|
|
fprintf( cfgfile, "# " );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s\n", DescList->m_Comment );
|
2007-09-06 11:52:26 +00:00
|
|
|
}
|
2007-09-19 15:29:50 +00:00
|
|
|
msg = *DescList->m_SectionTag;
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s\n", CONV_TO_UTF8( msg ) );
|
2007-09-06 11:52:26 +00:00
|
|
|
List = DescList->m_HK_InfoList;
|
|
|
|
for( ; *List != NULL; List++ )
|
|
|
|
{
|
|
|
|
Ki_HotkeyInfo* hk_decr = *List;
|
|
|
|
msg = wxT( "shortcut " );
|
|
|
|
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
|
|
|
|
AddDelimiterString( keyname );
|
|
|
|
infokey = hk_decr->m_InfoMsg;
|
|
|
|
AddDelimiterString( infokey );
|
|
|
|
msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
|
2007-09-06 11:52:26 +00:00
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msg = wxT( "$Endlist\n" );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( cfgfile, "%s\n", CONV_TO_UTF8( msg ) );
|
2007-08-30 08:15:05 +00:00
|
|
|
fclose( cfgfile );
|
|
|
|
return 1;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-23 15:16:50 +00:00
|
|
|
* Read a configuration file (<file>.key) and fill the current hotkey list
|
|
|
|
* with hotkeys
|
|
|
|
* @param Filename = default full file name to create. If void, A filename
|
2010-01-20 18:59:46 +00:00
|
|
|
* will be asked
|
2007-09-06 11:52:26 +00:00
|
|
|
* @param DescList = current hotkey list descr. to initialise.
|
2007-08-21 19:37:31 +00:00
|
|
|
* the input format is: shortcut "key" "function"
|
|
|
|
* lines starting by # are ignored (comments)
|
2009-11-23 15:16:50 +00:00
|
|
|
* lines like [xxx] are tags (example: [common] or [libedit] which identify
|
|
|
|
* sections
|
2007-08-30 08:15:05 +00:00
|
|
|
*
|
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
int WinEDA_BasicFrame::ReadHotkeyConfigFile(
|
|
|
|
const wxString& Filename,
|
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* DescList,
|
|
|
|
bool verbose )
|
2007-08-21 19:37:31 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
wxString FullFilename = Filename;
|
|
|
|
FILE* cfgfile;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( FullFilename.IsEmpty() || verbose )
|
|
|
|
{
|
|
|
|
wxString Mask, Path, Ext;
|
|
|
|
Ext = DEFAULT_HOTKEY_FILENAME_EXT;
|
2009-06-19 20:13:22 +00:00
|
|
|
Mask = wxT( "*." ) + Ext;
|
2007-09-19 15:29:50 +00:00
|
|
|
Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
2009-02-21 15:12:26 +00:00
|
|
|
FullFilename = EDA_FileSelector( _( "Open Hotkey Configuration File:" ),
|
2009-11-23 15:16:50 +00:00
|
|
|
Path,
|
|
|
|
FullFilename,
|
|
|
|
Ext,
|
|
|
|
Mask,
|
2007-08-30 08:15:05 +00:00
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
2009-11-23 15:16:50 +00:00
|
|
|
TRUE );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( FullFilename.IsEmpty() )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cfgfile = wxFopen( FullFilename, wxT( "rt" ) );
|
|
|
|
|
|
|
|
if( cfgfile == NULL )
|
|
|
|
{
|
|
|
|
if( verbose )
|
|
|
|
{
|
|
|
|
msg = _( "Unable to read " ) + FullFilename;
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
wxString keyname;
|
|
|
|
char Line[1024];
|
|
|
|
int LineNum = 0;
|
|
|
|
Ki_HotkeyInfo** CurrentHotkeyList = NULL;
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* Read the file */
|
2007-08-21 19:37:31 +00:00
|
|
|
while( GetLine( cfgfile, Line, &LineNum ) != NULL )
|
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
char* line_type, * keyname, * fctname;
|
|
|
|
line_type = strtok( Line, " \t\n\r" );
|
|
|
|
msg = CONV_FROM_UTF8( line_type );
|
2007-09-06 11:52:26 +00:00
|
|
|
if( msg[0] == '[' ) // A tag is found. search infos in list
|
|
|
|
{
|
|
|
|
CurrentHotkeyList = NULL;
|
|
|
|
Ki_HotkeyInfoSectionDescriptor* DList = DescList;
|
|
|
|
for( ; DList->m_HK_InfoList != NULL; DList++ )
|
|
|
|
{
|
|
|
|
if( *DList->m_SectionTag == msg )
|
|
|
|
{
|
|
|
|
CurrentHotkeyList = DList->m_HK_InfoList;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
if( msg != wxT( "shortcut" ) )
|
|
|
|
continue;
|
|
|
|
if( msg == wxT( "$Endlist" ) )
|
|
|
|
break;
|
2007-09-06 11:52:26 +00:00
|
|
|
if( CurrentHotkeyList == NULL )
|
|
|
|
continue;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
/* Get the key name */
|
|
|
|
strtok( NULL, "\"\n\r" );
|
|
|
|
keyname = strtok( NULL, "\"\n\r" );
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
strtok( NULL, "\"\n\r" );
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* Get the command name */
|
|
|
|
fctname = strtok( NULL, "\"\n\r" );
|
2010-01-20 18:59:46 +00:00
|
|
|
msg = CONV_FROM_UTF8( fctname );
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* search the hotkey in current hotkey list */
|
|
|
|
for( Ki_HotkeyInfo** List = CurrentHotkeyList; *List != NULL; List++ )
|
|
|
|
{
|
|
|
|
Ki_HotkeyInfo* hk_decr = *List;
|
|
|
|
if( hk_decr->m_InfoMsg == msg )
|
|
|
|
{
|
|
|
|
msg = CONV_FROM_UTF8( keyname );
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
int code = ReturnKeyCodeFromKeyName( msg );
|
|
|
|
if( code )
|
|
|
|
hk_decr->m_KeyCode = code;
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose( cfgfile );
|
|
|
|
return 1;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* return the hotkey config file path
|
2008-09-03 16:19:06 +00:00
|
|
|
* @param choice : 0 = home, 1 = kicad/share/template
|
2007-09-19 15:29:50 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
wxString ReturnHotkeyConfigFilePath( int choice )
|
2007-09-19 15:29:50 +00:00
|
|
|
{
|
2010-01-20 18:59:46 +00:00
|
|
|
wxString path;
|
2009-04-06 18:54:57 +00:00
|
|
|
wxAppTraits* traits = wxGetApp().GetTraits();
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
switch( choice )
|
|
|
|
{
|
|
|
|
case 0:
|
2009-04-06 18:54:57 +00:00
|
|
|
path = traits->GetStandardPaths().GetUserConfigDir() +
|
2010-01-20 18:59:46 +00:00
|
|
|
wxFileName::GetPathSeparator();
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
case 1:
|
2010-01-20 18:59:46 +00:00
|
|
|
|
2009-04-06 18:54:57 +00:00
|
|
|
/* TODO: This is broken under a normal Poxis system. Users
|
|
|
|
* generally do no have write permissions to this path
|
|
|
|
* and there is no provision for prompting for the root
|
|
|
|
* password. Suggest we remove this unless someone has
|
|
|
|
* a workable solution (Wayne).
|
|
|
|
*/
|
2008-09-03 16:19:06 +00:00
|
|
|
path = ReturnKicadDatasPath() + wxT( "template/" );
|
2007-09-19 15:29:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
/** add hotkey config options submenu to a menu
|
2007-11-14 16:02:19 +00:00
|
|
|
* @param menu : initial menu
|
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;
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
wxMenuItem* item;
|
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*/
|
2009-11-23 15:16:50 +00:00
|
|
|
item = new wxMenuItem( HotkeySubmenu,
|
2010-01-20 18:59:46 +00:00
|
|
|
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
|
|
|
|
_( "List Current Keys" ),
|
|
|
|
_( "Displays the current hotkeys list and corresponding commands" ) );
|
2007-11-14 16:02:19 +00:00
|
|
|
item->SetBitmap( info_xpm );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeySubmenu->Append( item );
|
2007-11-14 16:02:19 +00:00
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
/* (Re)create hotkey file */
|
|
|
|
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_CREATE_CONFIG,
|
2010-01-18 12:37:53 +00:00
|
|
|
_( "(Re)create Hotkeys File" ),
|
2010-01-20 18:59:46 +00:00
|
|
|
_(
|
|
|
|
"Create or recreate the hotkey configuration file from current hotkey list" )
|
2007-09-22 14:31:20 +00:00
|
|
|
);
|
2007-09-19 15:29:50 +00:00
|
|
|
item->SetBitmap( save_setup_xpm );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeySubmenu->Append( item );
|
2007-11-14 16:02:19 +00:00
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
/* Reload hotkey file */
|
|
|
|
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_READ_CONFIG,
|
2010-01-20 18:59:46 +00:00
|
|
|
_( "Reload Hotkeys File" ),
|
|
|
|
_( "Reload the hotkey configuration file" ) );
|
2007-09-19 15:29:50 +00:00
|
|
|
item->SetBitmap( reload_xpm );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeySubmenu->Append( item );
|
|
|
|
|
|
|
|
/* Edit hotkey file */
|
|
|
|
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_EDIT_CONFIG,
|
2010-01-18 12:37:53 +00:00
|
|
|
_( "Edit Hotkeys File" ),
|
2009-10-27 13:48:24 +00:00
|
|
|
_( "Edit the hotkey configuration file in a text editor" ) );
|
2007-09-19 15:29:50 +00:00
|
|
|
item->SetBitmap( editor_xpm );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeySubmenu->Append( item );
|
|
|
|
|
|
|
|
/* Append HotkeySubmenu to menu */
|
2010-01-18 12:37:53 +00:00
|
|
|
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( aMenu, HotkeySubmenu,
|
|
|
|
ID_PREFERENCES_HOTKEY_SUBMENU, _( "Hotkeys" ),
|
2010-01-20 18:59:46 +00:00
|
|
|
_( "Hotkeys configuration and preferences" ), hotkeys_xpm );
|
2009-10-27 13:48:24 +00:00
|
|
|
|
|
|
|
/* Hotkey path */
|
|
|
|
wxMenu* HotkeyLocationSubmenu = new wxMenu();
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
/* Home directory */
|
2009-11-23 15:16:50 +00:00
|
|
|
item = new wxMenuItem( HotkeyLocationSubmenu,
|
|
|
|
ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
|
2009-10-27 13:48:24 +00:00
|
|
|
_( "Home directory" ),
|
2007-10-28 20:33:19 +00:00
|
|
|
_( "Use home directory to load or store Hotkey config files" ),
|
2007-09-22 14:31:20 +00:00
|
|
|
wxITEM_CHECK );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeyLocationSubmenu->Append( item );
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* KiCad template directory */
|
|
|
|
item = new wxMenuItem( HotkeyLocationSubmenu,
|
|
|
|
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
|
2009-10-27 13:48:24 +00:00
|
|
|
_( "KiCad template directory" ),
|
2007-10-28 20:33:19 +00:00
|
|
|
_( "Use kicad/template directory to load or store Hotkey config files" ),
|
2007-09-22 14:31:20 +00:00
|
|
|
wxITEM_CHECK );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeyLocationSubmenu->Append( item );
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
/* Append location submenu to HotkeySubmenu */
|
2009-11-23 15:16:50 +00:00
|
|
|
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( HotkeySubmenu, HotkeyLocationSubmenu,
|
|
|
|
-1, _( "Location" ),
|
|
|
|
_( "Select hotkey configuration file location" ),
|
|
|
|
right_xpm );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeyLocationSubmenu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
|
2009-11-23 15:16:50 +00:00
|
|
|
g_ConfigFileLocationChoice == 0 );
|
2009-10-27 13:48:24 +00:00
|
|
|
HotkeyLocationSubmenu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
|
2009-11-23 15:16:50 +00:00
|
|
|
g_ConfigFileLocationChoice == 1 );
|
2007-09-19 15:29:50 +00:00
|
|
|
}
|
2007-09-20 05:41:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* called on hotkey file location selecton menu
|
2007-09-22 14:31:20 +00:00
|
|
|
* @param frame = current WinEDA_DrawFrame
|
|
|
|
* @param id = selected menu id
|
|
|
|
* @return g_ConfigFileLocationChoice (global) = new selection
|
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id )
|
2007-09-20 05:41:40 +00:00
|
|
|
{
|
2007-09-22 14:31:20 +00:00
|
|
|
wxMenuBar* menu = frame->GetMenuBar();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-01-20 18:59:46 +00:00
|
|
|
wxConfig* config = wxGetApp().m_EDA_CommonConfig;
|
2007-09-22 14:31:20 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
|
|
|
if( g_ConfigFileLocationChoice != 0 )
|
|
|
|
{
|
|
|
|
g_ConfigFileLocationChoice = 0;
|
|
|
|
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, true );
|
|
|
|
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, false );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( HOTKEY_CFG_PATH_OPT, g_ConfigFileLocationChoice );
|
2007-09-22 14:31:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-09-20 05:41:40 +00:00
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
|
|
|
|
if( g_ConfigFileLocationChoice != 1 )
|
|
|
|
{
|
|
|
|
g_ConfigFileLocationChoice = 1;
|
|
|
|
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, false );
|
|
|
|
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, true );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( HOTKEY_CFG_PATH_OPT, g_ConfigFileLocationChoice );
|
2007-09-22 14:31:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|