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

Fixed compatibility with wxWidegets 2.9.1.

Added hotkeys editor from David Turner, with a lot of enhancements and fixes
Added pins connections info in intermediate netlist for each compoment. This is redundant, but some netlist formats (ORCADPCB, PSPICE) are very easy to create with this redundant info.
parent 91530e7a
...@@ -26,6 +26,8 @@ set(COMMON_SRCS ...@@ -26,6 +26,8 @@ set(COMMON_SRCS
confirm.cpp confirm.cpp
copy_to_clipboard.cpp copy_to_clipboard.cpp
dialog_display_info_HTML_base.cpp dialog_display_info_HTML_base.cpp
dialog_hotkeys_editor.cpp
dialog_hotkeys_editor_base.cpp
dialog_load_error.cpp dialog_load_error.cpp
dcsvg.cpp dcsvg.cpp
dialog_page_settings_base.cpp dialog_page_settings_base.cpp
...@@ -42,6 +44,7 @@ set(COMMON_SRCS ...@@ -42,6 +44,7 @@ set(COMMON_SRCS
get_component_dialog.cpp get_component_dialog.cpp
gr_basic.cpp gr_basic.cpp
hotkeys_basic.cpp hotkeys_basic.cpp
hotkey_grid_table.cpp
msgpanel.cpp msgpanel.cpp
netlist_keywords.cpp netlist_keywords.cpp
newstroke_font.cpp newstroke_font.cpp
......
...@@ -355,13 +355,21 @@ void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& WXUNUSED( ev ...@@ -355,13 +355,21 @@ void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& WXUNUSED( ev
#define __BO_COMPILER ",unknown" #define __BO_COMPILER ",unknown"
#endif #endif
#if wxCHECK_VERSION( 2, 9, 0 )
#define KICAD_BUILD_OPTIONS_SIGNATURE \
" (" __WX_BO_UNICODE \
__ABI_VERSION __BO_COMPILER \
__WX_BO_STL \
__WX_BO_WXWIN_COMPAT_2_6 __WX_BO_WXWIN_COMPAT_2_8 \
")"
#else
#define KICAD_BUILD_OPTIONS_SIGNATURE \ #define KICAD_BUILD_OPTIONS_SIGNATURE \
" (" __WX_BO_DEBUG "," __WX_BO_UNICODE \ " (" __WX_BO_DEBUG "," __WX_BO_UNICODE \
__ABI_VERSION __BO_COMPILER \ __ABI_VERSION __BO_COMPILER \
__WX_BO_STL \ __WX_BO_STL \
__WX_BO_WXWIN_COMPAT_2_4 __WX_BO_WXWIN_COMPAT_2_6 \ __WX_BO_WXWIN_COMPAT_2_4 __WX_BO_WXWIN_COMPAT_2_6 \
")" ")"
#endif
tmp = wxT( "Application: " ) + wxGetApp().GetTitle() + wxT( "\n" ); tmp = wxT( "Application: " ) + wxGetApp().GetTitle() + wxT( "\n" );
tmp += wxT( "Version: " ) + GetBuildVersion() + wxT( "\n" ); tmp += wxT( "Version: " ) + GetBuildVersion() + wxT( "\n" );
tmp << wxT( "Build: " ) << wxVERSION_STRING tmp << wxT( "Build: " ) << wxVERSION_STRING
......
#include <wx/tooltip.h>
#include <algorithm>
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "dialog_hotkeys_editor.h"
void InstallHotkeyFrame( WinEDA_DrawFrame* parent,
Ki_HotkeyInfoSectionDescriptor* hotkeys )
{
HOTKEYS_EDITOR_DIALOG dialog( parent, hotkeys );
int diag = dialog.ShowModal();
if( diag == wxID_OK )
{
parent->ReCreateMenuBar();
parent->Refresh();
}
}
HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( WinEDA_DrawFrame* parent,
Ki_HotkeyInfoSectionDescriptor* hotkeys ) :
HOTKEYS_EDITOR_DIALOG_BASE( parent )
{
m_parent = parent;
m_hotkeys = hotkeys;
m_table = new HotkeyGridTable( hotkeys );
m_hotkeyGrid->SetTable( m_table, true );
m_hotkeyGrid->AutoSizeColumn( 0 );
m_hotkeyGrid->EnableDragGridSize( false );
for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i )
{
m_hotkeyGrid->SetReadOnly( i, 0, true );
m_hotkeyGrid->SetReadOnly( i, 1, true );
}
SetFocus();
GetSizer()->SetSizeHints( this );
Center();
}
void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
{
/* edit the live hotkey table */
HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys();
Ki_HotkeyInfoSectionDescriptor* section;
for( section = m_hotkeys; section->m_HK_InfoList; section++ )
{
wxString sectionTag = *section->m_SectionTag;
Ki_HotkeyInfo** info_ptr;
for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
{
Ki_HotkeyInfo* info = *info_ptr;
/* find the corresponding hotkey */
HotkeyGridTable::hotkey_spec_vector::iterator i;
for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i )
{
if( i->first == sectionTag
&& i->second
&& i->second->m_Idcommand == info->m_Idcommand )
{
info->m_KeyCode = i->second->m_KeyCode;
break;
}
}
}
}
/* save the hotkeys */
m_parent->WriteHotkeyConfig( m_hotkeys );
Close( TRUE );
}
void HOTKEYS_EDITOR_DIALOG::CancelClicked( wxCommandEvent& event )
{
Close( TRUE );
}
void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& event )
{
m_table->RestoreFrom( m_hotkeys );
m_hotkeyGrid->Refresh();
Update();
}
void HOTKEYS_EDITOR_DIALOG::SetHotkeyCellState( int aRow, bool aHightlight )
{
if( aHightlight )
{
m_hotkeyGrid->SetCellTextColour( aRow, 1, *wxRED );
wxFont bold_font(m_hotkeyGrid->GetDefaultCellFont() );
bold_font.SetWeight(wxFONTWEIGHT_BOLD);
m_hotkeyGrid->SetCellFont( aRow, 1, bold_font );
}
else
{
m_hotkeyGrid->SetCellTextColour( aRow, 1, m_hotkeyGrid->GetDefaultCellTextColour() );
m_hotkeyGrid->SetCellFont( aRow, 1, m_hotkeyGrid->GetDefaultCellFont() );
}
}
void HOTKEYS_EDITOR_DIALOG::StartEditing( wxGridEvent& event )
{
if( m_curEditingRow != -1 )
SetHotkeyCellState( m_curEditingRow, false );
int newRow = event.GetRow();
if( m_curEditingRow == newRow || m_table->isHeader( newRow ) )
{
m_curEditingRow = -1;
}
else
{
m_curEditingRow = newRow;
SetHotkeyCellState( m_curEditingRow, true );
}
m_hotkeyGrid->Refresh();
Update();
}
void HOTKEYS_EDITOR_DIALOG::KeyPressed( wxKeyEvent& event )
{
if( m_curEditingRow != -1 )
{
long key = event.GetKeyCode();
switch( key )
{
case WXK_ESCAPE:
SetHotkeyCellState( m_curEditingRow, false );
m_curEditingRow = -1;
break;
default:
if( event.ControlDown() )
key |= GR_KB_CTRL;
if( event.AltDown() )
key |= GR_KB_ALT;
if( event.ShiftDown() && (key > 256) )
key |= GR_KB_SHIFT;
// Remap Ctrl A (=1+GR_KB_CTRL) to Ctrl Z(=26+GR_KB_CTRL)
// to GR_KB_CTRL+'A' .. GR_KB_CTRL+'Z'
if( (key > GR_KB_CTRL) && (key <= GR_KB_CTRL+26) )
key += ('A' - 1);
if( key >= 'a' && key <= 'z' ) //upcase key
key = key + ('A' - 'a');
#if 0 // For debug
wxString msg;
msg.Printf(wxT("key %X, keycode %X"),event.GetKeyCode(), key);
wxMessageBox(msg);
#endif
// See if this key code is handled in hotkeys list
bool exists;
ReturnKeyNameFromKeyCode( key, &exists );
if( !exists ) // not handled, see s_Hotkey_Name_List[] in hotkeys_basic.cpp
wxMessageBox( _("Hotkey value not handled" ) );
else
{
m_table->SetKeyCode( m_curEditingRow, key );
SetHotkeyCellState( m_curEditingRow, false );
}
break;
}
}
m_hotkeyGrid->Refresh();
Update();
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_hotkeys_editor_base.h"
///////////////////////////////////////////////////////////////////////////
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 )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
m_hotkeyGrid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_hotkeyGrid->CreateGrid( 5, 2 );
m_hotkeyGrid->EnableEditing( true );
m_hotkeyGrid->EnableGridLines( true );
m_hotkeyGrid->EnableDragGridSize( false );
m_hotkeyGrid->SetMargins( 0, 0 );
// Columns
m_hotkeyGrid->AutoSizeColumns();
m_hotkeyGrid->EnableDragColMove( false );
m_hotkeyGrid->EnableDragColSize( true );
m_hotkeyGrid->SetColLabelSize( 30 );
m_hotkeyGrid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_hotkeyGrid->EnableDragRowSize( true );
m_hotkeyGrid->SetRowLabelSize( 0 );
m_hotkeyGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_hotkeyGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bMainSizer->Add( m_hotkeyGrid, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxVERTICAL );
m_OKButton = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_OKButton, 0, wxALL|wxEXPAND, 5 );
m_cancelButton = new wxButton( this, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_cancelButton, 0, wxALL|wxEXPAND, 5 );
m_undoButton = new wxButton( this, wxID_CANCEL, _("Undo"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( bSizer2, 0, wxALIGN_CENTER_VERTICAL, 5 );
this->SetSizer( bMainSizer );
this->Layout();
// Connect Events
m_hotkeyGrid->Connect( wxEVT_CHAR, wxKeyEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::KeyPressed ), NULL, this );
m_hotkeyGrid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::StartEditing ), NULL, this );
m_OKButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnOKClicked ), NULL, this );
m_cancelButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::CancelClicked ), NULL, this );
m_undoButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::UndoClicked ), NULL, this );
}
HOTKEYS_EDITOR_DIALOG_BASE::~HOTKEYS_EDITOR_DIALOG_BASE()
{
// Disconnect Events
m_hotkeyGrid->Disconnect( wxEVT_CHAR, wxKeyEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::KeyPressed ), NULL, this );
m_hotkeyGrid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::StartEditing ), NULL, this );
m_OKButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::OnOKClicked ), NULL, this );
m_cancelButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::CancelClicked ), NULL, this );
m_undoButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::UndoClicked ), NULL, this );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_hotkeys_editor_base__
#define __dialog_hotkeys_editor_base__
#include <wx/intl.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class HOTKEYS_EDITOR_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog
{
private:
protected:
wxGrid* m_hotkeyGrid;
wxButton* m_OKButton;
wxButton* m_cancelButton;
wxButton* m_undoButton;
// Virtual event handlers, overide them in your derived class
virtual void KeyPressed( wxKeyEvent& event ){ event.Skip(); }
virtual void StartEditing( wxGridEvent& event ){ event.Skip(); }
virtual void OnOKClicked( wxCommandEvent& event ){ event.Skip(); }
virtual void CancelClicked( wxCommandEvent& event ){ event.Skip(); }
virtual void UndoClicked( wxCommandEvent& event ){ event.Skip(); }
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();
};
#endif //__dialog_hotkeys_editor_base__
...@@ -1384,9 +1384,9 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) ...@@ -1384,9 +1384,9 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
/* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z /* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
* They have an ascii code from 1 to 27 remapped * They have an ascii code from 1 to 27 remapped
* GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z' * to GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z'
*/ */
if( (localkey & (GR_KB_CTRL|GR_KB_ALT|GR_KB_SHIFT)) == GR_KB_CTRL ) if( (localkey > GR_KB_CTRL) && (localkey <= GR_KB_CTRL+26) )
localkey += 'A' - 1; localkey += 'A' - 1;
INSTALL_DC( DC, this ); INSTALL_DC( DC, this );
......
...@@ -612,8 +612,6 @@ void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory) ...@@ -612,8 +612,6 @@ void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory)
m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ), m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ),
wxLANGUAGE_DEFAULT ); wxLANGUAGE_DEFAULT );
m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) ); m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) );
g_ConfigFileLocationChoice = m_EDA_CommonConfig->Read( HOTKEY_CFG_PATH_OPT,
0L );
m_fileHistory.Load( *m_EDA_Config ); m_fileHistory.Load( *m_EDA_Config );
......
#include "hotkey_grid_table.h"
/*
* Reads the hotkey table from its stored format into a format suitable
* for a wxGrid.
*/
HotkeyGridTable::HotkeyGridTable( struct
Ki_HotkeyInfoSectionDescriptor* origin ) :
wxGridTableBase(),
m_hotkeys()
{
Ki_HotkeyInfoSectionDescriptor* section;
for( section = origin; section->m_HK_InfoList; section++ )
{
hotkey_spec spec( *section->m_SectionTag, 0 );
m_hotkeys.push_back( spec );
Ki_HotkeyInfo** info_ptr;
for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
{
Ki_HotkeyInfo* info = *info_ptr;
hotkey_spec spec( *section->m_SectionTag,
new Ki_HotkeyInfo( info ) );
m_hotkeys.push_back( spec );
}
}
}
HotkeyGridTable::hotkey_spec_vector& HotkeyGridTable::getHotkeys()
{
return m_hotkeys;
}
int HotkeyGridTable::GetNumberRows()
{
return m_hotkeys.size();
}
int HotkeyGridTable::GetNumberCols()
{
return 2;
}
bool HotkeyGridTable::IsEmptyCell( int row, int col )
{
return col == 1 && m_hotkeys[row].second == 0;
}
wxString HotkeyGridTable::GetValue( int row, int col )
{
if( col == 0 )
{
if( m_hotkeys[row].second == 0 )
{
// section header
return m_hotkeys[row].first;
}
else
{
return m_hotkeys[row].second->m_InfoMsg;
}
}
else
{
if( m_hotkeys[row].second == 0 )
{
return wxString();
}
else
{
return ReturnKeyNameFromKeyCode( m_hotkeys[row].second->m_KeyCode );
}
}
}
void HotkeyGridTable::SetValue( int row, int col, const wxString& value )
{
}
wxString HotkeyGridTable::GetTypeName( int row, int col )
{
return wxGRID_VALUE_STRING;
}
bool HotkeyGridTable::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 )
{
return false;
}
long HotkeyGridTable::GetValueAsLong( int row, int col )
{
return -1L;
}
double HotkeyGridTable::GetValueAsDouble( int row, int col )
{
return 0.0;
}
bool HotkeyGridTable::GetValueAsBool( int row, int col )
{
return false;
}
void HotkeyGridTable::SetValueAsLong( int row, int col, long value )
{
}
void HotkeyGridTable::SetValueAsDouble( int row, int col, double value )
{
}
void HotkeyGridTable::SetValueAsBool( int row, int col, bool value )
{
}
void* HotkeyGridTable::GetValueAsCustom( int row, int col )
{
return 0;
}
void HotkeyGridTable::SetValueAsCustom( int row, int col, void* value )
{
}
wxString HotkeyGridTable::GetColLabelValue( int col )
{
return col == 0 ? _( "Command" ) : _( "Hotkey" );
}
bool HotkeyGridTable::isHeader( int row )
{
return m_hotkeys[row].second == 0;
}
void HotkeyGridTable::SetKeyCode( int row, long key )
{
m_hotkeys[row].second->m_KeyCode = key;
}
void HotkeyGridTable::RestoreFrom( struct
Ki_HotkeyInfoSectionDescriptor* origin )
{
int row = 0;
Ki_HotkeyInfoSectionDescriptor* section;
for( section = origin; section->m_HK_InfoList; section++ )
{
++row;
Ki_HotkeyInfo** info_ptr;
for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
{
Ki_HotkeyInfo* info = *info_ptr;
m_hotkeys[row++].second->m_KeyCode = info->m_KeyCode;
}
}
}
HotkeyGridTable::~HotkeyGridTable()
{
hotkey_spec_vector::iterator i;
for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i )
{
if( i->second )
{
delete i->second;
}
}
}
This diff is collapsed.
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "hotkeys.h"
#include <wx/snglinst.h> #include <wx/snglinst.h>
...@@ -147,10 +148,9 @@ bool WinEDA_App::OnInit() ...@@ -147,10 +148,9 @@ bool WinEDA_App::OnInit()
bool reopenLastUsedDirectory = argc == 1; bool reopenLastUsedDirectory = argc == 1;
GetSettings( reopenLastUsedDirectory ); GetSettings( reopenLastUsedDirectory );
Read_Hotkey_Config( frame, false ); /* Must be called before creating /* Must be called before creating the main frame in order to
* the main frame in order to * display the real hotkeys in menus or tool tips */
* display the real hotkeys in menus ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr );
* or tool tips */
// Create main frame (schematic frame) : // Create main frame (schematic frame) :
frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ), frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ),
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "worksheet.h" #include "worksheet.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "dialog_eeschema_options.h" #include "dialog_eeschema_options.h"
#include "dialog_hotkeys_editor.h"
#include <wx/fdrepdlg.h> #include <wx/fdrepdlg.h>
...@@ -65,30 +66,16 @@ void WinEDA_LibeditFrame::Process_Config( wxCommandEvent& event ) ...@@ -65,30 +66,16 @@ void WinEDA_LibeditFrame::Process_Config( wxCommandEvent& event )
/* Hotkey IDs */ /* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG: case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ), InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
HOTKEY_FILENAME,
DEFAULT_HOTKEY_FILENAME_EXT );
WriteHotkeyConfigFile( fn.GetFullPath(), s_Eeschema_Hokeys_Descr, true );
break; break;
case ID_PREFERENCES_HOTKEY_READ_CONFIG: case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
Read_Hotkey_Config( this, true ); ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
break; break;
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG: case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
{ ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr );
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
HOTKEY_FILENAME, DEFAULT_HOTKEY_FILENAME_EXT );
wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
}
break;
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
HandleHotkeyConfigMenuSelection( this, id );
break; break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
...@@ -141,30 +128,16 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) ...@@ -141,30 +128,16 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
/* Hotkey IDs */ /* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG: case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ), ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
HOTKEY_FILENAME,
DEFAULT_HOTKEY_FILENAME_EXT );
WriteHotkeyConfigFile( fn.GetFullPath(), s_Eeschema_Hokeys_Descr, true );
break; break;
case ID_PREFERENCES_HOTKEY_READ_CONFIG: case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
Read_Hotkey_Config( this, true ); ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG:
{
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
HOTKEY_FILENAME, DEFAULT_HOTKEY_FILENAME_EXT );
wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
}
break; break;
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME: case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD: InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
HandleHotkeyConfigMenuSelection( this, id );
break; break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
...@@ -260,25 +233,6 @@ void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event ) ...@@ -260,25 +233,6 @@ void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event )
} }
/*
* Read the hotkey files config for eeschema and libedit
*/
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
{
wxString FullFileName = ReturnHotkeyConfigFilePath(
g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += wxT( "." );
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
frame->ReadHotkeyConfigFile( FullFileName,
s_Eeschema_Hokeys_Descr,
verbose );
return TRUE;
}
/** /**
* Return project file parameter list for EESchema. * Return project file parameter list for EESchema.
* *
......
...@@ -213,9 +213,9 @@ Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] = ...@@ -213,9 +213,9 @@ Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] =
// an hotkey config file) // an hotkey config file)
struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[] = struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[] =
{ {
{ &g_CommonSectionTag, s_Common_Hotkey_List, "Common keys" }, { &g_CommonSectionTag, s_Common_Hotkey_List, L"Common keys" },
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, "Schematic editor keys" }, { &g_SchematicSectionTag, s_Schematic_Hotkey_List, L"Schematic editor keys" },
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, "library editor keys" }, { &g_LibEditSectionTag, s_LibEdit_Hotkey_List, L"library editor keys" },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
......
...@@ -23,7 +23,7 @@ static wxArrayString s_PowerNameList; ...@@ -23,7 +23,7 @@ static wxArrayString s_PowerNameList;
*/ */
void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem(); SCH_ITEM* DrawStruct = GetScreen()->GetCurItem();
if( ( m_ID_current_state == 0 ) || ( DrawStruct && DrawStruct->m_Flags ) ) if( ( m_ID_current_state == 0 ) || ( DrawStruct && DrawStruct->m_Flags ) )
{ {
...@@ -60,12 +60,16 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -60,12 +60,16 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
default: default:
DisplayError( this, {
wxT( "WinEDA_SchematicFrame::OnLeftClick err: m_Flags != 0" ) ); wxString msg;
msg.Printf(wxT( "WinEDA_SchematicFrame::OnLeftClick err: m_Flags != 0, itmetype %d" ),
DrawStruct->Type());
DisplayError( this, msg );
DrawStruct->m_Flags = 0; DrawStruct->m_Flags = 0;
break; break;
} }
} }
}
else else
{ {
DrawStruct = SchematicGeneralLocateAndDisplay( true ); DrawStruct = SchematicGeneralLocateAndDisplay( true );
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--XSL style sheet to EESCHEMA Generic Netlist Format to CADSTAR netlist format
Copyright (C) 2010, SoftPLC Corporation.
GPL v2.
How to use:
https://lists.launchpad.net/kicad-developers/msg05157.html
-->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF -->
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<!-- Netlist header -->
<xsl:template match="/export">
<xsl:text>( { EESchema Netlist Version 1.1 </xsl:text>
<xsl:apply-templates select="design/date"/> <!-- Generate line .TIM <time> -->
<xsl:apply-templates select="design/tool"/> <!-- Generate line .APP <eeschema version> -->
<xsl:text>}&nl;</xsl:text>
<xsl:apply-templates select="components/comp"/> <!-- Generate list of components -->
<xsl:text>)&nl;*&nl;</xsl:text>
</xsl:template>
<!-- Generate id in header like "eeschema (2010-08-17 BZR 2450)-unstable" -->
<xsl:template match="tool">
<xsl:apply-templates/>
</xsl:template>
<!-- Generate date in header like "20/08/2010 10:45:33" -->
<xsl:template match="date">
<xsl:apply-templates/>
<xsl:text>&nl;</xsl:text>
</xsl:template>
<!-- for each component -->
<xsl:template match="comp">
<xsl:text> ( </xsl:text>
<xsl:choose>
<xsl:when test = "tstamp != '' ">
<xsl:apply-templates select="tstamp"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>00000000</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test = "footprint != '' ">
<xsl:apply-templates select="footprint"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>$noname</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:value-of select="@ref"/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test = "value != '' ">
<xsl:apply-templates select="value"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>"~"</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&nl;</xsl:text>
<xsl:apply-templates select="pins/pin"/>
<xsl:text> )&nl;</xsl:text>
</xsl:template>
<!-- for each pin in a component -->
<xsl:template match="pin">
<xsl:text> ( </xsl:text>
<xsl:value-of select="@num"/>
<xsl:text> = </xsl:text>
<xsl:choose>
<xsl:when test = "@netname != '' ">
<xsl:apply-templates select="@netname"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>?</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> )&nl;</xsl:text>
</xsl:template>
</xsl:stylesheet>
...@@ -171,11 +171,6 @@ EDA_Colors ReturnLayerColor( int Layer ); ...@@ -171,11 +171,6 @@ EDA_Colors ReturnLayerColor( int Layer );
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent, void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
const wxPoint& pos ); const wxPoint& pos );
/***************/
/* EECONFIG.CPP */
/***************/
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/**************/ /**************/
/* NETLIST.CPP */ /* NETLIST.CPP */
......
...@@ -6,6 +6,7 @@ add_definitions(-DGERBVIEW -DPCBNEW) ...@@ -6,6 +6,7 @@ add_definitions(-DGERBVIEW -DPCBNEW)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
../3d-viewer ../3d-viewer
../common
../cvpcb ../cvpcb
../pcbnew ../pcbnew
../polygon) ../polygon)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "zones.h" #include "zones.h"
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "colors_selection.h" #include "colors_selection.h"
#include "hotkeys.h"
#include "build_version.h" #include "build_version.h"
...@@ -101,10 +102,10 @@ bool WinEDA_App::OnInit() ...@@ -101,10 +102,10 @@ bool WinEDA_App::OnInit()
g_DrawBgColor = BLACK; g_DrawBgColor = BLACK;
Read_Hotkey_Config( frame, false ); /* Must be called before creating the /* Must be called before creating the main frame in order to
* main frame in order to display the * display the real hotkeys in menus or tool tips */
* real hotkeys in menus or tool tips ReadHotkeyConfig( wxT("GerberFrame"), s_Gerbview_Hokeys_Descr );
*/
frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ), frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ),
wxPoint( 0, 0 ), wxPoint( 0, 0 ),
wxSize( 600, 400 ) ); wxSize( 600, 400 ) );
......
...@@ -13,13 +13,8 @@ ...@@ -13,13 +13,8 @@
#include "pcbplot.h" #include "pcbplot.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "gerbview_config.h" #include "gerbview_config.h"
#include "protos.h" #include "dialog_hotkeys_editor.h"
#define HOTKEY_FILENAME wxT( "gerbview" )
void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
{ {
...@@ -44,37 +39,20 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event ) ...@@ -44,37 +39,20 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
break; break;
/* Hotkey IDs */ /* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG: case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); ExportHotkeyConfigToFile( s_Gerbview_Hokeys_Descr );
FullFileName += HOTKEY_FILENAME;
FullFileName += wxT(".");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
WriteHotkeyConfigFile( FullFileName, s_Gerbview_Hokeys_Descr, true );
break;
case ID_PREFERENCES_HOTKEY_READ_CONFIG:
Read_Hotkey_Config( this, true );
break; break;
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG: case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
{ ImportHotkeyConfigFromFile( s_Gerbview_Hokeys_Descr );
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += wxT(".");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
AddDelimiterString( FullFileName );
wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, FullFileName );
}
break; break;
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME: case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD: InstallHotkeyFrame( this, s_Gerbview_Hokeys_Descr );
HandleHotkeyConfigMenuSelection( this, id );
break; break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
// Display current hotkey list for eeschema.
DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr ); DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
break; break;
...@@ -121,19 +99,3 @@ void WinEDA_GerberFrame::Update_config() ...@@ -121,19 +99,3 @@ void WinEDA_GerberFrame::Update_config()
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList ); wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList );
} }
/*
* Read the hotkey files config for pcbnew and module_edit
*/
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
{
wxString FullFileName =
ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += wxT(".");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
return frame->ReadHotkeyConfigFile( FullFileName,
s_Gerbview_Hokeys_Descr,
verbose );
}
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
int* InstallDialogLayerPairChoice( WinEDA_GerberFrame* parent ); int* InstallDialogLayerPairChoice( WinEDA_GerberFrame* parent );
bool Read_Config(); bool Read_Config();
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
void Print_PcbItems( BOARD* Pcb, wxDC* DC, int drawmode, int printmasklayer ); void Print_PcbItems( BOARD* Pcb, wxDC* DC, int drawmode, int printmasklayer );
......
...@@ -95,14 +95,14 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) ...@@ -95,14 +95,14 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
wxGetApp().AddMenuLanguageList( configmenu ); wxGetApp().AddMenuLanguageList( configmenu );
AddHotkeyConfigMenu( configmenu );
configmenu->AppendSeparator(); configmenu->AppendSeparator();
ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_SAVE, _( "&Save Setup" ), ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_SAVE, _( "&Save Setup" ),
_( "Save application preferences" ), _( "Save application preferences" ),
save_setup_xpm ); save_setup_xpm );
configmenu->AppendSeparator();
AddHotkeyConfigMenu( configmenu );
wxMenu* miscellaneous_menu = new wxMenu; wxMenu* miscellaneous_menu = new wxMenu;
ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_GERBVIEW_SHOW_LIST_DCODES, ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_GERBVIEW_SHOW_LIST_DCODES,
_( "&List DCodes" ), _( "&List DCodes" ),
......
#ifndef __dialog_hotkeys_editor__
#define __dialog_hotkeys_editor__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/choice.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/stattext.h>
#include <wx/button.h>
#include <wx/listctrl.h>
#include <wx/dialog.h>
#include <wx/grid.h>
#include "hotkeys_basic.h"
#include "hotkey_grid_table.h"
#include "wxstruct.h"
#include "dialog_hotkeys_editor_base.h"
class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
{
protected:
WinEDA_DrawFrame* m_parent;
struct Ki_HotkeyInfoSectionDescriptor* m_hotkeys;
HotkeyGridTable* m_table;
int m_curEditingRow;
public:
HOTKEYS_EDITOR_DIALOG( WinEDA_DrawFrame* parent,
Ki_HotkeyInfoSectionDescriptor* hotkeys );
~HOTKEYS_EDITOR_DIALOG() {};
private:
void OnOKClicked( wxCommandEvent& event );
void CancelClicked( wxCommandEvent& event );
void UndoClicked( wxCommandEvent& event );
void StartEditing( wxGridEvent& event );
void KeyPressed( wxKeyEvent& event );
void SetHotkeyCellState( int aRow, bool aHightlight );
};
void InstallHotkeyFrame( WinEDA_DrawFrame* parent,
Ki_HotkeyInfoSectionDescriptor* hotkeys );
#endif
#ifndef __hotkeys_grid_table__
#define __hotkeys_grid_table__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/grid.h>
#include <vector>
#include <utility>
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "hotkeys_basic.h"
class HotkeyGridTable : public wxGridTableBase
{
public:
typedef std::pair< wxString, Ki_HotkeyInfo* > hotkey_spec;
typedef std::vector< hotkey_spec > hotkey_spec_vector;
HotkeyGridTable( struct Ki_HotkeyInfoSectionDescriptor* origin );
virtual ~HotkeyGridTable();
hotkey_spec_vector& getHotkeys();
virtual int GetNumberRows();
virtual int GetNumberCols();
virtual bool IsEmptyCell( int row, int col );
virtual wxString GetValue( int row, int col );
virtual void SetValue( int row, int col, const wxString& value );
virtual wxString GetTypeName( int row, int col );
virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
virtual long GetValueAsLong( int row, int col );
virtual double GetValueAsDouble( int row, int col );
virtual bool GetValueAsBool( int row, int col );
virtual void SetValueAsLong( int row, int col, long value );
virtual void SetValueAsDouble( int row, int col, double value );
virtual void SetValueAsBool( int row, int col, bool value );
virtual void* GetValueAsCustom( int row, int col );
virtual void SetValueAsCustom( int row, int col, void* value );
virtual wxString GetColLabelValue( int col );
virtual bool isHeader( int row );
virtual void SetKeyCode( int row, long key );
virtual void RestoreFrom( struct Ki_HotkeyInfoSectionDescriptor* origin );
protected:
std::vector< hotkey_spec > m_hotkeys;
};
#endif
...@@ -10,9 +10,6 @@ ...@@ -10,9 +10,6 @@
#define DEFAULT_HOTKEY_FILENAME_EXT wxT( "key" ) #define DEFAULT_HOTKEY_FILENAME_EXT wxT( "key" )
/* keyword idetifier in kicad config use ti store/retrieve path option */
#define HOTKEY_CFG_PATH_OPT wxT( "HotkeyPathOption" )
/* Class to handle hotkey commnands. hotkeys have a default value /* Class to handle hotkey commnands. hotkeys have a default value
* This class allows the real key code changed by user(from a key code list file) * This class allows the real key code changed by user(from a key code list file)
...@@ -27,6 +24,7 @@ public: ...@@ -27,6 +24,7 @@ public:
public: public:
Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent = 0 ); Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent = 0 );
Ki_HotkeyInfo( const Ki_HotkeyInfo* base);
}; };
/* handle a Section name and the corresponding list of hotkeys (Ki_HotkeyInfo list) /* handle a Section name and the corresponding list of hotkeys (Ki_HotkeyInfo list)
...@@ -43,7 +41,7 @@ struct Ki_HotkeyInfoSectionDescriptor ...@@ -43,7 +41,7 @@ struct Ki_HotkeyInfoSectionDescriptor
public: public:
wxString* m_SectionTag; // The section name wxString* m_SectionTag; // The section name
Ki_HotkeyInfo** m_HK_InfoList; // List of Ki_HotkeyInfo pointers Ki_HotkeyInfo** m_HK_InfoList; // List of Ki_HotkeyInfo pointers
const char* m_Comment; // comment: will be printed in the config file const wchar_t* m_Comment; // comment: will be printed in the config file
// Info usage only // Info usage only
}; };
...@@ -56,12 +54,9 @@ extern wxString g_LibEditSectionTag; ...@@ -56,12 +54,9 @@ extern wxString g_LibEditSectionTag;
extern wxString g_BoardEditorSectionTag; extern wxString g_BoardEditorSectionTag;
extern wxString g_ModuleEditSectionTag; extern wxString g_ModuleEditSectionTag;
extern int g_ConfigFileLocationChoice;
/* Functions: /* Functions:
*/ */
wxString ReturnHotkeyConfigFilePath( int choice );
void AddHotkeyConfigMenu( wxMenu* menu ); void AddHotkeyConfigMenu( wxMenu* menu );
void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id ); void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id );
...@@ -70,9 +65,10 @@ void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id ...@@ -70,9 +65,10 @@ void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id
* Only some wxWidgets key values are handled for function key ( see * Only some wxWidgets key values are handled for function key ( see
* s_Hotkey_Name_List[] ) * s_Hotkey_Name_List[] )
* @param aKeycode = key code (ascii value, or wxWidgets value for function keys) * @param aKeycode = key code (ascii value, or wxWidgets value for function keys)
* @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default)
* @return the key name in a wxString * @return the key name in a wxString
*/ */
wxString ReturnKeyNameFromKeyCode( int aKeycode ); wxString ReturnKeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL );
/** 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)
...@@ -127,6 +123,18 @@ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame ...@@ -127,6 +123,18 @@ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame
*/ */
Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList ); Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList );
/** function ReadHotkeyConfig * Read hotkey configuration for a given
app, possibly before the frame for that app has been created
@param Appname = the value of the app's m_FrameName
@param DescList = the hotkey data
*/
void ReadHotkeyConfig( const wxString& Appname,
struct Ki_HotkeyInfoSectionDescriptor* DescList );
void ParseHotkeyConfig( const wxString& data,
struct Ki_HotkeyInfoSectionDescriptor* DescList );
// common hotkeys event id // common hotkeys event id
// these hotkey ID are used in many files, so they are define here only once. // these hotkey ID are used in many files, so they are define here only once.
......
...@@ -35,11 +35,9 @@ enum main_id ...@@ -35,11 +35,9 @@ enum main_id
ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_START,
ID_PREFERENCES_HOTKEY_SUBMENU, ID_PREFERENCES_HOTKEY_SUBMENU,
ID_PREFERENCES_HOTKEY_CREATE_CONFIG, ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
ID_PREFERENCES_HOTKEY_READ_CONFIG, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
ID_PREFERENCES_HOTKEY_EDIT_CONFIG, ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
ID_PREFERENCES_HOTKEY_END, ID_PREFERENCES_HOTKEY_END,
......
...@@ -127,12 +127,48 @@ public: ...@@ -127,12 +127,48 @@ public:
virtual void LoadSettings(); virtual void LoadSettings();
virtual void SaveSettings(); virtual void SaveSettings();
int WriteHotkeyConfigFile( const wxString& Filename, // Read/Save and Import/export hotkeys config
struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose ); /** Function ReadHotkeyConfig
* Read configuration data and fill the current hotkey list with hotkeys
* @param aDescList = current hotkey list descr. to initialise.
*/
int ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList );
/** Function WriteHotkeyConfig
* Store the current hotkey list
* It is stored using the standard wxConfig mechanism or a file.
*
* @param aDescList = pointer to the current hotkey list.
* @param aFullFileName = a wxString pointer to a fuill file name.
* if NULL, use the standard wxConfig mechanism (default)
* the output format is: shortcut "key" "function"
* lines starting with # are comments
*/
int WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList,
wxString * aFullFileName = NULL);
/** Function ReadHotkeyConfigFile
* Read an old configuration file (<file>.key) and fill the current hotkey list
* with hotkeys
* @param aFilename = file name to read.
* @param aDescList = current hotkey list descr. to initialise.
*/
int ReadHotkeyConfigFile( const wxString& Filename, int ReadHotkeyConfigFile( const wxString& Filename,
struct Ki_HotkeyInfoSectionDescriptor* DescList, struct Ki_HotkeyInfoSectionDescriptor* aDescList );
bool verbose );
/** Function ImportHotkeyConfigFromFile
* Prompt the user for an old hotkey file to read, and read it.
* @param aDescList = current hotkey list descr. to initialise.
*/
void ImportHotkeyConfigFromFile( struct Ki_HotkeyInfoSectionDescriptor* aDescList );
/** Function ExportHotkeyConfigToFile
* Prompt the user for an old hotkey file to read, and read it.
* @param aDescList = current hotkey list descr. to initialise.
*/
void ExportHotkeyConfigToFile( struct Ki_HotkeyInfoSectionDescriptor* aDescList );
/** function SetLanguage /** function SetLanguage
* called on a language menu selection * called on a language menu selection
* when using a derived function, do not forget to call this one * when using a derived function, do not forget to call this one
......
...@@ -6,6 +6,7 @@ add_definitions(-DPCBNEW) ...@@ -6,6 +6,7 @@ add_definitions(-DPCBNEW)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
../3d-viewer ../3d-viewer
../common
../polygon) ../polygon)
### ###
......
...@@ -176,12 +176,12 @@ Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = { NULL }; ...@@ -176,12 +176,12 @@ Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = { NULL };
// list of sections and corresponding hotkey list for pcbnew (used to create an hotkey config file) // list of sections and corresponding hotkey list for pcbnew (used to create an hotkey config file)
struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[] = struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[] =
{ { { {
&g_CommonSectionTag, s_Common_Hotkey_List, "Common keys" &g_CommonSectionTag, s_Common_Hotkey_List, L"Common keys"
}, },
{ {
&g_BoardEditorSectionTag, s_board_edit_Hotkey_List, "Board editor keys" &g_BoardEditorSectionTag, s_board_edit_Hotkey_List, L"Board editor keys"
},{ },{
&g_ModuleEditSectionTag, s_module_edit_Hotkey_List, "Footprint editor keys" &g_ModuleEditSectionTag, s_module_edit_Hotkey_List, L"Footprint editor keys"
},{ },{
NULL, NULL, NULL NULL, NULL, NULL
} }; } };
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "id.h" #include "id.h"
#include "hotkeys.h"
#include "build_version.h" #include "build_version.h"
...@@ -134,10 +135,10 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); ...@@ -134,10 +135,10 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
} }
g_DrawBgColor = BLACK; g_DrawBgColor = BLACK;
Read_Hotkey_Config( frame, false ); /* Must be called before creating the
* main frame in order to display the
* real hotkeys in menus or tool tips */
/* Must be called before creating the main frame in order to
* display the real hotkeys in menus or tool tips */
ReadHotkeyConfig( wxT("PcbFrame"), s_Board_Editor_Hokeys_Descr );
frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "dialog_general_options.h" #include "dialog_general_options.h"
#include "pcbnew_config.h" #include "pcbnew_config.h"
#include "dialog_hotkeys_editor.h"
#define HOTKEY_FILENAME wxT( "pcbnew" ) #define HOTKEY_FILENAME wxT( "pcbnew" )
...@@ -105,35 +106,22 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) ...@@ -105,35 +106,22 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
LoadProjectSettings( dlg.GetPath() ); LoadProjectSettings( dlg.GetPath() );
break; break;
} }
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG:
fn.SetPath( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ) );
fn.SetName( HOTKEY_FILENAME );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
WriteHotkeyConfigFile( fn.GetFullPath(), s_Pcbnew_Editor_Hokeys_Descr, true );
break;
case ID_PREFERENCES_HOTKEY_READ_CONFIG: /* Hotkey IDs */
Read_Hotkey_Config( this, true ); case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( s_Board_Editor_Hokeys_Descr );
break; break;
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG: case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
{ ImportHotkeyConfigFromFile( s_Board_Editor_Hokeys_Descr );
fn.SetPath( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ) );
fn.SetName( HOTKEY_FILENAME );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
break; break;
}
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME: case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD: InstallHotkeyFrame( this, s_Board_Editor_Hokeys_Descr );
HandleHotkeyConfigMenuSelection( this, id );
break; break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
// Display current hotkey list for eeschema.
DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr ); DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr );
break; break;
...@@ -143,20 +131,6 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) ...@@ -143,20 +131,6 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
} }
/*
* Read the hotkey files config for pcbnew and module_edit
*/
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
{
wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += wxT( "." );
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
return frame->ReadHotkeyConfigFile( FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose );
}
/** /**
* Read the project configuration file settings. * Read the project configuration file settings.
* *
......
...@@ -43,17 +43,6 @@ class D_PAD; ...@@ -43,17 +43,6 @@ class D_PAD;
void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector ); void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector );
/* Create a sorted list of pointers to pads.
* This list is sorted by X coordinate value.
* The list must be freed bu user
*/
/**************/
/* PCBCFG.CPP */
/**************/
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/***************/ /***************/
/* TRPISTE.CPP */ /* TRPISTE.CPP */
/***************/ /***************/
......
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