From e27d3f8c781345ee55ca25fe057a6207a9a05f2e Mon Sep 17 00:00:00 2001 From: CHARRAS Date: Thu, 6 Sep 2007 11:52:26 +0000 Subject: [PATCH] more work on programmable hotkeys. Most of features are ok. --- change_log.txt | 8 ++ common/common.cpp | 17 +---- common/edaappl.cpp | 1 + common/hotkeys_basic.cpp | 150 ++++++++++++++++++++++++++++---------- eeschema/eeconfig.cpp | 16 +--- eeschema/hotkeys.cpp | 79 ++++++++++++++------ eeschema/hotkeys.h | 10 ++- eeschema/onrightclick.cpp | 10 +-- eeschema/tool_lib.cpp | 6 +- eeschema/tool_sch.cpp | 6 +- include/build_version.h | 2 +- include/common.h | 2 +- include/hotkeys_basic.h | 54 +++++++++++++- include/wxstruct.h | 4 +- libs.win | 2 +- pcbnew/hotkeys.cpp | 85 +++++++++++++++------ pcbnew/hotkeys.h | 18 ++++- pcbnew/pcbcfg.cpp | 16 +--- pcbnew/tool_modedit.cpp | 6 +- pcbnew/tool_pcb.cpp | 32 ++++++-- 20 files changed, 365 insertions(+), 159 deletions(-) diff --git a/change_log.txt b/change_log.txt index a216546a22..d7018a1eb6 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,14 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2007-sept-6 UPDATE Jean-Pierre Charras +================================================================================ ++ 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 ================================================================================ diff --git a/common/common.cpp b/common/common.cpp index 488edf981f..51a10d08e8 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -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". @@ -305,21 +305,6 @@ wxString ReturnPcbLayerName( int layer_number, bool is_filename, bool is_gui ) else 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; } diff --git a/common/edaappl.cpp b/common/edaappl.cpp index 6c46e54f72..7de06b85ab 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -26,6 +26,7 @@ #include "worksheet.h" #include "id.h" #include "build_version.h" +#include "hotkeys_basic.h" #include "bitmaps.h" #include "Language.xpm" diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index d3ea61c264..fafda6fb60 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -4,6 +4,7 @@ /* Some functions to handle hotkeys in kicad */ + #include "fctsys.h" #include "common.h" #include "wxstruct.h" @@ -11,7 +12,7 @@ #include "macros.h" /* 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 ) @@ -30,7 +31,8 @@ struct hotkey_name_descr 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( "F2" ), WXK_F2 }, @@ -71,7 +73,7 @@ struct hotkey_name_descr s_Hotkey_Name_List[] = { wxT( "*" ), '*' }, { wxT( "+" ), '+' }, { wxT( "-" ), '-' }, - { wxT( "\%" ), '%' }, + { wxT( "\%" ), '%' }, { wxT( "A" ), 'A' }, { wxT( "B" ), 'B' }, { wxT( "C" ), 'C' }, @@ -136,7 +138,7 @@ wxString ReturnKeyNameFromKeyCode( int keycode ) /* * 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) * @return the key name in a wxString */ @@ -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 ) -/***********************************************************************/ +/*************************************************************************/ /* * return the key name from the Command id value ( m_Idcommand member value) @@ -225,7 +259,7 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname ) /* * return the key code from its key name * 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 */ { @@ -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 - * @param frame = current open frame - * @param List = pointer to a Ki_HotkeyInfo list of commands + * @param frame = current active frame + * @param List = pointer to a Ki_HotkeyInfoSectionDescriptor list (Null terminated) * @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; - msg += _( "key " ); - keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); - msg += keyname + wxT( ": " ) + hk_decr->m_InfoMsg + wxT( "\n" ); + List = DescList->m_HK_InfoList; + for( ; *List != NULL; List++ ) + { + 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 ); @@ -296,8 +335,9 @@ int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List ) /*************************************************************************/ -int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename, - Ki_HotkeyInfo** List, bool verbose ) +int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename, + struct Ki_HotkeyInfoSectionDescriptor* DescList, + bool verbose ) /*************************************************************************/ /* @@ -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() ) msg += wxT( "\n" ); msg += wxT( "#\n#\n" ); fprintf( cfgfile, CONV_TO_UTF8( msg ) ); - /* Print the current list */ - for( ; *List != NULL; List++ ) + /* Print the current hotkey list */ + Ki_HotkeyInfo** List; + for( ; DescList->m_HK_InfoList != NULL; DescList++ ) { - 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 ) ); + if( DescList->m_Comment ) + { + fprintf( cfgfile, "# " ); + fprintf( cfgfile, DescList->m_Comment ); + fprintf( cfgfile, "\n" ); + } + fprintf( cfgfile, CONV_TO_UTF8( *DescList->m_SectionTag ) ); + 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" ); @@ -398,16 +451,18 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename, /********************************************************************************************/ -int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& Filename, - Ki_HotkeyInfo** CurrentHotkeyList, bool verbose ) +int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& Filename, + struct Ki_HotkeyInfoSectionDescriptor* DescList, + bool verbose ) /********************************************************************************************/ /* * Read a configuration 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 CurrentHotkeyList = current hotkey list to initialise. + * @param DescList = current hotkey list descr. to initialise. * the input format is: shortcut "key" "function" * 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, return 0; } - wxString keyname; - char Line[1024]; - int LineNum = 0; + wxString keyname; + char Line[1024]; + int LineNum = 0; + Ki_HotkeyInfo** CurrentHotkeyList = NULL; + /* Read the file */ while( GetLine( cfgfile, Line, &LineNum ) != NULL ) { char* line_type, * keyname, * fctname; line_type = strtok( Line, " \t\n\r" ); 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" ) ) continue; if( msg == wxT( "$Endlist" ) ) break; + if( CurrentHotkeyList == NULL ) + continue; /* Get the key name */ strtok( NULL, "\"\n\r" ); diff --git a/eeschema/eeconfig.cpp b/eeschema/eeconfig.cpp index b1f7a36864..7460f18121 100644 --- a/eeschema/eeconfig.cpp +++ b/eeschema/eeconfig.cpp @@ -11,12 +11,10 @@ #include "eeconfig.h" #include "worksheet.h" #include "hotkeys_basic.h" +#include "hotkeys.h" #include "id.h" -extern Ki_HotkeyInfo *s_Schematic_Hotkey_List[]; -extern Ki_HotkeyInfo *s_LibEdit_Hotkey_List[]; - /* Variables locales */ @@ -80,11 +78,7 @@ wxString FullFileName; FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; FullFileName += wxT("eeschema"); FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - WriteHotkeyConfigFile(FullFileName, s_Schematic_Hotkey_List, true); - FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; - FullFileName += wxT("libedit"); - FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - WriteHotkeyConfigFile(FullFileName, s_LibEdit_Hotkey_List, true); + WriteHotkeyConfigFile(FullFileName, s_Eeschema_Hokeys_Descr, true); break; case ID_PREFERENCES_READ_CONFIG_HOTKEYS: @@ -107,11 +101,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ) wxString FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; FullFileName += wxT("eeschema"); FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - frame->ReadHotkeyConfigFile(FullFileName, s_Schematic_Hotkey_List, verbose); - FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; - FullFileName += wxT("libedit"); - FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - frame->ReadHotkeyConfigFile(FullFileName, s_LibEdit_Hotkey_List, verbose); + frame->ReadHotkeyConfigFile(FullFileName, s_Eeschema_Hokeys_Descr, verbose); return TRUE; } diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 69fe6317b5..913f66346e 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -24,7 +24,8 @@ * "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. * 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. * 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 @@ -38,6 +39,15 @@ /* local variables */ /* 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 HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' ); static Ki_HotkeyInfo HkMirrorYComponent( wxT( @@ -54,19 +64,24 @@ static Ki_HotkeyInfo HkMove2Drag( wxT( HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' ); 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 HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' ); 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 ); -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, '?' ); + +// Library editor: +static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT ); + + +// List of common hotkey descriptors +Ki_HotkeyInfo* s_Common_Hotkey_List[] = +{ + &HkHelp, + &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, + &HkResetLocalCoord, + NULL +}; // List of hotkey descriptors for schematic Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = { - &HkHelp, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkNextSearch, &HkResetLocalCoord, + &HkNextSearch, &HkDelete, &HkInsert, &HkMove2Drag, &HkMoveComponent, &HkAddComponent, &HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, &HkOrientNormalComponent, @@ -74,25 +89,41 @@ Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = { NULL }; -// Library editor: -static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT ); - // List of hotkey descriptors for libray editor Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] = { - &HkHelp, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkResetLocalCoord, &HkInsertPin, 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, 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 */ { @@ -113,7 +144,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, hotkey += 'A' - 'a'; // 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 ) { @@ -123,7 +156,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_HELP: // Display Current hotkey list - DisplayHotkeyList( this, s_Schematic_Hotkey_List ); + DisplayHotkeyList( this, s_Schematic_Hokeys_Descr ); break; case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ @@ -319,7 +352,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, 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 */ { @@ -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 */ if( (hotkey >= 'a') && (hotkey <= 'z') ) 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 ) { @@ -343,7 +378,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_HELP: // Display Current hotkey list - DisplayHotkeyList( this, s_LibEdit_Hotkey_List ); + DisplayHotkeyList( this, s_Libedit_Hokeys_Descr ); break; case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ diff --git a/eeschema/hotkeys.h b/eeschema/hotkeys.h index 59a642b20b..1e124e605b 100644 --- a/eeschema/hotkeys.h +++ b/eeschema/hotkeys.h @@ -27,9 +27,11 @@ enum hotkey_id_commnand { HK_BEGIN_WIRE }; -// List of hotkey descriptors for schematic -extern Ki_HotkeyInfo* s_Schematic_Hotkey_List[]; -// List of hotkey descriptors for libray editor -extern Ki_HotkeyInfo* s_LibEdit_Hotkey_List[]; +// List of hotkey descriptors for eeschema +extern struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[]; +// List of hotkey descriptors for the schematic editor only +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 diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 4300974ac3..7b18d01529 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -281,22 +281,22 @@ void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component ) 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, msg, move_xpm ); } // add menu orient et sous menu: 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, msg, rotate_pos_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 ); - 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 ); - 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_WITH_SUBMENU( PopMenu, orientmenu, ID_POPUP_SCH_GENERIC_ORIENT_CMP, _( diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 8f964774d0..95b2fba34f 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -167,15 +167,15 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() _( "Test duplicate pins" ) ); 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 ), 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 ), 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 ), msg ); diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index 8ab2667f84..578691a875 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -104,15 +104,15 @@ void WinEDA_SchematicFrame::ReCreateHToolbar() _( "Run Pcbnew" ) ); 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 ), 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 ), 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 ), msg ); diff --git a/include/build_version.h b/include/build_version.h index 05e18d33fc..90a3c4004c 100644 --- a/include/build_version.h +++ b/include/build_version.h @@ -5,7 +5,7 @@ COMMON_GLOBL wxString g_BuildVersion #ifdef EDA_BASE - (wxT("(2007-08-30)")) + (wxT("(2007-09-06)")) #endif ; diff --git a/include/common.h b/include/common.h index e4b6848382..dcb7d378da 100644 --- a/include/common.h +++ b/include/common.h @@ -345,7 +345,7 @@ class WinEDA_DrawPanel; /* 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". if "is_filename" == TRUE, the name can be used for a file name (not internatinalized, no space)*/ diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index e14ff52885..74d3d25225 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -8,6 +8,10 @@ #ifndef HOTKEYS_BASIC_H #define HOTKEYS_BASIC_H +#ifndef COMMON_GLOBL +#define COMMON_GLOBL extern +#endif + #define DEFAULT_HOTKEY_FILENAME_EXT wxT( ".key" ) /* define default path for config key file */ @@ -32,12 +36,60 @@ public: 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: */ wxString ReturnKeyNameFromKeyCode( int keycode ); wxString ReturnKeyNameFromCommandId( 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 ); diff --git a/include/wxstruct.h b/include/wxstruct.h index a9784c2683..4599063229 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -177,8 +177,8 @@ public: void PrintMsg( const wxString& text ); void GetSettings(); void SaveSettings(); - int WriteHotkeyConfigFile(const wxString & Filename, Ki_HotkeyInfo ** List, bool verbose); - int ReadHotkeyConfigFile(const wxString & Filename, Ki_HotkeyInfo ** List, bool verbose); + int WriteHotkeyConfigFile(const wxString & Filename, struct Ki_HotkeyInfoSectionDescriptor * DescList, bool verbose); + int ReadHotkeyConfigFile(const wxString & Filename, struct Ki_HotkeyInfoSectionDescriptor * DescList, bool verbose); void SetLanguage( wxCommandEvent& event ); void ProcessFontPreferences( int id ); diff --git a/libs.win b/libs.win index a596284328..2811bb369d 100644 --- a/libs.win +++ b/libs.win @@ -17,7 +17,7 @@ KICAD_BIN = /f/kicad/winexe #Define the wxWidget path (if not found in environment variables): ifndef WXWIN -WXWIN=f:/wxMSW-2.8.4 +WXWIN=f:/wxMSW-2.8.5 endif LIBVERSION = 2.8 diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index ba1a505cf2..990e8be6f0 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -26,7 +26,7 @@ * 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.) * - * 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) * and see this list for some ascii keys (space ...) */ @@ -35,10 +35,10 @@ /* Hotkey list: */ static Ki_HotkeyInfo HkSwitch2CopperLayer( wxT( "Switch to Copper layer" ), - HK_SWITCH_LAYER_TO_COPPER, '-' ); + HK_SWITCH_LAYER_TO_COPPER, WXK_PAGEUP ); static Ki_HotkeyInfo HkSwitch2ComponentLayer( wxT( "Switch to Component layer" ), - HK_SWITCH_LAYER_TO_COMPONENT, '+' ); + HK_SWITCH_LAYER_TO_COMPONENT, WXK_PAGEDOWN ); static Ki_HotkeyInfo HkSwitch2InnerLayer1( wxT( "Switch to Inner layer 1" ), HK_SWITCH_LAYER_TO_INNER1, WXK_F5 ); @@ -58,6 +58,13 @@ static Ki_HotkeyInfo HkSwitch2InnerLayer6( wxT( "Switch to Inner layer 6" ), 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 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 ); @@ -83,12 +90,17 @@ static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ), 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 Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = { - &HkHelp, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkResetLocalCoord, &HkSwitchUnits, &HkTrackDisplayMode, + &HkTrackDisplayMode, &HkDelete, &HkBackspace, &HkAddVia, &HkEndTrack, &HkMoveFootprint, &HkFlipFootprint, @@ -103,19 +115,41 @@ Ki_HotkeyInfo* s_board_edit_Hotkey_List[] = { &HkSwitch2InnerLayer5, &HkSwitch2InnerLayer6, &HkSwitch2ComponentLayer, + &HkSwitch2NextCopperLayer, + &HkSwitch2PreviousCopperLayer, NULL }; // List of hotkey descriptors for the module editor Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = { - &HkHelp, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkSwitchUnits, &HkResetLocalCoord, - &HkDelete, &HkBackspace, 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, EDA_BaseStruct* DrawStruct ) @@ -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 * Commands are case insensitive - * Zoom commands are not managed here * @param DC = current device context * @param hotkey = hothey code (ascii or wxWidget code for special keys) * @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, if( (hotkey >= 'a') && (hotkey <= 'z') ) 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; switch( CommandCode ) @@ -218,7 +253,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_HELP: // Display Current hotkey list - DisplayHotkeyList( this, s_board_edit_Hotkey_List ); + DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr ); break; case HK_ZOOM_IN: @@ -434,9 +469,8 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ) /***********************************************************/ -/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element - * sous le courseur souris - * Les majuscules/minuscules sont indifferenciees +/* Hot keys. Some commands are relative to the item under the mouse cursor + * Commands are case insensitive */ { if( hotkey == 0 ) @@ -446,7 +480,9 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, if( (hotkey >= 'a') && (hotkey <= 'z') ) 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 ) { @@ -456,7 +492,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, break; case HK_HELP: // Display Current hotkey list - DisplayHotkeyList( this, s_module_edit_Hotkey_List ); + DisplayHotkeyList( this, s_Module_Editor_Hokeys_Descr ); break; case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ @@ -491,12 +527,13 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey, bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) /******************************************************************************/ -/* Efface l'item pointe par la souris, en reponse a la touche "Del" - * Effet dependant de l'outil selectionne: - * Outil trace de pistes - * Efface le segment en cours ou la piste si pas d'element - * Outil module: - * Efface le module. +/* Delete the item foun under the mouse cursor + * Depending on the current active tool:: + * Tool track + * if a track is in progress: Delete the last segment + * else delete the entire track + * Tool module (footprint): + * Delete the module. */ { bool ItemFree = (GetScreen()->GetCurItem() == NULL ) diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index c315e61c25..4ce1100c85 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -34,12 +34,22 @@ enum hotkey_id_commnand { HK_SWITCH_LAYER_TO_INNER3, HK_SWITCH_LAYER_TO_INNER4, 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 -extern Ki_HotkeyInfo* s_board_edit_Hotkey_List[]; -// List of hotkey descriptors for the module editor -extern Ki_HotkeyInfo* s_module_edit_Hotkey_List[]; +extern struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[]; +// List of hotkey descriptors for the board editor only +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 diff --git a/pcbnew/pcbcfg.cpp b/pcbnew/pcbcfg.cpp index 82ff04e897..45a76af361 100644 --- a/pcbnew/pcbcfg.cpp +++ b/pcbnew/pcbcfg.cpp @@ -13,12 +13,10 @@ #include "worksheet.h" #include "id.h" #include "hotkeys_basic.h" +#include "hotkeys.h" #include "protos.h" -extern Ki_HotkeyInfo *s_board_edit_Hotkey_List[]; -extern Ki_HotkeyInfo *s_module_edit_Hotkey_List[]; - /* Routines Locales */ /* Variables locales */ @@ -89,11 +87,7 @@ wxString FullFileName; FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; FullFileName += wxT("pcbnew"); FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - WriteHotkeyConfigFile(FullFileName, s_board_edit_Hotkey_List, true); - FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; - FullFileName += wxT("module_edit"); - FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - WriteHotkeyConfigFile(FullFileName, s_module_edit_Hotkey_List, true); + WriteHotkeyConfigFile(FullFileName, s_Pcbnew_Editor_Hokeys_Descr, true); break; case ID_PREFERENCES_READ_CONFIG_HOTKEYS: @@ -116,11 +110,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ) wxString FullFileName = DEFAULT_HOTKEY_FILENAME_PATH; FullFileName += wxT("pcbnew"); FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; - frame->ReadHotkeyConfigFile(FullFileName, s_board_edit_Hotkey_List, 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); + return frame->ReadHotkeyConfigFile(FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose); } diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index a4a3d12e5b..ffc5893b16 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -112,15 +112,15 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() _( "Print Module" ) ); 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 ), 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 ), 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 ), msg ); diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 9d5ba27567..217cf89cb6 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -267,15 +267,15 @@ void WinEDA_PcbFrame::ReCreateHToolbar() _( "Plot (HPGL, PostScript, or GERBER format)" ) ); 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 ), 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 ), 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 ), msg ); @@ -283,7 +283,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() _( "auto zoom" ) ); 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 ), msg ); @@ -643,9 +643,31 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) m_SelLayerBox->Clear(); 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) ) { - 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 ); jj++; }