Commit d5ecafd5 authored by jean-pierre charras's avatar jean-pierre charras

Fix some minor issues in hotkey dialogs

parent 3053d45b
...@@ -54,7 +54,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, ...@@ -54,7 +54,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent,
m_hotkeys = hotkeys; m_hotkeys = hotkeys;
m_curEditingRow = -1; m_curEditingRow = -1;
m_table = new HotkeyGridTable( hotkeys ); m_table = new HOTKEY_EDITOR_GRID_TABLE( hotkeys );
m_hotkeyGrid->SetTable( m_table, true ); m_hotkeyGrid->SetTable( m_table, true );
m_hotkeyGrid->AutoSizeColumn( 0 ); m_hotkeyGrid->AutoSizeColumn( 0 );
...@@ -76,7 +76,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent, ...@@ -76,7 +76,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent,
void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event ) 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(); HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys();
EDA_HOTKEY_CONFIG* section; EDA_HOTKEY_CONFIG* section;
...@@ -91,7 +91,7 @@ void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event ) ...@@ -91,7 +91,7 @@ void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
EDA_HOTKEY* info = *info_ptr; EDA_HOTKEY* info = *info_ptr;
/* find the corresponding hotkey */ /* 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 ) for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i )
{ {
...@@ -158,7 +158,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event ) ...@@ -158,7 +158,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event )
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;
} }
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -9,7 +9,7 @@ ...@@ -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 ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
...@@ -55,8 +55,10 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind ...@@ -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 ); m_undoButton = new wxButton( this, wxID_CANCEL, _("Undo"), wxDefaultPosition, wxDefaultSize, 0 );
b_buttonsSizer->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 ); b_buttonsSizer->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
this->SetSizer( bMainSizer ); this->SetSizer( bMainSizer );
this->Layout(); this->Layout();
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_hotkeys_editor_base__ #ifndef __DIALOG_HOTKEYS_EDITOR_BASE_H__
#define __dialog_hotkeys_editor_base__ #define __DIALOG_HOTKEYS_EDITOR_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/string.h> #include <wx/string.h>
...@@ -26,7 +30,7 @@ ...@@ -26,7 +30,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class HOTKEYS_EDITOR_DIALOG_BASE /// Class HOTKEYS_EDITOR_DIALOG_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog class HOTKEYS_EDITOR_DIALOG_BASE : public DIALOG_SHIM
{ {
private: private:
...@@ -52,4 +56,4 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog ...@@ -52,4 +56,4 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog
}; };
#endif //__dialog_hotkeys_editor_base__ #endif //__DIALOG_HOTKEYS_EDITOR_BASE_H__
...@@ -4,174 +4,179 @@ ...@@ -4,174 +4,179 @@
* 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 EDA_HOTKEY_CONFIG* origin ) : HOTKEY_EDITOR_GRID_TABLE::HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin ) :
wxGridTableBase(), wxGridTableBase(), m_hotkeys()
m_hotkeys()
{ {
EDA_HOTKEY_CONFIG* 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 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 ); 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; EDA_HOTKEY* hotkey_descr = *hotkey_descr_list;
hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( info ) ); hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( hotkey_descr ) );
m_hotkeys.push_back( spec ); 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; return m_hotkeys;
} }
int HotkeyGridTable::GetNumberRows() int HOTKEY_EDITOR_GRID_TABLE::GetNumberRows()
{ {
return m_hotkeys.size(); return m_hotkeys.size();
} }
int HotkeyGridTable::GetNumberCols() int HOTKEY_EDITOR_GRID_TABLE::GetNumberCols()
{ {
return 2; 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( col == 0 )
{ {
if( m_hotkeys[row].second == 0 ) if( hotkey_descr == NULL )
{ {
// section header // section header
return m_hotkeys[row].first; return m_hotkeys[row].first;
} }
else else
{ {
return m_hotkeys[row].second->m_InfoMsg; return hotkey_descr->m_InfoMsg;
} }
} }
else else
{ {
if( m_hotkeys[row].second == 0 ) if( hotkey_descr == NULL )
{ {
return wxString(); // section header
return wxEmptyString;
} }
else 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; 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; 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; return false;
} }
long HotkeyGridTable::GetValueAsLong( int row, int col ) long HOTKEY_EDITOR_GRID_TABLE::GetValueAsLong( int row, int col )
{ {
return -1L; return -1L;
} }
double HotkeyGridTable::GetValueAsDouble( int row, int col ) double HOTKEY_EDITOR_GRID_TABLE::GetValueAsDouble( int row, int col )
{ {
return 0.0; return 0.0;
} }
bool HotkeyGridTable::GetValueAsBool( int row, int col ) bool HOTKEY_EDITOR_GRID_TABLE::GetValueAsBool( int row, int col )
{ {
return false; 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; 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" ); 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; 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; int row = 0;
EDA_HOTKEY_CONFIG* section; EDA_HOTKEY_CONFIG* section;
for( section = origin; section->m_HK_InfoList; section++ ) for( section = origin; section->m_HK_InfoList; section++ )
{ {
++row; ++row; // Skip header
EDA_HOTKEY** 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++ )
...@@ -183,15 +188,10 @@ void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin ) ...@@ -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; hotkey_spec_vector::iterator i;
for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i ) for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i )
{
if( i->second )
{
delete i->second; delete i->second;
}
}
} }
/* /*
* 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.
* *
* 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 <stambaughw@verizon.net> * Copyright (C) 2010-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
...@@ -212,17 +212,12 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) ...@@ -212,17 +212,12 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
*/ */
static void AddModifierToKey( wxString& aFullKey, const wxString & aKey ) 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')) if( (aKey.Length() == 1) && (aKey[0] >= 'A') && (aKey[0] <= 'Z'))
// We can use Shift+<key> as accelerator ans <key> for hot key // We can use Shift+<key> as accelerator and <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey; aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey;
else else
// We must use Alt+<key> as accelerator ans <key> for hot key // We must use Alt+<key> as accelerator ans <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey; aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey;
#endif
} }
/* AddHotkeyName /* AddHotkeyName
...@@ -430,6 +425,10 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescL ...@@ -430,6 +425,10 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescL
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 );
// Some chars should be modified, using html encoding, to be
// displayed by DisplayHtmlInfoMessage()
keyname.Replace( wxT("<"), wxT("&lt;") );
keyname.Replace( wxT(">"), wxT("&gt;") );
msg += wxT( "<tr><td>" ) + hk_decr->m_InfoMsg + wxT("</td>"); msg += wxT( "<tr><td>" ) + hk_decr->m_InfoMsg + wxT("</td>");
msg += wxT("<td><b>&nbsp;&nbsp;") + keyname + wxT( "</b></td></tr>" ); msg += wxT("<td><b>&nbsp;&nbsp;") + keyname + wxT( "</b></td></tr>" );
} }
......
...@@ -26,7 +26,7 @@ class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE ...@@ -26,7 +26,7 @@ class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
protected: protected:
EDA_DRAW_FRAME* m_parent; EDA_DRAW_FRAME* m_parent;
struct EDA_HOTKEY_CONFIG* m_hotkeys; struct EDA_HOTKEY_CONFIG* m_hotkeys;
HotkeyGridTable* m_table; HOTKEY_EDITOR_GRID_TABLE* m_table;
int m_curEditingRow; int m_curEditingRow;
......
...@@ -14,15 +14,15 @@ ...@@ -14,15 +14,15 @@
#include <common.h> #include <common.h>
#include <hotkeys_basic.h> #include <hotkeys_basic.h>
class HotkeyGridTable : public wxGridTableBase class HOTKEY_EDITOR_GRID_TABLE : public wxGridTableBase
{ {
public: public:
typedef std::pair< wxString, EDA_HOTKEY* > hotkey_spec; typedef std::pair< wxString, EDA_HOTKEY* > hotkey_spec;
typedef std::vector< hotkey_spec > hotkey_spec_vector; typedef std::vector< hotkey_spec > hotkey_spec_vector;
HotkeyGridTable( struct EDA_HOTKEY_CONFIG* origin ); HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin );
virtual ~HotkeyGridTable(); virtual ~HOTKEY_EDITOR_GRID_TABLE();
hotkey_spec_vector& getHotkeys(); hotkey_spec_vector& getHotkeys();
private: private:
...@@ -45,7 +45,7 @@ private: ...@@ -45,7 +45,7 @@ private:
virtual wxString GetColLabelValue( int col ); virtual wxString GetColLabelValue( int col );
public: public:
virtual bool isHeader( int row ); virtual bool IsHeader( int row );
virtual void SetKeyCode( int row, long key ); virtual void SetKeyCode( int row, long key );
virtual void RestoreFrom( struct EDA_HOTKEY_CONFIG* origin ); virtual void RestoreFrom( struct EDA_HOTKEY_CONFIG* origin );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment