Commit e27d3f8c authored by CHARRAS's avatar CHARRAS

more work on programmable hotkeys. Most of features are ok.

parent 4a8bf70d
...@@ -4,6 +4,14 @@ Started 2007-June-11 ...@@ -4,6 +4,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-sept-6 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+ eeschema & pcbnew
Programmable hotkeys update.
some features are still subject to change (mainly path for config files: see 2007-aug-30 UPDATE))
The preference menu has a command to create and reread config hotkey files.
the hotkey ? lists the current hotkeys.
2007-Sep-4 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Sep-4 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
......
...@@ -265,7 +265,7 @@ void MyFree( void* pt_mem ) ...@@ -265,7 +265,7 @@ void MyFree( void* pt_mem )
/**************************************************************/ /**************************************************************/
wxString ReturnPcbLayerName( int layer_number, bool is_filename, bool is_gui ) wxString ReturnPcbLayerName( int layer_number, bool is_filename )
/**************************************************************/ /**************************************************************/
/* Return the name of the layer number "layer_number". /* Return the name of the layer number "layer_number".
...@@ -305,21 +305,6 @@ wxString ReturnPcbLayerName( int layer_number, bool is_filename, bool is_gui ) ...@@ -305,21 +305,6 @@ wxString ReturnPcbLayerName( int layer_number, bool is_filename, bool is_gui )
else else
layer_name = layer_name_list[layer_number]; layer_name = layer_name_list[layer_number];
if( is_gui )
{
static const wxString hotkey_list[] = {
wxT( "(PgDn)" ), wxT( "(F5)" ), wxT( "(F6)" ), wxT( "(F7)" ),
wxT( "(F8)" ), wxT( "(F9)" ), wxT( "(F10)" ), wxT( " " ),
wxT( " " ), wxT( " " ), wxT( " " ), wxT( " " ),
wxT( " " ), wxT( " " ), wxT( " " ), wxT( " (PgUp)" ),
wxT( " " ), wxT( " " ), wxT( " " ), wxT( " " ),
wxT( " " ), wxT( " " ), wxT( " " ), wxT( " " ),
wxT( " " ), wxT( " " ), wxT( " " ), wxT( " " ),
wxT( " " ), wxT( " " ), wxT( " " ), wxT( " " )
};
layer_name += wxT( " " ) + hotkey_list[layer_number];
}
return layer_name; return layer_name;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "worksheet.h" #include "worksheet.h"
#include "id.h" #include "id.h"
#include "build_version.h" #include "build_version.h"
#include "hotkeys_basic.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "Language.xpm" #include "Language.xpm"
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
/* Some functions to handle hotkeys in kicad /* Some functions to handle hotkeys in kicad
*/ */
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "wxstruct.h" #include "wxstruct.h"
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
#include "macros.h" #include "macros.h"
/* Class to handle hotkey commnands. hotkeys have a default value /* Class to handle hotkey commnands. hotkeys have a default value
* This class allows (for the future..) the real key code changed by user(from a key code list file, TODO) * This class allows the real key code changed by user from a key code list file
*/ */
Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode ) Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode )
...@@ -30,7 +31,8 @@ struct hotkey_name_descr ...@@ -30,7 +31,8 @@ struct hotkey_name_descr
int m_KeyCode; int m_KeyCode;
}; };
struct hotkey_name_descr s_Hotkey_Name_List[] =
static struct hotkey_name_descr s_Hotkey_Name_List[] =
{ {
{ wxT( "F1" ), WXK_F1 }, { wxT( "F1" ), WXK_F1 },
{ wxT( "F2" ), WXK_F2 }, { wxT( "F2" ), WXK_F2 },
...@@ -71,7 +73,7 @@ struct hotkey_name_descr s_Hotkey_Name_List[] = ...@@ -71,7 +73,7 @@ struct hotkey_name_descr s_Hotkey_Name_List[] =
{ wxT( "*" ), '*' }, { wxT( "*" ), '*' },
{ wxT( "+" ), '+' }, { wxT( "+" ), '+' },
{ wxT( "-" ), '-' }, { wxT( "-" ), '-' },
{ wxT( "\%" ), '%' }, { wxT( "\%" ), '%' },
{ wxT( "A" ), 'A' }, { wxT( "A" ), 'A' },
{ wxT( "B" ), 'B' }, { wxT( "B" ), 'B' },
{ wxT( "C" ), 'C' }, { wxT( "C" ), 'C' },
...@@ -136,7 +138,7 @@ wxString ReturnKeyNameFromKeyCode( int keycode ) ...@@ -136,7 +138,7 @@ wxString ReturnKeyNameFromKeyCode( int keycode )
/* /*
* return the key name from the key code * return the key name from the key code
* Only some wxWidgets key values are handled for function key * Only some wxWidgets key values are handled for function key ( see s_Hotkey_Name_List[] )
* @param key = key code (ascii value, or wxWidgets value for function keys) * @param key = key code (ascii value, or wxWidgets value for function keys)
* @return the key name in a wxString * @return the key name in a wxString
*/ */
...@@ -191,9 +193,41 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, int CommandI ...@@ -191,9 +193,41 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, int CommandI
} }
/***********************************************************************/ /***********************************************************/
wxString AddHotkeyName( const wxString& text,
struct Ki_HotkeyInfoSectionDescriptor* DescList,
int CommandId )
/***********************************************************/
/*
* Add the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor* DescrList of commands
* @param CommandId = Command Id value
* @return text (key name) in a wxString if found or text without modification
*/
{
wxString msg = text;
wxString keyname;
Ki_HotkeyInfo** List;
for( ; DescList->m_HK_InfoList != NULL; DescList++ )
{
List = DescList->m_HK_InfoList;
keyname = ReturnKeyNameFromCommandId( List, CommandId );
if( !keyname.IsEmpty() )
{
msg << wxT( " (" ) << keyname << wxT( ")" );
break;
}
}
return msg;
}
/*************************************************************************/
wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId ) wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId )
/***********************************************************************/ /*************************************************************************/
/* /*
* return the key name from the Command id value ( m_Idcommand member value) * return the key name from the Command id value ( m_Idcommand member value)
...@@ -225,7 +259,7 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname ) ...@@ -225,7 +259,7 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
/* /*
* return the key code from its key name * return the key code from its key name
* Only some wxWidgets key values are handled for function key * Only some wxWidgets key values are handled for function key
* @param keyname = wxString key name to find in s_Hotkey_Name_List[] * @param keyname = wxString key name to find in s_Hotkey_Name_List[], like F2 or space or an usual (ascii) char
* @return the key code * @return the key code
*/ */
{ {
...@@ -246,27 +280,32 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname ) ...@@ -246,27 +280,32 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
} }
/****************************************************************************/ /********************************************************************************************/
void DisplayHotkeyList( WinEDA_DrawFrame* frame, Ki_HotkeyInfo** List ) void DisplayHotkeyList( WinEDA_DrawFrame* frame, struct Ki_HotkeyInfoSectionDescriptor* DescList )
/*****************************************************************************/ /***************************************************************************************/
/* /*
* Displays the current hotkey list * Displays the current hotkey list
* @param frame = current open frame * @param frame = current active frame
* @param List = pointer to a Ki_HotkeyInfo list of commands * @param List = pointer to a Ki_HotkeyInfoSectionDescriptor list (Null terminated)
* @return none * @return none
*/ */
{ {
wxString keyname; wxString keyname;
Ki_HotkeyInfo** List;
wxString msg = _( "Current hotkey list:\n\n" ); wxString msg = _( "Current hotkey list:\n\n" );
for( ; *List != NULL; List++ ) for( ; DescList->m_HK_InfoList != NULL; DescList++ )
{ {
Ki_HotkeyInfo* hk_decr = *List; List = DescList->m_HK_InfoList;
msg += _( "key " ); for( ; *List != NULL; List++ )
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); {
msg += keyname + wxT( ": " ) + hk_decr->m_InfoMsg + wxT( "\n" ); Ki_HotkeyInfo* hk_decr = *List;
msg += _( "key " );
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
msg += keyname + wxT( ": " ) + hk_decr->m_InfoMsg + wxT( "\n" );
}
} }
DisplayInfo( frame, msg ); DisplayInfo( frame, msg );
...@@ -296,8 +335,9 @@ int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List ) ...@@ -296,8 +335,9 @@ int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List )
/*************************************************************************/ /*************************************************************************/
int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename, int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename,
Ki_HotkeyInfo** List, bool verbose ) struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose )
/*************************************************************************/ /*************************************************************************/
/* /*
...@@ -371,23 +411,36 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename, ...@@ -371,23 +411,36 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename,
} }
} }
/* print the last line */ /* print the last line of the info section */
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
msg += wxT( "\n" ); msg += wxT( "\n" );
msg += wxT( "#\n#\n" ); msg += wxT( "#\n#\n" );
fprintf( cfgfile, CONV_TO_UTF8( msg ) ); fprintf( cfgfile, CONV_TO_UTF8( msg ) );
/* Print the current list */ /* Print the current hotkey list */
for( ; *List != NULL; List++ ) Ki_HotkeyInfo** List;
for( ; DescList->m_HK_InfoList != NULL; DescList++ )
{ {
Ki_HotkeyInfo* hk_decr = *List; if( DescList->m_Comment )
msg = wxT( "shortcut " ); {
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); fprintf( cfgfile, "# " );
AddDelimiterString( keyname ); fprintf( cfgfile, DescList->m_Comment );
infokey = hk_decr->m_InfoMsg; fprintf( cfgfile, "\n" );
AddDelimiterString( infokey ); }
msg += keyname + wxT( ": " ) + infokey + wxT( "\n" ); fprintf( cfgfile, CONV_TO_UTF8( *DescList->m_SectionTag ) );
fprintf( cfgfile, CONV_TO_UTF8( msg ) ); fprintf( cfgfile, "\n" );
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" );
fprintf( cfgfile, CONV_TO_UTF8( msg ) );
}
} }
msg = wxT( "$Endlist\n" ); msg = wxT( "$Endlist\n" );
...@@ -398,16 +451,18 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename, ...@@ -398,16 +451,18 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename,
/********************************************************************************************/ /********************************************************************************************/
int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& Filename, int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& Filename,
Ki_HotkeyInfo** CurrentHotkeyList, bool verbose ) struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose )
/********************************************************************************************/ /********************************************************************************************/
/* /*
* Read a configuration file (<file>.key) and fill the current hotkey list with hotkeys * 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 will be asked * @param Filename = default full file name to create. If void, A filename will be asked
* @param CurrentHotkeyList = current hotkey list to initialise. * @param DescList = current hotkey list descr. to initialise.
* the input format is: shortcut "key" "function" * the input format is: shortcut "key" "function"
* lines starting by # are ignored (comments) * lines starting by # are ignored (comments)
* lines like [xxx] are tags (example: [common] or [libedit] which identify sections
* *
*/ */
{ {
...@@ -446,19 +501,38 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& Filename, ...@@ -446,19 +501,38 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& Filename,
return 0; return 0;
} }
wxString keyname; wxString keyname;
char Line[1024]; char Line[1024];
int LineNum = 0; int LineNum = 0;
Ki_HotkeyInfo** CurrentHotkeyList = NULL;
/* Read the file */ /* Read the file */
while( GetLine( cfgfile, Line, &LineNum ) != NULL ) while( GetLine( cfgfile, Line, &LineNum ) != NULL )
{ {
char* line_type, * keyname, * fctname; char* line_type, * keyname, * fctname;
line_type = strtok( Line, " \t\n\r" ); line_type = strtok( Line, " \t\n\r" );
msg = CONV_FROM_UTF8( line_type ); msg = CONV_FROM_UTF8( line_type );
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;
}
if( msg != wxT( "shortcut" ) ) if( msg != wxT( "shortcut" ) )
continue; continue;
if( msg == wxT( "$Endlist" ) ) if( msg == wxT( "$Endlist" ) )
break; break;
if( CurrentHotkeyList == NULL )
continue;
/* Get the key name */ /* Get the key name */
strtok( NULL, "\"\n\r" ); strtok( NULL, "\"\n\r" );
......
...@@ -11,12 +11,10 @@ ...@@ -11,12 +11,10 @@
#include "eeconfig.h" #include "eeconfig.h"
#include "worksheet.h" #include "worksheet.h"
#include "hotkeys_basic.h" #include "hotkeys_basic.h"
#include "hotkeys.h"
#include "id.h" #include "id.h"
extern Ki_HotkeyInfo *s_Schematic_Hotkey_List[];
extern Ki_HotkeyInfo *s_LibEdit_Hotkey_List[];
/* Variables locales */ /* Variables locales */
...@@ -80,11 +78,7 @@ wxString FullFileName; ...@@ -80,11 +78,7 @@ wxString FullFileName;
FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("eeschema"); FullFileName += wxT("eeschema");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
WriteHotkeyConfigFile(FullFileName, s_Schematic_Hotkey_List, true); WriteHotkeyConfigFile(FullFileName, s_Eeschema_Hokeys_Descr, true);
FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("libedit");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
WriteHotkeyConfigFile(FullFileName, s_LibEdit_Hotkey_List, true);
break; break;
case ID_PREFERENCES_READ_CONFIG_HOTKEYS: case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
...@@ -107,11 +101,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ) ...@@ -107,11 +101,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose )
wxString FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; wxString FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("eeschema"); FullFileName += wxT("eeschema");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
frame->ReadHotkeyConfigFile(FullFileName, s_Schematic_Hotkey_List, verbose); frame->ReadHotkeyConfigFile(FullFileName, s_Eeschema_Hokeys_Descr, verbose);
FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("libedit");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
frame->ReadHotkeyConfigFile(FullFileName, s_LibEdit_Hotkey_List, verbose);
return TRUE; return TRUE;
} }
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
* "Command Label" is the name used in hotkey list display, and the identifier in the hotkey list file * "Command Label" is the name used in hotkey list display, and the identifier in the hotkey list file
* MY_NEW_ID_FUNCTION is an equivalent id function used in the switch in OnHotKey() function. * MY_NEW_ID_FUNCTION is an equivalent id function used in the switch in OnHotKey() function.
* default key value is the default hotkey for this command. Can be overrided by the user hotkey list file * default key value is the default hotkey for this command. Can be overrided by the user hotkey list file
* add the HkMyNewEntry pointer in the s_Schematic_Hotkey_List list ( or/and the s_LibEdit_Hotkey_List list) * add the HkMyNewEntry pointer in the s_Schematic_Hotkey_List list or the s_LibEdit_Hotkey_List list
* ( or s_Common_Hotkey_List if the same command is added both in eeschema and libedit)
* Add the new code in the switch in OnHotKey() function. * Add the new code in the switch in OnHotKey() function.
* when the variable PopupOn is true, an item is currently edited. * when the variable PopupOn is true, an item is currently edited.
* This can be usefull if the new function cannot be executed while an item is currently being edited * This can be usefull if the new function cannot be executed while an item is currently being edited
...@@ -38,6 +39,15 @@ ...@@ -38,6 +39,15 @@
/* local variables */ /* local variables */
/* Hotkey list: */ /* Hotkey list: */
// Common commands
static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' );
// Schematic editor
static Ki_HotkeyInfo HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' ); static Ki_HotkeyInfo HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' );
static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' ); static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' );
static Ki_HotkeyInfo HkMirrorYComponent( wxT( static Ki_HotkeyInfo HkMirrorYComponent( wxT(
...@@ -54,19 +64,24 @@ static Ki_HotkeyInfo HkMove2Drag( wxT( ...@@ -54,19 +64,24 @@ static Ki_HotkeyInfo HkMove2Drag( wxT(
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' ); HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' );
static Ki_HotkeyInfo HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT ); static Ki_HotkeyInfo HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
static Ki_HotkeyInfo HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE ); static Ki_HotkeyInfo HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' );
static Ki_HotkeyInfo HkNextSearch( wxT( "Next Search" ), HK_NEXT_SEARCH, WXK_F5 ); static Ki_HotkeyInfo HkNextSearch( wxT( "Next Search" ), HK_NEXT_SEARCH, WXK_F5 );
static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); // Library editor:
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
// List of common hotkey descriptors
Ki_HotkeyInfo* s_Common_Hotkey_List[] =
{
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord,
NULL
};
// List of hotkey descriptors for schematic // List of hotkey descriptors for schematic
Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = { Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = {
&HkHelp, &HkNextSearch,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkNextSearch, &HkResetLocalCoord,
&HkDelete, &HkInsert, &HkMove2Drag, &HkDelete, &HkInsert, &HkMove2Drag,
&HkMoveComponent, &HkAddComponent, &HkMoveComponent, &HkAddComponent,
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, &HkOrientNormalComponent, &HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, &HkOrientNormalComponent,
...@@ -74,25 +89,41 @@ Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = { ...@@ -74,25 +89,41 @@ Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = {
NULL NULL
}; };
// Library editor:
static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
// List of hotkey descriptors for libray editor // List of hotkey descriptors for libray editor
Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] = Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] =
{ {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord,
&HkInsertPin, &HkInsertPin,
NULL NULL
}; };
// list of sections and corresponding hotkey list for eeschema (used to create an hotkey config file)
struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[] = {
{ &g_CommonSectionTag, s_Common_Hotkey_List, "Common keys" },
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, "Schematic editor keys"},
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, "library editor keys"},
NULL, NULL
};
// list of sections and corresponding hotkey list for the schematic editor (used to list current hotkeys)
struct Ki_HotkeyInfoSectionDescriptor s_Schematic_Hokeys_Descr[] = {
{ &g_CommonSectionTag, s_Common_Hotkey_List, NULL},
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, NULL},
NULL, NULL
};
// list of sections and corresponding hotkey list for the component editor (used to list current hotkeys)
struct Ki_HotkeyInfoSectionDescriptor s_Libedit_Hokeys_Descr[] = {
{ &g_CommonSectionTag, s_Common_Hotkey_List, NULL},
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, NULL},
NULL, NULL
};
/***********************************************************/ /***********************************************************/
void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct ) EDA_BaseStruct* DrawStruct )
/***********************************************************/ /***********************************************************/
/* Hot keys. Some commands are relatives to the item under the mouse cursor /* Hot keys. Some commands are relative to the item under the mouse cursor
* Commands are case insensitive * Commands are case insensitive
*/ */
{ {
...@@ -113,7 +144,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -113,7 +144,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
hotkey += 'A' - 'a'; hotkey += 'A' - 'a';
// Search command from key : // Search command from key :
int CommandCode = GetCommandCodeFromHotkey( hotkey, s_Schematic_Hotkey_List ); int CommandCode = GetCommandCodeFromHotkey( hotkey, s_Common_Hotkey_List );
if ( CommandCode == HK_NOT_FOUND )
CommandCode = GetCommandCodeFromHotkey( hotkey, s_Schematic_Hotkey_List );
switch( CommandCode ) switch( CommandCode )
{ {
...@@ -123,7 +156,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -123,7 +156,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_HELP: // Display Current hotkey list case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_Schematic_Hotkey_List ); DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
break; break;
case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ case HK_RESET_LOCAL_COORD: /* Reset the relative coord */
...@@ -319,7 +352,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -319,7 +352,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct ) EDA_BaseStruct* DrawStruct )
/***********************************************************/ /***********************************************************/
/* Hot keys for the component editot. Some commands are relatives to the item under the mouse cursor /* Hot keys for the component editor. Some commands are relatives to the item under the mouse cursor
* Commands are case insensitive * Commands are case insensitive
*/ */
{ {
...@@ -333,7 +366,9 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -333,7 +366,9 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */ /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') ) if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a'; hotkey += 'A' - 'a';
int CommandCode = GetCommandCodeFromHotkey( hotkey, s_LibEdit_Hotkey_List ); int CommandCode = GetCommandCodeFromHotkey( hotkey, s_Common_Hotkey_List );
if ( CommandCode == HK_NOT_FOUND )
CommandCode = GetCommandCodeFromHotkey( hotkey, s_LibEdit_Hotkey_List );
switch( CommandCode ) switch( CommandCode )
{ {
...@@ -343,7 +378,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -343,7 +378,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_HELP: // Display Current hotkey list case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_LibEdit_Hotkey_List ); DisplayHotkeyList( this, s_Libedit_Hokeys_Descr );
break; break;
case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ case HK_RESET_LOCAL_COORD: /* Reset the relative coord */
......
...@@ -27,9 +27,11 @@ enum hotkey_id_commnand { ...@@ -27,9 +27,11 @@ enum hotkey_id_commnand {
HK_BEGIN_WIRE HK_BEGIN_WIRE
}; };
// List of hotkey descriptors for schematic // List of hotkey descriptors for eeschema
extern Ki_HotkeyInfo* s_Schematic_Hotkey_List[]; extern struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[];
// List of hotkey descriptors for libray editor // List of hotkey descriptors for the schematic editor only
extern Ki_HotkeyInfo* s_LibEdit_Hotkey_List[]; extern struct Ki_HotkeyInfoSectionDescriptor s_Schematic_Hokeys_Descr[];
// List of hotkey descriptors for the lib editor only
extern struct Ki_HotkeyInfoSectionDescriptor s_Libedit_Hokeys_Descr[];
#endif // KOTKEYS_H #endif // KOTKEYS_H
...@@ -281,22 +281,22 @@ void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component ) ...@@ -281,22 +281,22 @@ void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component )
if( !Component->m_Flags ) if( !Component->m_Flags )
{ {
msg = AddHotkeyName( _( "Move Component" ), s_Schematic_Hotkey_List, HK_MOVE_COMPONENT ); msg = AddHotkeyName( _( "Move Component" ), s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST,
msg, move_xpm ); msg, move_xpm );
} }
// add menu orient et sous menu: // add menu orient et sous menu:
wxMenu* orientmenu = new wxMenu; wxMenu* orientmenu = new wxMenu;
msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hotkey_List, HK_ROTATE_COMPONENT ); msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hokeys_Descr, HK_ROTATE_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE,
msg, rotate_pos_xpm ); msg, rotate_pos_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), rotate_neg_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), rotate_neg_xpm );
msg = AddHotkeyName( _( "Mirror --" ), s_Schematic_Hotkey_List, HK_MIRROR_X_COMPONENT ); msg = AddHotkeyName( _( "Mirror --" ), s_Schematic_Hokeys_Descr, HK_MIRROR_X_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, msg, mirror_V_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, msg, mirror_V_xpm );
msg = AddHotkeyName( _( "Mirror ||" ), s_Schematic_Hotkey_List, HK_MIRROR_Y_COMPONENT ); msg = AddHotkeyName( _( "Mirror ||" ), s_Schematic_Hokeys_Descr, HK_MIRROR_Y_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, msg, mirror_H_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, msg, mirror_H_xpm );
msg = AddHotkeyName( _( "Normal" ), s_Schematic_Hotkey_List, HK_ORIENT_NORMAL_COMPONENT ); msg = AddHotkeyName( _( "Normal" ), s_Schematic_Hokeys_Descr, HK_ORIENT_NORMAL_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, msg, normal_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, msg, normal_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu, ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu,
ID_POPUP_SCH_GENERIC_ORIENT_CMP, _( ID_POPUP_SCH_GENERIC_ORIENT_CMP, _(
......
...@@ -167,15 +167,15 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() ...@@ -167,15 +167,15 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
_( "Test duplicate pins" ) ); _( "Test duplicate pins" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "zoom +" ), s_LibEdit_Hotkey_List, HK_ZOOM_IN ); msg = AddHotkeyName( _( "zoom +" ), s_Libedit_Hokeys_Descr, HK_ZOOM_IN );
m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ), m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "zoom -" ), s_LibEdit_Hotkey_List, HK_ZOOM_OUT ); msg = AddHotkeyName( _( "zoom -" ), s_Libedit_Hokeys_Descr, HK_ZOOM_OUT );
m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ), m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "redraw" ), s_LibEdit_Hotkey_List, HK_ZOOM_REDRAW ); msg = AddHotkeyName( _( "redraw" ), s_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW );
m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ), m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ),
msg ); msg );
......
...@@ -104,15 +104,15 @@ void WinEDA_SchematicFrame::ReCreateHToolbar() ...@@ -104,15 +104,15 @@ void WinEDA_SchematicFrame::ReCreateHToolbar()
_( "Run Pcbnew" ) ); _( "Run Pcbnew" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "zoom +" ), s_Schematic_Hotkey_List, HK_ZOOM_IN ); msg = AddHotkeyName( _( "zoom +" ), s_Schematic_Hokeys_Descr, HK_ZOOM_IN );
m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ), m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "zoom -" ), s_Schematic_Hotkey_List, HK_ZOOM_OUT ); msg = AddHotkeyName( _( "zoom -" ), s_Schematic_Hokeys_Descr, HK_ZOOM_OUT );
m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ), m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "redraw" ), s_Schematic_Hotkey_List, HK_ZOOM_REDRAW ); msg = AddHotkeyName( _( "redraw" ), s_Schematic_Hokeys_Descr, HK_ZOOM_REDRAW );
m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ), m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ),
msg ); msg );
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
COMMON_GLOBL wxString g_BuildVersion COMMON_GLOBL wxString g_BuildVersion
#ifdef EDA_BASE #ifdef EDA_BASE
(wxT("(2007-08-30)")) (wxT("(2007-09-06)"))
#endif #endif
; ;
......
...@@ -345,7 +345,7 @@ class WinEDA_DrawPanel; ...@@ -345,7 +345,7 @@ class WinEDA_DrawPanel;
/* COMMON.CPP */ /* COMMON.CPP */
wxString ReturnPcbLayerName(int layer_number, bool is_filename = FALSE, bool is_gui = FALSE); wxString ReturnPcbLayerName(int layer_number, bool is_filename = FALSE);
/* Return the name of the layer number "layer_number". /* Return the name of the layer number "layer_number".
if "is_filename" == TRUE, the name can be used for a file name if "is_filename" == TRUE, the name can be used for a file name
(not internatinalized, no space)*/ (not internatinalized, no space)*/
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#ifndef HOTKEYS_BASIC_H #ifndef HOTKEYS_BASIC_H
#define HOTKEYS_BASIC_H #define HOTKEYS_BASIC_H
#ifndef COMMON_GLOBL
#define COMMON_GLOBL extern
#endif
#define DEFAULT_HOTKEY_FILENAME_EXT wxT( ".key" ) #define DEFAULT_HOTKEY_FILENAME_EXT wxT( ".key" )
/* define default path for config key file */ /* define default path for config key file */
...@@ -32,12 +36,60 @@ public: ...@@ -32,12 +36,60 @@ public:
Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode ); Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode );
}; };
/* handle a Section name and the corresponding list of hotkeys (Ki_HotkeyInfo list) */
struct Ki_HotkeyInfoSectionDescriptor
{
public:
wxString* m_SectionTag; // The section name
Ki_HotkeyInfo** m_HK_InfoList; // pointer on List of Ki_HotkeyInfo
char* m_Comment; // comment: will be printed in the config file
/*
* public:
* Ki_HotkeyInfoSectionDescriptor( wxString * SectionTag, Ki_HotkeyInfo ** HK_InfoList )
* { m_SectionTag = SectionTag; m_HK_InfoList = HK_InfoList; }
*/
};
/* Identifiers (tags) in key code configuration file file
* .m_SectionTag member of a Ki_HotkeyInfoSectionDescriptor
*/
COMMON_GLOBL wxString g_CommonSectionTag
#ifdef EDA_BASE
( wxT( "[common]" ) )
#endif
;
COMMON_GLOBL wxString g_SchematicSectionTag
#ifdef EDA_BASE
( wxT( "[eeschema]" ) )
#endif
;
COMMON_GLOBL wxString g_LibEditSectionTag
#ifdef EDA_BASE
( wxT( "[libedit]" ) )
#endif
;
COMMON_GLOBL wxString g_BoardEditorSectionTag
#ifdef EDA_BASE
( wxT( "[pcbnew]" ) )
#endif
;
COMMON_GLOBL wxString g_ModuleEditSectionTag
#ifdef EDA_BASE
( wxT( "[footprinteditor]" ) )
#endif
;
/* Functions: /* Functions:
*/ */
wxString ReturnKeyNameFromKeyCode( int keycode ); wxString ReturnKeyNameFromKeyCode( int keycode );
wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId ); wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId );
wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, int CommandId ); wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, int CommandId );
void DisplayHotkeyList( WinEDA_DrawFrame* frame, Ki_HotkeyInfo** List ); wxString AddHotkeyName( const wxString& text,
struct Ki_HotkeyInfoSectionDescriptor* DescrList,
int CommandId );
void DisplayHotkeyList( WinEDA_DrawFrame* frame,
struct Ki_HotkeyInfoSectionDescriptor* List );
int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List ); int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List );
......
...@@ -177,8 +177,8 @@ public: ...@@ -177,8 +177,8 @@ public:
void PrintMsg( const wxString& text ); void PrintMsg( const wxString& text );
void GetSettings(); void GetSettings();
void SaveSettings(); void SaveSettings();
int WriteHotkeyConfigFile(const wxString & Filename, Ki_HotkeyInfo ** List, bool verbose); int WriteHotkeyConfigFile(const wxString & Filename, struct Ki_HotkeyInfoSectionDescriptor * DescList, bool verbose);
int ReadHotkeyConfigFile(const wxString & Filename, Ki_HotkeyInfo ** List, bool verbose); int ReadHotkeyConfigFile(const wxString & Filename, struct Ki_HotkeyInfoSectionDescriptor * DescList, bool verbose);
void SetLanguage( wxCommandEvent& event ); void SetLanguage( wxCommandEvent& event );
void ProcessFontPreferences( int id ); void ProcessFontPreferences( int id );
......
...@@ -17,7 +17,7 @@ KICAD_BIN = /f/kicad/winexe ...@@ -17,7 +17,7 @@ KICAD_BIN = /f/kicad/winexe
#Define the wxWidget path (if not found in environment variables): #Define the wxWidget path (if not found in environment variables):
ifndef WXWIN ifndef WXWIN
WXWIN=f:/wxMSW-2.8.4 WXWIN=f:/wxMSW-2.8.5
endif endif
LIBVERSION = 2.8 LIBVERSION = 2.8
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* This can be usefull if the new function cannot be executed while an item is currently being edited * This can be usefull if the new function cannot be executed while an item is currently being edited
* ( For example, one cannot start a new wire when a component is moving.) * ( For example, one cannot start a new wire when a component is moving.)
* *
* Note: If an hotkey is a special key be sure the corresponding wxWidget keycode (WXK_XXXX) * Note: If an hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX)
* is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp) * is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp)
* and see this list for some ascii keys (space ...) * and see this list for some ascii keys (space ...)
*/ */
...@@ -35,10 +35,10 @@ ...@@ -35,10 +35,10 @@
/* Hotkey list: */ /* Hotkey list: */
static Ki_HotkeyInfo HkSwitch2CopperLayer( wxT( static Ki_HotkeyInfo HkSwitch2CopperLayer( wxT(
"Switch to Copper layer" ), "Switch to Copper layer" ),
HK_SWITCH_LAYER_TO_COPPER, '-' ); HK_SWITCH_LAYER_TO_COPPER, WXK_PAGEUP );
static Ki_HotkeyInfo HkSwitch2ComponentLayer( wxT( static Ki_HotkeyInfo HkSwitch2ComponentLayer( wxT(
"Switch to Component layer" ), "Switch to Component layer" ),
HK_SWITCH_LAYER_TO_COMPONENT, '+' ); HK_SWITCH_LAYER_TO_COMPONENT, WXK_PAGEDOWN );
static Ki_HotkeyInfo HkSwitch2InnerLayer1( wxT( static Ki_HotkeyInfo HkSwitch2InnerLayer1( wxT(
"Switch to Inner layer 1" ), "Switch to Inner layer 1" ),
HK_SWITCH_LAYER_TO_INNER1, WXK_F5 ); HK_SWITCH_LAYER_TO_INNER1, WXK_F5 );
...@@ -58,6 +58,13 @@ static Ki_HotkeyInfo HkSwitch2InnerLayer6( wxT( ...@@ -58,6 +58,13 @@ static Ki_HotkeyInfo HkSwitch2InnerLayer6( wxT(
"Switch to Inner layer 6" ), "Switch to Inner layer 6" ),
HK_SWITCH_LAYER_TO_INNER6, WXK_F10 ); HK_SWITCH_LAYER_TO_INNER6, WXK_F10 );
static Ki_HotkeyInfo HkSwitch2NextCopperLayer( wxT(
"Switch to Next Layer" ),
HK_SWITCH_LAYER_TO_NEXT, '+' );
static Ki_HotkeyInfo HkSwitch2PreviousCopperLayer( wxT(
"Switch to Previous Layer" ),
HK_SWITCH_LAYER_TO_PREVIOUS, '-');
static Ki_HotkeyInfo HkSavefile( wxT( "Save board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL ); static Ki_HotkeyInfo HkSavefile( wxT( "Save board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL );
static Ki_HotkeyInfo HkLoadfile( wxT( "Load board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL ); static Ki_HotkeyInfo HkLoadfile( wxT( "Load board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL );
static Ki_HotkeyInfo HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL ); static Ki_HotkeyInfo HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL );
...@@ -83,12 +90,17 @@ static Ki_HotkeyInfo HkTrackDisplayMode( wxT( ...@@ -83,12 +90,17 @@ static Ki_HotkeyInfo HkTrackDisplayMode( wxT(
"Track Display Mode" ), "Track Display Mode" ),
HK_SWITCH_TRACK_DISPLAY_MODE, 'F' ); HK_SWITCH_TRACK_DISPLAY_MODE, 'F' );
// List of common hotkey descriptors
Ki_HotkeyInfo* s_Common_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkSwitchUnits, &HkResetLocalCoord,
NULL
};
// List of hotkey descriptors for pcbnew // List of hotkey descriptors for pcbnew
Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = { Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = {
&HkHelp, &HkTrackDisplayMode,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord, &HkSwitchUnits, &HkTrackDisplayMode,
&HkDelete, &HkBackspace, &HkDelete, &HkBackspace,
&HkAddVia, &HkEndTrack, &HkAddVia, &HkEndTrack,
&HkMoveFootprint, &HkFlipFootprint, &HkMoveFootprint, &HkFlipFootprint,
...@@ -103,19 +115,41 @@ Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = { ...@@ -103,19 +115,41 @@ Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = {
&HkSwitch2InnerLayer5, &HkSwitch2InnerLayer5,
&HkSwitch2InnerLayer6, &HkSwitch2InnerLayer6,
&HkSwitch2ComponentLayer, &HkSwitch2ComponentLayer,
&HkSwitch2NextCopperLayer,
&HkSwitch2PreviousCopperLayer,
NULL NULL
}; };
// List of hotkey descriptors for the module editor // List of hotkey descriptors for the module editor
Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = { Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkSwitchUnits, &HkResetLocalCoord,
&HkDelete, &HkBackspace,
NULL NULL
}; };
// list of sections and corresponding hotkey list for pcbnew (used to create an hotkey config file)
struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[] = {
{ &g_CommonSectionTag, s_Common_Hotkey_List, "Common keys"},
{ &g_BoardEditorSectionTag, s_board_edit_Hotkey_List, "Board editor keys"},
{ &g_ModuleEditSectionTag, s_module_edit_Hotkey_List, "Footprint editor keys"},
NULL, NULL
};
// list of sections and corresponding hotkey list for the board editor (used to list current hotkeys)
struct Ki_HotkeyInfoSectionDescriptor s_Board_Editor_Hokeys_Descr[] = {
{ &g_CommonSectionTag, s_Common_Hotkey_List, NULL},
{ &g_BoardEditorSectionTag, s_board_edit_Hotkey_List, NULL},
NULL, NULL
};
// list of sections and corresponding hotkey list for the footprint editor (used to list current hotkeys)
struct Ki_HotkeyInfoSectionDescriptor s_Module_Editor_Hokeys_Descr[] = {
{ &g_CommonSectionTag, s_Common_Hotkey_List, NULL},
{ &g_ModuleEditSectionTag, s_module_edit_Hotkey_List, NULL},
NULL, NULL
};
/***********************************************************/ /***********************************************************/
void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct ) EDA_BaseStruct* DrawStruct )
...@@ -123,7 +157,6 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -123,7 +157,6 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
/* Hot keys. Some commands are relatives to the item under the mouse cursor /* Hot keys. Some commands are relatives to the item under the mouse cursor
* Commands are case insensitive * Commands are case insensitive
* Zoom commands are not managed here
* @param DC = current device context * @param DC = current device context
* @param hotkey = hothey code (ascii or wxWidget code for special keys) * @param hotkey = hothey code (ascii or wxWidget code for special keys)
* @param DrawStruct = NULL or pointer on a EDA_BaseStruct under the mouse cursor * @param DrawStruct = NULL or pointer on a EDA_BaseStruct under the mouse cursor
...@@ -148,7 +181,9 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -148,7 +181,9 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
if( (hotkey >= 'a') && (hotkey <= 'z') ) if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a'; hotkey += 'A' - 'a';
int CommandCode = GetCommandCodeFromHotkey( hotkey, s_board_edit_Hotkey_List ); int CommandCode = GetCommandCodeFromHotkey( hotkey, s_Common_Hotkey_List );
if ( CommandCode == HK_NOT_FOUND )
CommandCode = GetCommandCodeFromHotkey( hotkey, s_board_edit_Hotkey_List );
int ll; int ll;
switch( CommandCode ) switch( CommandCode )
...@@ -218,7 +253,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -218,7 +253,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_HELP: // Display Current hotkey list case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_board_edit_Hotkey_List ); DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr );
break; break;
case HK_ZOOM_IN: case HK_ZOOM_IN:
...@@ -434,9 +469,8 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -434,9 +469,8 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct ) EDA_BaseStruct* DrawStruct )
/***********************************************************/ /***********************************************************/
/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element /* Hot keys. Some commands are relative to the item under the mouse cursor
* sous le courseur souris * Commands are case insensitive
* Les majuscules/minuscules sont indifferenciees
*/ */
{ {
if( hotkey == 0 ) if( hotkey == 0 )
...@@ -446,7 +480,9 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -446,7 +480,9 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
if( (hotkey >= 'a') && (hotkey <= 'z') ) if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a'; hotkey += 'A' - 'a';
int CommandCode = GetCommandCodeFromHotkey( hotkey, s_module_edit_Hotkey_List ); int CommandCode = GetCommandCodeFromHotkey( hotkey, s_Common_Hotkey_List );
if ( CommandCode == HK_NOT_FOUND )
CommandCode = GetCommandCodeFromHotkey( hotkey, s_module_edit_Hotkey_List );
switch( CommandCode ) switch( CommandCode )
{ {
...@@ -456,7 +492,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -456,7 +492,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_HELP: // Display Current hotkey list case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_module_edit_Hotkey_List ); DisplayHotkeyList( this, s_Module_Editor_Hokeys_Descr );
break; break;
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
...@@ -491,12 +527,13 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -491,12 +527,13 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
/******************************************************************************/ /******************************************************************************/
/* Efface l'item pointe par la souris, en reponse a la touche "Del" /* Delete the item foun under the mouse cursor
* Effet dependant de l'outil selectionne: * Depending on the current active tool::
* Outil trace de pistes * Tool track
* Efface le segment en cours ou la piste si pas d'element * if a track is in progress: Delete the last segment
* Outil module: * else delete the entire track
* Efface le module. * Tool module (footprint):
* Delete the module.
*/ */
{ {
bool ItemFree = (GetScreen()->GetCurItem() == NULL ) bool ItemFree = (GetScreen()->GetCurItem() == NULL )
......
...@@ -34,12 +34,22 @@ enum hotkey_id_commnand { ...@@ -34,12 +34,22 @@ enum hotkey_id_commnand {
HK_SWITCH_LAYER_TO_INNER3, HK_SWITCH_LAYER_TO_INNER3,
HK_SWITCH_LAYER_TO_INNER4, HK_SWITCH_LAYER_TO_INNER4,
HK_SWITCH_LAYER_TO_INNER5, HK_SWITCH_LAYER_TO_INNER5,
HK_SWITCH_LAYER_TO_INNER6 HK_SWITCH_LAYER_TO_INNER6,
HK_SWITCH_LAYER_TO_INNER7,
HK_SWITCH_LAYER_TO_INNER8,
HK_SWITCH_LAYER_TO_INNER9,
HK_SWITCH_LAYER_TO_INNER10,
HK_SWITCH_LAYER_TO_INNER11,
HK_SWITCH_LAYER_TO_INNER12,
HK_SWITCH_LAYER_TO_INNER13,
HK_SWITCH_LAYER_TO_INNER14
}; };
// List of hotkey descriptors for pcbnew // List of hotkey descriptors for pcbnew
extern Ki_HotkeyInfo* s_board_edit_Hotkey_List[]; extern struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[];
// List of hotkey descriptors for the module editor // List of hotkey descriptors for the board editor only
extern Ki_HotkeyInfo* s_module_edit_Hotkey_List[]; extern struct Ki_HotkeyInfoSectionDescriptor s_Board_Editor_Hokeys_Descr[];
// List of hotkey descriptors for the footprint editor only
extern struct Ki_HotkeyInfoSectionDescriptor s_Module_Editor_Hokeys_Descr[];
#endif // KOTKEYS_H #endif // KOTKEYS_H
...@@ -13,12 +13,10 @@ ...@@ -13,12 +13,10 @@
#include "worksheet.h" #include "worksheet.h"
#include "id.h" #include "id.h"
#include "hotkeys_basic.h" #include "hotkeys_basic.h"
#include "hotkeys.h"
#include "protos.h" #include "protos.h"
extern Ki_HotkeyInfo *s_board_edit_Hotkey_List[];
extern Ki_HotkeyInfo *s_module_edit_Hotkey_List[];
/* Routines Locales */ /* Routines Locales */
/* Variables locales */ /* Variables locales */
...@@ -89,11 +87,7 @@ wxString FullFileName; ...@@ -89,11 +87,7 @@ wxString FullFileName;
FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("pcbnew"); FullFileName += wxT("pcbnew");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
WriteHotkeyConfigFile(FullFileName, s_board_edit_Hotkey_List, true); WriteHotkeyConfigFile(FullFileName, s_Pcbnew_Editor_Hokeys_Descr, true);
FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("module_edit");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
WriteHotkeyConfigFile(FullFileName, s_module_edit_Hotkey_List, true);
break; break;
case ID_PREFERENCES_READ_CONFIG_HOTKEYS: case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
...@@ -116,11 +110,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ) ...@@ -116,11 +110,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose )
wxString FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; wxString FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("pcbnew"); FullFileName += wxT("pcbnew");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
frame->ReadHotkeyConfigFile(FullFileName, s_board_edit_Hotkey_List, verbose); return frame->ReadHotkeyConfigFile(FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose);
FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
FullFileName += wxT("module_edit");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
return frame->ReadHotkeyConfigFile(FullFileName, s_module_edit_Hotkey_List, verbose);
} }
......
...@@ -112,15 +112,15 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() ...@@ -112,15 +112,15 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar()
_( "Print Module" ) ); _( "Print Module" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "zoom +" ), s_module_edit_Hotkey_List, HK_ZOOM_IN ); msg = AddHotkeyName( _( "zoom +" ), s_Module_Editor_Hokeys_Descr, HK_ZOOM_IN );
m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ), m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "zoom -" ), s_module_edit_Hotkey_List, HK_ZOOM_OUT ); msg = AddHotkeyName( _( "zoom -" ), s_Module_Editor_Hokeys_Descr, HK_ZOOM_OUT );
m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ), m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "redraw" ), s_module_edit_Hotkey_List, HK_ZOOM_REDRAW ); msg = AddHotkeyName( _( "redraw" ), s_Module_Editor_Hokeys_Descr, HK_ZOOM_REDRAW );
m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ), m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ),
msg ); msg );
......
...@@ -267,15 +267,15 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -267,15 +267,15 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
_( "Plot (HPGL, PostScript, or GERBER format)" ) ); _( "Plot (HPGL, PostScript, or GERBER format)" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "zoom +" ), s_board_edit_Hotkey_List, HK_ZOOM_IN ); msg = AddHotkeyName( _( "zoom +" ), s_Board_Editor_Hokeys_Descr, HK_ZOOM_IN );
m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ), m_HToolBar->AddTool( ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "zoom -" ), s_board_edit_Hotkey_List, HK_ZOOM_OUT ); msg = AddHotkeyName( _( "zoom -" ), s_Board_Editor_Hokeys_Descr, HK_ZOOM_OUT );
m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ), m_HToolBar->AddTool( ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ),
msg ); msg );
msg = AddHotkeyName( _( "redraw" ), s_board_edit_Hotkey_List, HK_ZOOM_REDRAW ); msg = AddHotkeyName( _( "redraw" ), s_Board_Editor_Hokeys_Descr, HK_ZOOM_REDRAW );
m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ), m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( repaint_xpm ),
msg ); msg );
...@@ -283,7 +283,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -283,7 +283,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
_( "auto zoom" ) ); _( "auto zoom" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "Find components and texts" ), s_board_edit_Hotkey_List, HK_FIND_ITEM ); msg = AddHotkeyName( _( "Find components and texts" ), s_Board_Editor_Hokeys_Descr, HK_FIND_ITEM );
m_HToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, BITMAP( find_xpm ), m_HToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, BITMAP( find_xpm ),
msg ); msg );
...@@ -643,9 +643,31 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) ...@@ -643,9 +643,31 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
m_SelLayerBox->Clear(); m_SelLayerBox->Clear();
for( ii = 0, jj = 0; ii <= EDGE_N; ii++ ) for( ii = 0, jj = 0; ii <= EDGE_N; ii++ )
{ {
// List to append hotkeys in layer box selection
static int HK_SwitchLayer[EDGE_N+1] = {
HK_SWITCH_LAYER_TO_COPPER,
HK_SWITCH_LAYER_TO_INNER1,
HK_SWITCH_LAYER_TO_INNER2,
HK_SWITCH_LAYER_TO_INNER3,
HK_SWITCH_LAYER_TO_INNER4,
HK_SWITCH_LAYER_TO_INNER5,
HK_SWITCH_LAYER_TO_INNER6,
HK_SWITCH_LAYER_TO_INNER7,
HK_SWITCH_LAYER_TO_INNER8,
HK_SWITCH_LAYER_TO_INNER9,
HK_SWITCH_LAYER_TO_INNER10,
HK_SWITCH_LAYER_TO_INNER11,
HK_SWITCH_LAYER_TO_INNER12,
HK_SWITCH_LAYER_TO_INNER13,
HK_SWITCH_LAYER_TO_INNER14,
HK_SWITCH_LAYER_TO_COMPONENT
};
if( (g_TabOneLayerMask[ii] & Masque_Layer) ) if( (g_TabOneLayerMask[ii] & Masque_Layer) )
{ {
m_SelLayerBox->Append( ReturnPcbLayerName( ii, false, true ) ); wxString msg = ReturnPcbLayerName( ii, false );
msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr, HK_SwitchLayer[ii] );
m_SelLayerBox->Append( msg );
m_SelLayerBox->SetClientData( jj, (void*) ii ); m_SelLayerBox->SetClientData( jj, (void*) ii );
jj++; jj++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment