7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 15:19:38 +00:00

Move hotkeys to ACTION architecture.

This commit is contained in:
Jeff Young 2019-06-09 22:57:23 +01:00
parent c13ef839c1
commit 5e49517781
162 changed files with 1851 additions and 4227 deletions
3d-viewer/3d_viewer
bitmap2component
common
cvpcb
eeschema
gerbview
include
kicad
pagelayout_editor
pcbnew
qa
common
gal/gal_pixel_alignment
pcb_test_window
qa_utils

View File

@ -201,7 +201,8 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
void DisplayHotKeys()
{
DisplayHotkeyList( this, GetHotkeyConfig() );
// JEY TODO: need a toolManager....
DisplayHotkeyList( this, GetToolManager() );
}
/**

View File

@ -31,7 +31,7 @@
#include "../3d_viewer_id.h"
// Define 3D Viewer Hotkeys
static EDA_HOTKEY HkHotkeysHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
static EDA_HOTKEY HkHotkeysHelp( _HKI( "List Hotkeys" ), wxID_HELP, GR_KB_CTRL + WXK_F1 );
static EDA_HOTKEY Hk3D_PivotCenter( _HKI( "Center pivot rotation (Middle mouse click)" ), 0, WXK_SPACE );
static EDA_HOTKEY Hk3D_MoveLeft( _HKI( "Move board Left" ), ID_POPUP_MOVE3D_LEFT, WXK_LEFT );
static EDA_HOTKEY Hk3D_MoveRight( _HKI( "Move board Right" ), ID_POPUP_MOVE3D_RIGHT, WXK_RIGHT );

View File

@ -3,6 +3,8 @@ if( COMPILER_SUPPORTS_WSHADOW )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WSHADOW_FLAGS}")
endif()
add_definitions( -DBITMAP_2_CMP )
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
../potrace

View File

@ -25,20 +25,17 @@
#include <fctsys.h>
#include <macros.h>
#include <wx/clipbrd.h>
#include <pgm_base.h>
#include <confirm.h>
#include <gestfich.h>
#include <wildcards_and_files_ext.h>
#include <bitmap_io.h>
#include <bitmaps.h>
#include <build_version.h>
#include <menus_helpers.h>
#include <kiway.h>
#include <kiface_i.h>
#include <wx/rawbmp.h>
#include <potracelib.h>
#include "bitmap2component.h"
#include "bitmap2cmp_gui_base.h"

View File

@ -376,6 +376,7 @@ set( COMMON_SRCS
tool/action_menu.cpp
tool/action_toolbar.cpp
tool/actions.cpp
tool/common_control.cpp
tool/common_tools.cpp
tool/conditional_menu.cpp
tool/edit_constraints.cpp

View File

@ -30,15 +30,15 @@
#include <wx/button.h>
DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aDescList ):
DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolMgr ):
DIALOG_SHIM( aParent, wxID_ANY, _( "Hotkey List" ) )
{
const auto margin = KIUI::GetStdMargin();
auto main_sizer = new wxBoxSizer( wxVERTICAL );
m_hk_list = new PANEL_HOTKEYS_EDITOR( aParent, this, true,
aDescList, aDescList, {} );
m_hk_list = new PANEL_HOTKEYS_EDITOR( this, true );
m_hk_list->AddHotKeys( aToolMgr );
main_sizer->Add( m_hk_list, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, margin );

View File

@ -32,27 +32,23 @@
#include <dialog_shim.h>
// Private forwards
class TOOL_MANAGER;
class PANEL_HOTKEYS_EDITOR;
/**
* A dialog that presents the user with a read-only list of hotkeys and
* their current bindings.
* A dialog that presents the user with a read-only list of hotkeys and their current bindings.
*/
class DIALOG_LIST_HOTKEYS: public DIALOG_SHIM
{
public:
/**
* Construct a hotkey list dialog on the given frame, with a set of hotkeys
* Construct a hotkey list dialog on the given frame
*
* @param aParent the parent frame
* @param aDescList the list of hotkey sections (each of which has a list
* of hotkeys) to display
*/
DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent,
EDA_HOTKEY_CONFIG* aDescList );
DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolManager );
protected:
@ -62,7 +58,6 @@ protected:
bool TransferDataToWindow() override;
private:
PANEL_HOTKEYS_EDITOR* m_hk_list;
};

View File

@ -22,16 +22,14 @@
*/
#include <panel_hotkeys_editor.h>
#include <eda_base_frame.h>
#include <kiway_player.h>
#include <wx/srchctrl.h>
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <widgets/button_row_panel.h>
#include <widgets/ui_common.h>
#include <tool/tool_manager.h>
static const wxSize default_dialog_size { 500, 350 };
static const wxSize min_dialog_size { -1, 350 };
@ -57,17 +55,10 @@ static wxSearchCtrl* CreateTextFilterBox( wxWindow* aParent, const wxString& aDe
}
PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow,
bool aReadOnly,
EDA_HOTKEY_CONFIG* aHotkeys,
EDA_HOTKEY_CONFIG* aShowHotkeys,
const wxString& aNickname ) :
PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( wxWindow* aWindow, bool aReadOnly ) :
wxPanel( aWindow, wxID_ANY, wxDefaultPosition, default_dialog_size ),
m_frame( aFrame ),
m_readOnly( aReadOnly ),
m_hotkeys( aHotkeys ),
m_nickname( aNickname ),
m_hotkeyStore( aShowHotkeys )
m_hotkeyStore()
{
const auto margin = KIUI::GetStdMargin();
auto mainSizer = new wxBoxSizer( wxVERTICAL );
@ -93,8 +84,13 @@ PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aW
this->Layout();
// Connect Events
filterSearch->Bind( wxEVT_COMMAND_TEXT_UPDATED,
&PANEL_HOTKEYS_EDITOR::OnFilterSearch, this );
filterSearch->Bind( wxEVT_COMMAND_TEXT_UPDATED, &PANEL_HOTKEYS_EDITOR::OnFilterSearch, this );
}
void PANEL_HOTKEYS_EDITOR::AddHotKeys( TOOL_MANAGER* aToolMgr )
{
m_toolManagers.push_back( aToolMgr );
}
@ -116,26 +112,19 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
[this]( wxCommandEvent& ){
m_hotkeyListCtrl->ResetAllHotkeys( true );
}
},
{
wxID_ANY,
_( "Import Hotkeys..." ),
_( "Import hotkey definitions from an external file, replacing the current values" ),
[this]( wxCommandEvent& ){
// JEY TODO: implement hotkey import....
/*m_frame->ImportHotkeyConfigFromFile( m_hotkeys, m_nickname );*/
}
}
};
const BUTTON_ROW_PANEL::BTN_DEF_LIST r_btn_defs = {
{
wxID_ANY,
_( "Import..." ),
_( "Import hotkey definitions from an external file, replacing the current values" ),
[this]( wxCommandEvent& ){
m_frame->ImportHotkeyConfigFromFile( m_hotkeys, m_nickname );
}
},
{
wxID_ANY,
_( "Export..." ),
_( "Export these hotkey definitions to an external file" ),
[this]( wxCommandEvent& ){
m_frame->ExportHotkeyConfigToFile( m_hotkeys, m_nickname );
}
},
};
auto btnPanel = std::make_unique<BUTTON_ROW_PANEL>( this, l_btn_defs, r_btn_defs );
@ -146,6 +135,7 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
bool PANEL_HOTKEYS_EDITOR::TransferDataToWindow()
{
m_hotkeyStore.Init( m_toolManagers );
return m_hotkeyListCtrl->TransferDataToControl();
}
@ -156,7 +146,8 @@ bool PANEL_HOTKEYS_EDITOR::TransferDataFromWindow()
return false;
// save the hotkeys
m_frame->WriteHotkeyConfig( m_hotkeys );
for( TOOL_MANAGER* toolMgr : m_toolManagers )
WriteHotKeyConfig( toolMgr->GetActions() );
return true;
}

View File

@ -37,14 +37,15 @@
#include <widgets/paged_dialog.h>
#include <bitmaps.h>
#include <tool/action_menu.h>
#include <tool/common_control.h>
#include <tool/tool_manager.h>
#include <menus_helpers.h>
#include <tool/actions.h>
/// The default auto save interval is 10 minutes.
#define DEFAULT_AUTO_SAVE_INTERVAL 600
#define URL_GET_INVOLVED "http://kicad-pcb.org/contribute/"
///@{
/// \ingroup config
@ -66,10 +67,8 @@ static const wxString entryMaximized = "Maximized"; ///< Nonzero iff frame is m
BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
EVT_MENU( wxID_HELP, EDA_BASE_FRAME::GetKicadHelp )
EVT_MENU( wxID_INDEX, EDA_BASE_FRAME::GetKicadHelp )
EVT_MENU( ID_HELP_GET_INVOLVED, EDA_BASE_FRAME::GetKicadContribute )
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuOpen )
@ -290,30 +289,18 @@ void EDA_BASE_FRAME::ReCreateMenuBar()
void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
{
wxMenu* helpMenu = new wxMenu;
COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
ACTION_MENU* helpMenu = new ACTION_MENU();
AddMenuItem( helpMenu, wxID_HELP,
_( "&Help" ),
_( "Open product documentation in a web browser" ),
KiBitmap( online_help_xpm ) );
AddMenuItem( helpMenu, wxID_INDEX,
_( "&Getting Started with KiCad" ),
_( "Open \"Getting Started in KiCad\" guide for beginners" ),
KiBitmap( help_xpm ) );
// JEY TODO: move to actions...
AddMenuItem( helpMenu, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, _( "&List Hotkeys..." ),
_( "Displays current hotkeys table and corresponding commands" ),
KiBitmap( hotkeys_xpm ) );
helpMenu->SetTool( commonControl );
helpMenu->Add( ACTIONS::help );
helpMenu->Add( ACTIONS::gettingStarted );
helpMenu->Add( ACTIONS::listHotKeys );
helpMenu->Add( ACTIONS::getInvolved );
helpMenu->AppendSeparator();
AddMenuItem( helpMenu, ID_HELP_GET_INVOLVED, _( "Get &Involved" ),
_( "Open \"Contribute to KiCad\" in a web browser" ),
KiBitmap( info_xpm ) );
helpMenu->AppendSeparator();
AddMenuItem( helpMenu, wxID_ABOUT, _( "&About KiCad" ), KiBitmap( about_xpm ) );
helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
aMenuBar->Append( helpMenu, _( "&Help" ) );
}
@ -517,112 +504,33 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
}
void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
{
const SEARCH_STACK& search = sys_search();
/* We have to get document for beginners,
* or the full specific doc
* if event id is wxID_INDEX, we want the document for beginners.
* else the specific doc file (its name is in Kiface().GetHelpFileName())
* The document for beginners is the same for all KiCad utilities
*/
if( event.GetId() == wxID_INDEX )
{
// List of possible names for Getting Started in KiCad
const wxChar* names[2] = {
wxT( "getting_started_in_kicad" ),
wxT( "Getting_Started_in_KiCad" )
};
wxString helpFile;
// Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
// or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
for( unsigned ii = 0; ii < arrayDim( names ); ii++ )
{
helpFile = SearchHelpFileFullPath( search, names[ii] );
if( !helpFile.IsEmpty() )
break;
}
if( !helpFile )
{
wxString msg = wxString::Format( _(
"Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] );
wxMessageBox( msg );
}
else
{
GetAssociatedDocument( this, helpFile );
}
return;
}
wxString base_name = help_name();
wxString helpFile = SearchHelpFileFullPath( search, base_name );
if( !helpFile )
{
wxString msg = wxString::Format( _(
"Help file \"%s\" could not be found." ),
GetChars( base_name )
);
wxMessageBox( msg );
}
else
{
GetAssociatedDocument( this, helpFile );
}
}
void EDA_BASE_FRAME::GetKicadContribute( wxCommandEvent& event )
{
if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
{
wxString msg;
msg.Printf( _( "Could not launch the default browser.\n"
"For information on how to help the KiCad project, visit %s" ),
URL_GET_INVOLVED );
wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
}
}
void EDA_BASE_FRAME::GetKicadAbout( wxCommandEvent& event )
void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
{
void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
ShowAboutDialog( this );
}
bool EDA_BASE_FRAME::ShowPreferences( EDA_HOTKEY_CONFIG* aHotkeys, EDA_HOTKEY_CONFIG* aShowHotkeys,
const wxString& aHotkeysNickname )
void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
{
PAGED_DIALOG dlg( this, _( "Preferences" ) );
wxTreebook* book = dlg.GetTreebook();
book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
book->AddPage( new PANEL_HOTKEYS_EDITOR( this, book, false,
aHotkeys, aShowHotkeys, aHotkeysNickname ), _( "Hotkeys" ) );
PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( book, false );
book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
{
KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
if( frame )
frame->InstallPreferences( &dlg );
frame->InstallPreferences( &dlg, hotkeysPanel );
}
if( dlg.ShowModal() == wxID_OK )
{
dlg.Kiway().CommonSettingsChanged();
return true;
}
return false;
}

View File

@ -86,11 +86,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_auxiliaryToolBar = NULL;
m_gridSelectBox = NULL;
m_zoomSelectBox = NULL;
m_hotkeysDescrList = NULL;
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
m_galCanvas = NULL;
m_actions = NULL;
m_toolDispatcher = NULL;
m_messagePanel = NULL;
m_currentScreen = NULL;
@ -241,17 +239,6 @@ void EDA_DRAW_FRAME::EraseMsgBox()
}
bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
{
// Checks all the toolbars and returns true if the given tool id is toggled.
return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) ||
( m_auxiliaryToolBar && m_auxiliaryToolBar->GetToolToggled( aToolId ) )
);
}
void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// No need to update the grid select box if it doesn't exist or the grid setting change
@ -275,18 +262,6 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
}
int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
wxString* aFullFileName )
{
int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
if( GetToolManager() )
GetToolManager()->UpdateHotKeys();
return result;
}
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC )
{
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -22,28 +22,82 @@
*/
#include <hotkey_store.h>
#include <tool/tool_manager.h>
#include <tool/tool_action.h>
HOTKEY_STORE::HOTKEY_STORE( EDA_HOTKEY_CONFIG* aHotkeys )
wxString HOTKEY_STORE::GetAppName( TOOL_ACTION* aAction )
{
for( EDA_HOTKEY_CONFIG* section = aHotkeys; section->m_HK_InfoList; ++section )
{
m_hk_sections.push_back( genSection( *section ) );
}
wxString name( aAction->GetName() );
return name.BeforeFirst( '.' );
}
HOTKEY_SECTION HOTKEY_STORE::genSection( EDA_HOTKEY_CONFIG& aSection )
wxString HOTKEY_STORE::GetSectionName( TOOL_ACTION* aAction )
{
HOTKEY_SECTION generated_section { {}, {}, aSection };
std::map<wxString, wxString> s_AppNames = {
{ wxT( "common" ), _( "Common" ) },
{ wxT( "kicad" ), _( "Kicad Manager" ) },
{ wxT( "eeschema" ), _( "Eeschema" ) },
{ wxT( "pcbnew" ), _( "PcbNew" ) },
{ wxT( "plEditor" ), _( "Page Layout Editor" ) }
};
generated_section.m_name = wxGetTranslation( *aSection.m_Title );
wxString appName = GetAppName( aAction );
if( s_AppNames.count( appName ) )
return s_AppNames[ appName ];
else
return wxT( "XXX" + appName );
}
for( EDA_HOTKEY** info_ptr = aSection.m_HK_InfoList; *info_ptr; ++info_ptr )
HOTKEY_STORE::HOTKEY_STORE()
{
}
void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList )
{
m_toolManagers = std::move( aToolManagerList );
// Collect all action maps into a single master map. This will re-group everything
// and elimate duplicates
std::map<std::string, TOOL_ACTION*> masterMap;
for( TOOL_MANAGER* toolMgr : m_toolManagers )
{
generated_section.m_hotkeys.push_back( { **info_ptr, *aSection.m_SectionTag } );
for( const auto& entry : toolMgr->GetActions() )
{
// Internal actions probably shouldn't be allowed hotkeys
if( entry.second->GetMenuItem().IsEmpty() )
continue;
masterMap[ entry.first ] = entry.second;
}
}
wxString currentApp;
HOTKEY_SECTION* currentSection = nullptr;
HOTKEY* currentHotKey = nullptr;
return generated_section;
for( const auto& entry : masterMap )
{
wxString thisApp = GetAppName( entry.second );
if( thisApp != currentApp )
{
m_hk_sections.emplace_back( HOTKEY_SECTION() );
currentApp = thisApp;
currentSection = &m_hk_sections.back();
currentSection->m_SectionName = GetSectionName( entry.second );
}
currentSection->m_HotKeys.emplace_back( HOTKEY() );
currentHotKey = &currentSection->m_HotKeys.back();
currentHotKey->m_Parent = entry.second;
currentHotKey->m_EditKeycode = entry.second->GetHotKey();
}
}
@ -53,102 +107,57 @@ std::vector<HOTKEY_SECTION>& HOTKEY_STORE::GetSections()
}
CHANGED_HOTKEY* HOTKEY_STORE::FindHotkey( const wxString& aTag, int aCmdId )
{
CHANGED_HOTKEY* found_key = nullptr;
for( auto& section: m_hk_sections )
{
if( *section.m_section.m_SectionTag != aTag)
continue;
for( auto& hotkey: section.m_hotkeys )
{
auto& curr_hk = hotkey.GetCurrentValue();
if( curr_hk.m_Idcommand == aCmdId )
{
found_key = &hotkey;
break;
}
}
}
return found_key;
}
void HOTKEY_STORE::SaveAllHotkeys()
{
for( auto& section: m_hk_sections )
for( HOTKEY_SECTION& section: m_hk_sections )
{
for( auto& hotkey: section.m_hotkeys )
{
hotkey.SaveHotkey();
}
for( HOTKEY& hotkey: section.m_HotKeys )
hotkey.m_Parent->SetHotKey( hotkey.m_EditKeycode );
}
}
void HOTKEY_STORE::ResetAllHotkeysToDefault()
{
for( auto& section: m_hk_sections )
for( HOTKEY_SECTION& section: m_hk_sections )
{
for( auto& hotkey: section.m_hotkeys )
{
hotkey.GetCurrentValue().ResetKeyCodeToDefault();
}
for( HOTKEY& hotkey: section.m_HotKeys )
hotkey.m_EditKeycode = hotkey.m_Parent->GetDefaultHotKey();
}
}
void HOTKEY_STORE::ResetAllHotkeysToOriginal()
{
for( auto& section: m_hk_sections )
for( HOTKEY_SECTION& section: m_hk_sections )
{
for( auto& hotkey: section.m_hotkeys )
{
hotkey.GetCurrentValue().m_KeyCode = hotkey.GetOriginalValue().m_KeyCode;
}
for( HOTKEY& hotkey: section.m_HotKeys )
hotkey.m_EditKeycode = hotkey.m_Parent->GetHotKey();
}
}
bool HOTKEY_STORE::CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect )
bool HOTKEY_STORE::CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY** aConflict )
{
EDA_HOTKEY* conflicting_key = nullptr;
EDA_HOTKEY_CONFIG* conflicting_section = nullptr;
wxString sectionName = GetSectionName( aAction );
for( auto& section: m_hk_sections )
for( HOTKEY_SECTION& section: m_hk_sections )
{
const auto& sectionTag = *section.m_section.m_SectionTag;
if( aSectionTag != g_CommonSectionTag
&& sectionTag != g_CommonSectionTag
&& sectionTag != aSectionTag )
{
// This key and its conflict candidate are in orthogonal sections, so skip.
if( section.m_SectionName != sectionName )
continue;
}
// See if any *current* hotkeys are in conflict
for( auto& hotkey: section.m_hotkeys )
for( HOTKEY& hotkey: section.m_HotKeys )
{
auto& curr_hk = hotkey.GetCurrentValue();
if( aKey == curr_hk.m_KeyCode )
if( hotkey.m_Parent == aAction )
continue;
if( hotkey.m_EditKeycode == aKey )
{
conflicting_key = &curr_hk;
conflicting_section = &section.m_section;
*aConflict = &hotkey;
return true;
}
}
}
// Write the outparams
if( aConfKey )
*aConfKey = conflicting_key;
if( aConfSect )
*aConfSect = conflicting_section;
return conflicting_key == nullptr;
return false;
}

View File

@ -41,14 +41,12 @@
#include <eda_draw_frame.h>
#include <tool/tool_manager.h>
#include "dialogs/dialog_hotkey_list.h"
#include <wx/apptrait.h>
#include <wx/stdpaths.h>
#include <wx/tokenzr.h>
#include <tool/tool_action.h>
#define HOTKEYS_CONFIG_KEY wxT( "Keys" )
wxString g_CommonSectionTag( wxT( "[common]" ) );
@ -59,23 +57,8 @@ wxString g_CommonSectionTag( wxT( "[common]" ) );
*/
EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent ) :
m_defaultKeyCode( keycode ), m_KeyCode( keycode ), m_InfoMsg( infomsg ),
m_Idcommand( idcommand ), m_IdMenuEvent( idmenuevent )
{
}
EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base )
{
m_defaultKeyCode = base->m_defaultKeyCode; // initialize default key code
m_KeyCode = base->m_KeyCode;
m_InfoMsg = base->m_InfoMsg;
m_Idcommand = base->m_Idcommand;
m_IdMenuEvent = base->m_IdMenuEvent;
}
EDA_HOTKEY_CLIENT_DATA::~EDA_HOTKEY_CLIENT_DATA()
m_KeyCode( keycode ), m_InfoMsg( infomsg ), m_Idcommand( idcommand ),
m_IdMenuEvent( idmenuevent )
{
}
@ -174,16 +157,16 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
bool found = false;
// Assume keycode of 0 is "unassigned"
if( (aKeycode & GR_KB_CTRL) != 0 )
if( (aKeycode & MD_CTRL) != 0 )
modifier << MODIFIER_CTRL;
if( (aKeycode & GR_KB_ALT) != 0 )
if( (aKeycode & MD_ALT) != 0 )
modifier << MODIFIER_ALT;
if( (aKeycode & GR_KB_SHIFT) != 0 )
if( (aKeycode & MD_SHIFT) != 0 )
modifier << MODIFIER_SHIFT;
aKeycode &= ~( GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT );
aKeycode &= ~( MD_CTRL | MD_ALT | MD_SHIFT );
if( (aKeycode > ' ') && (aKeycode < 0x7F ) )
{
@ -217,58 +200,26 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
}
/*
* helper function use in AddHotkeyName to calculate an accelerator string
* In some menus, accelerators do not perform exactly the same action as
* the hotkey that perform a similar action.
* this is usually the case when this action uses the current mouse position
* for instance zoom action is ran from the F1 key or the Zoom menu.
* a zoom uses the mouse position from a hot key and not from the menu
* In this case, the accelerator if Shift+<hotkey>
* But for many keys, the Shift modifier is not usable, and the accelerator is Alt+<hotkey>
/**
* AddHotkeyName
* @param aText - the base text on which to append the hotkey
* @param aHotKey - the hotkey keycode
* @param aStyle - IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys)
* IS_COMMENT to add <spaces><(keyname)> mainly in tool tips
*/
static void AddModifierToKey( wxString& aFullKey, const wxString & aKey )
{
if( (aKey.Length() == 1) && (aKey[0] >= 'A') && (aKey[0] <= 'Z'))
// We can use Shift+<key> as accelerator and <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey;
else
// We must use Alt+<key> as accelerator and <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey;
}
/* AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value)
* aText = a wxString. returns aText + key name
* aList = pointer to a EDA_HOTKEY list of commands
* aCommandId = Command Id value
* aShortCutType = IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys)
* IS_ACCELERATOR to add <tab><Shift+keyname> (accelerators in menus, not hotkeys)
* IS_COMMENT to add <spaces><(keyname)> mainly in tool tips
* Return a wxString (aTest + key name) if key found or aText without modification
*/
wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList,
int aCommandId, HOTKEY_ACTION_TYPE aShortCutType )
wxString AddHotkeyName( const wxString& aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle )
{
wxString msg = aText;
wxString keyname;
if( aList )
keyname = KeyNameFromCommandId( aList, aCommandId );
wxString keyname = KeyNameFromKeyCode( aHotKey );
if( !keyname.IsEmpty() )
{
switch( aShortCutType )
switch( aStyle )
{
case IS_HOTKEY:
msg << wxT( "\t" ) << keyname;
break;
case IS_ACCELERATOR:
AddModifierToKey( msg, keyname );
break;
case IS_COMMENT:
msg << wxT( " (" ) << keyname << wxT( ")" );
break;
@ -300,6 +251,7 @@ wxString AddHotkeyName( const wxString& aText,
int aCommandId,
HOTKEY_ACTION_TYPE aShortCutType )
{
// JEY TODO: obsolete once 3DViewer and ProjectManager are moved over...
wxString msg = aText;
wxString keyname;
EDA_HOTKEY** list;
@ -319,10 +271,6 @@ wxString AddHotkeyName( const wxString& aText,
msg << wxT( "\t" ) << keyname;
break;
case IS_ACCELERATOR:
AddModifierToKey( msg, keyname );
break;
case IS_COMMENT:
msg << wxT( " (" ) << keyname << wxT( ")" );
break;
@ -352,6 +300,7 @@ wxString AddHotkeyName( const wxString& aText,
*/
wxString KeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId )
{
// JEY TODO: obsolete once 3DViewer and ProjectManager are moved over...
wxString keyname;
for( ; *aList != nullptr; aList++ )
@ -387,28 +336,28 @@ int KeyCodeFromKeyName( const wxString& keyname )
wxString prefix;
int modifier = 0;
while( 1 )
while( true )
{
prefix.Empty();
if( key.StartsWith( MODIFIER_CTRL_BASE ) )
{
modifier |= GR_KB_CTRL;
modifier |= MD_CTRL;
prefix = MODIFIER_CTRL_BASE;
}
else if( key.StartsWith( MODIFIER_CMD_MAC ) )
{
modifier |= GR_KB_CTRL;
modifier |= MD_CTRL;
prefix = MODIFIER_CMD_MAC;
}
else if( key.StartsWith( MODIFIER_ALT ) )
{
modifier |= GR_KB_ALT;
modifier |= MD_ALT;
prefix = MODIFIER_ALT;
}
else if( key.StartsWith( MODIFIER_SHIFT ) )
{
modifier |= GR_KB_SHIFT;
modifier |= MD_SHIFT;
prefix = MODIFIER_SHIFT;
}
else
@ -440,139 +389,104 @@ int KeyCodeFromKeyName( const wxString& keyname )
}
/* DisplayHotkeyList
* Displays the current hotkey list
* aList = a EDA_HOTKEY_CONFIG list(Null terminated)
/*
* DisplayHotkeyList
* Displays the hotkeys registered with the given tool manager.
*/
void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList )
void DisplayHotkeyList( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolManager )
{
DIALOG_LIST_HOTKEYS dlg( aFrame, aDescList );
DIALOG_LIST_HOTKEYS dlg( aParent, aToolManager );
dlg.ShowModal();
}
/**
* Function GetDescriptorFromHotkey
* Return a EDA_HOTKEY * pointer from a key code for OnHotKey() function
* @param aKey = key code (ascii value, or wxWidgets value for function keys
* @param aList = pointer to a EDA_HOTKEY list of commands
* @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List
*/
EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList )
int WriteHotKeyConfig( std::map<std::string, TOOL_ACTION*> aActionMap )
{
for( ; *aList != nullptr; aList++ )
{
EDA_HOTKEY* hk_decr = *aList;
wxFileName fn( "user" );
if( hk_decr->m_KeyCode == aKey )
return hk_decr;
}
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetPath( GetKicadConfigPath() );
return nullptr;
}
EDA_HOTKEY* GetDescriptorFromCommand( int aCommand, EDA_HOTKEY** aList )
{
for( ; *aList != nullptr; aList++ )
{
EDA_HOTKEY* hk_decr = *aList;
if( hk_decr->m_Idcommand == aCommand )
return hk_decr;
}
return nullptr;
}
int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
wxString* aFullFileName )
{
wxString msg;
wxString keyname, infokey;
FILE* file;
msg = wxT( "$hotkey list\n" );
// Print the current hotkey list
EDA_HOTKEY** list;
for( ; aDescList->m_HK_InfoList != nullptr; aDescList++ )
{
if( aDescList->m_Title )
{
msg += wxT( "# " );
msg += *aDescList->m_Title;
msg += wxT( "\n" );
}
msg += *aDescList->m_SectionTag;
msg += wxT( "\n" );
list = aDescList->m_HK_InfoList;
for( ; *list != nullptr; list++ )
{
EDA_HOTKEY* hk_decr = *list;
msg += wxT( "shortcut " );
keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
AddDelimiterString( keyname );
infokey = hk_decr->m_InfoMsg;
AddDelimiterString( infokey );
msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
}
}
msg += wxT( "$Endlist\n" );
if( aFullFileName )
file = wxFopen( *aFullFileName, wxT( "wt" ) );
else
{
wxString configName( ConfigBaseName() );
if( configName == SCH_EDIT_FRAME_NAME || configName == LIB_EDIT_FRAME_NAME )
configName = EESCHEMA_HOTKEY_NAME;
else if( configName == PCB_EDIT_FRAME_NAME ||
configName == FOOTPRINT_EDIT_FRAME_NAME )
configName = PCBNEW_HOTKEY_NAME;
wxFileName fn( configName );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetPath( GetKicadConfigPath() );
file = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
}
if( file )
{
wxFputs( msg, file );
fclose( file );
}
else
{
msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
if( !wxFile::Exists( fn.GetFullPath() ) )
return 0;
wxFile file( fn.GetFullPath(), wxFile::OpenMode::read );
if( !file.IsOpened() ) // There is a problem to open file
return 0;
// Read entire hotkey set into map
//
wxString input;
std::map<wxString, int> hotkeys;
file.ReadAll( &input );
input.Replace( "\r\n", "\n" ); // Convert Windows files to Unix line-ends
wxStringTokenizer fileTokenizer( input, "\n", wxTOKEN_STRTOK );
while( fileTokenizer.HasMoreTokens() )
{
wxStringTokenizer lineTokenizer( fileTokenizer.GetNextToken(), "\t" );
wxString cmdName = lineTokenizer.GetNextToken();
wxString keyName = lineTokenizer.GetNextToken();
if( !cmdName.IsEmpty() )
hotkeys[ cmdName ] = KeyCodeFromKeyName( keyName );
}
file.Close();
// Overlay this app's hotkey definitions onto the map
//
for( const auto& ii : aActionMap )
{
if( ii.second->GetHotKey() )
hotkeys[ ii.first ] = ii.second->GetHotKey();
}
// Write entire hotkey set
//
file.Open( fn.GetFullPath(), wxFile::OpenMode::write );
for( const auto& ii : hotkeys )
file.Write( wxString::Format( "%s\t%s\n", ii.first, KeyNameFromKeyCode( ii.second ) ) );
file.Close();
return 1;
}
int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList,
const bool aDefaultLocation )
int ReadLegacyHotkeyConfig( const wxString& aAppname, std::map<std::string, int>& aMap )
{
// For Eeschema and Pcbnew frames, we read the new combined file.
// For other kifaces, we read the frame-based file
if( aAppname == LIB_EDIT_FRAME_NAME || aAppname == SCH_EDIT_FRAME_NAME )
{
return ReadLegacyHotkeyConfigFile( EESCHEMA_HOTKEY_NAME, aMap );
}
else if( aAppname == PCB_EDIT_FRAME_NAME || aAppname == FOOTPRINT_EDIT_FRAME_NAME )
{
return ReadLegacyHotkeyConfigFile( PCBNEW_HOTKEY_NAME, aMap );
}
return ReadLegacyHotkeyConfigFile( aAppname, aMap );
}
int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string, int>& aMap )
{
wxFileName fn( aFilename );
if( aDefaultLocation )
{
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetPath( GetKicadConfigPath() );
}
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetPath( GetKicadConfigPath() );
if( !wxFile::Exists( fn.GetFullPath() ) )
return 0;
wxFile cfgfile( fn.GetFullPath() );
if( !cfgfile.IsOpened() ) // There is a problem to open file
return 0;
@ -591,43 +505,7 @@ int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* a
data.Replace( "\\n", "\n", true );
// parse
ParseHotkeyConfig( data, aDescList, aFilename );
// cleanup
cfgfile.Close();
return 1;
}
int ReadHotkeyConfig( const wxString& aAppname, struct EDA_HOTKEY_CONFIG* aDescList )
{
// For Eeschema and Pcbnew frames, we read the new combined file.
// For other kifaces, we read the frame-based file
if( aAppname == LIB_EDIT_FRAME_NAME || aAppname == SCH_EDIT_FRAME_NAME )
{
return ReadHotkeyConfigFile( EESCHEMA_HOTKEY_NAME, aDescList );
}
else if( aAppname == PCB_EDIT_FRAME_NAME || aAppname == FOOTPRINT_EDIT_FRAME_NAME )
{
return ReadHotkeyConfigFile( PCBNEW_HOTKEY_NAME, aDescList );
}
return ReadHotkeyConfigFile( aAppname, aDescList );
}
/* 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 EDA_HOTKEY_CONFIG* aDescList,
const wxString& aAppname )
{
// Read the config
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
EDA_HOTKEY** CurrentHotkeyList = nullptr;
while( tokenizer.HasMoreTokens() )
{
@ -636,38 +514,11 @@ void ParseHotkeyConfig( const wxString& data,
wxString line_type = lineTokenizer.GetNextToken();
if( line_type[0] == '#' ) //comment
if( line_type[0] == '#' ) // comment
continue;
if( line_type[0] == '[' ) // A tag is found. search infos in list
{
CurrentHotkeyList = nullptr;
EDA_HOTKEY_CONFIG* DList = aDescList;
for( ; DList->m_HK_InfoList; DList++ )
{
if( *DList->m_SectionTag == line_type )
{
CurrentHotkeyList = DList->m_HK_InfoList;
break;
}
}
if( line_type[0] == '[' ) // tags ignored reading legacy hotkeys
continue;
}
// Do not accept hotkey assignments from hotkey files that don't match the application
if( aAppname == LIB_EDIT_FRAME_NAME && line_type == wxT( "[eeschema]" ) )
CurrentHotkeyList = nullptr;
if( aAppname == SCH_EDIT_FRAME_NAME && line_type == wxT( "[libedit]" ) )
CurrentHotkeyList = nullptr;
if( aAppname == PCB_EDIT_FRAME_NAME && line_type == wxT( "[footprinteditor]" ) )
CurrentHotkeyList = nullptr;
if( aAppname == FOOTPRINT_EDIT_FRAME_NAME && line_type == wxT( "[pcbnew]" ) )
CurrentHotkeyList = nullptr;
if( line_type == wxT( "$Endlist" ) )
break;
@ -675,9 +526,6 @@ void ParseHotkeyConfig( const wxString& data,
if( line_type != wxT( "shortcut" ) )
continue;
if( CurrentHotkeyList == nullptr )
continue;
// Get the key name
lineTokenizer.SetString( lineTokenizer.GetString(), L"\"\r\n\t ", wxTOKEN_STRTOK );
wxString keyname = lineTokenizer.GetNextToken();
@ -687,22 +535,13 @@ void ParseHotkeyConfig( const wxString& data,
// Get the command name
wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' );
// search the hotkey in current hotkey list
for( EDA_HOTKEY** list = CurrentHotkeyList; *list != nullptr; list++ )
{
EDA_HOTKEY* hk_decr = *list;
if( hk_decr->m_InfoMsg == fctname )
{
int keycode = KeyCodeFromKeyName( keyname );
if( keycode != KEY_NON_FOUND ) // means the key name is found in list or unassigned
hk_decr->m_KeyCode = keycode;
break;
}
}
// Add the pair to the map
aMap[ fctname.ToStdString() ] = KeyCodeFromKeyName( keyname );
}
// cleanup
cfgfile.Close();
return 1;
}
@ -729,8 +568,9 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList,
if( filename.IsEmpty() )
return;
::ReadHotkeyConfigFile( filename, aDescList, false );
WriteHotkeyConfig( aDescList );
// JEY TODO: implement import of new hotkeys file....
//::ReadHotkeyConfigFile( filename, aDescList, false );
//WriteHotKeyConfig( aDescList );
SetMruPath( wxFileName( filename ).GetPath() );
}
@ -761,7 +601,8 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList,
if( filename.IsEmpty() )
return;
WriteHotkeyConfig( aDescList, &filename );
// JEY TODO: make this whole routine oboslete?
//WriteHotKeyConfig( aDescList, &filename );
SetMruPath( wxFileName( filename ).GetPath() );
}

View File

@ -178,6 +178,12 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
}
const std::map<std::string, TOOL_ACTION*>& ACTION_MANAGER::GetActions()
{
return m_actionNameIndex;
}
int ACTION_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const
{
std::map<int, int>::const_iterator it = m_hotkeys.find( aAction.GetId() );
@ -191,13 +197,19 @@ int ACTION_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const
void ACTION_MANAGER::UpdateHotKeys()
{
std::map<std::string, int> legacyHotKeyMap;
std::map<std::string, int> userHotKeyMap;
m_actionHotKeys.clear();
m_hotkeys.clear();
ReadLegacyHotkeyConfig( m_toolMgr->GetEditFrame()->ConfigBaseName(), legacyHotKeyMap );
// JEY TODO: read user hotkey config...
for( const auto& actionName : m_actionNameIndex )
{
TOOL_ACTION* action = actionName.second;
int hotkey = processHotKey( action );
int hotkey = processHotKey( action, legacyHotKeyMap, userHotKeyMap );
if( hotkey <= 0 )
continue;
@ -218,53 +230,20 @@ void ACTION_MANAGER::UpdateHotKeys()
m_actionHotKeys[hotkey].push_back( action );
m_hotkeys[action->GetId()] = hotkey;
}
}
int ACTION_MANAGER::processHotKey( TOOL_ACTION* aAction )
int ACTION_MANAGER::processHotKey( TOOL_ACTION* aAction, std::map<std::string, int> aLegacyMap,
std::map<std::string, int> aHotKeyMap )
{
int hotkey = aAction->getDefaultHotKey();
if( ( hotkey & TOOL_ACTION::LEGACY_HK ) )
{
hotkey = hotkey & ~TOOL_ACTION::LEGACY_HK; // it leaves only HK_xxx identifier
auto frame = static_cast<EDA_DRAW_FRAME*>( m_toolMgr->GetEditFrame() );
EDA_HOTKEY* hk_desc = nullptr;
if( frame )
hk_desc = frame->GetHotKeyDescription( hotkey );
if( hk_desc )
{
hotkey = hk_desc->m_KeyCode;
// Convert modifiers to the ones used by the Tool Framework
if( hotkey & GR_KB_CTRL )
{
hotkey &= ~GR_KB_CTRL;
hotkey |= MD_CTRL;
}
if( hotkey & GR_KB_ALT )
{
hotkey &= ~GR_KB_ALT;
hotkey |= MD_ALT;
}
if( hotkey & GR_KB_SHIFT )
{
hotkey &= ~GR_KB_SHIFT;
hotkey |= MD_SHIFT;
}
}
else
{
hotkey = 0;
}
}
return hotkey;
aAction->m_hotKey = aAction->m_defaultHotKey;
if( !aAction->m_legacyName.empty() && aLegacyMap.count( aAction->m_legacyName ) )
aAction->m_hotKey = aLegacyMap[ aAction->m_legacyName ];
if( aHotKeyMap.count( aAction->m_name ) )
aAction->m_hotKey = aHotKeyMap[ aAction->m_name ];
return aAction->m_hotKey;
}

View File

@ -1,415 +1,564 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <tool/actions.h>
#include <hotkeys.h>
#include <bitmaps.h>
// These members are static in class ACTIONS: Build them here:
TOOL_ACTION ACTIONS::doNew( "common.Control.new",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_NEW ),
AS_GLOBAL,
MD_CTRL + 'N', LEGACY_HK_NAME( "New" ),
_( "New..." ), _( "Create a new document in the editor" ),
new_generic_xpm );
TOOL_ACTION ACTIONS::newLibrary( "common.Control.newLibrary",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "New Library..." ), _( "Create a new library folder" ),
new_generic_xpm );
TOOL_ACTION ACTIONS::addLibrary( "common.Control.addLibrary",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Add Library..." ), _( "Add an existing library folder" ),
add_library_xpm );
TOOL_ACTION ACTIONS::open( "common.Control.open",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_OPEN ),
AS_GLOBAL,
MD_CTRL + 'O', LEGACY_HK_NAME( "Open" ),
_( "Open..." ), _( "Open existing document" ),
directory_xpm );
TOOL_ACTION ACTIONS::save( "common.Control.save",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SAVE ),
AS_GLOBAL,
MD_CTRL + 'S', LEGACY_HK_NAME( "Save" ),
_( "Save" ), _( "Save changes" ),
save_xpm );
TOOL_ACTION ACTIONS::saveAs( "common.Control.saveAs",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SAVEAS ),
AS_GLOBAL,
MD_SHIFT + MD_CTRL + 'S', LEGACY_HK_NAME( "Save As" ),
_( "Save As..." ), _( "Save current document to another location" ),
save_as_xpm );
TOOL_ACTION ACTIONS::saveCopyAs( "common.Control.saveCopyAs",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Save Copy As..." ), _( "Save a copy of the current document to another location" ),
save_as_xpm );
TOOL_ACTION ACTIONS::saveAll( "common.Control.saveAll",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Save All" ), _( "Save all changes" ),
save_xpm );
TOOL_ACTION ACTIONS::revert( "common.Control.revert",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Revert" ), _( "Throw away changes" ),
undo_xpm );
TOOL_ACTION ACTIONS::pageSettings( "common.Control.pageSettings",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Page Settings..." ), _( "Settings for paper size and frame references" ),
sheetset_xpm );
TOOL_ACTION ACTIONS::print( "common.Control.print",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_PRINT ),
AS_GLOBAL,
MD_CTRL + 'P', LEGACY_HK_NAME( "Print" ),
_( "Print..." ), _( "Print" ),
print_button_xpm );
TOOL_ACTION ACTIONS::plot( "common.Control.plot",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Plot..." ), _( "Plot" ),
plot_xpm );
TOOL_ACTION ACTIONS::quit( "common.Control.quit",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "", // Not currently in use due to wxWidgets crankiness
_( "Quit" ), _( "Close the current editor" ),
exit_xpm );
// Generic Edit Actions
TOOL_ACTION ACTIONS::cancelInteractive( "common.Interactive.cancel",
AS_GLOBAL, 0, // ESC key is handled in the dispatcher
AS_GLOBAL,
0, "", // ESC key is handled in the dispatcher
_( "Cancel" ), _( "Cancel current tool" ),
cancel_xpm, AF_NONE );
TOOL_ACTION ACTIONS::updateMenu( "common.Interactive.updateMenu",
AS_GLOBAL, 0, "", "" ); // This is an internal event
AS_GLOBAL );
TOOL_ACTION ACTIONS::undo( "common.Interactive.undo",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UNDO ),
AS_GLOBAL,
MD_CTRL + 'Z', LEGACY_HK_NAME( "Undo" ),
_( "Undo" ), _( "Undo last edit" ),
undo_xpm );
TOOL_ACTION ACTIONS::redo( "common.Interactive.redo",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_REDO ),
AS_GLOBAL,
#if defined( __WXMAC__ )
MD_SHIFT + MD_CTRL + 'Z',
#else
MD_CTRL + 'Y',
#endif
LEGACY_HK_NAME( "Redo" ),
_( "Redo" ), _( "Redo last edit" ),
redo_xpm );
TOOL_ACTION ACTIONS::cut( "common.Interactive.cut",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CUT ),
AS_GLOBAL,
MD_CTRL + 'X', LEGACY_HK_NAME( "Cut" ),
_( "Cut" ), _( "Cut selected item(s) to clipboard" ),
cut_xpm );
TOOL_ACTION ACTIONS::copy( "common.Interactive.copy",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_COPY ),
AS_GLOBAL,
MD_CTRL + 'C', LEGACY_HK_NAME( "Copy" ),
_( "Copy" ), _( "Copy selected item(s) to clipboard" ),
copy_xpm );
TOOL_ACTION ACTIONS::paste( "common.Interactive.paste",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_PASTE ),
AS_GLOBAL,
MD_CTRL + 'V', LEGACY_HK_NAME( "Paste" ),
_( "Paste" ), _( "Paste clipboard into schematic" ),
paste_xpm );
TOOL_ACTION ACTIONS::duplicate( "common.Interactive.duplicate",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE ),
AS_GLOBAL,
MD_CTRL + 'D', LEGACY_HK_NAME( "Duplicate" ),
_( "Duplicate" ), _( "Duplicates the selected item(s)" ),
duplicate_xpm );
TOOL_ACTION ACTIONS::doDelete( "common.Interactive.delete",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ),
AS_GLOBAL,
WXK_DELETE, LEGACY_HK_NAME( "Delete Item" ),
_( "Delete" ), _( "Deletes selected item(s)" ),
delete_xpm );
TOOL_ACTION ACTIONS::activatePointEditor( "common.Control.activatePointEditor",
AS_GLOBAL, 0, "", "" ); // This is an internal event
AS_GLOBAL );
TOOL_ACTION ACTIONS::find( "common.Interactive.find",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FIND ),
AS_GLOBAL,
MD_CTRL + 'F', LEGACY_HK_NAME( "Find" ),
_( "Find" ), _( "Find text" ),
find_xpm );
TOOL_ACTION ACTIONS::findAndReplace( "common.Interactive.findAndReplace",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_REPLACE ),
AS_GLOBAL,
MD_CTRL + MD_ALT + 'F', LEGACY_HK_NAME( "Find and Replace" ),
_( "Find and Replace" ), _( "Find and replace text" ),
find_replace_xpm );
TOOL_ACTION ACTIONS::findNext( "common.Interactive.findNext",
AS_GLOBAL, 0,
AS_GLOBAL,
WXK_F5, LEGACY_HK_NAME( "Find Next" ),
_( "Find Next" ), _( "Find next match" ),
find_xpm );
TOOL_ACTION ACTIONS::findNextMarker( "common.Interactive.findNextMarker",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FIND_NEXT_MARKER ),
AS_GLOBAL,
MD_SHIFT + WXK_F5, LEGACY_HK_NAME( "Find Next Marker" ),
_( "Find Next Marker" ), "",
find_xpm );
TOOL_ACTION ACTIONS::replaceAndFindNext( "common.Interactive.replaceAndFindNext",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Replace and Find Next" ), _( "Replace current match and find next" ),
find_replace_xpm );
TOOL_ACTION ACTIONS::replaceAll( "common.Interactive.replaceAll",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Replace All" ), _( "Replace all matches" ),
find_replace_xpm );
TOOL_ACTION ACTIONS::updateFind( "common.Control.updateFind",
AS_GLOBAL, 0, "", "" ); // This is an internal event
AS_GLOBAL );
// View Controls
TOOL_ACTION ACTIONS::zoomRedraw( "common.Control.zoomRedraw",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_REDRAW ),
AS_GLOBAL,
#if defined( __WXMAC__ )
MD_CTRL + 'R',
#else
WXK_F3,
#endif
LEGACY_HK_NAME( "Zoom Redraw" ),
_( "Refresh" ), "",
zoom_redraw_xpm );
TOOL_ACTION ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen",
AS_GLOBAL,
#if defined( __WXMAC__ )
MD_CTRL + '0',
#else
WXK_HOME,
#endif
LEGACY_HK_NAME( "Zoom Auto" ),
_( "Zoom to Fit" ), "",
zoom_fit_in_page_xpm );
TOOL_ACTION ACTIONS::zoomIn( "common.Control.zoomIn",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_IN ),
AS_GLOBAL,
#if defined( __WXMAC__ )
MD_CTRL + '+',
#else
WXK_F1,
#endif
LEGACY_HK_NAME( "Zoom In" ),
_( "Zoom In" ), "",
zoom_in_xpm );
TOOL_ACTION ACTIONS::zoomOut( "common.Control.zoomOut",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_OUT ),
AS_GLOBAL,
#if defined( __WXMAC__ )
MD_CTRL + '-',
#else
WXK_F2,
#endif
LEGACY_HK_NAME( "Zoom Out" ),
_( "Zoom Out" ), "",
zoom_out_xpm );
TOOL_ACTION ACTIONS::zoomInCenter( "common.Control.zoomInCenter",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Zoom In" ), "",
zoom_in_xpm );
TOOL_ACTION ACTIONS::zoomOutCenter( "common.Control.zoomOutCenter",
AS_GLOBAL, 0,
AS_GLOBAL,
0, "",
_( "Zoom Out" ), "",
zoom_out_xpm );
TOOL_ACTION ACTIONS::zoomCenter( "common.Control.zoomCenter",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_CENTER ),
AS_GLOBAL,
WXK_F4, LEGACY_HK_NAME( "Zoom Center" ),
_( "Center" ), "",
zoom_center_on_screen_xpm );
TOOL_ACTION ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_AUTO ),
_( "Zoom to Fit" ), "",
zoom_fit_in_page_xpm );
TOOL_ACTION ACTIONS::zoomTool( "common.Control.zoomTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_SELECTION ),
AS_GLOBAL,
MD_CTRL + WXK_F5, LEGACY_HK_NAME( "Zoom to Selection" ),
_( "Zoom to Selection" ), "",
zoom_area_xpm, AF_ACTIVATE );
TOOL_ACTION ACTIONS::zoomPreset( "common.Control.zoomPreset",
AS_GLOBAL, 0,
"", "" );
AS_GLOBAL );
TOOL_ACTION ACTIONS::centerContents( "common.Control.centerContents",
AS_GLOBAL, 0,
"", "" );
AS_GLOBAL );
// Cursor control
TOOL_ACTION ACTIONS::cursorUp( "common.Control.cursorUp",
AS_GLOBAL, WXK_UP,
"", "", NULL, AF_NONE, (void*) CURSOR_UP );
AS_GLOBAL,
WXK_UP, "",
"", "",
nullptr, AF_NONE, (void*) CURSOR_UP );
TOOL_ACTION ACTIONS::cursorDown( "common.Control.cursorDown",
AS_GLOBAL, WXK_DOWN,
"", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
AS_GLOBAL,
WXK_DOWN, "",
"", "" ,
nullptr, AF_NONE, (void*) CURSOR_DOWN );
TOOL_ACTION ACTIONS::cursorLeft( "common.Control.cursorLeft",
AS_GLOBAL, WXK_LEFT,
"", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
AS_GLOBAL,
WXK_LEFT, "",
"", "" ,
nullptr, AF_NONE, (void*) CURSOR_LEFT );
TOOL_ACTION ACTIONS::cursorRight( "common.Control.cursorRight",
AS_GLOBAL, WXK_RIGHT,
"", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
AS_GLOBAL,
WXK_RIGHT, "",
"", "" ,
nullptr, AF_NONE, (void*) CURSOR_RIGHT );
TOOL_ACTION ACTIONS::cursorUpFast( "common.Control.cursorUpFast",
AS_GLOBAL, MD_CTRL + WXK_UP,
"", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) );
AS_GLOBAL,
MD_CTRL + WXK_UP, "",
"", "",
nullptr, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) );
TOOL_ACTION ACTIONS::cursorDownFast( "common.Control.cursorDownFast",
AS_GLOBAL, MD_CTRL + WXK_DOWN,
"", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) );
AS_GLOBAL,
MD_CTRL + WXK_DOWN, "",
"", "" ,
nullptr, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) );
TOOL_ACTION ACTIONS::cursorLeftFast( "common.Control.cursorLeftFast",
AS_GLOBAL, MD_CTRL + WXK_LEFT,
"", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) );
AS_GLOBAL,
MD_CTRL + WXK_LEFT, "",
"", "" ,
nullptr, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) );
TOOL_ACTION ACTIONS::cursorRightFast( "common.Control.cursorRightFast",
AS_GLOBAL, MD_CTRL + WXK_RIGHT,
"", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) );
AS_GLOBAL,
MD_CTRL + WXK_RIGHT, "",
"", "" ,
nullptr, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) );
TOOL_ACTION ACTIONS::cursorClick( "common.Control.cursorClick",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_CLICK ),
"", "", NULL, AF_NONE, (void*) CURSOR_CLICK );
AS_GLOBAL,
WXK_RETURN, LEGACY_HK_NAME( "Mouse Left Click" ),
"", "",
nullptr, AF_NONE, (void*) CURSOR_CLICK );
TOOL_ACTION ACTIONS::cursorDblClick( "common.Control.cursorDblClick",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_DCLICK ),
"", "", NULL, AF_NONE, (void*) CURSOR_DBL_CLICK );
AS_GLOBAL,
WXK_END, LEGACY_HK_NAME( "Mouse Left Double Click" ),
"", "",
nullptr, AF_NONE, (void*) CURSOR_DBL_CLICK );
TOOL_ACTION ACTIONS::panUp( "common.Control.panUp",
AS_GLOBAL, MD_SHIFT + WXK_UP,
"", "", NULL, AF_NONE, (void*) CURSOR_UP );
AS_GLOBAL,
MD_SHIFT + WXK_UP, "",
"", "",
nullptr, AF_NONE, (void*) CURSOR_UP );
TOOL_ACTION ACTIONS::panDown( "common.Control.panDown",
AS_GLOBAL, MD_SHIFT + WXK_DOWN,
"", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
AS_GLOBAL,
MD_SHIFT + WXK_DOWN, "",
"", "" ,
nullptr, AF_NONE, (void*) CURSOR_DOWN );
TOOL_ACTION ACTIONS::panLeft( "common.Control.panLeft",
AS_GLOBAL, MD_SHIFT + WXK_LEFT,
"", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
AS_GLOBAL,
MD_SHIFT + WXK_LEFT, "",
"", "" ,
nullptr, AF_NONE, (void*) CURSOR_LEFT );
TOOL_ACTION ACTIONS::panRight( "common.Control.panRight",
AS_GLOBAL, MD_SHIFT + WXK_RIGHT,
"", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
AS_GLOBAL,
MD_SHIFT + WXK_RIGHT, "",
"", "" ,
nullptr, AF_NONE, (void*) CURSOR_RIGHT );
// Grid control
TOOL_ACTION ACTIONS::gridFast1( "common.Control.gridFast1",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_FASTGRID1 ),
AS_GLOBAL,
MD_ALT + '1', LEGACY_HK_NAME( "Switch Grid To Fast Grid1" ),
"", "" );
TOOL_ACTION ACTIONS::gridFast2( "common.Control.gridFast2",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_FASTGRID2 ),
AS_GLOBAL,
MD_ALT + '2', LEGACY_HK_NAME( "Switch Grid To Fast Grid2" ),
"", "" );
TOOL_ACTION ACTIONS::gridNext( "common.Control.gridNext",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_NEXT ),
AS_GLOBAL,
'N', LEGACY_HK_NAME( "Switch Grid To Next" ),
"", "" );
TOOL_ACTION ACTIONS::gridPrev( "common.Control.gridPrev",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_PREVIOUS ),
AS_GLOBAL, MD_SHIFT + 'N', LEGACY_HK_NAME( "Switch Grid To Previous" ),
"", "" );
TOOL_ACTION ACTIONS::gridSetOrigin( "common.Control.gridSetOrigin",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SET_GRID_ORIGIN ),
AS_GLOBAL,
'S', LEGACY_HK_NAME( "Set Grid Origin" ),
_( "Grid Origin" ), _( "Set the grid origin point" ),
grid_select_axis_xpm );
TOOL_ACTION ACTIONS::gridResetOrigin( "common.Control.gridResetOrigin",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_GRID_ORIGIN ),
AS_GLOBAL,
'Z', LEGACY_HK_NAME( "Reset Grid Origin" ),
"", "" );
TOOL_ACTION ACTIONS::gridPreset( "common.Control.gridPreset",
AS_GLOBAL, 0,
"", "" );
AS_GLOBAL );
TOOL_ACTION ACTIONS::toggleGrid( "common.Control.toggleGrid",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Show Grid" ), _( "Display grid dots or lines in the edit window" ),
grid_xpm );
TOOL_ACTION ACTIONS::gridProperties( "common.Control.gridProperties",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Grid Properties..." ), _( "Set grid dimensions" ),
grid_select_xpm );
TOOL_ACTION ACTIONS::imperialUnits( "common.Control.imperialUnits",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Imperial" ), _( "Use inches and mils" ),
unit_inch_xpm );
TOOL_ACTION ACTIONS::metricUnits( "common.Control.metricUnits",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Metric" ), _( "Use millimeters" ),
unit_mm_xpm );
TOOL_ACTION ACTIONS::toggleUnits( "common.Control.toggleUnits",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_UNITS ),
AS_GLOBAL,
MD_CTRL + 'U', LEGACY_HK_NAME( "Switch Units" ),
_( "Switch units" ), _( "Switch between inches and millimeters" ),
unit_mm_xpm );
TOOL_ACTION ACTIONS::togglePolarCoords( "common.Control.togglePolarCoords",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Polar Coordinates" ), _( "Switch between polar and cartesian coordinate systems" ),
polar_coord_xpm );
TOOL_ACTION ACTIONS::resetLocalCoords( "common.Control.resetLocalCoords",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ),
AS_GLOBAL,
' ', LEGACY_HK_NAME( "Reset Local Coordinates" ),
"", "" );
TOOL_ACTION ACTIONS::toggleCursor( "common.Control.toggleCursor",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_TOGGLE_CURSOR ),
AS_GLOBAL,
MD_CTRL + MD_SHIFT + 'X', LEGACY_HK_NAME( "Toggle Cursor Display (Modern Toolset only)" ),
_( "Always Show Cursor" ), _( "Display crosshairs even in selection tool" ),
cursor_xpm );
TOOL_ACTION ACTIONS::toggleCursorStyle( "common.Control.toggleCursorStyle",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Full-Window Crosshairs" ), _( "Switch display of full-window crosshairs" ),
cursor_shape_xpm );
TOOL_ACTION ACTIONS::highContrastMode( "common.Control.highContrastMode",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_HIGHCONTRAST_MODE ),
AS_GLOBAL,
MD_CTRL + 'H', LEGACY_HK_NAME( "Toggle High Contrast Mode" ),
_( "High Contrast Mode" ), _( "Use high contrast display mode" ),
contrast_mode_xpm );
TOOL_ACTION ACTIONS::highContrastInc( "common.Control.highContrastInc",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HIGHCONTRAST_INC ),
"", "" );
TOOL_ACTION ACTIONS::highContrastDec( "common.Control.highContrastDec",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HIGHCONTRAST_DEC ),
"", "" );
TOOL_ACTION ACTIONS::selectionTool( "common.InteractiveSelection.selectionTool",
AS_GLOBAL, 0, _( "Select item(s)" ), "",
AS_GLOBAL, 0, "",
_( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION ACTIONS::measureTool( "common.InteractiveEdit.measureTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MEASURE_TOOL ),
AS_GLOBAL,
MD_CTRL + MD_SHIFT + 'M', LEGACY_HK_NAME( "Measure Distance (Modern Toolset only)" ),
_( "Measure Tool" ), _( "Interactively measure distance between points" ),
measurement_xpm, AF_ACTIVATE );
TOOL_ACTION ACTIONS::show3DViewer( "common.Control.show3DViewer",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_3D_VIEWER ),
AS_GLOBAL,
MD_ALT + '3', LEGACY_HK_NAME( "3D Viewer" ),
_( "3D Viewer" ), _( "Show 3D viewer window" ),
three_d_xpm );
TOOL_ACTION ACTIONS::showSymbolBrowser( "common.Control.showSymbolBrowser",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Symbol Library Browser" ), _( "Browse symbol libraries" ),
library_browse_xpm );
TOOL_ACTION ACTIONS::showSymbolEditor( "common.Control.showSymbolEditor",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Symbol Editor" ), _( "Create, delete and edit symbols" ),
libedit_xpm );
TOOL_ACTION ACTIONS::showFootprintBrowser( "common.Control.showFootprintBrowser",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Footprint Library Browser" ), _( "Browse footprint libraries" ),
modview_icon_xpm );
TOOL_ACTION ACTIONS::showFootprintEditor( "common.Control.showFootprintEditor",
AS_GLOBAL, 0,
AS_GLOBAL, 0, "",
_( "Footprint Editor" ), _( "Create, delete and edit footprints" ),
module_editor_xpm );
TOOL_ACTION ACTIONS::updatePcbFromSchematic( "common.Control.updatePcbFromSchematic",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UPDATE_PCB_FROM_SCH ),
AS_GLOBAL,
WXK_F8, LEGACY_HK_NAME( "Update PCB from Schematic" ),
_( "Update PCB from Schematic..." ), _( "Push changes from schematic to PCB" ),
update_pcb_from_sch_xpm );
TOOL_ACTION ACTIONS::configurePaths( "common.Control.configurePaths",
AS_GLOBAL, 0,
_( "Configure Paths..." ), _( "Edit path configuration environment variables" ),
path_xpm );
TOOL_ACTION ACTIONS::showSymbolLibTable( "common.Control.showSymbolLibTable",
AS_GLOBAL, 0,
_( "Manage Symbol Libraries..." ),
_( "Edit the global and project symbol library lists" ),
library_table_xpm );
TOOL_ACTION ACTIONS::showFootprintLibTable( "common.Control.showFootprintLibTable",
AS_GLOBAL, 0,
_( "Manage Footprint Libraries..." ),
_( "Edit the global and project footprint library lists" ),
library_table_xpm );
TOOL_ACTION ACTIONS::acceleratedGraphics( "common.Control.acceleratedGraphics",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CANVAS_OPENGL ),
AS_GLOBAL,
#ifdef __WXMAC__
MD_ALT + WXK_F11,
#else
WXK_F11,
#endif
LEGACY_HK_NAME( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ),
_( "Accelerated Graphics" ), _( "Use hardware-accelerated graphics (recommended)" ),
tools_xpm );
TOOL_ACTION ACTIONS::standardGraphics( "common.Control.standardGraphics",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CANVAS_CAIRO ),
AS_GLOBAL,
#ifdef __WXMAC__
MD_ALT + WXK_F12,
#else
WXK_F12,
#endif
LEGACY_HK_NAME( "Switch to Modern Toolset with software graphics (fall-back)" ),
_( "Standard Graphics" ), _( "Use software graphics (fall-back)" ),
tools_xpm );
TOOL_ACTION ACTIONS::configurePaths( "common.SuiteControl.configurePaths",
AS_GLOBAL, 0, "",
_( "Configure Paths..." ), _( "Edit path configuration environment variables" ),
path_xpm );
TOOL_ACTION ACTIONS::showSymbolLibTable( "common.SuiteControl.showSymbolLibTable",
AS_GLOBAL, 0, "",
_( "Manage Symbol Libraries..." ),
_( "Edit the global and project symbol library lists" ),
library_table_xpm );
TOOL_ACTION ACTIONS::showFootprintLibTable( "common.SuiteControl.showFootprintLibTable",
AS_GLOBAL, 0, "",
_( "Manage Footprint Libraries..." ),
_( "Edit the global and project footprint library lists" ),
library_table_xpm );
TOOL_ACTION ACTIONS::gettingStarted( "common.SuiteControl.gettingStarted",
AS_GLOBAL, 0, "",
_( "Getting Started with KiCad" ),
_( "Open \"Getting Started in KiCad\" guide for beginners" ),
help_xpm );
TOOL_ACTION ACTIONS::help( "common.SuiteControl.help",
AS_GLOBAL, 0, "",
_( "Help" ),
_( "Open product documentation in a web browser" ),
online_help_xpm );
TOOL_ACTION ACTIONS::listHotKeys( "common.SuiteControl.listHotKeys",
AS_GLOBAL,
MD_CTRL + WXK_F1, LEGACY_HK_NAME( "List Hotkeys" ),
_( "List Hotkeys..." ),
_( "Displays current hotkeys table and corresponding commands" ),
hotkeys_xpm );
TOOL_ACTION ACTIONS::getInvolved( "common.SuiteControl.getInvolved",
AS_GLOBAL, 0, "",
_( "Get Involved" ),
_( "Open \"Contribute to KiCad\" in a web browser" ),
info_xpm );
// System-wide selection Events

View File

@ -0,0 +1,201 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2016 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <bitmaps.h>
#include <tool/actions.h>
#include <tool/tool_manager.h>
#include <eda_draw_frame.h>
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <base_screen.h>
#include <tool/common_control.h>
#include <id.h>
#include <project.h>
#include <kiface_i.h>
#include <dialog_configure_paths.h>
#include <eda_doc.h>
#define URL_GET_INVOLVED "http://kicad-pcb.org/contribute/"
void COMMON_CONTROL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<EDA_BASE_FRAME>();
}
int COMMON_CONTROL::ConfigurePaths( const TOOL_EVENT& aEvent )
{
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
kiface->CreateWindow( m_frame, DIALOG_CONFIGUREPATHS, &m_frame->Kiway() );
return 0;
}
int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
{
if( aEvent.IsAction( &ACTIONS::showSymbolLibTable ) )
{
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH );
kiface->CreateWindow( m_frame, DIALOG_SCH_LIBRARY_TABLE, &m_frame->Kiway() );
}
else if( aEvent.IsAction( &ACTIONS::showFootprintLibTable ) )
{
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
kiface->CreateWindow( m_frame, DIALOG_PCB_LIBRARY_TABLE, &m_frame->Kiway() );
}
return 0;
}
int COMMON_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
{
FRAME_T playerType = FRAME_SCH_VIEWER;
if( aEvent.IsAction( &ACTIONS::showSymbolBrowser ) )
playerType = FRAME_SCH_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showSymbolEditor ) )
playerType = FRAME_SCH_LIB_EDITOR;
else if( aEvent.IsAction( &ACTIONS::showFootprintBrowser ) )
playerType = FRAME_PCB_MODULE_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showFootprintEditor ) )
playerType = FRAME_PCB_MODULE_EDITOR;
else
wxFAIL_MSG( "ShowPlayer(): unexpected request" );
KIWAY_PLAYER* editor = m_frame->Kiway().Player( playerType, true );
// Needed on Windows, other platforms do not use it, but it creates no issue
if( editor->IsIconized() )
editor->Iconize( false );
editor->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != editor )
editor->SetFocus();
return 0;
}
int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
{
const SEARCH_STACK& search = m_frame->sys_search();
wxString helpFile;
wxString msg;
/* We have to get document for beginners,
* or the full specific doc
* if event id is wxID_INDEX, we want the document for beginners.
* else the specific doc file (its name is in Kiface().GetHelpFileName())
* The document for beginners is the same for all KiCad utilities
*/
if( aEvent.IsAction( &ACTIONS::gettingStarted ) )
{
// List of possible names for Getting Started in KiCad
const wxChar* names[2] = {
wxT( "getting_started_in_kicad" ),
wxT( "Getting_Started_in_KiCad" )
};
// Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
// or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
for( auto& name : names )
{
helpFile = SearchHelpFileFullPath( search, name );
if( !helpFile.IsEmpty() )
break;
}
if( !helpFile )
{
msg = wxString::Format( _( "Html or pdf help file \n%s\nor\n%s could not be found." ),
names[0], names[1] );
wxMessageBox( msg );
return -1;
}
}
else
{
wxString base_name = m_frame->help_name();
helpFile = SearchHelpFileFullPath( search, base_name );
if( !helpFile )
{
msg = wxString::Format( _( "Help file \"%s\" could not be found." ), base_name );
wxMessageBox( msg );
return -1;
}
}
GetAssociatedDocument( m_frame, helpFile );
return 0;
}
int COMMON_CONTROL::ListHotKeys( const TOOL_EVENT& aEvent )
{
DisplayHotkeyList( m_frame, m_toolMgr );
return 0;
}
int COMMON_CONTROL::GetInvolved( const TOOL_EVENT& aEvent )
{
if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
{
wxString msg;
msg.Printf( _( "Could not launch the default browser.\n"
"For information on how to help the KiCad project, visit %s" ),
URL_GET_INVOLVED );
wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, m_frame );
}
return 0;
}
void COMMON_CONTROL::setTransitions()
{
Go( &COMMON_CONTROL::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() );
Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showSymbolLibTable.MakeEvent() );
Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showFootprintLibTable.MakeEvent() );
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showSymbolBrowser.MakeEvent() );
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showSymbolEditor.MakeEvent() );
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showFootprintBrowser.MakeEvent() );
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showFootprintEditor.MakeEvent() );
Go( &COMMON_CONTROL::ShowHelp, ACTIONS::gettingStarted.MakeEvent() );
Go( &COMMON_CONTROL::ShowHelp, ACTIONS::help.MakeEvent() );
Go( &COMMON_CONTROL::ListHotKeys, ACTIONS::listHotKeys.MakeEvent() );
Go( &COMMON_CONTROL::GetInvolved, ACTIONS::getInvolved.MakeEvent() );
}

View File

@ -31,7 +31,6 @@
#include <view/view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <base_screen.h>
#include <hotkeys.h>
#include <tool/common_tools.h>
#include <id.h>
#include <project.h>
@ -494,31 +493,6 @@ int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::ConfigurePaths( const TOOL_EVENT& aEvent )
{
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
kiface->CreateWindow( m_frame, DIALOG_CONFIGUREPATHS, &m_frame->Kiway() );
return 0;
}
int COMMON_TOOLS::ShowLibraryTable( const TOOL_EVENT& aEvent )
{
if( aEvent.IsAction( &ACTIONS::showSymbolLibTable ) )
{
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH );
kiface->CreateWindow( m_frame, DIALOG_SCH_LIBRARY_TABLE, &m_frame->Kiway() );
}
else if( aEvent.IsAction( &ACTIONS::showFootprintLibTable ) )
{
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
kiface->CreateWindow( m_frame, DIALOG_PCB_LIBRARY_TABLE, &m_frame->Kiway() );
}
return 0;
}
int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent )
{
if( aEvent.IsAction( &ACTIONS::acceleratedGraphics ) )
@ -532,38 +506,6 @@ int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::ShowPlayer( const TOOL_EVENT& aEvent )
{
FRAME_T playerType = FRAME_SCH_VIEWER;
if( aEvent.IsAction( &ACTIONS::showSymbolBrowser ) )
playerType = FRAME_SCH_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showSymbolEditor ) )
playerType = FRAME_SCH_LIB_EDITOR;
else if( aEvent.IsAction( &ACTIONS::showFootprintBrowser ) )
playerType = FRAME_PCB_MODULE_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showFootprintEditor ) )
playerType = FRAME_PCB_MODULE_EDITOR;
else
wxFAIL_MSG( "ShowPlayer(): unexpected request" );
KIWAY_PLAYER* editor = m_frame->Kiway().Player( playerType, true );
// Needed on Windows, other platforms do not use it, but it creates no issue
if( editor->IsIconized() )
editor->Iconize( false );
editor->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != editor )
editor->SetFocus();
return 0;
}
void COMMON_TOOLS::setTransitions()
{
// Cursor control
@ -594,33 +536,27 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::ZoomCenter, ACTIONS::zoomCenter.MakeEvent() );
Go( &COMMON_TOOLS::ZoomFitScreen, ACTIONS::zoomFitScreen.MakeEvent() );
Go( &COMMON_TOOLS::ZoomPreset, ACTIONS::zoomPreset.MakeEvent() );
Go( &COMMON_TOOLS::CenterContents, ACTIONS::centerContents.MakeEvent() );
// Grid control
Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() );
Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() );
Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() );
Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() );
Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() );
// Units and coordinates
Go( &COMMON_TOOLS::ImperialUnits, ACTIONS::imperialUnits.MakeEvent() );
Go( &COMMON_TOOLS::MetricUnits, ACTIONS::metricUnits.MakeEvent() );
Go( &COMMON_TOOLS::ToggleUnits, ACTIONS::toggleUnits.MakeEvent() );
Go( &COMMON_TOOLS::TogglePolarCoords, ACTIONS::togglePolarCoords.MakeEvent() );
Go( &COMMON_TOOLS::ResetLocalCoords, ACTIONS::resetLocalCoords.MakeEvent() );
// Misc
Go( &COMMON_TOOLS::ToggleCursor, ACTIONS::toggleCursor.MakeEvent() );
Go( &COMMON_TOOLS::ToggleCursorStyle, ACTIONS::toggleCursorStyle.MakeEvent() );
Go( &COMMON_TOOLS::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() );
Go( &COMMON_TOOLS::ShowLibraryTable, ACTIONS::showSymbolLibTable.MakeEvent() );
Go( &COMMON_TOOLS::ShowLibraryTable, ACTIONS::showFootprintLibTable.MakeEvent() );
Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::acceleratedGraphics.MakeEvent() );
Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::standardGraphics.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showSymbolBrowser.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showSymbolEditor.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showFootprintBrowser.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showFootprintEditor.MakeEvent() );
}

View File

@ -28,11 +28,19 @@
#include <algorithm>
TOOL_ACTION::TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope,
int aDefaultHotKey, const wxString& aMenuItem, const wxString& aMenuDesc,
const BITMAP_OPAQUE* aIcon, TOOL_ACTION_FLAGS aFlags, void* aParam ) :
m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
m_menuItem( aMenuItem ), m_menuDescription( aMenuDesc ),
m_icon( aIcon ), m_id( -1 ), m_flags( aFlags ), m_param( aParam )
int aDefaultHotKey, const std::string& aLegacyHotKeyName,
const wxString& aMenuText, const wxString& aTooltip,
const BITMAP_OPAQUE* aIcon, TOOL_ACTION_FLAGS aFlags, void* aParam ) :
m_name( aName ),
m_scope( aScope ),
m_defaultHotKey( aDefaultHotKey ),
m_legacyName( aLegacyHotKeyName ),
m_menuText( aMenuText ),
m_tooltip( aTooltip ),
m_icon( aIcon ),
m_id( -1 ),
m_flags( aFlags ),
m_param( aParam )
{
ACTION_MANAGER::GetActionList().push_back( this );
}

View File

@ -45,7 +45,7 @@ KIGFX::VIEW_CONTROLS* TOOL_BASE::getViewControls() const
}
wxWindow* TOOL_BASE::getEditFrameInt() const
EDA_BASE_FRAME* TOOL_BASE::getEditFrameInt() const
{
return m_toolMgr->GetEditFrame();
}

