Loading common/dialogs/dialog_hotkeys_editor.cpp +28 −15 Original line number Original line Diff line number Diff line /* /** dialog_hotkeys_editor.cpp * @file dialog_hotkeys_editor.cpp */ */ /* /* * This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application. * * Loading Loading @@ -32,8 +33,7 @@ dialog_hotkeys_editor.cpp #include "dialog_hotkeys_editor.h" #include "dialog_hotkeys_editor.h" void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, EDA_HOTKEY_CONFIG* hotkeys ) Ki_HotkeyInfoSectionDescriptor* hotkeys ) { { HOTKEYS_EDITOR_DIALOG dialog( parent, hotkeys ); HOTKEYS_EDITOR_DIALOG dialog( parent, hotkeys ); Loading @@ -47,7 +47,7 @@ void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, Ki_HotkeyInfoSectionDescriptor* hotkeys ) : EDA_HOTKEY_CONFIG* hotkeys ) : HOTKEYS_EDITOR_DIALOG_BASE( parent ) HOTKEYS_EDITOR_DIALOG_BASE( parent ) { { m_parent = parent; m_parent = parent; Loading Loading @@ -78,18 +78,21 @@ void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event ) /* edit the live hotkey table */ /* edit the live hotkey table */ HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys(); HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys(); Ki_HotkeyInfoSectionDescriptor* section; EDA_HOTKEY_CONFIG* section; for( section = m_hotkeys; section->m_HK_InfoList; section++ ) for( section = m_hotkeys; section->m_HK_InfoList; section++ ) { { wxString sectionTag = *section->m_SectionTag; wxString sectionTag = *section->m_SectionTag; Ki_HotkeyInfo** info_ptr; EDA_HOTKEY** info_ptr; for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) { { Ki_HotkeyInfo* info = *info_ptr; EDA_HOTKEY* info = *info_ptr; /* find the corresponding hotkey */ /* find the corresponding hotkey */ HotkeyGridTable::hotkey_spec_vector::iterator i; HotkeyGridTable::hotkey_spec_vector::iterator i; for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i ) for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i ) { { if( i->first == sectionTag if( i->first == sectionTag Loading Loading @@ -122,6 +125,7 @@ void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& event ) { { m_table->RestoreFrom( m_hotkeys ); m_table->RestoreFrom( m_hotkeys ); m_curEditingRow = -1; m_curEditingRow = -1; for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i ) for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i ) SetHotkeyCellState( i, false ); SetHotkeyCellState( i, false ); Loading Loading @@ -153,6 +157,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event ) SetHotkeyCellState( m_curEditingRow, false ); SetHotkeyCellState( m_curEditingRow, false ); int newRow = event.GetRow(); int newRow = event.GetRow(); if( ( event.GetCol() != 1 ) || ( m_table->isHeader( newRow ) ) ) if( ( event.GetCol() != 1 ) || ( m_table->isHeader( newRow ) ) ) { { m_curEditingRow = -1; m_curEditingRow = -1; Loading @@ -166,6 +171,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event ) Update(); Update(); } } /** OnRightClickOnCell /** OnRightClickOnCell * If a cell is selected, display a list of keys for selection * If a cell is selected, display a list of keys for selection * The list is restricted to keys that cannot be entered: * The list is restricted to keys that cannot be entered: Loading Loading @@ -194,18 +200,19 @@ void HOTKEYS_EDITOR_DIALOG::OnRightClickOnCell( wxGridEvent& event ) wxT("Alt+Space"), wxT("Alt+Space"), }; }; wxString keyname = wxGetSingleChoice( wxString keyname = wxGetSingleChoice( _( "Special keys only. For others keys, use keyboard" ), _("Special keys only. For others keys, use keyboard"), _( "Select a key" ), C_COUNT, choices, this ); _( "Select a key" ), C_COUNT, choices, this ); int key = ReturnKeyCodeFromKeyName( keyname ); int key = ReturnKeyCodeFromKeyName( keyname ); if( key == 0 ) if( key == 0 ) return; return; m_table->SetKeyCode( m_curEditingRow, key ); m_table->SetKeyCode( m_curEditingRow, key ); m_hotkeyGrid->Refresh(); m_hotkeyGrid->Refresh(); Update(); Update(); } } void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) { { if( m_curEditingRow != -1 ) if( m_curEditingRow != -1 ) Loading @@ -222,8 +229,10 @@ void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) default: default: if( event.ControlDown() ) if( event.ControlDown() ) key |= GR_KB_CTRL; key |= GR_KB_CTRL; if( event.AltDown() ) if( event.AltDown() ) key |= GR_KB_ALT; key |= GR_KB_ALT; if( event.ShiftDown() && (key > 256) ) if( event.ShiftDown() && (key > 256) ) key |= GR_KB_SHIFT; key |= GR_KB_SHIFT; Loading @@ -243,12 +252,16 @@ void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) // See if this key code is handled in hotkeys names list // See if this key code is handled in hotkeys names list bool exists; bool exists; ReturnKeyNameFromKeyCode( key, &exists ); ReturnKeyNameFromKeyCode( key, &exists ); if( !exists ) // not handled, see hotkeys_basic.cpp if( !exists ) // not handled, see hotkeys_basic.cpp { wxMessageBox( _( "Hotkey code not handled" ) ); wxMessageBox( _( "Hotkey code not handled" ) ); } else else { { m_table->SetKeyCode( m_curEditingRow, key ); m_table->SetKeyCode( m_curEditingRow, key ); } } break; break; } } } } Loading common/hotkey_grid_table.cpp +12 −13 Original line number Original line Diff line number Diff line Loading @@ -4,24 +4,23 @@ * Reads the hotkey table from its stored format into a format suitable * Reads the hotkey table from its stored format into a format suitable * for a wxGrid. * for a wxGrid. */ */ HotkeyGridTable::HotkeyGridTable( struct HotkeyGridTable::HotkeyGridTable( struct EDA_HOTKEY_CONFIG* origin ) : Ki_HotkeyInfoSectionDescriptor* origin ) : wxGridTableBase(), wxGridTableBase(), m_hotkeys() m_hotkeys() { { Ki_HotkeyInfoSectionDescriptor* section; EDA_HOTKEY_CONFIG* section; for( section = origin; section->m_HK_InfoList; section++ ) for( section = origin; section->m_HK_InfoList; section++ ) { { hotkey_spec spec( *section->m_SectionTag, new Ki_HotkeyInfo( NULL, 0, 0 ) ); hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( NULL, 0, 0 ) ); m_hotkeys.push_back( spec ); m_hotkeys.push_back( spec ); Ki_HotkeyInfo** info_ptr; EDA_HOTKEY** info_ptr; for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) { { Ki_HotkeyInfo* info = *info_ptr; EDA_HOTKEY* info = *info_ptr; hotkey_spec spec( *section->m_SectionTag, hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( info ) ); new Ki_HotkeyInfo( info ) ); m_hotkeys.push_back( spec ); m_hotkeys.push_back( spec ); } } } } Loading Loading @@ -165,19 +164,19 @@ void HotkeyGridTable::SetKeyCode( int row, long key ) } } void HotkeyGridTable::RestoreFrom( struct void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin ) Ki_HotkeyInfoSectionDescriptor* origin ) { { int row = 0; int row = 0; Ki_HotkeyInfoSectionDescriptor* section; EDA_HOTKEY_CONFIG* section; for( section = origin; section->m_HK_InfoList; section++ ) for( section = origin; section->m_HK_InfoList; section++ ) { { ++row; ++row; Ki_HotkeyInfo** info_ptr; EDA_HOTKEY** info_ptr; for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) { { Ki_HotkeyInfo* info = *info_ptr; EDA_HOTKEY* info = *info_ptr; m_hotkeys[row++].second->m_KeyCode = info->m_KeyCode; m_hotkeys[row++].second->m_KeyCode = info->m_KeyCode; } } } } Loading common/hotkeys_basic.cpp +61 −55 Original line number Original line Diff line number Diff line /*********************/ /** /* hotkeys_basic.cpp */ * @file hotkeys_basic.cpp /*********************/ */ /* Some functions to handle hotkeys in kicad /* Some functions to handle hotkeys in kicad */ */ Loading Loading @@ -34,8 +34,7 @@ wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) ); * file. * file. */ */ Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent ) int keycode, int idmenuevent ) { { m_KeyCode = keycode; // Key code (ascii value for ascii keys m_KeyCode = keycode; // Key code (ascii value for ascii keys // or wxWidgets code for function key // or wxWidgets code for function key Loading @@ -47,7 +46,7 @@ Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, } } Ki_HotkeyInfo::Ki_HotkeyInfo( const Ki_HotkeyInfo* base ) EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base ) { { m_KeyCode = base->m_KeyCode; m_KeyCode = base->m_KeyCode; m_InfoMsg = base->m_InfoMsg; m_InfoMsg = base->m_InfoMsg; Loading Loading @@ -154,6 +153,7 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) keyname = wxT( "<unknown>" ); keyname = wxT( "<unknown>" ); break; break; } } if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode ) if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode ) { { keyname = s_Hotkey_Name_List[ii].m_Name; keyname = s_Hotkey_Name_List[ii].m_Name; Loading @@ -173,8 +173,8 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) /* /* * helper function use in AddHotkeyName to calculate an accelerator string * helper function use in AddHotkeyName to calculate an accelerator string * In some menus, accelerators do not perform exactely the same action as * In some menus, accelerators do not perform exactly the same action as * the hotkey that perfoms a similar action. * the hotkey that perform a similar action. * this is usually the case when this action uses the current mouse position * this is usually the case when this action uses the current mouse position * for instance zoom action is ran from the F1 key or the Zoom menu. * for instance zoom action is ran from the F1 key or the Zoom menu. * a zoom uses the mouse position from a hot key and not from the menu * a zoom uses the mouse position from a hot key and not from the menu Loading @@ -199,14 +199,14 @@ static void AddModifierToKey( wxString& aFullKey, const wxString & aKey ) /* AddHotkeyName /* AddHotkeyName * Add the key name from the Command id value ( m_Idcommand member value) * Add the key name from the Command id value ( m_Idcommand member value) * aText = a wxString. returns aText + key name * aText = a wxString. returns aText + key name * aList = pointer to a Ki_HotkeyInfo list of commands * aList = pointer to a EDA_HOTKEY list of commands * aCommandId = Command Id value * aCommandId = Command Id value * aShortCutType = IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys) * aShortCutType = IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys) * IS_ACCELERATOR to add <tab><Shift+keyname> (accelerators in menus, not hotkeys) * IS_ACCELERATOR to add <tab><Shift+keyname> (accelerators in menus, not hotkeys) * IS_COMMENT to add <spaces><(keyname)> mainly in tool tips * IS_COMMENT to add <spaces><(keyname)> mainly in tool tips * Return a wxString (aTest + key name) if key found or aText without modification * Return a wxString (aTest + key name) if key found or aText without modification */ */ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) { { wxString msg = aText; wxString msg = aText; Loading @@ -222,9 +222,11 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, case IS_HOTKEY: case IS_HOTKEY: msg << wxT( "\t" ) << keyname; msg << wxT( "\t" ) << keyname; break; break; case IS_ACCELERATOR: case IS_ACCELERATOR: AddModifierToKey( msg, keyname ); AddModifierToKey( msg, keyname ); break; break; case IS_COMMENT: case IS_COMMENT: msg << wxT( " (" ) << keyname << wxT( ")" ); msg << wxT( " (" ) << keyname << wxT( ")" ); break; break; Loading @@ -238,7 +240,7 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, /* AddHotkeyName /* AddHotkeyName * Add the key name from the Command id value ( m_Idcommand member value) * Add the key name from the Command id value ( m_Idcommand member value) * aText = a wxString. returns aText + key name * aText = a wxString. returns aText + key name * aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands * aList = pointer to a EDA_HOTKEY_CONFIG DescrList of commands * aCommandId = Command Id value * aCommandId = Command Id value * aShortCutType = IS_HOTKEY to add <tab><keyname> (active shortcuts in menus) * aShortCutType = IS_HOTKEY to add <tab><keyname> (active shortcuts in menus) * IS_ACCELERATOR to add <tab><Shift+keyname> (active accelerators in menus) * IS_ACCELERATOR to add <tab><Shift+keyname> (active accelerators in menus) Loading @@ -246,13 +248,13 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, * Return a wxString (aText + key name) if key found or aText without modification * Return a wxString (aText + key name) if key found or aText without modification */ */ wxString AddHotkeyName( const wxString& aText, wxString AddHotkeyName( const wxString& aText, struct Ki_HotkeyInfoSectionDescriptor* aDescList, struct EDA_HOTKEY_CONFIG* aDescList, int aCommandId, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) HOTKEY_ACTION_TYPE aShortCutType ) { { wxString msg = aText; wxString msg = aText; wxString keyname; wxString keyname; Ki_HotkeyInfo** List; EDA_HOTKEY** List; if( aDescList ) if( aDescList ) { { Loading @@ -268,9 +270,11 @@ wxString AddHotkeyName( const wxString& aText, case IS_HOTKEY: case IS_HOTKEY: msg << wxT( "\t" ) << keyname; msg << wxT( "\t" ) << keyname; break; break; case IS_ACCELERATOR: case IS_ACCELERATOR: AddModifierToKey( msg, keyname ); AddModifierToKey( msg, keyname ); break; break; case IS_COMMENT: case IS_COMMENT: msg << wxT( " (" ) << keyname << wxT( ")" ); msg << wxT( " (" ) << keyname << wxT( ")" ); break; break; Loading @@ -287,17 +291,17 @@ wxString AddHotkeyName( const wxString& aText, /** /** * Function ReturnKeyNameFromCommandId * Function ReturnKeyNameFromCommandId * 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) * @param aList = pointer to a Ki_HotkeyInfo list of commands * @param aList = pointer to a EDA_HOTKEY list of commands * @param aCommandId = Command Id value * @param aCommandId = Command Id value * @return the key name in a wxString * @return the key name in a wxString */ */ wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** aList, int aCommandId ) wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId ) { { wxString keyname; wxString keyname; for( ; *aList != NULL; aList++ ) for( ; *aList != NULL; aList++ ) { { Ki_HotkeyInfo* hk_decr = *aList; EDA_HOTKEY* hk_decr = *aList; if( hk_decr->m_Idcommand == aCommandId ) if( hk_decr->m_Idcommand == aCommandId ) { { Loading Loading @@ -373,13 +377,12 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname ) /* DisplayHotkeyList /* DisplayHotkeyList * Displays the current hotkey list * Displays the current hotkey list * aList = a Ki_HotkeyInfoSectionDescriptor list(Null terminated) * aList = a EDA_HOTKEY_CONFIG list(Null terminated) */ */ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList ) struct Ki_HotkeyInfoSectionDescriptor* aDescList ) { { wxString keyname; wxString keyname; Ki_HotkeyInfo** List; EDA_HOTKEY** List; wxString msg = wxT( "<html><body bgcolor=\"#E2E2E2\">" ); wxString msg = wxT( "<html><body bgcolor=\"#E2E2E2\">" ); Loading @@ -393,7 +396,8 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, for( ; *List != NULL; List++ ) for( ; *List != NULL; List++ ) { { Ki_HotkeyInfo* hk_decr = *List; EDA_HOTKEY* hk_decr = *List; if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) ) if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) ) { { keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); Loading @@ -410,16 +414,17 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, /** /** * Function GetDescriptorFromHotkey * Function GetDescriptorFromHotkey * Return a Ki_HotkeyInfo * pointer fron a key code for OnHotKey() function * Return a EDA_HOTKEY * pointer from a key code for OnHotKey() function * @param aKey = key code (ascii value, or wxWidgets value for function keys * @param aKey = key code (ascii value, or wxWidgets value for function keys * @param aList = pointer to a Ki_HotkeyInfo list of commands * @param aList = pointer to a EDA_HOTKEY list of commands * @return the corresponding Ki_HotkeyInfo pointer from the Ki_HotkeyInfo List * @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List */ */ Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList ) EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList ) { { for( ; *aList != NULL; aList++ ) for( ; *aList != NULL; aList++ ) { { Ki_HotkeyInfo* hk_decr = *aList; EDA_HOTKEY* hk_decr = *aList; if( hk_decr->m_KeyCode == aKey ) if( hk_decr->m_KeyCode == aKey ) return hk_decr; return hk_decr; } } Loading @@ -434,12 +439,12 @@ Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList ) * It is stored using the standard wxConfig mechanism or a file. * It is stored using the standard wxConfig mechanism or a file. * * * @param aDescList = pointer to the current hotkey list. * @param aDescList = pointer to the current hotkey list. * @param aFullFileName = a wxString pointer to a fuill file name. * @param aFullFileName = a wxString pointer to a full file name. * if NULL, use the standard wxConfig mechanism (default) * if NULL, use the standard wxConfig mechanism (default) * the output format is: shortcut "key" "function" * the output format is: shortcut "key" "function" * lines starting with # are comments * lines starting with # are comments */ */ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList, int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName ) wxString* aFullFileName ) { { wxString msg; wxString msg; Loading @@ -448,7 +453,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD msg = wxT( "$hotkey list\n" ); msg = wxT( "$hotkey list\n" ); /* Print the current hotkey list */ /* Print the current hotkey list */ Ki_HotkeyInfo** List; EDA_HOTKEY** List; for( ; aDescList->m_HK_InfoList != NULL; aDescList++ ) for( ; aDescList->m_HK_InfoList != NULL; aDescList++ ) { { Loading @@ -466,7 +471,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD for( ; *List != NULL; List++ ) for( ; *List != NULL; List++ ) { { Ki_HotkeyInfo* hk_decr = *List; EDA_HOTKEY* hk_decr = *List; msg += wxT( "shortcut " ); msg += wxT( "shortcut " ); keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); AddDelimiterString( keyname ); AddDelimiterString( keyname ); Loading Loading @@ -510,7 +515,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD * @param aDescList = current hotkey list descr. to initialise. * @param aDescList = current hotkey list descr. to initialise. */ */ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename, int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename, struct Ki_HotkeyInfoSectionDescriptor* aDescList ) struct EDA_HOTKEY_CONFIG* aDescList ) { { wxFile cfgfile( aFilename ); wxFile cfgfile( aFilename ); Loading @@ -534,8 +539,7 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& return 1; return 1; } } void ReadHotkeyConfig( const wxString& Appname, void ReadHotkeyConfig( const wxString& Appname, struct EDA_HOTKEY_CONFIG* aDescList ) struct Ki_HotkeyInfoSectionDescriptor* aDescList ) { { wxConfig config( Appname ); wxConfig config( Appname ); Loading @@ -553,9 +557,9 @@ void ReadHotkeyConfig( const wxString& Appname, /* Function ReadHotkeyConfig /* Function ReadHotkeyConfig * Read configuration data and fill the current hotkey list with hotkeys * Read configuration data and fill the current hotkey list with hotkeys * aDescList is the current hotkey list descr. to initialise. * aDescList is the current hotkey list descr. to initialize. */ */ int EDA_BASE_FRAME::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList ) int EDA_BASE_FRAME::ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList ) { { ::ReadHotkeyConfig( m_FrameName, aDescList ); ::ReadHotkeyConfig( m_FrameName, aDescList ); return 1; return 1; Loading @@ -568,11 +572,11 @@ int EDA_BASE_FRAME::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDe * lines like [xxx] are tags (example: [common] or [libedit] which identify sections * lines like [xxx] are tags (example: [common] or [libedit] which identify sections */ */ void ParseHotkeyConfig( const wxString& data, void ParseHotkeyConfig( const wxString& data, struct Ki_HotkeyInfoSectionDescriptor* aDescList ) struct EDA_HOTKEY_CONFIG* aDescList ) { { /* Read the config */ /* Read the config */ wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK ); wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK ); Ki_HotkeyInfo** CurrentHotkeyList = 0; EDA_HOTKEY** CurrentHotkeyList = 0; while( tokenizer.HasMoreTokens() ) while( tokenizer.HasMoreTokens() ) { { Loading @@ -580,13 +584,14 @@ void ParseHotkeyConfig( const wxString& data, wxStringTokenizer lineTokenizer( line ); wxStringTokenizer lineTokenizer( line ); wxString line_type = lineTokenizer.GetNextToken(); wxString line_type = lineTokenizer.GetNextToken(); if( line_type[0] == '#' ) //comment if( line_type[0] == '#' ) //comment continue; continue; if( line_type[0] == '[' ) // A tag is found. search infos in list if( line_type[0] == '[' ) // A tag is found. search infos in list { { CurrentHotkeyList = 0; CurrentHotkeyList = 0; Ki_HotkeyInfoSectionDescriptor* DList = aDescList; EDA_HOTKEY_CONFIG* DList = aDescList; for( ; DList->m_HK_InfoList; DList++ ) for( ; DList->m_HK_InfoList; DList++ ) { { Loading Loading @@ -619,9 +624,10 @@ void ParseHotkeyConfig( const wxString& data, wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' ); wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' ); /* search the hotkey in current hotkey list */ /* search the hotkey in current hotkey list */ for( Ki_HotkeyInfo** List = CurrentHotkeyList; *List != NULL; List++ ) for( EDA_HOTKEY** List = CurrentHotkeyList; *List != NULL; List++ ) { { Ki_HotkeyInfo* hk_decr = *List; EDA_HOTKEY* hk_decr = *List; if( hk_decr->m_InfoMsg == fctname ) if( hk_decr->m_InfoMsg == fctname ) { { int code = ReturnKeyCodeFromKeyName( keyname ); int code = ReturnKeyCodeFromKeyName( keyname ); Loading @@ -639,9 +645,9 @@ void ParseHotkeyConfig( const wxString& data, /** /** * Function ImportHotkeyConfigFromFile * Function ImportHotkeyConfigFromFile * Prompt the user for an old hotkey file to read, and read it. * Prompt the user for an old hotkey file to read, and read it. * @param aDescList = current hotkey list descr. to initialise. * @param aDescList = current hotkey list descr. to initialize. */ */ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct Ki_HotkeyInfoSectionDescriptor* aDescList ) void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDescList ) { { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; wxString mask = wxT( "*." ) + ext; Loading @@ -667,9 +673,9 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct Ki_HotkeyInfoSectionDesc /** /** * Function ExportHotkeyConfigToFile * Function ExportHotkeyConfigToFile * Prompt the user for an old hotkey file to read, and read it. * Prompt the user for an old hotkey file to read, and read it. * @param aDescList = current hotkey list descr. to initialise. * @param aDescList = current hotkey list descr. to initialize. */ */ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct Ki_HotkeyInfoSectionDescriptor* aDescList ) void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescList ) { { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; wxString mask = wxT( "*." ) + ext; Loading Loading
common/dialogs/dialog_hotkeys_editor.cpp +28 −15 Original line number Original line Diff line number Diff line /* /** dialog_hotkeys_editor.cpp * @file dialog_hotkeys_editor.cpp */ */ /* /* * This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application. * * Loading Loading @@ -32,8 +33,7 @@ dialog_hotkeys_editor.cpp #include "dialog_hotkeys_editor.h" #include "dialog_hotkeys_editor.h" void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, EDA_HOTKEY_CONFIG* hotkeys ) Ki_HotkeyInfoSectionDescriptor* hotkeys ) { { HOTKEYS_EDITOR_DIALOG dialog( parent, hotkeys ); HOTKEYS_EDITOR_DIALOG dialog( parent, hotkeys ); Loading @@ -47,7 +47,7 @@ void InstallHotkeyFrame( EDA_DRAW_FRAME* parent, HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, Ki_HotkeyInfoSectionDescriptor* hotkeys ) : EDA_HOTKEY_CONFIG* hotkeys ) : HOTKEYS_EDITOR_DIALOG_BASE( parent ) HOTKEYS_EDITOR_DIALOG_BASE( parent ) { { m_parent = parent; m_parent = parent; Loading Loading @@ -78,18 +78,21 @@ void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event ) /* edit the live hotkey table */ /* edit the live hotkey table */ HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys(); HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys(); Ki_HotkeyInfoSectionDescriptor* section; EDA_HOTKEY_CONFIG* section; for( section = m_hotkeys; section->m_HK_InfoList; section++ ) for( section = m_hotkeys; section->m_HK_InfoList; section++ ) { { wxString sectionTag = *section->m_SectionTag; wxString sectionTag = *section->m_SectionTag; Ki_HotkeyInfo** info_ptr; EDA_HOTKEY** info_ptr; for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) { { Ki_HotkeyInfo* info = *info_ptr; EDA_HOTKEY* info = *info_ptr; /* find the corresponding hotkey */ /* find the corresponding hotkey */ HotkeyGridTable::hotkey_spec_vector::iterator i; HotkeyGridTable::hotkey_spec_vector::iterator i; for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i ) for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i ) { { if( i->first == sectionTag if( i->first == sectionTag Loading Loading @@ -122,6 +125,7 @@ void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& event ) { { m_table->RestoreFrom( m_hotkeys ); m_table->RestoreFrom( m_hotkeys ); m_curEditingRow = -1; m_curEditingRow = -1; for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i ) for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i ) SetHotkeyCellState( i, false ); SetHotkeyCellState( i, false ); Loading Loading @@ -153,6 +157,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event ) SetHotkeyCellState( m_curEditingRow, false ); SetHotkeyCellState( m_curEditingRow, false ); int newRow = event.GetRow(); int newRow = event.GetRow(); if( ( event.GetCol() != 1 ) || ( m_table->isHeader( newRow ) ) ) if( ( event.GetCol() != 1 ) || ( m_table->isHeader( newRow ) ) ) { { m_curEditingRow = -1; m_curEditingRow = -1; Loading @@ -166,6 +171,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event ) Update(); Update(); } } /** OnRightClickOnCell /** OnRightClickOnCell * If a cell is selected, display a list of keys for selection * If a cell is selected, display a list of keys for selection * The list is restricted to keys that cannot be entered: * The list is restricted to keys that cannot be entered: Loading Loading @@ -194,18 +200,19 @@ void HOTKEYS_EDITOR_DIALOG::OnRightClickOnCell( wxGridEvent& event ) wxT("Alt+Space"), wxT("Alt+Space"), }; }; wxString keyname = wxGetSingleChoice( wxString keyname = wxGetSingleChoice( _( "Special keys only. For others keys, use keyboard" ), _("Special keys only. For others keys, use keyboard"), _( "Select a key" ), C_COUNT, choices, this ); _( "Select a key" ), C_COUNT, choices, this ); int key = ReturnKeyCodeFromKeyName( keyname ); int key = ReturnKeyCodeFromKeyName( keyname ); if( key == 0 ) if( key == 0 ) return; return; m_table->SetKeyCode( m_curEditingRow, key ); m_table->SetKeyCode( m_curEditingRow, key ); m_hotkeyGrid->Refresh(); m_hotkeyGrid->Refresh(); Update(); Update(); } } void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) { { if( m_curEditingRow != -1 ) if( m_curEditingRow != -1 ) Loading @@ -222,8 +229,10 @@ void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) default: default: if( event.ControlDown() ) if( event.ControlDown() ) key |= GR_KB_CTRL; key |= GR_KB_CTRL; if( event.AltDown() ) if( event.AltDown() ) key |= GR_KB_ALT; key |= GR_KB_ALT; if( event.ShiftDown() && (key > 256) ) if( event.ShiftDown() && (key > 256) ) key |= GR_KB_SHIFT; key |= GR_KB_SHIFT; Loading @@ -243,12 +252,16 @@ void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event ) // See if this key code is handled in hotkeys names list // See if this key code is handled in hotkeys names list bool exists; bool exists; ReturnKeyNameFromKeyCode( key, &exists ); ReturnKeyNameFromKeyCode( key, &exists ); if( !exists ) // not handled, see hotkeys_basic.cpp if( !exists ) // not handled, see hotkeys_basic.cpp { wxMessageBox( _( "Hotkey code not handled" ) ); wxMessageBox( _( "Hotkey code not handled" ) ); } else else { { m_table->SetKeyCode( m_curEditingRow, key ); m_table->SetKeyCode( m_curEditingRow, key ); } } break; break; } } } } Loading
common/hotkey_grid_table.cpp +12 −13 Original line number Original line Diff line number Diff line Loading @@ -4,24 +4,23 @@ * Reads the hotkey table from its stored format into a format suitable * Reads the hotkey table from its stored format into a format suitable * for a wxGrid. * for a wxGrid. */ */ HotkeyGridTable::HotkeyGridTable( struct HotkeyGridTable::HotkeyGridTable( struct EDA_HOTKEY_CONFIG* origin ) : Ki_HotkeyInfoSectionDescriptor* origin ) : wxGridTableBase(), wxGridTableBase(), m_hotkeys() m_hotkeys() { { Ki_HotkeyInfoSectionDescriptor* section; EDA_HOTKEY_CONFIG* section; for( section = origin; section->m_HK_InfoList; section++ ) for( section = origin; section->m_HK_InfoList; section++ ) { { hotkey_spec spec( *section->m_SectionTag, new Ki_HotkeyInfo( NULL, 0, 0 ) ); hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( NULL, 0, 0 ) ); m_hotkeys.push_back( spec ); m_hotkeys.push_back( spec ); Ki_HotkeyInfo** info_ptr; EDA_HOTKEY** info_ptr; for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) { { Ki_HotkeyInfo* info = *info_ptr; EDA_HOTKEY* info = *info_ptr; hotkey_spec spec( *section->m_SectionTag, hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( info ) ); new Ki_HotkeyInfo( info ) ); m_hotkeys.push_back( spec ); m_hotkeys.push_back( spec ); } } } } Loading Loading @@ -165,19 +164,19 @@ void HotkeyGridTable::SetKeyCode( int row, long key ) } } void HotkeyGridTable::RestoreFrom( struct void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin ) Ki_HotkeyInfoSectionDescriptor* origin ) { { int row = 0; int row = 0; Ki_HotkeyInfoSectionDescriptor* section; EDA_HOTKEY_CONFIG* section; for( section = origin; section->m_HK_InfoList; section++ ) for( section = origin; section->m_HK_InfoList; section++ ) { { ++row; ++row; Ki_HotkeyInfo** info_ptr; EDA_HOTKEY** info_ptr; for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) { { Ki_HotkeyInfo* info = *info_ptr; EDA_HOTKEY* info = *info_ptr; m_hotkeys[row++].second->m_KeyCode = info->m_KeyCode; m_hotkeys[row++].second->m_KeyCode = info->m_KeyCode; } } } } Loading
common/hotkeys_basic.cpp +61 −55 Original line number Original line Diff line number Diff line /*********************/ /** /* hotkeys_basic.cpp */ * @file hotkeys_basic.cpp /*********************/ */ /* Some functions to handle hotkeys in kicad /* Some functions to handle hotkeys in kicad */ */ Loading Loading @@ -34,8 +34,7 @@ wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) ); * file. * file. */ */ Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent ) int keycode, int idmenuevent ) { { m_KeyCode = keycode; // Key code (ascii value for ascii keys m_KeyCode = keycode; // Key code (ascii value for ascii keys // or wxWidgets code for function key // or wxWidgets code for function key Loading @@ -47,7 +46,7 @@ Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, } } Ki_HotkeyInfo::Ki_HotkeyInfo( const Ki_HotkeyInfo* base ) EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base ) { { m_KeyCode = base->m_KeyCode; m_KeyCode = base->m_KeyCode; m_InfoMsg = base->m_InfoMsg; m_InfoMsg = base->m_InfoMsg; Loading Loading @@ -154,6 +153,7 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) keyname = wxT( "<unknown>" ); keyname = wxT( "<unknown>" ); break; break; } } if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode ) if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode ) { { keyname = s_Hotkey_Name_List[ii].m_Name; keyname = s_Hotkey_Name_List[ii].m_Name; Loading @@ -173,8 +173,8 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) /* /* * helper function use in AddHotkeyName to calculate an accelerator string * helper function use in AddHotkeyName to calculate an accelerator string * In some menus, accelerators do not perform exactely the same action as * In some menus, accelerators do not perform exactly the same action as * the hotkey that perfoms a similar action. * the hotkey that perform a similar action. * this is usually the case when this action uses the current mouse position * this is usually the case when this action uses the current mouse position * for instance zoom action is ran from the F1 key or the Zoom menu. * for instance zoom action is ran from the F1 key or the Zoom menu. * a zoom uses the mouse position from a hot key and not from the menu * a zoom uses the mouse position from a hot key and not from the menu Loading @@ -199,14 +199,14 @@ static void AddModifierToKey( wxString& aFullKey, const wxString & aKey ) /* AddHotkeyName /* AddHotkeyName * Add the key name from the Command id value ( m_Idcommand member value) * Add the key name from the Command id value ( m_Idcommand member value) * aText = a wxString. returns aText + key name * aText = a wxString. returns aText + key name * aList = pointer to a Ki_HotkeyInfo list of commands * aList = pointer to a EDA_HOTKEY list of commands * aCommandId = Command Id value * aCommandId = Command Id value * aShortCutType = IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys) * aShortCutType = IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys) * IS_ACCELERATOR to add <tab><Shift+keyname> (accelerators in menus, not hotkeys) * IS_ACCELERATOR to add <tab><Shift+keyname> (accelerators in menus, not hotkeys) * IS_COMMENT to add <spaces><(keyname)> mainly in tool tips * IS_COMMENT to add <spaces><(keyname)> mainly in tool tips * Return a wxString (aTest + key name) if key found or aText without modification * Return a wxString (aTest + key name) if key found or aText without modification */ */ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) { { wxString msg = aText; wxString msg = aText; Loading @@ -222,9 +222,11 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, case IS_HOTKEY: case IS_HOTKEY: msg << wxT( "\t" ) << keyname; msg << wxT( "\t" ) << keyname; break; break; case IS_ACCELERATOR: case IS_ACCELERATOR: AddModifierToKey( msg, keyname ); AddModifierToKey( msg, keyname ); break; break; case IS_COMMENT: case IS_COMMENT: msg << wxT( " (" ) << keyname << wxT( ")" ); msg << wxT( " (" ) << keyname << wxT( ")" ); break; break; Loading @@ -238,7 +240,7 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, /* AddHotkeyName /* AddHotkeyName * Add the key name from the Command id value ( m_Idcommand member value) * Add the key name from the Command id value ( m_Idcommand member value) * aText = a wxString. returns aText + key name * aText = a wxString. returns aText + key name * aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands * aList = pointer to a EDA_HOTKEY_CONFIG DescrList of commands * aCommandId = Command Id value * aCommandId = Command Id value * aShortCutType = IS_HOTKEY to add <tab><keyname> (active shortcuts in menus) * aShortCutType = IS_HOTKEY to add <tab><keyname> (active shortcuts in menus) * IS_ACCELERATOR to add <tab><Shift+keyname> (active accelerators in menus) * IS_ACCELERATOR to add <tab><Shift+keyname> (active accelerators in menus) Loading @@ -246,13 +248,13 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, * Return a wxString (aText + key name) if key found or aText without modification * Return a wxString (aText + key name) if key found or aText without modification */ */ wxString AddHotkeyName( const wxString& aText, wxString AddHotkeyName( const wxString& aText, struct Ki_HotkeyInfoSectionDescriptor* aDescList, struct EDA_HOTKEY_CONFIG* aDescList, int aCommandId, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType ) HOTKEY_ACTION_TYPE aShortCutType ) { { wxString msg = aText; wxString msg = aText; wxString keyname; wxString keyname; Ki_HotkeyInfo** List; EDA_HOTKEY** List; if( aDescList ) if( aDescList ) { { Loading @@ -268,9 +270,11 @@ wxString AddHotkeyName( const wxString& aText, case IS_HOTKEY: case IS_HOTKEY: msg << wxT( "\t" ) << keyname; msg << wxT( "\t" ) << keyname; break; break; case IS_ACCELERATOR: case IS_ACCELERATOR: AddModifierToKey( msg, keyname ); AddModifierToKey( msg, keyname ); break; break; case IS_COMMENT: case IS_COMMENT: msg << wxT( " (" ) << keyname << wxT( ")" ); msg << wxT( " (" ) << keyname << wxT( ")" ); break; break; Loading @@ -287,17 +291,17 @@ wxString AddHotkeyName( const wxString& aText, /** /** * Function ReturnKeyNameFromCommandId * Function ReturnKeyNameFromCommandId * 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) * @param aList = pointer to a Ki_HotkeyInfo list of commands * @param aList = pointer to a EDA_HOTKEY list of commands * @param aCommandId = Command Id value * @param aCommandId = Command Id value * @return the key name in a wxString * @return the key name in a wxString */ */ wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** aList, int aCommandId ) wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId ) { { wxString keyname; wxString keyname; for( ; *aList != NULL; aList++ ) for( ; *aList != NULL; aList++ ) { { Ki_HotkeyInfo* hk_decr = *aList; EDA_HOTKEY* hk_decr = *aList; if( hk_decr->m_Idcommand == aCommandId ) if( hk_decr->m_Idcommand == aCommandId ) { { Loading Loading @@ -373,13 +377,12 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname ) /* DisplayHotkeyList /* DisplayHotkeyList * Displays the current hotkey list * Displays the current hotkey list * aList = a Ki_HotkeyInfoSectionDescriptor list(Null terminated) * aList = a EDA_HOTKEY_CONFIG list(Null terminated) */ */ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList ) struct Ki_HotkeyInfoSectionDescriptor* aDescList ) { { wxString keyname; wxString keyname; Ki_HotkeyInfo** List; EDA_HOTKEY** List; wxString msg = wxT( "<html><body bgcolor=\"#E2E2E2\">" ); wxString msg = wxT( "<html><body bgcolor=\"#E2E2E2\">" ); Loading @@ -393,7 +396,8 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, for( ; *List != NULL; List++ ) for( ; *List != NULL; List++ ) { { Ki_HotkeyInfo* hk_decr = *List; EDA_HOTKEY* hk_decr = *List; if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) ) if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) ) { { keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); Loading @@ -410,16 +414,17 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, /** /** * Function GetDescriptorFromHotkey * Function GetDescriptorFromHotkey * Return a Ki_HotkeyInfo * pointer fron a key code for OnHotKey() function * Return a EDA_HOTKEY * pointer from a key code for OnHotKey() function * @param aKey = key code (ascii value, or wxWidgets value for function keys * @param aKey = key code (ascii value, or wxWidgets value for function keys * @param aList = pointer to a Ki_HotkeyInfo list of commands * @param aList = pointer to a EDA_HOTKEY list of commands * @return the corresponding Ki_HotkeyInfo pointer from the Ki_HotkeyInfo List * @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List */ */ Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList ) EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList ) { { for( ; *aList != NULL; aList++ ) for( ; *aList != NULL; aList++ ) { { Ki_HotkeyInfo* hk_decr = *aList; EDA_HOTKEY* hk_decr = *aList; if( hk_decr->m_KeyCode == aKey ) if( hk_decr->m_KeyCode == aKey ) return hk_decr; return hk_decr; } } Loading @@ -434,12 +439,12 @@ Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList ) * It is stored using the standard wxConfig mechanism or a file. * It is stored using the standard wxConfig mechanism or a file. * * * @param aDescList = pointer to the current hotkey list. * @param aDescList = pointer to the current hotkey list. * @param aFullFileName = a wxString pointer to a fuill file name. * @param aFullFileName = a wxString pointer to a full file name. * if NULL, use the standard wxConfig mechanism (default) * if NULL, use the standard wxConfig mechanism (default) * the output format is: shortcut "key" "function" * the output format is: shortcut "key" "function" * lines starting with # are comments * lines starting with # are comments */ */ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList, int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName ) wxString* aFullFileName ) { { wxString msg; wxString msg; Loading @@ -448,7 +453,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD msg = wxT( "$hotkey list\n" ); msg = wxT( "$hotkey list\n" ); /* Print the current hotkey list */ /* Print the current hotkey list */ Ki_HotkeyInfo** List; EDA_HOTKEY** List; for( ; aDescList->m_HK_InfoList != NULL; aDescList++ ) for( ; aDescList->m_HK_InfoList != NULL; aDescList++ ) { { Loading @@ -466,7 +471,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD for( ; *List != NULL; List++ ) for( ; *List != NULL; List++ ) { { Ki_HotkeyInfo* hk_decr = *List; EDA_HOTKEY* hk_decr = *List; msg += wxT( "shortcut " ); msg += wxT( "shortcut " ); keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); AddDelimiterString( keyname ); AddDelimiterString( keyname ); Loading Loading @@ -510,7 +515,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD * @param aDescList = current hotkey list descr. to initialise. * @param aDescList = current hotkey list descr. to initialise. */ */ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename, int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename, struct Ki_HotkeyInfoSectionDescriptor* aDescList ) struct EDA_HOTKEY_CONFIG* aDescList ) { { wxFile cfgfile( aFilename ); wxFile cfgfile( aFilename ); Loading @@ -534,8 +539,7 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& return 1; return 1; } } void ReadHotkeyConfig( const wxString& Appname, void ReadHotkeyConfig( const wxString& Appname, struct EDA_HOTKEY_CONFIG* aDescList ) struct Ki_HotkeyInfoSectionDescriptor* aDescList ) { { wxConfig config( Appname ); wxConfig config( Appname ); Loading @@ -553,9 +557,9 @@ void ReadHotkeyConfig( const wxString& Appname, /* Function ReadHotkeyConfig /* Function ReadHotkeyConfig * Read configuration data and fill the current hotkey list with hotkeys * Read configuration data and fill the current hotkey list with hotkeys * aDescList is the current hotkey list descr. to initialise. * aDescList is the current hotkey list descr. to initialize. */ */ int EDA_BASE_FRAME::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList ) int EDA_BASE_FRAME::ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList ) { { ::ReadHotkeyConfig( m_FrameName, aDescList ); ::ReadHotkeyConfig( m_FrameName, aDescList ); return 1; return 1; Loading @@ -568,11 +572,11 @@ int EDA_BASE_FRAME::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDe * lines like [xxx] are tags (example: [common] or [libedit] which identify sections * lines like [xxx] are tags (example: [common] or [libedit] which identify sections */ */ void ParseHotkeyConfig( const wxString& data, void ParseHotkeyConfig( const wxString& data, struct Ki_HotkeyInfoSectionDescriptor* aDescList ) struct EDA_HOTKEY_CONFIG* aDescList ) { { /* Read the config */ /* Read the config */ wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK ); wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK ); Ki_HotkeyInfo** CurrentHotkeyList = 0; EDA_HOTKEY** CurrentHotkeyList = 0; while( tokenizer.HasMoreTokens() ) while( tokenizer.HasMoreTokens() ) { { Loading @@ -580,13 +584,14 @@ void ParseHotkeyConfig( const wxString& data, wxStringTokenizer lineTokenizer( line ); wxStringTokenizer lineTokenizer( line ); wxString line_type = lineTokenizer.GetNextToken(); wxString line_type = lineTokenizer.GetNextToken(); if( line_type[0] == '#' ) //comment if( line_type[0] == '#' ) //comment continue; continue; if( line_type[0] == '[' ) // A tag is found. search infos in list if( line_type[0] == '[' ) // A tag is found. search infos in list { { CurrentHotkeyList = 0; CurrentHotkeyList = 0; Ki_HotkeyInfoSectionDescriptor* DList = aDescList; EDA_HOTKEY_CONFIG* DList = aDescList; for( ; DList->m_HK_InfoList; DList++ ) for( ; DList->m_HK_InfoList; DList++ ) { { Loading Loading @@ -619,9 +624,10 @@ void ParseHotkeyConfig( const wxString& data, wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' ); wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' ); /* search the hotkey in current hotkey list */ /* search the hotkey in current hotkey list */ for( Ki_HotkeyInfo** List = CurrentHotkeyList; *List != NULL; List++ ) for( EDA_HOTKEY** List = CurrentHotkeyList; *List != NULL; List++ ) { { Ki_HotkeyInfo* hk_decr = *List; EDA_HOTKEY* hk_decr = *List; if( hk_decr->m_InfoMsg == fctname ) if( hk_decr->m_InfoMsg == fctname ) { { int code = ReturnKeyCodeFromKeyName( keyname ); int code = ReturnKeyCodeFromKeyName( keyname ); Loading @@ -639,9 +645,9 @@ void ParseHotkeyConfig( const wxString& data, /** /** * Function ImportHotkeyConfigFromFile * Function ImportHotkeyConfigFromFile * Prompt the user for an old hotkey file to read, and read it. * Prompt the user for an old hotkey file to read, and read it. * @param aDescList = current hotkey list descr. to initialise. * @param aDescList = current hotkey list descr. to initialize. */ */ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct Ki_HotkeyInfoSectionDescriptor* aDescList ) void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDescList ) { { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; wxString mask = wxT( "*." ) + ext; Loading @@ -667,9 +673,9 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct Ki_HotkeyInfoSectionDesc /** /** * Function ExportHotkeyConfigToFile * Function ExportHotkeyConfigToFile * Prompt the user for an old hotkey file to read, and read it. * Prompt the user for an old hotkey file to read, and read it. * @param aDescList = current hotkey list descr. to initialise. * @param aDescList = current hotkey list descr. to initialize. */ */ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct Ki_HotkeyInfoSectionDescriptor* aDescList ) void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescList ) { { wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString mask = wxT( "*." ) + ext; wxString mask = wxT( "*." ) + ext; Loading