Coding style fixes
This commit is contained in:
parent
73faa8238e
commit
80fae7161e
|
@ -28,6 +28,7 @@ void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
|
|||
HOTKEYS_EDITOR_DIALOG dialog( aParent, aHotkeys );
|
||||
|
||||
int diag = dialog.ShowModal();
|
||||
|
||||
if( diag == wxID_OK )
|
||||
{
|
||||
aParent->ReCreateMenuBar();
|
||||
|
@ -83,4 +84,3 @@ void HOTKEYS_EDITOR_DIALOG::ResetClicked( wxCommandEvent& aEvent )
|
|||
{
|
||||
m_hotkeyListCtrl->TransferDataToControl();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ class WIDGET_HOTKEY_CLIENT_DATA: public wxClientData
|
|||
|
||||
public:
|
||||
WIDGET_HOTKEY_CLIENT_DATA( const EDA_HOTKEY& aHotkey, const wxString& aSectionTag )
|
||||
: m_hotkey( aHotkey ),
|
||||
m_section_tag( aSectionTag )
|
||||
: m_hotkey( aHotkey ), m_section_tag( aSectionTag )
|
||||
{}
|
||||
|
||||
EDA_HOTKEY& GetHotkey() { return m_hotkey; }
|
||||
|
@ -79,17 +78,19 @@ public:
|
|||
wxPanel* panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize );
|
||||
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
// Dialog layout:
|
||||
//
|
||||
// inst_label........................
|
||||
// ----------------------------------
|
||||
//
|
||||
// cmd_label_0 cmd_label_1 \
|
||||
// | fgsizer
|
||||
// key_label_0 key_label_1 /
|
||||
/* Dialog layout:
|
||||
*
|
||||
* inst_label........................
|
||||
* ----------------------------------
|
||||
*
|
||||
* cmd_label_0 cmd_label_1 \
|
||||
* | fgsizer
|
||||
* key_label_0 key_label_1 /
|
||||
*/
|
||||
|
||||
wxStaticText* inst_label = new wxStaticText( panel, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL );
|
||||
|
||||
inst_label->SetLabelText( _( "Press a new hotkey, or press Esc to cancel..." ) );
|
||||
sizer->Add( inst_label, 0, wxALL, 5 );
|
||||
|
||||
|
@ -128,14 +129,12 @@ public:
|
|||
panel->Bind( wxEVT_CHAR, &HK_PROMPT_DIALOG::OnChar, this );
|
||||
}
|
||||
|
||||
|
||||
void OnChar( wxKeyEvent& aEvent )
|
||||
{
|
||||
m_event = aEvent;
|
||||
EndFlexible( wxID_OK );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* End the dialog whether modal or quasimodal
|
||||
*/
|
||||
|
@ -147,11 +146,11 @@ public:
|
|||
EndModal( aRtnCode );
|
||||
}
|
||||
|
||||
|
||||
static wxKeyEvent PromptForKey( wxWindow* aParent, const wxString& aName,
|
||||
const wxString& aCurrentKey )
|
||||
{
|
||||
HK_PROMPT_DIALOG dialog( aParent, wxID_ANY, _( "Set Hotkey" ), aName, aCurrentKey );
|
||||
|
||||
if( dialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
return dialog.m_event;
|
||||
|
@ -170,6 +169,7 @@ WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetHKClientData( wxTreeListItem a
|
|||
if( aItem.IsOk() )
|
||||
{
|
||||
wxClientData* data = GetItemData( aItem );
|
||||
|
||||
if( !data )
|
||||
{
|
||||
return NULL;
|
||||
|
@ -221,6 +221,7 @@ void WIDGET_HOTKEY_LIST::LoadSection( EDA_HOTKEY_CONFIG* aSection )
|
|||
m_hotkeys.push_back( list );
|
||||
}
|
||||
|
||||
|
||||
void WIDGET_HOTKEY_LIST::EditItem( wxTreeListItem aItem )
|
||||
{
|
||||
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem );
|
||||
|
@ -239,7 +240,6 @@ void WIDGET_HOTKEY_LIST::EditItem( wxTreeListItem aItem )
|
|||
|
||||
if( hkdata && key )
|
||||
{
|
||||
|
||||
// See if this key code is handled in hotkeys names list
|
||||
bool exists;
|
||||
KeyNameFromKeyCode( key, &exists );
|
||||
|
@ -268,11 +268,13 @@ void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem )
|
|||
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
|
||||
{
|
||||
wxString& section_tag = *( m_sections[sec_index].m_section->m_SectionTag );
|
||||
|
||||
if( section_tag != hkdata->GetSectionTag() )
|
||||
continue;
|
||||
|
||||
HOTKEY_LIST& each_list = m_hotkeys[sec_index];
|
||||
HOTKEY_LIST::iterator hk_it;
|
||||
|
||||
for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it )
|
||||
{
|
||||
if( hk_it->m_Idcommand == hk->m_Idcommand )
|
||||
|
@ -365,6 +367,7 @@ bool WIDGET_HOTKEY_LIST::CheckKeyConflicts( long aKey, const wxString& aSectionT
|
|||
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
|
||||
{
|
||||
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
|
||||
|
||||
if( !hkdata )
|
||||
continue;
|
||||
|
||||
|
@ -385,6 +388,7 @@ bool WIDGET_HOTKEY_LIST::CheckKeyConflicts( long aKey, const wxString& aSectionT
|
|||
|
||||
// Find the section
|
||||
HOTKEY_SECTIONS::iterator it;
|
||||
|
||||
for( it = m_sections.begin(); it != m_sections.end(); ++it )
|
||||
{
|
||||
if( *it->m_section->m_SectionTag == tag )
|
||||
|
@ -460,6 +464,7 @@ WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, const HOTKEY_SECTIONS
|
|||
HOTKEY_SECTIONS WIDGET_HOTKEY_LIST::GenSections( EDA_HOTKEY_CONFIG* aHotkeys )
|
||||
{
|
||||
HOTKEY_SECTIONS sections;
|
||||
|
||||
for( EDA_HOTKEY_CONFIG* section = aHotkeys; section->m_HK_InfoList; ++section )
|
||||
{
|
||||
HOTKEY_SECTION sec;
|
||||
|
@ -467,6 +472,7 @@ HOTKEY_SECTIONS WIDGET_HOTKEY_LIST::GenSections( EDA_HOTKEY_CONFIG* aHotkeys )
|
|||
sec.m_section = section;
|
||||
sections.push_back( sec );
|
||||
}
|
||||
|
||||
return sections;
|
||||
}
|
||||
|
||||
|
@ -474,6 +480,7 @@ HOTKEY_SECTIONS WIDGET_HOTKEY_LIST::GenSections( EDA_HOTKEY_CONFIG* aHotkeys )
|
|||
void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel )
|
||||
{
|
||||
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
sizer->Add( this, 1, wxALL | wxEXPAND, 0 );
|
||||
aPanel->SetSizer( sizer );
|
||||
}
|
||||
|
@ -498,6 +505,7 @@ bool WIDGET_HOTKEY_LIST::TransferDataToControl()
|
|||
|
||||
HOTKEY_LIST& each_list = m_hotkeys[sec_index];
|
||||
HOTKEY_LIST::iterator hk_it;
|
||||
|
||||
for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it )
|
||||
{
|
||||
wxTreeListItem item = AppendItem( parent, wxEmptyString );
|
||||
|
@ -519,16 +527,20 @@ bool WIDGET_HOTKEY_LIST::TransferDataFromControl()
|
|||
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
|
||||
{
|
||||
EDA_HOTKEY_CONFIG* section = m_sections[sec_index].m_section;
|
||||
|
||||
for( EDA_HOTKEY** info_ptr = section->m_HK_InfoList; *info_ptr; ++info_ptr )
|
||||
{
|
||||
EDA_HOTKEY* info = *info_ptr;
|
||||
|
||||
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
|
||||
{
|
||||
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
|
||||
|
||||
if( !hkdata )
|
||||
continue;
|
||||
|
||||
EDA_HOTKEY& hk = hkdata->GetHotkey();
|
||||
|
||||
if( hk.m_Idcommand == info->m_Idcommand )
|
||||
{
|
||||
info->m_KeyCode = hk.m_KeyCode;
|
||||
|
@ -541,6 +553,7 @@ bool WIDGET_HOTKEY_LIST::TransferDataFromControl()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
long WIDGET_HOTKEY_LIST::MapKeypressToKeycode( const wxKeyEvent& aEvent )
|
||||
{
|
||||
long key = aEvent.GetKeyCode();
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
|
||||
#include <dialog_eeschema_options.h>
|
||||
#include <widgets/widget_hotkey_list.h>
|
||||
#include "../schframe.h"
|
||||
#include "hotkeys.h"
|
||||
#include <schframe.h>
|
||||
#include <hotkeys.h>
|
||||
|
||||
#include "wx/settings.h"
|
||||
#include <wx/settings.h>
|
||||
|
||||
/**
|
||||
* Menu IDs for the import/export menu.
|
||||
|
@ -47,6 +47,7 @@ enum IMP_EXP_MENU_IDS
|
|||
ID_EXPORT_HOTKEYS
|
||||
};
|
||||
|
||||
|
||||
DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) :
|
||||
DIALOG_EESCHEMA_OPTIONS_BASE( parent )
|
||||
{
|
||||
|
@ -82,6 +83,7 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) :
|
|||
{
|
||||
m_notebook->GetPage( i )->Layout();
|
||||
}
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
@ -117,18 +119,22 @@ void DIALOG_EESCHEMA_OPTIONS::OnMenu( wxCommandEvent& aEvent )
|
|||
aEvent.SetId( ID_CONFIG_READ );
|
||||
GetParent()->Process_Config( aEvent );
|
||||
break;
|
||||
|
||||
case ID_EXPORT_PREFS:
|
||||
aEvent.SetId( ID_CONFIG_SAVE );
|
||||
GetParent()->Process_Config( aEvent );
|
||||
break;
|
||||
|
||||
case ID_IMPORT_HOTKEYS:
|
||||
aEvent.SetId( ID_PREFERENCES_HOTKEY_IMPORT_CONFIG );
|
||||
GetParent()->Process_Config( aEvent );
|
||||
break;
|
||||
|
||||
case ID_EXPORT_HOTKEYS:
|
||||
aEvent.SetId( ID_PREFERENCES_HOTKEY_EXPORT_CONFIG );
|
||||
GetParent()->Process_Config( aEvent );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "Unexpected menu ID" );
|
||||
}
|
||||
|
@ -226,11 +232,13 @@ void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
|
|||
for( int row = 0; row < m_fieldGrid->GetNumberRows(); ++row )
|
||||
{
|
||||
bool this_row_selected = false;
|
||||
|
||||
for( int col = 0; col < m_fieldGrid->GetNumberCols(); ++col )
|
||||
{
|
||||
if( m_fieldGrid->IsInSelection( row, col ) )
|
||||
this_row_selected = true;
|
||||
}
|
||||
|
||||
if( this_row_selected )
|
||||
{
|
||||
selected_row = row;
|
||||
|
@ -277,10 +285,12 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )
|
|||
TransferDataFromWindow();
|
||||
|
||||
int n_rows = m_fieldGrid->GetNumberRows();
|
||||
|
||||
for( int count = 0; count < n_rows; ++count )
|
||||
{
|
||||
// Iterate backwards, unsigned-friendly way for future
|
||||
int row = n_rows - count - 1;
|
||||
|
||||
if( rows_to_delete[row] )
|
||||
{
|
||||
templateFields.erase( templateFields.begin() + row );
|
||||
|
@ -300,8 +310,10 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataToWindow()
|
|||
return false;
|
||||
|
||||
m_fieldGrid->Freeze();
|
||||
|
||||
if( m_fieldGrid->GetNumberRows() )
|
||||
m_fieldGrid->DeleteRows( 0, m_fieldGrid->GetNumberRows() );
|
||||
|
||||
m_fieldGrid->AppendRows( templateFields.size() );
|
||||
|
||||
for( int row = 0; row < m_fieldGrid->GetNumberRows(); ++row )
|
||||
|
@ -320,6 +332,7 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataToWindow()
|
|||
m_fieldGrid->SetCellRenderer( row, 2, new wxGridCellBoolRenderer() );
|
||||
m_fieldGrid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
}
|
||||
|
||||
m_fieldGrid->AutoSizeRows();
|
||||
m_fieldGrid->Thaw();
|
||||
|
||||
|
@ -365,4 +378,3 @@ TEMPLATE_FIELDNAMES DIALOG_EESCHEMA_OPTIONS::GetTemplateFields( void )
|
|||
{
|
||||
return templateFields;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue