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
confirm.cpp
copy_to_clipboard.cpp
dialog_display_info_HTML_base.cpp
dialog_hotkeys_editor.cpp
dialog_hotkeys_editor_base.cpp
dialog_load_error.cpp
dcsvg.cpp
dialog_page_settings_base.cpp
......@@ -42,6 +44,7 @@ set(COMMON_SRCS
get_component_dialog.cpp
gr_basic.cpp
hotkeys_basic.cpp
hotkey_grid_table.cpp
msgpanel.cpp
netlist_keywords.cpp
newstroke_font.cpp
......
......@@ -355,13 +355,21 @@ void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& WXUNUSED( ev
#define __BO_COMPILER ",unknown"
#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 \
" (" __WX_BO_DEBUG "," __WX_BO_UNICODE \
__ABI_VERSION __BO_COMPILER \
__WX_BO_STL \
__WX_BO_WXWIN_COMPAT_2_4 __WX_BO_WXWIN_COMPAT_2_6 \
")"
#endif
tmp = wxT( "Application: " ) + wxGetApp().GetTitle() + wxT( "\n" );
tmp += wxT( "Version: " ) + GetBuildVersion() + wxT( "\n" );
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 );
}
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="9" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_hotkeys_editor_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">dialog_hotkeys_editor_base</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="bg"></property>
<property name="center"></property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">HOTKEYS_EDITOR_DIALOG_BASE</property>
<property name="pos"></property>
<property name="size">304,235</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Hotkeys Editor</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bMainSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxGrid" expanded="1">
<property name="autosize_cols">1</property>
<property name="autosize_rows">0</property>
<property name="bg"></property>
<property name="cell_bg"></property>
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="col_label_size">30</property>
<property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">2</property>
<property name="column_sizes"></property>
<property name="context_help"></property>
<property name="drag_col_move">0</property>
<property name="drag_col_size">1</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">1</property>
<property name="editing">1</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label_bg"></property>
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">0</property>
<property name="margin_width">0</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_hotkeyGrid</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="row_label_size">0</property>
<property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="row_sizes"></property>
<property name="rows">5</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar">KeyPressed</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick">StartEditing</event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick"></event>
<event name="OnGridCellRightDClick"></event>
<event name="OnGridCmdCellChange"></event>
<event name="OnGridCmdCellLeftClick"></event>
<event name="OnGridCmdCellLeftDClick"></event>
<event name="OnGridCmdCellRightClick"></event>
<event name="OnGridCmdCellRightDClick"></event>
<event name="OnGridCmdColSize"></event>
<event name="OnGridCmdEditorCreated"></event>
<event name="OnGridCmdEditorHidden"></event>
<event name="OnGridCmdEditorShown"></event>
<event name="OnGridCmdLabelLeftClick"></event>
<event name="OnGridCmdLabelLeftDClick"></event>
<event name="OnGridCmdLabelRightClick"></event>
<event name="OnGridCmdLabelRightDClick"></event>
<event name="OnGridCmdRangeSelect"></event>
<event name="OnGridCmdRowSize"></event>
<event name="OnGridCmdSelectCell"></event>
<event name="OnGridColSize"></event>
<event name="OnGridEditorCreated"></event>
<event name="OnGridEditorHidden"></event>
<event name="OnGridEditorShown"></event>
<event name="OnGridLabelLeftClick"></event>
<event name="OnGridLabelLeftDClick"></event>
<event name="OnGridLabelRightClick"></event>
<event name="OnGridLabelRightDClick"></event>
<event name="OnGridRangeSelect"></event>
<event name="OnGridRowSize"></event>
<event name="OnGridSelectCell"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer2</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="default">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_OK</property>
<property name="label">OK</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_OKButton</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnOKClicked</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="default">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Close</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name"> m_cancelButton</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">CancelClicked</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="default">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_CANCEL</property>
<property name="label">Undo</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_undoButton</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">UndoClicked</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>
///////////////////////////////////////////////////////////////////////////
// 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 )
/* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
* 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;
INSTALL_DC( DC, this );
......
......@@ -612,8 +612,6 @@ void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory)
m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ),
wxLANGUAGE_DEFAULT );
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 );
......
#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;
}
}
}
......@@ -16,10 +16,13 @@
#include "kicad_string.h"
#include "gestfich.h"
#include "wxstruct.h"
#include "dialog_hotkeys_editor.h"
#include <wx/apptrait.h>
#include <wx/stdpaths.h>
#include <wx/tokenzr.h>
#define HOTKEYS_CONFIG_KEY wxT( "Keys" )
wxString g_CommonSectionTag( wxT( "[common]" ) );
wxString g_SchematicSectionTag( wxT( "[eeschema]" ) );
......@@ -28,13 +31,6 @@ wxString g_BoardEditorSectionTag( wxT( "[pcbnew]" ) );
wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) );
/* 0 = files are in Home directory (usefull under unix)
* 1 = kicad/template ( usefull only under windows )
* 2 ... = unused
*/
int g_ConfigFileLocationChoice;
/* 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.
......@@ -53,6 +49,15 @@ Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand,
}
Ki_HotkeyInfo::Ki_HotkeyInfo( const Ki_HotkeyInfo* base )
{
m_KeyCode = base->m_KeyCode;
m_InfoMsg = base->m_InfoMsg;
m_Idcommand = base->m_Idcommand;
m_IdMenuEvent = base->m_IdMenuEvent;
}
/* class to handle the printable name and the keycode
*/
struct hotkey_name_descr
......@@ -61,154 +66,44 @@ struct hotkey_name_descr
int m_KeyCode;
};
/* table giving the hotkey name from the hotkey code, for special keys
* Note : when modifiers (ATL, SHIFT, CTRL) do not modify
* the code of the key, do need to enter the modified key code
* For instance wxT( "F1" ), WXK_F1 handle F1, AltF1, CtrlF1 ...
*/
static struct hotkey_name_descr s_Hotkey_Name_List[] =
{
{ wxT( "F1" ), WXK_F1 },
{ wxT( "F2" ), WXK_F2 },
{ wxT( "F3" ), WXK_F3 },
{ wxT( "F4" ), WXK_F4 },
{ wxT( "F5" ), WXK_F5 },
{ wxT( "F6" ), WXK_F6 },
{ wxT( "F7" ), WXK_F7 },
{ wxT( "F8" ), WXK_F8 },
{ wxT( "F9" ), WXK_F9 },
{ wxT( "F10" ), WXK_F10 },
{ wxT( "F11" ), WXK_F11 },
{ wxT( "F12" ), WXK_F12 },
{ wxT( "Esc" ), WXK_ESCAPE },
{ wxT( "Del" ), WXK_DELETE },
{ wxT( "Tab" ), '\t' },
{ wxT( "BkSp" ), WXK_BACK },
{ wxT( "Ins" ), WXK_INSERT },
{ wxT( "Home" ), WXK_HOME },
{ wxT( "End" ), WXK_END },
{ wxT( "PgUp" ), WXK_PAGEUP },
{ wxT( "PgDn" ), WXK_PAGEDOWN },
{ wxT( "Up" ), WXK_UP },
{ wxT( "Down" ), WXK_DOWN },
{ wxT( "Left" ), WXK_LEFT },
{ wxT( "Right" ), WXK_RIGHT },
{ wxT( "space" ), ' ' },
{ wxT( "?" ), '?' },
{ wxT( "!" ), '!' },
{ wxT( ";" ), ';' },
{ wxT( ":" ), ':' },
{ wxT( "." ), '.' },
{ wxT( "," ), ',' },
{ wxT( "*" ), '*' },
{ wxT( "+" ), '+' },
{ wxT( "=" ), '=' },
{ wxT( "-" ), '-' },
{ wxT( "%%" ), '%' },
{ wxT( "[" ), '[' },
{ wxT( "]" ), ']' },
{ wxT( "'" ), '\'' },
{ wxT( "`" ), '`' },
{ wxT( "/" ), '/' },
{ wxT( "\\" ), '\\' },
{ wxT( "0" ), '0' },
{ wxT( "1" ), '1' },
{ wxT( "2" ), '2' },
{ wxT( "3" ), '3' },
{ wxT( "4" ), '4' },
{ wxT( "5" ), '5' },
{ wxT( "6" ), '6' },
{ wxT( "7" ), '7' },
{ wxT( "8" ), '8' },
{ wxT( "9" ), '9' },
{ wxT( "A" ), 'A' },
{ wxT( "B" ), 'B' },
{ wxT( "C" ), 'C' },
{ wxT( "D" ), 'D' },
{ wxT( "E" ), 'E' },
{ wxT( "F" ), 'F' },
{ wxT( "G" ), 'G' },
{ wxT( "H" ), 'H' },
{ wxT( "I" ), 'I' },
{ wxT( "J" ), 'J' },
{ wxT( "K" ), 'K' },
{ wxT( "L" ), 'L' },
{ wxT( "M" ), 'M' },
{ wxT( "N" ), 'N' },
{ wxT( "O" ), 'O' },
{ wxT( "P" ), 'P' },
{ wxT( "Q" ), 'Q' },
{ wxT( "R" ), 'R' },
{ wxT( "S" ), 'S' },
{ wxT( "T" ), 'T' },
{ wxT( "U" ), 'U' },
{ wxT( "V" ), 'V' },
{ wxT( "W" ), 'W' },
{ wxT( "X" ), 'X' },
{ wxT( "Y" ), 'Y' },
{ wxT( "Z" ), 'Z' },
{ wxT( "Ctrl++" ), GR_KB_CTRL + '+' },
{ wxT( "Ctrl+-" ), GR_KB_CTRL + '-' },
{ wxT( "Ctrl+A" ), GR_KB_CTRL + 'A' },
{ wxT( "Ctrl+B" ), GR_KB_CTRL + 'B' },
{ wxT( "Ctrl+C" ), GR_KB_CTRL + 'C' },
{ wxT( "Ctrl+D" ), GR_KB_CTRL + 'D' },
{ wxT( "Ctrl+E" ), GR_KB_CTRL + 'E' },
{ wxT( "Ctrl+F" ), GR_KB_CTRL + 'F' },
{ wxT( "Ctrl+G" ), GR_KB_CTRL + 'G' },
{ wxT( "Ctrl+H" ), GR_KB_CTRL + 'H' },
{ wxT( "Ctrl+I" ), GR_KB_CTRL + 'I' },
{ wxT( "Ctrl+J" ), GR_KB_CTRL + 'J' },
{ wxT( "Ctrl+K" ), GR_KB_CTRL + 'K' },
{ wxT( "Ctrl+L" ), GR_KB_CTRL + 'L' },
{ wxT( "Ctrl+M" ), GR_KB_CTRL + 'M' },
{ wxT( "Ctrl+N" ), GR_KB_CTRL + 'N' },
{ wxT( "Ctrl+O" ), GR_KB_CTRL + 'O' },
{ wxT( "Ctrl+P" ), GR_KB_CTRL + 'P' },
{ wxT( "Ctrl+Q" ), GR_KB_CTRL + 'Q' },
{ wxT( "Ctrl+R" ), GR_KB_CTRL + 'R' },
{ wxT( "Ctrl+S" ), GR_KB_CTRL + 'S' },
{ wxT( "Ctrl+T" ), GR_KB_CTRL + 'T' },
{ wxT( "Ctrl+U" ), GR_KB_CTRL + 'U' },
{ wxT( "Ctrl+V" ), GR_KB_CTRL + 'V' },
{ wxT( "Ctrl+W" ), GR_KB_CTRL + 'W' },
{ wxT( "Ctrl+X" ), GR_KB_CTRL + 'X' },
{ wxT( "Ctrl+Y" ), GR_KB_CTRL + 'Y' },
{ wxT( "Ctrl+Z" ), GR_KB_CTRL + 'Z' },
{ wxT( "Shift+Ctrl++" ), GR_KB_SHIFT + GR_KB_CTRL + '+' },
{ wxT( "Shift+Ctrl+-" ), GR_KB_SHIFT + GR_KB_CTRL + '-' },
{ wxT( "Shift+Ctrl+A" ), GR_KB_SHIFT + GR_KB_CTRL + 'A' },
{ wxT( "Shift+Ctrl+B" ), GR_KB_SHIFT + GR_KB_CTRL + 'B' },
{ wxT( "Shift+Ctrl+C" ), GR_KB_SHIFT + GR_KB_CTRL + 'C' },
{ wxT( "Shift+Ctrl+D" ), GR_KB_SHIFT + GR_KB_CTRL + 'D' },
{ wxT( "Shift+Ctrl+E" ), GR_KB_SHIFT + GR_KB_CTRL + 'E' },
{ wxT( "Shift+Ctrl+F" ), GR_KB_SHIFT + GR_KB_CTRL + 'F' },
{ wxT( "Shift+Ctrl+G" ), GR_KB_SHIFT + GR_KB_CTRL + 'G' },
{ wxT( "Shift+Ctrl+H" ), GR_KB_SHIFT + GR_KB_CTRL + 'H' },
{ wxT( "Shift+Ctrl+I" ), GR_KB_SHIFT + GR_KB_CTRL + 'I' },
{ wxT( "Shift+Ctrl+J" ), GR_KB_SHIFT + GR_KB_CTRL + 'J' },
{ wxT( "Shift+Ctrl+K" ), GR_KB_SHIFT + GR_KB_CTRL + 'K' },
{ wxT( "Shift+Ctrl+L" ), GR_KB_SHIFT + GR_KB_CTRL + 'L' },
{ wxT( "Shift+Ctrl+M" ), GR_KB_SHIFT + GR_KB_CTRL + 'M' },
{ wxT( "Shift+Ctrl+N" ), GR_KB_SHIFT + GR_KB_CTRL + 'N' },
{ wxT( "Shift+Ctrl+O" ), GR_KB_SHIFT + GR_KB_CTRL + 'O' },
{ wxT( "Shift+Ctrl+P" ), GR_KB_SHIFT + GR_KB_CTRL + 'P' },
{ wxT( "Shift+Ctrl+Q" ), GR_KB_SHIFT + GR_KB_CTRL + 'Q' },
{ wxT( "Shift+Ctrl+R" ), GR_KB_SHIFT + GR_KB_CTRL + 'R' },
{ wxT( "Shift+Ctrl+S" ), GR_KB_SHIFT + GR_KB_CTRL + 'S' },
{ wxT( "Shift+Ctrl+T" ), GR_KB_SHIFT + GR_KB_CTRL + 'T' },
{ wxT( "Shift+Ctrl+U" ), GR_KB_SHIFT + GR_KB_CTRL + 'U' },
{ wxT( "Shift+Ctrl+V" ), GR_KB_SHIFT + GR_KB_CTRL + 'V' },
{ wxT( "Shift+Ctrl+W" ), GR_KB_SHIFT + GR_KB_CTRL + 'W' },
{ wxT( "Shift+Ctrl+X" ), GR_KB_SHIFT + GR_KB_CTRL + 'X' },
{ wxT( "Shift+Ctrl+Y" ), GR_KB_SHIFT + GR_KB_CTRL + 'Y' },
{ wxT( "Shift+Ctrl+Z" ), GR_KB_SHIFT + GR_KB_CTRL + 'Z' },
{ wxT( "F1" ), WXK_F1 },
{ wxT( "F2" ), WXK_F2 },
{ wxT( "F3" ), WXK_F3 },
{ wxT( "F4" ), WXK_F4 },
{ wxT( "F5" ), WXK_F5 },
{ wxT( "F6" ), WXK_F6 },
{ wxT( "F7" ), WXK_F7 },
{ wxT( "F8" ), WXK_F8 },
{ wxT( "F9" ), WXK_F9 },
{ wxT( "F10" ), WXK_F10 },
{ wxT( "F11" ), WXK_F11 },
{ wxT( "F12" ), WXK_F12 },
{ wxT( "Esc" ), WXK_ESCAPE },
{ wxT( "Del" ), WXK_DELETE },
{ wxT( "Tab" ), '\t' },
{ wxT( "BkSp" ), WXK_BACK },
{ wxT( "Ins" ), WXK_INSERT },
{ wxT( "Home" ), WXK_HOME },
{ wxT( "End" ), WXK_END },
{ wxT( "PgUp" ), WXK_PAGEUP },
{ wxT( "PgDn" ), WXK_PAGEDOWN },
{ wxT( "Up" ), WXK_UP },
{ wxT( "Down" ), WXK_DOWN },
{ wxT( "Left" ), WXK_LEFT },
{ wxT( "Right" ), WXK_RIGHT },
// Do not change this line: end of list
{ wxT( "" ), 0 }
{ wxT( "" ), 0 }
};
......@@ -217,12 +112,14 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
* Only some wxWidgets key values are handled for function key ( see
* s_Hotkey_Name_List[] )
* @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
*/
wxString ReturnKeyNameFromKeyCode( int aKeycode )
wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
{
wxString keyname, modifier, fullkeyname;
int ii;
bool found = false;
if( (aKeycode & GR_KB_CTRL) != 0 )
modifier << wxT( "Ctrl+" );
......@@ -232,20 +129,32 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode )
modifier << wxT( "Shift+" );
aKeycode &= ~( GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT );
for( ii = 0; ; ii++ )
if( (aKeycode >= ' ') && (aKeycode < 0x7F ) )
{
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )
{
keyname = wxT( "<unknown>" );
break;
}
if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode )
found = true;
keyname.Append((wxChar)aKeycode);
}
else
{
for( ii = 0; ; ii++ )
{
keyname = s_Hotkey_Name_List[ii].m_Name;
break;
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 ) // End of list
{
keyname = wxT( "<unknown>" );
break;
}
if( s_Hotkey_Name_List[ii].m_KeyCode == aKeycode )
{
keyname = s_Hotkey_Name_List[ii].m_Name;
found = true;
break;
}
}
}
if( aIsFound )
*aIsFound = found;
fullkeyname = modifier + keyname;
return fullkeyname;
}
......@@ -261,23 +170,25 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode )
* @return a wxString (aTest + key name) if key found or aText without modification
*/
wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
int aCommandId , bool aIsShortCut )
int aCommandId, bool aIsShortCut )
{
wxString msg = aText;
wxString msg = aText;
wxString keyname;
if( aList )
keyname = ReturnKeyNameFromCommandId( aList, aCommandId );
if( !keyname.IsEmpty() )
{
if ( aIsShortCut )
if( aIsShortCut )
msg << wxT( "\t" ) << keyname;
else
msg << wxT( " <" ) << keyname << wxT(">");
msg << wxT( " <" ) << keyname << wxT( ">" );
}
return msg;
}
/** function AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value)
* @param aText = a wxString. returns aText + key name
......@@ -304,10 +215,10 @@ wxString AddHotkeyName( const wxString& aText,
keyname = ReturnKeyNameFromCommandId( List, aCommandId );
if( !keyname.IsEmpty() )
{
if ( aIsShortCut )
if( aIsShortCut )
msg << wxT( "\t" ) << keyname;
else
msg << wxT( " <" ) << keyname << wxT(">");
msg << wxT( " <" ) << keyname << wxT( ">" );
break;
}
}
......@@ -352,6 +263,37 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
{
int ii, keycode = 0;
// Search for modifiers: Ctrl+ Alt+ and Shift+
wxString key = keyname;
int modifier = 0;
while( 1 )
{
if( key.StartsWith(wxT("Ctrl+") ) )
{
modifier |= GR_KB_CTRL;
key.Remove( 0, 5 );
}
else if( key.StartsWith(wxT("Alt+") ) )
{
modifier |= GR_KB_ALT;
key.Remove( 0, 4 );
}
else if( key.StartsWith(wxT("Shift+") ) )
{
modifier |= GR_KB_SHIFT;
key.Remove( 0, 6 );
}
else
break;
}
if( (key[0] >= ' ') && (key[0] < 0x7F) )
{
keycode = key[0];
keycode += modifier;
}
for( ii = 0; ; ii++ )
{
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 ) // End of list reached
......@@ -359,7 +301,7 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
if( keyname.CmpNoCase( s_Hotkey_Name_List[ii].m_Name ) == 0 )
{
keycode = s_Hotkey_Name_List[ii].m_KeyCode;
keycode = s_Hotkey_Name_List[ii].m_KeyCode + modifier;
break;
}
}
......@@ -418,189 +360,165 @@ Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList )
}
/*
* Create a configuration file (*.key) from the current hotkey list
* @param Filename = default full file name to create. If void, A filename
* will be asked
* @param List = pointer to the current hotkey list.
* the ouput format is: shortcut "key" "function"
* lines starting with # are comments
/** 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 WinEDA_BasicFrame::WriteHotkeyConfigFile(
const wxString& Filename,
struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose )
int WinEDA_BasicFrame::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList,
wxString* aFullFileName )
{
wxString FullFilename = Filename;
FILE* cfgfile;
wxString msg;
if( FullFilename.IsEmpty() || verbose )
{
wxString Mask, Path, Ext;
Ext = DEFAULT_HOTKEY_FILENAME_EXT;
Mask = wxT( "*." ) + Ext;
Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFilename = EDA_FileSelector( _( "Save Hotkey Configuration File:" ),
Path,
FullFilename,
Ext,
Mask,
this,
wxFD_SAVE,
TRUE );
}
if( FullFilename.IsEmpty() )
return 0;
cfgfile = wxFopen( FullFilename, wxT( "wt" ) );
if( cfgfile == NULL )
{
if( verbose )
{
msg = _( "Unable to create " ) + FullFilename;
DisplayError( this, msg );
}
return 0;
}
wxString keyname, infokey;
msg = wxT( "$hotkey list\n" );
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
/* print the allowed keys, for info
*/
msg = wxT( "# " ); msg += _( "Allowed keys:\n" );
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
msg.Empty();
for( int ii = 0; ; ii++ )
{
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )
break;;
if( msg.IsEmpty() )
msg = wxT( "# " );
else
msg += wxT( ", " );
msg += s_Hotkey_Name_List[ii].m_Name;
if( msg.Len() > 60 )
{
msg += wxT( "\n" );
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
msg.Empty();
}
}
/* print the last line of the info section */
if( !msg.IsEmpty() )
msg += wxT( "\n" );
msg += wxT( "#\n#\n" );
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
/* Print the current hotkey list */
Ki_HotkeyInfo** List;
for( ; DescList->m_HK_InfoList != NULL; DescList++ )
for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
{
if( DescList->m_Comment )
if( aDescList->m_Comment )
{
fprintf( cfgfile, "# " );
fprintf( cfgfile, "%s\n", DescList->m_Comment );
msg += wxT( "# " );
msg += wxString( aDescList->m_Comment );
msg += wxT( "\n" );
}
msg = *DescList->m_SectionTag;
fprintf( cfgfile, "%s\n", CONV_TO_UTF8( msg ) );
List = DescList->m_HK_InfoList;
msg += *aDescList->m_SectionTag;
msg += wxT( "\n" );
List = aDescList->m_HK_InfoList;
for( ; *List != NULL; List++ )
{
Ki_HotkeyInfo* hk_decr = *List;
msg = wxT( "shortcut " );
msg += wxT( "shortcut " );
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
AddDelimiterString( keyname );
infokey = hk_decr->m_InfoMsg;
AddDelimiterString( infokey );
msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
fprintf( cfgfile, "%s", CONV_TO_UTF8( msg ) );
}
}
msg = wxT( "$Endlist\n" );
fprintf( cfgfile, "%s\n", CONV_TO_UTF8( msg ) );
fclose( cfgfile );
msg += wxT( "$Endlist\n" );
if( aFullFileName )
{
FILE* file = wxFopen( *aFullFileName, wxT( "wt" ) );
if( file )
fputs( CONV_TO_UTF8( msg ), file );
else
{
msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
return 0;
}
}
else
{
wxConfig config( m_FrameName );
config.Write( HOTKEYS_CONFIG_KEY, msg );
}
return 1;
}
/*
* Read a configuration file (<file>.key) and fill the current hotkey list
/** Function ReadHotkeyConfigFile
* Read an old configuration file (<file>.key) and fill the current hotkey list
* with hotkeys
* @param Filename = default full file name to create. If void, A filename
* will be asked
* @param DescList = current hotkey list descr. to initialise.
* the input format is: shortcut "key" "function"
* lines starting by # are ignored (comments)
* lines like [xxx] are tags (example: [common] or [libedit] which identify
* sections
*
* @param aFilename = file name to read.
* @param aDescList = current hotkey list descr. to initialise.
*/
int WinEDA_BasicFrame::ReadHotkeyConfigFile(
const wxString& Filename,
struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose )
const wxString& aFilename,
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
wxString FullFilename = Filename;
FILE* cfgfile;
wxString msg;
wxFile cfgfile( aFilename );
if( FullFilename.IsEmpty() || verbose )
{
wxString Mask, Path, Ext;
Ext = DEFAULT_HOTKEY_FILENAME_EXT;
Mask = wxT( "*." ) + Ext;
Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFilename = EDA_FileSelector( _( "Open Hotkey Configuration File:" ),
Path,
FullFilename,
Ext,
Mask,
this,
wxFD_OPEN,
TRUE );
if( FullFilename.IsEmpty() )
return 0;
}
/* get length */
cfgfile.SeekEnd();
wxFileOffset size = cfgfile.Tell();
cfgfile.Seek( 0 );
/* read data */
char* buffer = new char[size];
cfgfile.Read( buffer, size );
wxString data( buffer, wxConvUTF8 );
cfgfile = wxFopen( FullFilename, wxT( "rt" ) );
/* parse */
ParseHotkeyConfig( data, aDescList );
if( cfgfile == NULL )
/* cleanup */
delete buffer;
cfgfile.Close();
return 1;
}
void ReadHotkeyConfig( const wxString& Appname,
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
wxConfig config( Appname );
if( !config.HasEntry( HOTKEYS_CONFIG_KEY ) )
{
if( verbose )
{
msg = _( "Unable to read " ) + FullFilename;
DisplayError( this, msg );
}
return 0;
// assume defaults are ok
return;
}
wxString keyname;
char Line[1024];
int LineNum = 0;
Ki_HotkeyInfo** CurrentHotkeyList = NULL;
wxString data;
config.Read( HOTKEYS_CONFIG_KEY, &data );
ParseHotkeyConfig( data, aDescList );
}
/** Function ReadHotkeyConfig
* Read configuration data and fill the current hotkey list with hotkeys
* @param aDescList = current hotkey list descr. to initialise.
*/
int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
::ReadHotkeyConfig( m_FrameName, aDescList );
return 1;
}
/* Read the file */
while( GetLine( cfgfile, Line, &LineNum ) != NULL )
/** Function ParseHotkeyConfig
* the input format is: shortcut "key" "function"
* lines starting by # are ignored (comments)
* lines like [xxx] are tags (example: [common] or [libedit] which identify
* sections
*/
void ParseHotkeyConfig(
const wxString& data,
struct Ki_HotkeyInfoSectionDescriptor* DescList )
{
/* Read the config */
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
Ki_HotkeyInfo** CurrentHotkeyList = 0;
while( tokenizer.HasMoreTokens() )
{
char* line_type, * keyname, * fctname;
line_type = strtok( Line, " \t\n\r" );
msg = CONV_FROM_UTF8( line_type );
if( msg[0] == '[' ) // A tag is found. search infos in list
wxString line = tokenizer.GetNextToken();
wxStringTokenizer lineTokenizer( line );
wxString line_type = lineTokenizer.GetNextToken();
if( line_type[0] == '#' ) //comment
continue;
if( line_type[0] == '[' ) // A tag is found. search infos in list
{
CurrentHotkeyList = NULL;
CurrentHotkeyList = 0;
Ki_HotkeyInfoSectionDescriptor* DList = DescList;
for( ; DList->m_HK_InfoList != NULL; DList++ )
for( ; DList->m_HK_InfoList; DList++ )
{
if( *DList->m_SectionTag == msg )
if( *DList->m_SectionTag == line_type )
{
CurrentHotkeyList = DList->m_HK_InfoList;
break;
......@@ -609,32 +527,29 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(
continue;
}
if( msg != wxT( "shortcut" ) )
continue;
if( msg == wxT( "$Endlist" ) )
if( line_type == wxT( "$Endlist" ) )
break;
if( line_type != wxT( "shortcut" ) )
continue;
if( CurrentHotkeyList == NULL )
continue;
/* Get the key name */
strtok( NULL, "\"\n\r" );
keyname = strtok( NULL, "\"\n\r" );
lineTokenizer.SetString( lineTokenizer.GetString(), L"\"\r\n\t ", wxTOKEN_STRTOK );
wxString keyname = lineTokenizer.GetNextToken();
strtok( NULL, "\"\n\r" );
wxString remainder = lineTokenizer.GetString();
/* Get the command name */
fctname = strtok( NULL, "\"\n\r" );
msg = CONV_FROM_UTF8( fctname );
wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' );
/* search the hotkey in current hotkey list */
for( Ki_HotkeyInfo** List = CurrentHotkeyList; *List != NULL; List++ )
{
Ki_HotkeyInfo* hk_decr = *List;
if( hk_decr->m_InfoMsg == msg )
if( hk_decr->m_InfoMsg == fctname )
{
msg = CONV_FROM_UTF8( keyname );
int code = ReturnKeyCodeFromKeyName( msg );
int code = ReturnKeyCodeFromKeyName( keyname );
if( code )
hk_decr->m_KeyCode = code;
......@@ -642,47 +557,67 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(
}
}
}
fclose( cfgfile );
return 1;
}
/* return the hotkey config file path
* @param choice : 0 = home, 1 = kicad/share/template
/** Function ImportHotkeyConfigFromFile
* Prompt the user for an old hotkey file to read, and read it.
* @param aDescList = current hotkey list descr. to initialise.
*/
wxString ReturnHotkeyConfigFilePath( int choice )
void WinEDA_BasicFrame::ImportHotkeyConfigFromFile(
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
wxString path;
wxAppTraits* traits = wxGetApp().GetTraits();
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
wxString mask = wxT( "*." ) + ext;
wxString path = wxGetCwd();
wxString filename;
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
path,
filename,
ext,
mask,
this,
wxFD_OPEN,
TRUE );
if( filename.IsEmpty() )
return;
switch( choice )
{
case 0:
path = traits->GetStandardPaths().GetUserConfigDir() +
wxFileName::GetPathSeparator();
case 1:
/* TODO: This is broken under a normal Poxis system. Users
* generally do no have write permissions to this path
* and there is no provision for prompting for the root
* password. Suggest we remove this unless someone has
* a workable solution (Wayne).
*/
path = ReturnKicadDatasPath() + wxT( "template/" );
break;
default:
break;
}
ReadHotkeyConfigFile( filename, aDescList );
}
return path;
/** Function ExportHotkeyConfigToFile
* Prompt the user for an old hotkey file to read, and read it.
* @param aDescList = current hotkey list descr. to initialise.
*/
void WinEDA_BasicFrame::ExportHotkeyConfigToFile(
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
wxString mask = wxT( "*." ) + ext;
wxString path = wxGetCwd();
wxString filename;
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
path,
filename,
ext,
mask,
this,
wxFD_OPEN,
TRUE );
if( filename.IsEmpty() )
return;
WriteHotkeyConfig( aDescList, &filename );
}
/** add hotkey config options submenu to a menu
* @param menu : initial menu
* @param menu : root menu
*/
void AddHotkeyConfigMenu( wxMenu* aMenu )
{
......@@ -700,99 +635,33 @@ void AddHotkeyConfigMenu( wxMenu* aMenu )
item->SetBitmap( info_xpm );
HotkeySubmenu->Append( item );
/* (Re)create hotkey file */
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_CREATE_CONFIG,
_( "(Re)create Hotkeys File" ),
/* Call hotkeys editor*/
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
_( "Edit Hotkeys" ),
_( "Call the hotkeys editor" ) );
item->SetBitmap( editor_xpm );
HotkeySubmenu->Append( item );
HotkeySubmenu->AppendSeparator();
/* create hotkey file to export current hotkeys config */
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
_( "Export Hotkeys Config" ),
_(
"Create or recreate the hotkey configuration file from current hotkey list" )
"Create a hotkey configuration file to export the current hotkey config" )
);
item->SetBitmap( save_setup_xpm );
HotkeySubmenu->Append( item );
/* Reload hotkey file */
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_READ_CONFIG,
_( "Reload Hotkeys File" ),
_( "Reload the hotkey configuration file" ) );
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
_( "Import Hotkeys Config" ),
_( "Load an existing hotkey configuration file" ) );
item->SetBitmap( reload_xpm );
HotkeySubmenu->Append( item );
/* Edit hotkey file */
item = new wxMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_EDIT_CONFIG,
_( "Edit Hotkeys File" ),
_( "Edit the hotkey configuration file in a text editor" ) );
item->SetBitmap( editor_xpm );
HotkeySubmenu->Append( item );
/* Append HotkeySubmenu to menu */
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( aMenu, HotkeySubmenu,
ID_PREFERENCES_HOTKEY_SUBMENU, _( "Hotkeys" ),
_( "Hotkeys configuration and preferences" ), hotkeys_xpm );
/* Hotkey path */
wxMenu* HotkeyLocationSubmenu = new wxMenu();
/* Home directory */
item = new wxMenuItem( HotkeyLocationSubmenu,
ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
_( "Home directory" ),
_( "Use home directory to load or store Hotkey config files" ),
wxITEM_CHECK );
HotkeyLocationSubmenu->Append( item );
/* KiCad template directory */
item = new wxMenuItem( HotkeyLocationSubmenu,
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
_( "KiCad template directory" ),
_( "Use kicad/template directory to load or store Hotkey config files" ),
wxITEM_CHECK );
HotkeyLocationSubmenu->Append( item );
/* Append location submenu to HotkeySubmenu */
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( HotkeySubmenu, HotkeyLocationSubmenu,
-1, _( "Location" ),
_( "Select hotkey configuration file location" ),
right_xpm );
HotkeyLocationSubmenu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
g_ConfigFileLocationChoice == 0 );
HotkeyLocationSubmenu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
g_ConfigFileLocationChoice == 1 );
}
/* called on hotkey file location selecton menu
* @param frame = current WinEDA_DrawFrame
* @param id = selected menu id
* @return g_ConfigFileLocationChoice (global) = new selection
*/
void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id )
{
wxMenuBar* menu = frame->GetMenuBar();
wxConfig* config = wxGetApp().m_EDA_CommonConfig;
switch( id )
{
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
if( g_ConfigFileLocationChoice != 0 )
{
g_ConfigFileLocationChoice = 0;
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, true );
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, false );
config->Write( HOTKEY_CFG_PATH_OPT, g_ConfigFileLocationChoice );
}
break;
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
if( g_ConfigFileLocationChoice != 1 )
{
g_ConfigFileLocationChoice = 1;
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, false );
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, true );
config->Write( HOTKEY_CFG_PATH_OPT, g_ConfigFileLocationChoice );
}
break;
default:
break;
}
}
......@@ -15,6 +15,7 @@
#include "program.h"
#include "general.h"
#include "protos.h"
#include "hotkeys.h"
#include <wx/snglinst.h>
......@@ -147,10 +148,9 @@ bool WinEDA_App::OnInit()
bool reopenLastUsedDirectory = argc == 1;
GetSettings( reopenLastUsedDirectory );
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("SchematicFrame"), s_Eeschema_Hokeys_Descr );
// Create main frame (schematic frame) :
frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ),
......
......@@ -18,6 +18,7 @@
#include "worksheet.h"
#include "hotkeys.h"
#include "dialog_eeschema_options.h"
#include "dialog_hotkeys_editor.h"
#include <wx/fdrepdlg.h>
......@@ -65,30 +66,16 @@ void WinEDA_LibeditFrame::Process_Config( wxCommandEvent& event )
/* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG:
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
HOTKEY_FILENAME,
DEFAULT_HOTKEY_FILENAME_EXT );
WriteHotkeyConfigFile( fn.GetFullPath(), s_Eeschema_Hokeys_Descr, true );
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_READ_CONFIG:
Read_Hotkey_Config( this, true );
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( 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;
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
HandleHotkeyConfigMenuSelection( this, id );
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
......@@ -141,30 +128,16 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
/* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG:
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
HOTKEY_FILENAME,
DEFAULT_HOTKEY_FILENAME_EXT );
WriteHotkeyConfigFile( fn.GetFullPath(), s_Eeschema_Hokeys_Descr, true );
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_READ_CONFIG:
Read_Hotkey_Config( this, true );
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
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;
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
HandleHotkeyConfigMenuSelection( this, id );
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
......@@ -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.
*
......
......@@ -213,9 +213,9 @@ Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] =
// an hotkey config file)
struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[] =
{
{ &g_CommonSectionTag, s_Common_Hotkey_List, "Common keys" },
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, "Schematic editor keys" },
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, "library editor keys" },
{ &g_CommonSectionTag, s_Common_Hotkey_List, L"Common keys" },
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, L"Schematic editor keys" },
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, L"library editor keys" },
{ NULL, NULL, NULL }
};
......
......@@ -23,7 +23,7 @@ static wxArrayString s_PowerNameList;
*/
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 ) )
{
......@@ -60,11 +60,15 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break;
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;
break;
}
}
}
else
{
......
<?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 );
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
const wxPoint& pos );
/***************/
/* EECONFIG.CPP */
/***************/
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/**************/
/* NETLIST.CPP */
......
......@@ -6,6 +6,7 @@ add_definitions(-DGERBVIEW -DPCBNEW)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR}
../3d-viewer
../common
../cvpcb
../pcbnew
../polygon)
......@@ -82,7 +83,7 @@ endif(APPLE)
###
add_executable(gerbview WIN32 MACOSX_BUNDLE
${GERBVIEW_SRCS}
${GERBVIEW_EXTRA_SRCS}
${GERBVIEW_EXTRA_SRCS}
${GERBVIEW_RESOURCES})
###
......
......@@ -17,6 +17,7 @@
#include "zones.h"
#include "class_board_design_settings.h"
#include "colors_selection.h"
#include "hotkeys.h"
#include "build_version.h"
......@@ -101,10 +102,10 @@ bool WinEDA_App::OnInit()
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("GerberFrame"), s_Gerbview_Hokeys_Descr );
frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ) );
......
......@@ -13,13 +13,8 @@
#include "pcbplot.h"
#include "hotkeys.h"
#include "class_board_design_settings.h"
#include "gerbview_config.h"
#include "protos.h"
#define HOTKEY_FILENAME wxT( "gerbview" )
#include "dialog_hotkeys_editor.h"
void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
{
......@@ -44,37 +39,20 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
break;
/* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG:
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += wxT(".");
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
WriteHotkeyConfigFile( FullFileName, s_Gerbview_Hokeys_Descr, true );
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( s_Gerbview_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_READ_CONFIG:
Read_Hotkey_Config( this, true );
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
ImportHotkeyConfigFromFile( s_Gerbview_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG:
{
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;
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
HandleHotkeyConfigMenuSelection( this, id );
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
InstallHotkeyFrame( this, s_Gerbview_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
// Display current hotkey list for eeschema.
DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
break;
......@@ -121,19 +99,3 @@ void WinEDA_GerberFrame::Update_config()
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 @@
int* InstallDialogLayerPairChoice( WinEDA_GerberFrame* parent );
bool Read_Config();
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
void Print_PcbItems( BOARD* Pcb, wxDC* DC, int drawmode, int printmasklayer );
......
......@@ -95,14 +95,14 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
wxGetApp().AddMenuLanguageList( configmenu );
AddHotkeyConfigMenu( configmenu );
configmenu->AppendSeparator();
ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_SAVE, _( "&Save Setup" ),
_( "Save application preferences" ),
save_setup_xpm );
configmenu->AppendSeparator();
AddHotkeyConfigMenu( configmenu );
wxMenu* miscellaneous_menu = new wxMenu;
ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_GERBVIEW_SHOW_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 @@
#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
* This class allows the real key code changed by user(from a key code list file)
......@@ -27,6 +24,7 @@ public:
public:
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)
......@@ -43,7 +41,7 @@ struct Ki_HotkeyInfoSectionDescriptor
public:
wxString* m_SectionTag; // The section name
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
};
......@@ -56,12 +54,9 @@ extern wxString g_LibEditSectionTag;
extern wxString g_BoardEditorSectionTag;
extern wxString g_ModuleEditSectionTag;
extern int g_ConfigFileLocationChoice;
/* Functions:
*/
wxString ReturnHotkeyConfigFilePath( int choice );
void AddHotkeyConfigMenu( wxMenu* menu );
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
* s_Hotkey_Name_List[] )
* @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
*/
wxString ReturnKeyNameFromKeyCode( int aKeycode );
wxString ReturnKeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL );
/** function ReturnKeyNameFromCommandId
* return the key name from the Command id value ( m_Idcommand member value)
......@@ -127,6 +123,18 @@ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame
*/
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
// these hotkey ID are used in many files, so they are define here only once.
......
......@@ -35,11 +35,9 @@ enum main_id
ID_PREFERENCES_HOTKEY_START,
ID_PREFERENCES_HOTKEY_SUBMENU,
ID_PREFERENCES_HOTKEY_CREATE_CONFIG,
ID_PREFERENCES_HOTKEY_READ_CONFIG,
ID_PREFERENCES_HOTKEY_EDIT_CONFIG,
ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
ID_PREFERENCES_HOTKEY_END,
......
......@@ -127,12 +127,48 @@ public:
virtual void LoadSettings();
virtual void SaveSettings();
int WriteHotkeyConfigFile( const wxString& Filename,
struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose );
int ReadHotkeyConfigFile( const wxString& Filename,
struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose );
// Read/Save and Import/export hotkeys config
/** 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,
struct Ki_HotkeyInfoSectionDescriptor* aDescList );
/** 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
* called on a language menu selection
* when using a derived function, do not forget to call this one
......
......@@ -6,6 +6,7 @@ add_definitions(-DPCBNEW)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR}
../3d-viewer
../common
../polygon)
###
......
......@@ -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)
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
} };
......
......@@ -25,6 +25,7 @@
#include "class_drawpanel.h"
#include "id.h"
#include "hotkeys.h"
#include "build_version.h"
......@@ -134,10 +135,10 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
}
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->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
......
......@@ -21,6 +21,7 @@
#include "dialog_general_options.h"
#include "pcbnew_config.h"
#include "dialog_hotkeys_editor.h"
#define HOTKEY_FILENAME wxT( "pcbnew" )
......@@ -105,35 +106,22 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
LoadProjectSettings( dlg.GetPath() );
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:
Read_Hotkey_Config( this, true );
/* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( s_Board_Editor_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG:
{
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 ) );
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
ImportHotkeyConfigFromFile( s_Board_Editor_Hokeys_Descr );
break;
}
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
HandleHotkeyConfigMenuSelection( this, id );
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
InstallHotkeyFrame( this, s_Board_Editor_Hokeys_Descr );
break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
// Display current hotkey list for eeschema.
DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr );
break;
......@@ -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.
*
......
......@@ -43,17 +43,6 @@ class D_PAD;
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 */
/***************/
......
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