View File

@ -26,7 +26,6 @@
#include <map>
#include <stack>
#include <algorithm>
#include <core/optional.h>
#include <wx/event.h>
@ -311,6 +310,12 @@ void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara
}
const std::map<std::string, TOOL_ACTION*>& TOOL_MANAGER::GetActions()
{
return m_actionMgr->GetActions();
}
int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction )
{
return m_actionMgr->GetHotKey( aAction );
@ -464,6 +469,8 @@ void TOOL_MANAGER::InitTools()
}
}
m_actionMgr->UpdateHotKeys();
ResetTools( TOOL_BASE::RUN );
}
@ -863,7 +870,6 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
m_view = aView;
m_viewControls = aViewControls;
m_frame = aFrame;
m_actionMgr->UpdateHotKeys();
}

View File

@ -46,15 +46,6 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason )
int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
{
// This method is called both when the zoom tool is activated (on) or deactivated (off)
wxMenuBar* menu = m_frame->GetMenuBar();
bool zoom_tool_is_on = m_frame->GetToolToggled( ID_ZOOM_SELECTION ) ||
( menu && menu->IsChecked( ID_ZOOM_SELECTION ) );
if( !zoom_tool_is_on ) // This is a tool deselection: do nothing
return 0;
m_frame->SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
while( auto evt = Wait() )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -23,11 +23,9 @@
*/
#include <cctype>
#include <widgets/widget_hotkey_list.h>
#include <wx/statline.h>
#include <tool/tool_action.h>
#include <eda_draw_frame.h>
#include <dialog_shim.h>
@ -59,14 +57,14 @@ enum ID_WHKL_MENU_IDS
*/
class WIDGET_HOTKEY_CLIENT_DATA : public wxClientData
{
CHANGED_HOTKEY& m_changed_hotkey;
HOTKEY& m_changed_hotkey;
public:
WIDGET_HOTKEY_CLIENT_DATA( CHANGED_HOTKEY& aChangedHotkey )
WIDGET_HOTKEY_CLIENT_DATA( HOTKEY& aChangedHotkey )
: m_changed_hotkey( aChangedHotkey )
{}
CHANGED_HOTKEY& GetChangedHotkey() { return m_changed_hotkey; }
HOTKEY& GetChangedHotkey() { return m_changed_hotkey; }
};
@ -245,17 +243,17 @@ public:
*
* @return true on match (or if filter is disabled)
*/
bool FilterMatches( const EDA_HOTKEY& aHotkey ) const
bool FilterMatches( const HOTKEY& aHotkey ) const
{
if( !m_valid )
return true;
// Match in the (translated) filter string
const auto normedInfo = wxGetTranslation( aHotkey.m_InfoMsg ).Upper();
const auto normedInfo = wxGetTranslation( aHotkey.m_Parent->GetMenuItem() ).Upper();
if( normedInfo.Contains( m_normalised_filter_str ) )
return true;
const wxString keyName = KeyNameFromKeyCode( aHotkey.m_KeyCode );
const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode );
if( keyName.Upper().Contains( m_normalised_filter_str ) )
return true;
@ -275,25 +273,11 @@ WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetHKClientData( wxTreeListItem a
{
wxClientData* data = GetItemData( aItem );
if( !data )
{
return NULL;
}
else
{
if( data )
return static_cast<WIDGET_HOTKEY_CLIENT_DATA*>( data );
}
}
else
{
return NULL;
}
}
WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetSelHKClientData()
{
return GetHKClientData( GetSelection() );
return nullptr;
}
@ -318,15 +302,17 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData()
if( hkdata )
{
const auto& changed_hk = hkdata->GetChangedHotkey();
const EDA_HOTKEY& hk = changed_hk.GetCurrentValue();
wxString key_text = KeyNameFromKeyCode( hk.m_KeyCode );
wxString label = changed_hk.m_Parent->GetMenuItem();
wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode );
if( label.IsEmpty() )
label = changed_hk.m_Parent->GetName();
// mark unsaved changes
if( changed_hk.HasUnsavedChange() )
if( changed_hk.m_EditKeycode != changed_hk.m_Parent->GetHotKey() )
key_text += " *";
SetItemText( i, 0, wxGetTranslation( hk.m_InfoMsg ) );
SetItemText( i, 0, label );
SetItemText( i, 1, key_text);
}
}
@ -337,23 +323,16 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData()
}
void WIDGET_HOTKEY_LIST::changeHotkey( CHANGED_HOTKEY& aHotkey, long aKey )
void WIDGET_HOTKEY_LIST::changeHotkey( HOTKEY& aHotkey, long aKey )
{
// See if this key code is handled in hotkeys names list
bool exists;
KeyNameFromKeyCode( aKey, &exists );
auto& curr_hk = aHotkey.GetCurrentValue();
if( exists && curr_hk.m_KeyCode != aKey )
if( exists && aHotkey.m_EditKeycode != aKey )
{
const auto& tag = aHotkey.GetSectionTag();
bool can_update = ResolveKeyConflicts( aKey, tag );
if( can_update )
{
curr_hk.m_KeyCode = aKey;
}
if( ResolveKeyConflicts( aHotkey.m_Parent, aKey ) )
aHotkey.m_EditKeycode = aKey;
}
}
@ -387,9 +366,8 @@ void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem )
return;
auto& changed_hk = hkdata->GetChangedHotkey();
const auto& orig_hk = changed_hk.GetOriginalValue();
changeHotkey( changed_hk, orig_hk.m_KeyCode );
changeHotkey( changed_hk, changed_hk.m_Parent->GetHotKey() );
UpdateFromClientData();
}
@ -403,7 +381,7 @@ void WIDGET_HOTKEY_LIST::ResetItemToDefault( wxTreeListItem aItem )
auto& changed_hk = hkdata->GetChangedHotkey();
changeHotkey( changed_hk, changed_hk.GetCurrentValue().GetDefaultKeyCode() );
changeHotkey( changed_hk, changed_hk.m_Parent->GetDefaultHotKey() );
UpdateFromClientData();
}
@ -469,45 +447,38 @@ void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent )
}
bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( long aKey, const wxString& aSectionTag )
bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( TOOL_ACTION* aAction, long aKey )
{
EDA_HOTKEY* conflicting_key = nullptr;
EDA_HOTKEY_CONFIG* conflicting_section = nullptr;
HOTKEY* conflictingHotKey = nullptr;
m_hk_store.CheckKeyConflicts( aKey, aSectionTag, &conflicting_key, &conflicting_section );
m_hk_store.CheckKeyConflicts( aAction, aKey, &conflictingHotKey );
if( conflicting_key != nullptr )
{
wxString info = wxGetTranslation( conflicting_key->m_InfoMsg );
wxString msg = wxString::Format(
_( "\"%s\" is already assigned to \"%s\" in section \"%s\". Are you sure you want "
"to change its assignment?" ),
KeyNameFromKeyCode( aKey ), GetChars( info ),
*(conflicting_section->m_Title) );
wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
if( dlg.ShowModal() == wxID_YES )
{
// Reset the other hotkey
conflicting_key->m_KeyCode = 0;
UpdateFromClientData();
return true;
}
else
{
return false;
}
}
else
if( !conflictingHotKey )
return true;
TOOL_ACTION* conflictingAction = conflictingHotKey->m_Parent;
wxString msg = wxString::Format( _( "\"%s\" is already assigned to \"%s\" in section \"%s\". "
"Are you sure you want to change its assignment?" ),
KeyNameFromKeyCode( aKey ),
conflictingAction->GetMenuItem(),
HOTKEY_STORE::GetSectionName( conflictingAction ) );
wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
if( dlg.ShowModal() == wxID_YES )
{
// Reset the other hotkey
conflictingHotKey->m_EditKeycode = 0;
UpdateFromClientData();
return true;
}
return false;
}
WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore,
bool aReadOnly )
bool aReadOnly )
: TWO_COLUMN_TREE_LIST( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ),
m_hk_store( aHotkeyStore ),
m_readOnly( aReadOnly )
@ -573,14 +544,14 @@ void WIDGET_HOTKEY_LIST::updateShownItems( const wxString& aFilterStr )
HOTKEY_FILTER filter( aFilterStr );
for( auto& section: m_hk_store.GetSections() )
for( HOTKEY_SECTION& section: m_hk_store.GetSections() )
{
// Create parent tree item
wxTreeListItem parent = AppendItem( GetRootItem(), section.m_name );
wxTreeListItem parent = AppendItem( GetRootItem(), section.m_SectionName );
for( auto& hotkey: section.m_hotkeys )
for( HOTKEY& hotkey: section.m_HotKeys )
{
if( filter.FilterMatches( hotkey.GetCurrentValue() ) )
if( filter.FilterMatches( hotkey ) )
{
wxTreeListItem item = AppendItem( parent, wxEmptyString );
SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( hotkey ) );

View File

@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file cvpcb_mainframe.cpp
*/
#include <fctsys.h>
#include <build_version.h>
#include <kiway_express.h>
@ -48,7 +44,7 @@
#include <invoke_pcb_dialog.h>
#include <display_footprints_frame.h>
#include <cvpcb_id.h>
#include <tool/action_toolbar.h>
#include <cvpcb_mainframe.h>
wxSize const FRAME_MIN_SIZE_DU( 350, 250 );
@ -65,7 +61,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
// Menu events
EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::OnSaveAndContinue )
EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit )
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, CVPCB_MAINFRAME::OnConfigurePaths )
EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList )
// Toolbar events

