From a010b6177c1221f4dfe5407a2f54e3e0dc7ca1a9 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 21 Sep 2013 19:09:08 +0200 Subject: [PATCH] Fix some minor issues in hotkey dialogs --- common/dialogs/dialog_hotkeys_editor.cpp | 8 +- common/dialogs/dialog_hotkeys_editor_base.cpp | 6 +- common/dialogs/dialog_hotkeys_editor_base.fbp | 625 +++++++++++------- common/dialogs/dialog_hotkeys_editor_base.h | 16 +- common/hotkey_grid_table.cpp | 88 +-- common/hotkeys_basic.cpp | 13 +- include/dialog_hotkeys_editor.h | 2 +- include/hotkey_grid_table.h | 8 +- 8 files changed, 449 insertions(+), 317 deletions(-) diff --git a/common/dialogs/dialog_hotkeys_editor.cpp b/common/dialogs/dialog_hotkeys_editor.cpp index 25aea233a5..a1457febca 100644 --- a/common/dialogs/dialog_hotkeys_editor.cpp +++ b/common/dialogs/dialog_hotkeys_editor.cpp @@ -54,7 +54,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, m_hotkeys = hotkeys; m_curEditingRow = -1; - m_table = new HotkeyGridTable( hotkeys ); + m_table = new HOTKEY_EDITOR_GRID_TABLE( hotkeys ); m_hotkeyGrid->SetTable( m_table, true ); m_hotkeyGrid->AutoSizeColumn( 0 ); @@ -76,7 +76,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event ) { /* edit the live hotkey table */ - HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys(); + HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys(); EDA_HOTKEY_CONFIG* section; @@ -91,7 +91,7 @@ void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event ) EDA_HOTKEY* info = *info_ptr; /* find the corresponding hotkey */ - HotkeyGridTable::hotkey_spec_vector::iterator i; + HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector::iterator i; for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i ) { @@ -158,7 +158,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event ) int newRow = event.GetRow(); - if( ( event.GetCol() != 1 ) || ( m_table->isHeader( newRow ) ) ) + if( ( event.GetCol() != 1 ) || ( m_table->IsHeader( newRow ) ) ) { m_curEditingRow = -1; } diff --git a/common/dialogs/dialog_hotkeys_editor_base.cpp b/common/dialogs/dialog_hotkeys_editor_base.cpp index 401015f1b6..175ab779ee 100644 --- a/common/dialogs/dialog_hotkeys_editor_base.cpp +++ b/common/dialogs/dialog_hotkeys_editor_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -55,8 +55,10 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind m_undoButton = new wxButton( this, wxID_CANCEL, _("Undo"), wxDefaultPosition, wxDefaultSize, 0 ); b_buttonsSizer->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 ); + bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); + this->SetSizer( bMainSizer ); this->Layout(); diff --git a/common/dialogs/dialog_hotkeys_editor_base.fbp b/common/dialogs/dialog_hotkeys_editor_base.fbp index d89482acaf..a4cb362dfa 100644 --- a/common/dialogs/dialog_hotkeys_editor_base.fbp +++ b/common/dialogs/dialog_hotkeys_editor_base.fbp @@ -2,11 +2,13 @@ - + C++ 1 source_name + 0 0 + res UTF-8 connect dialog_hotkeys_editor_base @@ -14,73 +16,78 @@ none 1 dialog_hotkeys_editor_base - + . - + 1 + 1 1 0 0 - - - + 0 + wxAUI_MGR_DEFAULT + + + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + HOTKEYS_EDITOR_DIALOG_BASE - + 304,235 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - + DIALOG_SHIM; dialog_shim.h Hotkeys Editor - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bMainSizer wxHORIZONTAL none @@ -89,115 +96,142 @@ wxALL|wxEXPAND 1 + 1 + 1 + 1 + 1 + + + + 1 0 - - - + + + + 1 + + wxALIGN_LEFT - + wxALIGN_TOP + 0 + 1 wxALIGN_CENTRE 30 - + wxALIGN_CENTRE 2 - - + + 1 + 0 + Dock + 0 + Left 0 1 0 1 0 1 - - - + + 1 + + 1 + 0 0 wxID_ANY - - - + + + 0 0 - - + + 0 + + + 0 + + 1 m_hotkeyGrid + 1 + + protected - + 1 + + Resizable wxALIGN_CENTRE 0 - + wxALIGN_CENTRE - + 1 - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + + 0 + + + wxDOUBLE_BORDER|wxTAB_TRAVERSAL|wxWANTS_CHARS OnKeyPressed - - - - - + + + + + OnRightClickOnCell - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + OnClickOnCell - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -205,7 +239,7 @@ wxALIGN_CENTER_VERTICAL 0 - + b_buttonsSizer wxVERTICAL none @@ -214,56 +248,87 @@ wxALL|wxEXPAND 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 0 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_OK OK - - + + 0 + + + 0 + + 1 m_OKButton + 1 + + protected - - - - - - + 1 + + Resizable + 1 + + + + 0 + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnOKClicked - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -271,56 +336,87 @@ wxALL|wxEXPAND 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 0 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_CANCEL Close - - + + 0 + + + 0 + + 1 m_cancelButton + 1 + + protected - - - - - - + 1 + + Resizable + 1 + + + + 0 + + wxFILTER_NONE wxDefaultValidator - - - - + + + + CancelClicked - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -328,56 +424,87 @@ wxALL|wxEXPAND 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 0 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_CANCEL Undo - - + + 0 + + + 0 + + 1 m_undoButton + 1 + + protected - - - - - - + 1 + + Resizable + 1 + + + + 0 + + wxFILTER_NONE wxDefaultValidator - - - - + + + + UndoClicked - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/dialogs/dialog_hotkeys_editor_base.h b/common/dialogs/dialog_hotkeys_editor_base.h index 96f68bb613..5ce7605bae 100644 --- a/common/dialogs/dialog_hotkeys_editor_base.h +++ b/common/dialogs/dialog_hotkeys_editor_base.h @@ -1,15 +1,19 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __dialog_hotkeys_editor_base__ -#define __dialog_hotkeys_editor_base__ +#ifndef __DIALOG_HOTKEYS_EDITOR_BASE_H__ +#define __DIALOG_HOTKEYS_EDITOR_BASE_H__ +#include +#include #include +class DIALOG_SHIM; +#include "dialog_shim.h" #include #include #include @@ -26,7 +30,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class HOTKEYS_EDITOR_DIALOG_BASE /////////////////////////////////////////////////////////////////////////////// -class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog +class HOTKEYS_EDITOR_DIALOG_BASE : public DIALOG_SHIM { private: @@ -47,9 +51,9 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog public: - HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Hotkeys Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 304,235 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Hotkeys Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 304,235 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~HOTKEYS_EDITOR_DIALOG_BASE(); }; -#endif //__dialog_hotkeys_editor_base__ +#endif //__DIALOG_HOTKEYS_EDITOR_BASE_H__ diff --git a/common/hotkey_grid_table.cpp b/common/hotkey_grid_table.cpp index c08893d5cc..ee884f26cf 100644 --- a/common/hotkey_grid_table.cpp +++ b/common/hotkey_grid_table.cpp @@ -4,174 +4,179 @@ * Reads the hotkey table from its stored format into a format suitable * for a wxGrid. */ -HotkeyGridTable::HotkeyGridTable( struct EDA_HOTKEY_CONFIG* origin ) : - wxGridTableBase(), - m_hotkeys() +HOTKEY_EDITOR_GRID_TABLE::HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin ) : + wxGridTableBase(), m_hotkeys() { EDA_HOTKEY_CONFIG* section; for( section = origin; section->m_HK_InfoList; section++ ) { - hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( NULL, 0, 0 ) ); + // Add a dummy hotkey_spec which is a header before each hotkey list + hotkey_spec spec( *section->m_SectionTag, NULL ); m_hotkeys.push_back( spec ); - EDA_HOTKEY** info_ptr; + EDA_HOTKEY** hotkey_descr_list; - for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) + // Add hotkeys descr + for( hotkey_descr_list = section->m_HK_InfoList; *hotkey_descr_list; + hotkey_descr_list++ ) { - EDA_HOTKEY* info = *info_ptr; - hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( info ) ); + EDA_HOTKEY* hotkey_descr = *hotkey_descr_list; + hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( hotkey_descr ) ); m_hotkeys.push_back( spec ); } } } -HotkeyGridTable::hotkey_spec_vector& HotkeyGridTable::getHotkeys() +HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& HOTKEY_EDITOR_GRID_TABLE::getHotkeys() { return m_hotkeys; } -int HotkeyGridTable::GetNumberRows() +int HOTKEY_EDITOR_GRID_TABLE::GetNumberRows() { return m_hotkeys.size(); } -int HotkeyGridTable::GetNumberCols() +int HOTKEY_EDITOR_GRID_TABLE::GetNumberCols() { return 2; } -bool HotkeyGridTable::IsEmptyCell( int row, int col ) +bool HOTKEY_EDITOR_GRID_TABLE::IsEmptyCell( int row, int col ) { - return col == 1 && m_hotkeys[row].second == 0; + return col == 1 && m_hotkeys[row].second == NULL; } -wxString HotkeyGridTable::GetValue( int row, int col ) +wxString HOTKEY_EDITOR_GRID_TABLE::GetValue( int row, int col ) { + EDA_HOTKEY* hotkey_descr = m_hotkeys[row].second; + if( col == 0 ) { - if( m_hotkeys[row].second == 0 ) + if( hotkey_descr == NULL ) { // section header return m_hotkeys[row].first; } else { - return m_hotkeys[row].second->m_InfoMsg; + return hotkey_descr->m_InfoMsg; } } else { - if( m_hotkeys[row].second == 0 ) + if( hotkey_descr == NULL ) { - return wxString(); + // section header + return wxEmptyString; } else { - return ReturnKeyNameFromKeyCode( m_hotkeys[row].second->m_KeyCode ); + return ReturnKeyNameFromKeyCode( hotkey_descr->m_KeyCode ); } } } -void HotkeyGridTable::SetValue( int row, int col, const wxString& value ) +void HOTKEY_EDITOR_GRID_TABLE::SetValue( int row, int col, const wxString& value ) { } -wxString HotkeyGridTable::GetTypeName( int row, int col ) +wxString HOTKEY_EDITOR_GRID_TABLE::GetTypeName( int row, int col ) { return wxGRID_VALUE_STRING; } -bool HotkeyGridTable::CanGetValueAs( int row, int col, const wxString& typeName ) +bool HOTKEY_EDITOR_GRID_TABLE::CanGetValueAs( int row, int col, const wxString& typeName ) { return typeName == wxGRID_VALUE_STRING && col == 2; } -bool HotkeyGridTable::CanSetValueAs( int row, int col, const wxString& typeName ) +bool HOTKEY_EDITOR_GRID_TABLE::CanSetValueAs( int row, int col, const wxString& typeName ) { return false; } -long HotkeyGridTable::GetValueAsLong( int row, int col ) +long HOTKEY_EDITOR_GRID_TABLE::GetValueAsLong( int row, int col ) { return -1L; } -double HotkeyGridTable::GetValueAsDouble( int row, int col ) +double HOTKEY_EDITOR_GRID_TABLE::GetValueAsDouble( int row, int col ) { return 0.0; } -bool HotkeyGridTable::GetValueAsBool( int row, int col ) +bool HOTKEY_EDITOR_GRID_TABLE::GetValueAsBool( int row, int col ) { return false; } -void HotkeyGridTable::SetValueAsLong( int row, int col, long value ) +void HOTKEY_EDITOR_GRID_TABLE::SetValueAsLong( int row, int col, long value ) { } -void HotkeyGridTable::SetValueAsDouble( int row, int col, double value ) +void HOTKEY_EDITOR_GRID_TABLE::SetValueAsDouble( int row, int col, double value ) { } -void HotkeyGridTable::SetValueAsBool( int row, int col, bool value ) +void HOTKEY_EDITOR_GRID_TABLE::SetValueAsBool( int row, int col, bool value ) { } -void* HotkeyGridTable::GetValueAsCustom( int row, int col ) +void* HOTKEY_EDITOR_GRID_TABLE::GetValueAsCustom( int row, int col ) { return 0; } -void HotkeyGridTable::SetValueAsCustom( int row, int col, void* value ) +void HOTKEY_EDITOR_GRID_TABLE::SetValueAsCustom( int row, int col, void* value ) { } -wxString HotkeyGridTable::GetColLabelValue( int col ) +wxString HOTKEY_EDITOR_GRID_TABLE::GetColLabelValue( int col ) { return col == 0 ? _( "Command" ) : _( "Hotkey" ); } -bool HotkeyGridTable::isHeader( int row ) +bool HOTKEY_EDITOR_GRID_TABLE::IsHeader( int row ) { - return m_hotkeys[row].second == 0; + return m_hotkeys[row].second == NULL; } -void HotkeyGridTable::SetKeyCode( int row, long key ) +void HOTKEY_EDITOR_GRID_TABLE::SetKeyCode( int row, long key ) { m_hotkeys[row].second->m_KeyCode = key; } -void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin ) +void HOTKEY_EDITOR_GRID_TABLE::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin ) { int row = 0; EDA_HOTKEY_CONFIG* section; for( section = origin; section->m_HK_InfoList; section++ ) { - ++row; + ++row; // Skip header EDA_HOTKEY** info_ptr; for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ ) @@ -183,15 +188,10 @@ void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin ) } -HotkeyGridTable::~HotkeyGridTable() +HOTKEY_EDITOR_GRID_TABLE::~HOTKEY_EDITOR_GRID_TABLE() { hotkey_spec_vector::iterator i; for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i ) - { - if( i->second ) - { - delete i->second; - } - } + delete i->second; } diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 4bda133b72..aa16306d76 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2013 Jean-Pierre Charras, j-p.charras at wanadoo.fr * Copyright (C) 2010-2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * @@ -212,17 +212,12 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) */ static void AddModifierToKey( wxString& aFullKey, const wxString & aKey ) { -#if 0 // set to 0 for new behavior, 1 for old - aFullKey << wxT( " <" ) << aKey << wxT( ">" ); -#else if( (aKey.Length() == 1) && (aKey[0] >= 'A') && (aKey[0] <= 'Z')) - // We can use Shift+ as accelerator ans for hot key + // We can use Shift+ as accelerator and for hot key aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey; else // We must use Alt+ as accelerator ans for hot key aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey; - -#endif } /* AddHotkeyName @@ -430,6 +425,10 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescL if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) ) { keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode ); + // Some chars should be modified, using html encoding, to be + // displayed by DisplayHtmlInfoMessage() + keyname.Replace( wxT("<"), wxT("<") ); + keyname.Replace( wxT(">"), wxT(">") ); msg += wxT( "" ) + hk_decr->m_InfoMsg + wxT(""); msg += wxT("  ") + keyname + wxT( "" ); } diff --git a/include/dialog_hotkeys_editor.h b/include/dialog_hotkeys_editor.h index 6d090a71be..d8b671cd3d 100644 --- a/include/dialog_hotkeys_editor.h +++ b/include/dialog_hotkeys_editor.h @@ -26,7 +26,7 @@ class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE protected: EDA_DRAW_FRAME* m_parent; struct EDA_HOTKEY_CONFIG* m_hotkeys; - HotkeyGridTable* m_table; + HOTKEY_EDITOR_GRID_TABLE* m_table; int m_curEditingRow; diff --git a/include/hotkey_grid_table.h b/include/hotkey_grid_table.h index 7075ec4d9a..8856a18520 100644 --- a/include/hotkey_grid_table.h +++ b/include/hotkey_grid_table.h @@ -14,15 +14,15 @@ #include #include -class HotkeyGridTable : public wxGridTableBase +class HOTKEY_EDITOR_GRID_TABLE : public wxGridTableBase { public: typedef std::pair< wxString, EDA_HOTKEY* > hotkey_spec; typedef std::vector< hotkey_spec > hotkey_spec_vector; - HotkeyGridTable( struct EDA_HOTKEY_CONFIG* origin ); - virtual ~HotkeyGridTable(); + HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin ); + virtual ~HOTKEY_EDITOR_GRID_TABLE(); hotkey_spec_vector& getHotkeys(); private: @@ -45,7 +45,7 @@ private: virtual wxString GetColLabelValue( int col ); public: - virtual bool isHeader( int row ); + virtual bool IsHeader( int row ); virtual void SetKeyCode( int row, long key ); virtual void RestoreFrom( struct EDA_HOTKEY_CONFIG* origin );