View File

@ -25,8 +25,6 @@
#include <fctsys.h>
#include <common.h>
#include <gal/graphics_abstraction_layer.h>
#include <class_draw_panel_gal.h>
#include <pcb_draw_panel_gal.h>
#include <confirm.h>
#include <macros.h>
@ -36,7 +34,6 @@
#include <lib_id.h>
#include <fp_lib_table.h>
#include <eda_dockart.h>
#include <io_mgr.h>
#include <class_module.h>
#include <class_board.h>
#include <pcb_painter.h>
@ -44,10 +41,10 @@
#include <display_footprints_frame.h>
#include <cvpcb_id.h>
#include <listboxes.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <tool/common_tools.h>
#include <tool/zoom_tool.h>
#include <tools/cvpcb_actions.h>

View File

@ -102,9 +102,6 @@ public:
void InstallOptionsDisplay( wxCommandEvent& event );
MODULE* Get_Module( const wxString& CmpName );
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override { return NULL; }
/* SaveCopyInUndoList() virtual
* currently: do nothing in CvPcb.
* but but be defined because it is a pure virtual in PCB_BASE_FRAME

View File

@ -55,6 +55,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
wxMenu* preferencesMenu = new wxMenu;
// Path configuration edit dialog.
// JEY TODO: fix these....
AddMenuItem( preferencesMenu,
ID_PREFERENCES_CONFIGURE_PATHS,
_( "&Configure Paths..." ),

Some files were not shown because too many files have changed in this diff Show More