Move Kicad Manager launch bar to ACTIONs.
Also fixes a bug where hotkeys weren't getting put in menus.
This commit is contained in:
parent
31ee95c683
commit
620395608c
|
@ -70,7 +70,7 @@ void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList )
|
|||
for( const auto& entry : toolMgr->GetActions() )
|
||||
{
|
||||
// Internal actions probably shouldn't be allowed hotkeys
|
||||
if( entry.second->GetMenuItem().IsEmpty() )
|
||||
if( entry.second->GetLabel().IsEmpty() )
|
||||
continue;
|
||||
|
||||
masterMap[ entry.first ] = entry.second;
|
||||
|
|
|
@ -52,6 +52,19 @@ void ACTION_TOOLBAR::Add( const TOOL_ACTION& aAction, bool aIsToggleEntry )
|
|||
}
|
||||
|
||||
|
||||
void ACTION_TOOLBAR::AddButton( const TOOL_ACTION& aAction )
|
||||
{
|
||||
EDA_BASE_FRAME* editFrame = m_toolManager->GetEditFrame();
|
||||
int toolId = aAction.GetId() + ACTION_ID;
|
||||
|
||||
AddTool( toolId, wxEmptyString, KiScaledBitmap( aAction.GetIcon(), editFrame ),
|
||||
aAction.GetName(), wxITEM_NORMAL );
|
||||
|
||||
m_toolKinds[ toolId ] = false;
|
||||
m_toolActions[ toolId ] = &aAction;
|
||||
}
|
||||
|
||||
|
||||
void ACTION_TOOLBAR::Toggle( const TOOL_ACTION& aAction, bool aState )
|
||||
{
|
||||
int toolId = aAction.GetId() + ACTION_ID;
|
||||
|
|
|
@ -26,22 +26,24 @@
|
|||
#include <tool/action_manager.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <hotkeys_basic.h>
|
||||
|
||||
TOOL_ACTION::TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope,
|
||||
int aDefaultHotKey, const std::string& aLegacyHotKeyName,
|
||||
const wxString& aMenuText, const wxString& aTooltip,
|
||||
const wxString& aLabel, 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_label( aLabel ),
|
||||
m_tooltip( aTooltip ),
|
||||
m_icon( aIcon ),
|
||||
m_id( -1 ),
|
||||
m_flags( aFlags ),
|
||||
m_param( aParam )
|
||||
{
|
||||
SetHotKey( aDefaultHotKey );
|
||||
ACTION_MANAGER::GetActionList().push_back( this );
|
||||
}
|
||||
|
||||
|
@ -52,6 +54,13 @@ TOOL_ACTION::~TOOL_ACTION()
|
|||
}
|
||||
|
||||
|
||||
void TOOL_ACTION::SetHotKey( int aKeycode )
|
||||
{
|
||||
m_hotKey = aKeycode;
|
||||
m_menuItem = AddHotkeyName( m_label, m_hotKey, IS_HOTKEY );
|
||||
}
|
||||
|
||||
|
||||
std::string TOOL_ACTION::GetToolName() const
|
||||
{
|
||||
int dotCount = std::count( m_name.begin(), m_name.end(), '.' );
|
||||
|
|
|
@ -249,7 +249,7 @@ public:
|
|||
return true;
|
||||
|
||||
// Match in the (translated) filter string
|
||||
const auto normedInfo = wxGetTranslation( aHotkey.m_Parent->GetMenuItem() ).Upper();
|
||||
const auto normedInfo = wxGetTranslation( aHotkey.m_Parent->GetLabel() ).Upper();
|
||||
if( normedInfo.Contains( m_normalised_filter_str ) )
|
||||
return true;
|
||||
|
||||
|
@ -302,7 +302,7 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData()
|
|||
if( hkdata )
|
||||
{
|
||||
const auto& changed_hk = hkdata->GetChangedHotkey();
|
||||
wxString label = changed_hk.m_Parent->GetMenuItem();
|
||||
wxString label = changed_hk.m_Parent->GetLabel();
|
||||
wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode );
|
||||
|
||||
if( label.IsEmpty() )
|
||||
|
@ -460,7 +460,7 @@ bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( TOOL_ACTION* aAction, long aKey )
|
|||
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(),
|
||||
conflictingAction->GetLabel(),
|
||||
HOTKEY_STORE::GetSectionName( conflictingAction ) );
|
||||
|
||||
wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
|
||||
|
|
|
@ -53,6 +53,13 @@ public:
|
|||
*/
|
||||
void Add( const TOOL_ACTION& aAction, bool aIsToggleEntry = false );
|
||||
|
||||
/**
|
||||
* Function AddButton()
|
||||
* Adds a large button such as used in the Kicad Manager Frame's launch bar.
|
||||
* @param aAction
|
||||
*/
|
||||
void AddButton( const TOOL_ACTION& aAction );
|
||||
|
||||
/**
|
||||
* Applies the default toggle action. For checked items this is check/uncheck; for
|
||||
* non-checked items it's enable/disable.
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
* Returns the hotkey keycode which initiates the action.
|
||||
*/
|
||||
int GetHotKey() const { return m_hotKey; }
|
||||
void SetHotKey( int aKeycode ) { m_hotKey = aKeycode; }
|
||||
void SetHotKey( int aKeycode );
|
||||
|
||||
/**
|
||||
* Function GetId()
|
||||
|
@ -110,8 +110,9 @@ public:
|
|||
return TOOL_EVENT( TC_COMMAND, TA_ACTION, m_name, m_scope, m_param );
|
||||
}
|
||||
|
||||
const wxString& GetMenuItem() const { return m_menuText; }
|
||||
void SetMenuItem( const wxString& aItem ) { m_menuText = aItem; }
|
||||
const wxString& GetLabel() const { return m_label; }
|
||||
|
||||
const wxString& GetMenuItem() const { return m_menuItem; }
|
||||
|
||||
const wxString& GetDescription() const { return m_tooltip; }
|
||||
void SetDescription( const wxString& aDescription ) { m_tooltip = aDescription; }
|
||||
|
@ -160,7 +161,8 @@ private:
|
|||
int m_hotKey; // The curret hotkey (post-user-settings-application)
|
||||
const std::string m_legacyName; // Name for reading legacy hotkey settings
|
||||
|
||||
wxString m_menuText;
|
||||
const wxString m_label;
|
||||
wxString m_menuItem; // Label + hotkey text for menus
|
||||
wxString m_tooltip;
|
||||
const BITMAP_OPAQUE* m_icon; // Icon for the menu entry
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ include_directories(
|
|||
|
||||
|
||||
set( KICAD_SRCS
|
||||
commandframe.cpp
|
||||
dialogs/dialog_template_selector_base.cpp
|
||||
dialogs/dialog_template_selector.cpp
|
||||
files-io.cpp
|
||||
|
|
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004-2012 Jean-Pierre Charras
|
||||
* Copyright (C) 2004-2012 KiCad Developers, see change_log.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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file commandframe.cpp
|
||||
* @brief Frame showing fast launch buttons and messages box
|
||||
*/
|
||||
|
||||
|
||||
#include <bitmaps.h>
|
||||
#include <wx/statline.h>
|
||||
|
||||
#include "kicad_manager_frame.h"
|
||||
#include "kicad_id.h"
|
||||
|
||||
// Amount of clearance between tool buttons
|
||||
const int BUTTON_SEPARATION = 5;
|
||||
|
||||
// Buttons are larger than images by this amount
|
||||
const int BUTTON_EXPANSION = 6;
|
||||
|
||||
LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) :
|
||||
wxPanel( parent, wxID_ANY ),
|
||||
m_buttonSizer( nullptr )
|
||||
{
|
||||
|
||||
// Add bitmap buttons to launch KiCad utilities:
|
||||
ReCreateCommandToolbar();
|
||||
}
|
||||
|
||||
int LAUNCHER_PANEL::GetPanelHeight() const
|
||||
{
|
||||
return m_height + 2 * BUTTON_SEPARATION;
|
||||
}
|
||||
|
||||
int LAUNCHER_PANEL::GetPanelWidth() const
|
||||
{
|
||||
return m_width + BUTTON_SEPARATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add application launcher buttons
|
||||
* e.g. Eeschema, CvPcb, Pcbnew, GerbView
|
||||
*/
|
||||
void LAUNCHER_PANEL::ReCreateCommandToolbar()
|
||||
{
|
||||
if( m_buttonSizer )
|
||||
m_buttonSizer->Clear( true );
|
||||
else
|
||||
{
|
||||
m_buttonSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
SetSizer( m_buttonSizer );
|
||||
}
|
||||
|
||||
wxStaticLine* separator;
|
||||
|
||||
AddButton( ID_TO_SCH,
|
||||
KiBitmap( icon_eeschema_xpm ),
|
||||
_( "Schematic Layout Editor" ) );
|
||||
|
||||
AddButton( ID_TO_SCH_LIB_EDITOR,
|
||||
KiBitmap( icon_libedit_xpm ),
|
||||
_( "Symbol Editor" ) );
|
||||
|
||||
separator = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
||||
m_buttonSizer->Add( separator, 0, wxEXPAND | wxALL, 8 );
|
||||
|
||||
AddButton( ID_TO_PCB,
|
||||
KiBitmap( icon_pcbnew_xpm ),
|
||||
_( "PCB Layout Editor" ) );
|
||||
|
||||
AddButton( ID_TO_PCB_FP_EDITOR,
|
||||
KiBitmap( icon_modedit_xpm ),
|
||||
_( "Footprint Editor" ) );
|
||||
|
||||
separator = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
||||
m_buttonSizer->Add( separator, 0, wxEXPAND | wxALL, 8 );
|
||||
|
||||
AddButton( ID_TO_GERBVIEW,
|
||||
KiBitmap( icon_gerbview_xpm ),
|
||||
_( "Gerber Viewer" ) );
|
||||
|
||||
AddButton( ID_TO_BITMAP_CONVERTER,
|
||||
KiBitmap( icon_bitmap2component_xpm ),
|
||||
_( "Bitmap to Component Converter\n"
|
||||
"Convert bitmap images to schematic or PCB components" ) );
|
||||
|
||||
AddButton( ID_TO_PCB_CALCULATOR,
|
||||
KiBitmap( icon_pcbcalculator_xpm ),
|
||||
_( "PCB Calculator\n"
|
||||
"Run component calculations, track width calculations, etc." ) );
|
||||
|
||||
AddButton( ID_TO_PL_EDITOR,
|
||||
KiBitmap( icon_pagelayout_editor_xpm ),
|
||||
_( "Page Layout Editor\n"
|
||||
"Edit worksheet graphics and text" ) );
|
||||
|
||||
// Add a stretchy spacer to make button bar fill the entire screen
|
||||
m_buttonSizer->AddStretchSpacer();
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single button to the toolbar
|
||||
* @param aId is the ID of the button
|
||||
* @param aBitmap is the image to be used
|
||||
* @param aToolTip is the button mouse-over tool tip
|
||||
*/
|
||||
void LAUNCHER_PANEL::AddButton( wxWindowID aId, const wxBitmap& aBitmap, const wxString& aToolTip )
|
||||
{
|
||||
wxSize buttSize( aBitmap.GetWidth() + 2 * BUTTON_EXPANSION,
|
||||
aBitmap.GetHeight() + 2 * BUTTON_EXPANSION );
|
||||
|
||||
if( m_height < buttSize.y )
|
||||
m_height = buttSize.y;
|
||||
|
||||
m_width += buttSize.x + BUTTON_SEPARATION;
|
||||
|
||||
auto btn = new wxBitmapButton( this, aId, aBitmap, wxDefaultPosition, buttSize );
|
||||
|
||||
btn->SetToolTip( aToolTip );
|
||||
|
||||
m_buttonSizer->Add( btn, 0, wxALL | wxEXPAND, BUTTON_SEPARATION );
|
||||
}
|
|
@ -74,7 +74,7 @@ enum id_kicad_frm {
|
|||
ID_TO_PL_EDITOR,
|
||||
|
||||
ID_TO_TEXT_EDITOR,
|
||||
ID_BROWSE_AN_SELECT_FILE,
|
||||
ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR,
|
||||
ID_BROWSE_IN_FILE_EXPLORER,
|
||||
ID_SAVE_AND_ZIP_FILES,
|
||||
ID_READ_ZIP_ARCHIVE,
|
||||
|
|
|
@ -49,13 +49,41 @@
|
|||
|
||||
#define TREE_FRAME_WIDTH_ENTRY wxT( "LeftWinWidth" )
|
||||
|
||||
// Menubar and toolbar event table
|
||||
BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
|
||||
// Window events
|
||||
EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
|
||||
EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow )
|
||||
|
||||
// Menu events
|
||||
EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
|
||||
EVT_MENU( ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR, KICAD_MANAGER_FRAME::OnOpenFileInTextEditor )
|
||||
EVT_MENU( ID_BROWSE_IN_FILE_EXPLORER, KICAD_MANAGER_FRAME::OnBrowseInFileExplorer )
|
||||
EVT_MENU( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles )
|
||||
EVT_MENU( ID_READ_ZIP_ARCHIVE, KICAD_MANAGER_FRAME::OnUnarchiveFiles )
|
||||
EVT_MENU( ID_IMPORT_EAGLE_PROJECT, KICAD_MANAGER_FRAME::OnImportEagleFiles )
|
||||
|
||||
// Range menu events
|
||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
|
||||
KICAD_MANAGER_FRAME::language_change )
|
||||
|
||||
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, KICAD_MANAGER_FRAME::OnFileHistory )
|
||||
|
||||
// Special functions
|
||||
EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size ) :
|
||||
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME, &::Kiway )
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME, &::Kiway ),
|
||||
m_leftWin( nullptr ),
|
||||
m_launcher( nullptr ),
|
||||
m_messagesBox( nullptr ),
|
||||
m_mainToolBar( nullptr )
|
||||
{
|
||||
m_active_project = false;
|
||||
m_mainToolBar = nullptr;
|
||||
m_leftWinWidth = 60;
|
||||
m_AboutTitle = "KiCad";
|
||||
|
||||
|
@ -75,13 +103,10 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl
|
|||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||
|
||||
// Left window: is the box which display tree project
|
||||
m_LeftWin = new TREE_PROJECT_FRAME( this );
|
||||
|
||||
// Right top Window: buttons to launch applications
|
||||
m_Launcher = new LAUNCHER_PANEL( this );
|
||||
m_leftWin = new TREE_PROJECT_FRAME( this );
|
||||
|
||||
// Add the wxTextCtrl showing all messages from KiCad:
|
||||
m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
|
||||
m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE );
|
||||
|
||||
|
@ -96,20 +121,20 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl
|
|||
m_toolManager->InitTools();
|
||||
|
||||
RecreateBaseHToolbar();
|
||||
RecreateLauncher();
|
||||
ReCreateMenuBar();
|
||||
|
||||
m_auimgr.SetManagedWindow( this );
|
||||
|
||||
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
||||
|
||||
m_auimgr.AddPane( m_LeftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer(3)
|
||||
m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer(3)
|
||||
.CaptionVisible( false ).PaneBorder( false )
|
||||
.MinSize( 150, -1 ).BestSize( m_leftWinWidth, -1 ) );
|
||||
|
||||
m_auimgr.AddPane( m_Launcher, EDA_PANE().HToolbar().Name( "Launcher" ).Top().Layer(1)
|
||||
.MinSize( m_Launcher->GetPanelWidth(), m_Launcher->GetPanelHeight() ) );
|
||||
m_auimgr.AddPane( m_launcher, EDA_PANE().HToolbar().Name( "Launcher" ).Top().Layer(1) );
|
||||
|
||||
m_auimgr.AddPane( m_MessagesBox, EDA_PANE().Messages().Name( "MsgPanel" ).Center() );
|
||||
m_auimgr.AddPane( m_messagesBox, EDA_PANE().Messages().Name( "MsgPanel" ).Center() );
|
||||
|
||||
m_auimgr.Update();
|
||||
|
||||
|
@ -186,7 +211,7 @@ const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName()
|
|||
|
||||
void KICAD_MANAGER_FRAME::ReCreateTreePrj()
|
||||
{
|
||||
m_LeftWin->ReCreateTreePrj();
|
||||
m_leftWin->ReCreateTreePrj();
|
||||
}
|
||||
|
||||
|
||||
|
@ -204,7 +229,7 @@ wxString KICAD_MANAGER_FRAME::help_name()
|
|||
|
||||
void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText )
|
||||
{
|
||||
m_MessagesBox->AppendText( aText );
|
||||
m_messagesBox->AppendText( aText );
|
||||
}
|
||||
|
||||
|
||||
|
@ -239,7 +264,7 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
|
||||
Event.SetCanVeto( true );
|
||||
|
||||
m_LeftWin->Show( false );
|
||||
m_leftWin->Show( false );
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
@ -252,234 +277,6 @@ void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate( int pid, int status )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "%s closed [pid=%d]\n" ),
|
||||
m_appName,
|
||||
pid );
|
||||
|
||||
wxWindow* window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
|
||||
|
||||
if( window ) // Should always happen.
|
||||
{
|
||||
// Be sure the kicad frame manager is found
|
||||
// This dynamic cast is not really mandatory, but ...
|
||||
KICAD_MANAGER_FRAME* frame = dynamic_cast<KICAD_MANAGER_FRAME*> (window);
|
||||
|
||||
if( frame )
|
||||
frame->PrintMsg( msg );
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile, wxString params )
|
||||
{
|
||||
if( params.size() )
|
||||
AddDelimiterString( params );
|
||||
|
||||
TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
|
||||
|
||||
long pid = ExecuteFile( frame, execFile, params, callback );
|
||||
|
||||
if( pid > 0 )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ),
|
||||
execFile,
|
||||
params,
|
||||
pid );
|
||||
PrintMsg( msg );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile );
|
||||
system( msg.c_str() );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
delete callback;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName )
|
||||
{
|
||||
KIWAY_PLAYER* frame;
|
||||
|
||||
try
|
||||
{
|
||||
frame = Kiway().Player( FRAME_SCH, true );
|
||||
}
|
||||
catch( const IO_ERROR& err )
|
||||
{
|
||||
wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
|
||||
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !frame->IsShown() ) // A hidden frame might not have the project loaded.
|
||||
{
|
||||
if( !frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) ) )
|
||||
return;
|
||||
|
||||
frame->Show( true );
|
||||
}
|
||||
|
||||
// On Windows, Raise() does not bring the window on screen, when iconized or not shown
|
||||
// On linux, Raise() brings the window on screen, but this code works fine
|
||||
if( frame->IsIconized() )
|
||||
{
|
||||
frame->Iconize( false );
|
||||
// If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
|
||||
// to show the frame at its normal size: Maximize should be called.
|
||||
frame->Maximize( false );
|
||||
}
|
||||
|
||||
frame->Raise();
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn( GetProjectFileName() );
|
||||
fn.SetExt( SchematicFileExtension );
|
||||
RunEeschema( fn.GetFullPath() );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunSchLibEditor( wxCommandEvent& event )
|
||||
{
|
||||
KIWAY_PLAYER* frame;
|
||||
|
||||
try
|
||||
{
|
||||
frame = Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
|
||||
}
|
||||
catch( const IO_ERROR& err )
|
||||
{
|
||||
wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
|
||||
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !frame->IsShown() )
|
||||
frame->Show( true );
|
||||
|
||||
// On Windows, Raise() does not bring the window on screen, when iconized
|
||||
if( frame->IsIconized() )
|
||||
frame->Iconize( false );
|
||||
|
||||
frame->Raise();
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName )
|
||||
{
|
||||
KIWAY_PLAYER* frame;
|
||||
|
||||
try
|
||||
{
|
||||
frame = Kiway().Player( FRAME_PCB, true );
|
||||
}
|
||||
catch( const IO_ERROR& err )
|
||||
{
|
||||
wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
|
||||
wxOK | wxICON_ERROR, this );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !frame->IsVisible() ) // A hidden frame might not have the board loaded.
|
||||
{
|
||||
if( !frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) ) )
|
||||
return;
|
||||
|
||||
frame->Show( true );
|
||||
}
|
||||
|
||||
// On Windows, Raise() does not bring the window on screen, when iconized
|
||||
if( frame->IsIconized() )
|
||||
frame->Iconize( false );
|
||||
|
||||
frame->Raise();
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName kicad_board( PcbFileName() );
|
||||
wxFileName legacy_board( PcbLegacyFileName() );
|
||||
|
||||
wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
|
||||
kicad_board : legacy_board;
|
||||
|
||||
RunPcbNew( board.GetFullPath() );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunPcbFpEditor( wxCommandEvent& event )
|
||||
{
|
||||
KIWAY_PLAYER* frame;
|
||||
|
||||
try
|
||||
{
|
||||
frame = Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
|
||||
}
|
||||
catch( const IO_ERROR& err )
|
||||
{
|
||||
wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
|
||||
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !frame->IsShown() )
|
||||
frame->Show( true );
|
||||
|
||||
// On Windows, Raise() does not bring the window on screen, when iconized
|
||||
if( frame->IsIconized() )
|
||||
frame->Iconize( false );
|
||||
|
||||
frame->Raise();
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
|
||||
{
|
||||
Execute( this, BITMAPCONVERTER_EXE );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
|
||||
{
|
||||
Execute( this, PCB_CALCULATOR_EXE );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor( wxCommandEvent& event )
|
||||
{
|
||||
Execute( this, PL_EDITOR_EXE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
|
||||
{
|
||||
// Gerbview is called without any file to open, because we do not know
|
||||
// the list and the name of files to open (if any...).
|
||||
// however we run it in the path of the project
|
||||
Execute( this, GERBVIEW_EXE, Prj().GetProjectPath() );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnOpenTextEditor( wxCommandEvent& event )
|
||||
{
|
||||
wxString editorname = Pgm().GetEditorName();
|
||||
|
||||
if( !editorname.IsEmpty() )
|
||||
Execute( this, editorname, wxEmptyString );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
|
||||
{
|
||||
// show all files in file dialog (in Kicad all files are editable texts):
|
||||
|
@ -497,7 +294,7 @@ void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
|
|||
filename += dlg.GetPath() + wxT( "\"" );
|
||||
|
||||
if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
|
||||
Execute( this, Pgm().GetEditorName(), filename );
|
||||
m_toolManager->RunAction( KICAD_MANAGER_ACTIONS::openTextEditor, true, &filename );
|
||||
}
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
|
||||
|
@ -523,7 +320,7 @@ void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
|
|||
|
||||
void KICAD_MANAGER_FRAME::RefreshProjectTree()
|
||||
{
|
||||
m_LeftWin->ReCreateTreePrj();
|
||||
m_leftWin->ReCreateTreePrj();
|
||||
}
|
||||
|
||||
|
||||
|
@ -541,7 +338,7 @@ void KICAD_MANAGER_FRAME::ShowChangedLanguage()
|
|||
|
||||
// tooltips in toolbars
|
||||
RecreateBaseHToolbar();
|
||||
m_Launcher->ReCreateCommandToolbar();
|
||||
RecreateLauncher();
|
||||
|
||||
PrintPrjInfo();
|
||||
}
|
||||
|
@ -557,7 +354,7 @@ void KICAD_MANAGER_FRAME::CommonSettingsChanged()
|
|||
|
||||
void KICAD_MANAGER_FRAME::ClearMsg()
|
||||
{
|
||||
m_MessagesBox->Clear();
|
||||
m_messagesBox->Clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -571,7 +368,7 @@ void KICAD_MANAGER_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
void KICAD_MANAGER_FRAME::SaveSettings( wxConfigBase* aCfg )
|
||||
{
|
||||
EDA_BASE_FRAME::SaveSettings( aCfg );
|
||||
aCfg->Write( TREE_FRAME_WIDTH_ENTRY, m_LeftWin->GetSize().x );
|
||||
aCfg->Write( TREE_FRAME_WIDTH_ENTRY, m_leftWin->GetSize().x );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -86,16 +86,6 @@ public:
|
|||
void OnArchiveFiles( wxCommandEvent& event );
|
||||
void OnUnarchiveFiles( wxCommandEvent& event );
|
||||
|
||||
void OnRunEeschema( wxCommandEvent& event );
|
||||
void OnRunSchLibEditor( wxCommandEvent& event );
|
||||
void OnRunPcbNew( wxCommandEvent& event );
|
||||
void OnRunPcbFpEditor( wxCommandEvent& event );
|
||||
void OnRunGerbview( wxCommandEvent& event );
|
||||
void OnRunBitmapConverter( wxCommandEvent& event );
|
||||
void OnRunPcbCalculator( wxCommandEvent& event );
|
||||
void OnRunPageLayoutEditor( wxCommandEvent& event );
|
||||
|
||||
void OnOpenTextEditor( wxCommandEvent& event );
|
||||
void OnOpenFileInTextEditor( wxCommandEvent& event );
|
||||
void OnBrowseInFileExplorer( wxCommandEvent& event );
|
||||
|
||||
|
@ -104,6 +94,7 @@ public:
|
|||
|
||||
void ReCreateMenuBar() override;
|
||||
void RecreateBaseHToolbar();
|
||||
void RecreateLauncher();
|
||||
|
||||
/**
|
||||
* Open dialog to import Eagle schematic and board files.
|
||||
|
@ -150,30 +141,6 @@ public:
|
|||
void ShowChangedLanguage() override;
|
||||
void CommonSettingsChanged() override;
|
||||
|
||||
/**
|
||||
* Open another KiCad application and logs a message.
|
||||
*
|
||||
* @param frame = owner frame.
|
||||
* @param execFile = name of the executable file.
|
||||
* @param param = parameters to be passed to the executable.
|
||||
*/
|
||||
void Execute( wxWindow* frame, const wxString& execFile,
|
||||
wxString param = wxEmptyString );
|
||||
|
||||
class TERMINATE_HANDLER : public wxProcess
|
||||
{
|
||||
private:
|
||||
wxString m_appName;
|
||||
|
||||
public:
|
||||
TERMINATE_HANDLER( const wxString& appName ) :
|
||||
m_appName( appName )
|
||||
{
|
||||
}
|
||||
|
||||
void OnTerminate( int pid, int status ) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called by sending a event with id = ID_INIT_WATCHED_PATHS
|
||||
* rebuild the list of wahtched paths
|
||||
|
@ -192,63 +159,28 @@ public:
|
|||
|
||||
void ReCreateTreePrj();
|
||||
|
||||
/// Call this only for a PCB associated with the current project. That is,
|
||||
/// it must have the same path and name as the project *.pro file.
|
||||
void RunPcbNew( const wxString& aProjectBoardFileName );
|
||||
|
||||
/// Call this only for a SCH associated with the current project. That is,
|
||||
/// it must have the same path and name as the project *.pro file.
|
||||
void RunEeschema( const wxString& aProjectSchematicFileName );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
wxConfigBase* config() override;
|
||||
wxConfigBase* config() override;
|
||||
|
||||
const SEARCH_STACK& sys_search() override;
|
||||
|
||||
wxString help_name() override;
|
||||
|
||||
TREE_PROJECT_FRAME* m_LeftWin;
|
||||
LAUNCHER_PANEL* m_Launcher;
|
||||
wxTextCtrl* m_MessagesBox;
|
||||
ACTION_TOOLBAR* m_mainToolBar;
|
||||
|
||||
int m_leftWinWidth;
|
||||
|
||||
void language_change( wxCommandEvent& event );
|
||||
|
||||
bool m_active_project;
|
||||
private:
|
||||
TREE_PROJECT_FRAME* m_leftWin;
|
||||
ACTION_TOOLBAR* m_launcher;
|
||||
wxTextCtrl* m_messagesBox;
|
||||
ACTION_TOOLBAR* m_mainToolBar;
|
||||
|
||||
int m_leftWinWidth;
|
||||
bool m_active_project;
|
||||
};
|
||||
|
||||
|
||||
/** class LAUNCHER_PANEL
|
||||
*/
|
||||
class LAUNCHER_PANEL : public wxPanel
|
||||
{
|
||||
private:
|
||||
wxBoxSizer* m_buttonSizer;
|
||||
|
||||
int m_height = 0;
|
||||
int m_width = 0;
|
||||
|
||||
public: LAUNCHER_PANEL( wxWindow* parent );
|
||||
~LAUNCHER_PANEL() { };
|
||||
|
||||
int GetPanelHeight() const;
|
||||
int GetPanelWidth() const;
|
||||
|
||||
/**
|
||||
* Function CreateCommandToolbar
|
||||
* creates the main tool bar buttons (fast launch buttons)
|
||||
*/
|
||||
void ReCreateCommandToolbar();
|
||||
|
||||
private:
|
||||
|
||||
void AddButton( wxWindowID aId, const wxBitmap& aBitmap, const wxString& aToolTip );
|
||||
};
|
||||
|
||||
// The C++ project manager includes a single PROJECT in its link image.
|
||||
class PROJECT;
|
||||
extern PROJECT& Prj();
|
||||
|
|
|
@ -35,112 +35,6 @@
|
|||
#include "kicad_id.h"
|
||||
|
||||
|
||||
// Menubar and toolbar event table
|
||||
BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
|
||||
// Window events
|
||||
EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
|
||||
EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow )
|
||||
|
||||
// Menu events
|
||||
EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
|
||||
EVT_MENU( ID_TO_TEXT_EDITOR, KICAD_MANAGER_FRAME::OnOpenTextEditor )
|
||||
EVT_MENU( ID_BROWSE_AN_SELECT_FILE, KICAD_MANAGER_FRAME::OnOpenFileInTextEditor )
|
||||
EVT_MENU( ID_BROWSE_IN_FILE_EXPLORER, KICAD_MANAGER_FRAME::OnBrowseInFileExplorer )
|
||||
EVT_MENU( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles )
|
||||
EVT_MENU( ID_READ_ZIP_ARCHIVE, KICAD_MANAGER_FRAME::OnUnarchiveFiles )
|
||||
EVT_MENU( ID_IMPORT_EAGLE_PROJECT, KICAD_MANAGER_FRAME::OnImportEagleFiles )
|
||||
|
||||
// Range menu events
|
||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
|
||||
KICAD_MANAGER_FRAME::language_change )
|
||||
|
||||
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, KICAD_MANAGER_FRAME::OnFileHistory )
|
||||
|
||||
// Special functions
|
||||
EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
|
||||
|
||||
// Button events (in command frame), and menu events equivalent to buttons
|
||||
EVT_BUTTON( ID_TO_SCH, KICAD_MANAGER_FRAME::OnRunEeschema )
|
||||
EVT_MENU( ID_TO_SCH, KICAD_MANAGER_FRAME::OnRunEeschema )
|
||||
|
||||
EVT_BUTTON( ID_TO_SCH_LIB_EDITOR, KICAD_MANAGER_FRAME::OnRunSchLibEditor )
|
||||
EVT_MENU( ID_TO_SCH_LIB_EDITOR, KICAD_MANAGER_FRAME::OnRunSchLibEditor )
|
||||
|
||||
EVT_BUTTON( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew )
|
||||
EVT_MENU( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew )
|
||||
|
||||
EVT_BUTTON( ID_TO_PCB_FP_EDITOR, KICAD_MANAGER_FRAME::OnRunPcbFpEditor )
|
||||
EVT_MENU( ID_TO_PCB_FP_EDITOR, KICAD_MANAGER_FRAME::OnRunPcbFpEditor )
|
||||
|
||||
EVT_BUTTON( ID_TO_GERBVIEW, KICAD_MANAGER_FRAME::OnRunGerbview )
|
||||
EVT_MENU( ID_TO_GERBVIEW, KICAD_MANAGER_FRAME::OnRunGerbview )
|
||||
|
||||
EVT_BUTTON( ID_TO_BITMAP_CONVERTER, KICAD_MANAGER_FRAME::OnRunBitmapConverter )
|
||||
EVT_MENU( ID_TO_BITMAP_CONVERTER, KICAD_MANAGER_FRAME::OnRunBitmapConverter )
|
||||
|
||||
EVT_BUTTON( ID_TO_PCB_CALCULATOR, KICAD_MANAGER_FRAME::OnRunPcbCalculator )
|
||||
EVT_MENU( ID_TO_PCB_CALCULATOR, KICAD_MANAGER_FRAME::OnRunPcbCalculator )
|
||||
|
||||
EVT_BUTTON( ID_TO_PL_EDITOR, KICAD_MANAGER_FRAME::OnRunPageLayoutEditor )
|
||||
EVT_MENU( ID_TO_PL_EDITOR, KICAD_MANAGER_FRAME::OnRunPageLayoutEditor )
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
enum hotkey_id_command
|
||||
{
|
||||
HK_RUN_EESCHEMA = 0,
|
||||
HK_RUN_LIBEDIT,
|
||||
HK_RUN_PCBNEW,
|
||||
HK_RUN_FPEDITOR,
|
||||
HK_RUN_GERBVIEW,
|
||||
HK_RUN_BM2COMPONENT,
|
||||
HK_RUN_PCBCALCULATOR,
|
||||
HK_RUN_PLEDITOR
|
||||
};
|
||||
|
||||
///////////// Hotkeys management ///////////////////////////////////////
|
||||
|
||||
// Remark: the hotkey message info is used as keyword in hotkey config files and
|
||||
// as comments in help windows, therefore translated only when displayed
|
||||
// they are marked _HKI to be extracted by translation tools
|
||||
// See hotkeys_basic.h for more info
|
||||
|
||||
// hotkeys command:
|
||||
static EDA_HOTKEY HkRunEeschema( _HKI( "Run Eeschema" ), HK_RUN_EESCHEMA, 'E' + GR_KB_CTRL, 0 );
|
||||
static EDA_HOTKEY HkRunLibedit( _HKI( "Run LibEdit" ), HK_RUN_LIBEDIT, 'L' + GR_KB_CTRL, 0 );
|
||||
static EDA_HOTKEY HkRunPcbnew( _HKI( "Run Pcbnew" ), HK_RUN_PCBNEW, 'P' + GR_KB_CTRL, 0 );
|
||||
static EDA_HOTKEY HkRunModedit( _HKI( "Run FpEditor" ), HK_RUN_FPEDITOR, 'F' + GR_KB_CTRL, 0 );
|
||||
static EDA_HOTKEY HkRunGerbview( _HKI( "Run Gerbview" ), HK_RUN_GERBVIEW, 'G' + GR_KB_CTRL, 0 );
|
||||
static EDA_HOTKEY HkRunBm2Cmp( _HKI( "Run Bitmap2Component" ),
|
||||
HK_RUN_BM2COMPONENT, 'B' + GR_KB_CTRL, 0 );
|
||||
static EDA_HOTKEY HkRunPcbCalc( _HKI( "Run PcbCalculator" ),
|
||||
HK_RUN_PCBCALCULATOR, 'A' + GR_KB_CTRL, 0 );
|
||||
static EDA_HOTKEY HkRunPleditor( _HKI( "Run PlEditor" ), HK_RUN_PLEDITOR, 'Y' + GR_KB_CTRL, 0 );
|
||||
|
||||
// List of hotkey descriptors
|
||||
EDA_HOTKEY* common_Hotkey_List[] =
|
||||
{
|
||||
&HkRunEeschema, &HkRunLibedit,
|
||||
&HkRunPcbnew, &HkRunModedit, &HkRunGerbview,
|
||||
&HkRunBm2Cmp, &HkRunPcbCalc, &HkRunPleditor,
|
||||
NULL
|
||||
};
|
||||
|
||||
// list of sections and corresponding hotkey list for Kicad
|
||||
// (used to create an hotkey config file, and edit hotkeys )
|
||||
// here we have only one section.
|
||||
static wxString sectionTitle( _HKI( "Kicad Manager Hotkeys" ) );
|
||||
|
||||
struct EDA_HOTKEY_CONFIG kicad_Manager_Hotkeys_Descr[] = {
|
||||
{ &g_CommonSectionTag, common_Hotkey_List, §ionTitle },
|
||||
{ nullptr, nullptr, nullptr }
|
||||
};
|
||||
///////////// End hotkeys management ///////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* @brief (Re)Create the menubar
|
||||
*/
|
||||
void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
||||
{
|
||||
KICAD_MANAGER_CONTROL* controlTool = m_toolManager->GetTool<KICAD_MANAGER_CONTROL>();
|
||||
|
@ -198,20 +92,14 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
//-- View menu -----------------------------------------------------------
|
||||
//
|
||||
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, controlTool );
|
||||
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
viewMenu->AddSeparator();
|
||||
viewMenu->AddItem( ID_TO_TEXT_EDITOR,
|
||||
_( "Open Text Editor" ), _( "Launch preferred text editor" ),
|
||||
editor_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
viewMenu->AddItem( ID_BROWSE_AN_SELECT_FILE,
|
||||
_( "Open Local File..." ), _( "Edit local file" ),
|
||||
browse_files_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
viewMenu->AddItem( KICAD_MANAGER_ACTIONS::openTextEditor, SELECTION_CONDITIONS::ShowAlways );
|
||||
viewMenu->AddItem( ID_BROWSE_IN_FILE_EXPLORER,
|
||||
_( "Browse Project Files" ), _( "Open project directory in file browser" ),
|
||||
directory_browser_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
directory_browser_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
#ifdef __APPLE__
|
||||
viewMenu->AddSeparator();
|
||||
|
@ -221,42 +109,25 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
|
||||
//-- Tools menu -----------------------------------------------
|
||||
//
|
||||
wxMenu* toolsMenu = new wxMenu;
|
||||
wxString msg;
|
||||
msg = AddHotkeyName( _( "Edit Schematic" ), kicad_Manager_Hotkeys_Descr, HK_RUN_EESCHEMA );
|
||||
AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) );
|
||||
CONDITIONAL_MENU* toolsMenu = new CONDITIONAL_MENU( false, controlTool );
|
||||
|
||||
msg = AddHotkeyName( _( "Edit Schematic Symbols" ),
|
||||
kicad_Manager_Hotkeys_Descr, HK_RUN_LIBEDIT );
|
||||
AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) );
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::editSchematic, SELECTION_CONDITIONS::ShowAlways );
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::editSymbols, SELECTION_CONDITIONS::ShowAlways );
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::editPCB, SELECTION_CONDITIONS::ShowAlways );
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::editFootprints, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
msg = AddHotkeyName( _( "Edit PCB" ),
|
||||
kicad_Manager_Hotkeys_Descr, HK_RUN_PCBNEW );
|
||||
AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) );
|
||||
toolsMenu->AddSeparator();
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::viewGerbers, SELECTION_CONDITIONS::ShowAlways );
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::convertImage, SELECTION_CONDITIONS::ShowAlways );
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::showCalculator, SELECTION_CONDITIONS::ShowAlways );
|
||||
toolsMenu->AddItem( KICAD_MANAGER_ACTIONS::editWorksheet, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
msg = AddHotkeyName( _( "Edit PCB Footprints" ),
|
||||
kicad_Manager_Hotkeys_Descr, HK_RUN_FPEDITOR );
|
||||
AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) );
|
||||
toolsMenu->AddSeparator();
|
||||
toolsMenu->AddItem( ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR,
|
||||
_( "Edit Local File..." ), _( "Edit local file in text editor" ),
|
||||
browse_files_xpm, SELECTION_CONDITIONS::ShowAlways );
|
||||
|
||||
msg = AddHotkeyName( _( "View Gerber Files" ),
|
||||
kicad_Manager_Hotkeys_Descr, HK_RUN_GERBVIEW );
|
||||
AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) );
|
||||
|
||||
msg = AddHotkeyName( _( "Convert Image" ),
|
||||
kicad_Manager_Hotkeys_Descr, HK_RUN_BM2COMPONENT );
|
||||
AddMenuItem( toolsMenu, ID_TO_BITMAP_CONVERTER, msg,
|
||||
_( "Convert bitmap images to schematic or PCB components." ),
|
||||
KiBitmap( bitmap2component_xpm ) );
|
||||
|
||||
msg = AddHotkeyName( _( "Calculator Tools" ), kicad_Manager_Hotkeys_Descr, HK_RUN_PCBCALCULATOR );
|
||||
AddMenuItem( toolsMenu, ID_TO_PCB_CALCULATOR, msg,
|
||||
_( "Run component calculations, track width calculations, etc." ),
|
||||
KiBitmap( calculator_xpm ) );
|
||||
|
||||
msg = AddHotkeyName( _( "Edit Worksheet" ), kicad_Manager_Hotkeys_Descr, HK_RUN_PLEDITOR );
|
||||
AddMenuItem( toolsMenu, ID_TO_PL_EDITOR, msg,
|
||||
_( "Edit worksheet graphics and text" ),
|
||||
KiBitmap( pagelayout_load_xpm ) );
|
||||
toolsMenu->Resolve();
|
||||
|
||||
//-- Preferences menu -----------------------------------------------
|
||||
//
|
||||
|
@ -273,6 +144,8 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
prefsMenu->AddSeparator();
|
||||
Pgm().AddMenuLanguageList( prefsMenu );
|
||||
|
||||
prefsMenu->Resolve();
|
||||
|
||||
//-- Menubar -------------------------------------------------------------
|
||||
//
|
||||
menuBar->Append( fileMenu, _( "&File" ) );
|
||||
|
@ -324,13 +197,39 @@ void KICAD_MANAGER_FRAME::RecreateBaseHToolbar()
|
|||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::SyncMenusAndToolbars()
|
||||
void KICAD_MANAGER_FRAME::RecreateLauncher()
|
||||
{
|
||||
m_mainToolBar->ToggleTool( ID_TO_SCH, m_active_project );
|
||||
m_mainToolBar->ToggleTool( ID_TO_SCH_LIB_EDITOR, m_active_project );
|
||||
m_mainToolBar->ToggleTool( ID_TO_PCB, m_active_project );
|
||||
m_mainToolBar->ToggleTool( ID_TO_PCB_FP_EDITOR, m_active_project );
|
||||
m_mainToolBar->Refresh();
|
||||
if( m_launcher )
|
||||
m_launcher->Clear();
|
||||
else
|
||||
m_launcher = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
||||
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::editSchematic );
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::editSymbols );
|
||||
|
||||
KiScaledSeparator( m_launcher, this );
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::editPCB );
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::editFootprints );
|
||||
|
||||
KiScaledSeparator( m_launcher, this );
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::viewGerbers );
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::convertImage );
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::showCalculator );
|
||||
m_launcher->Add( KICAD_MANAGER_ACTIONS::editWorksheet );
|
||||
|
||||
// Create mlauncher
|
||||
m_launcher->Realize();
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::SyncMenusAndToolbars()
|
||||
{
|
||||
m_launcher->Toggle( KICAD_MANAGER_ACTIONS::editSchematic, m_active_project );
|
||||
m_launcher->Toggle( KICAD_MANAGER_ACTIONS::editSymbols, m_active_project );
|
||||
m_launcher->Toggle( KICAD_MANAGER_ACTIONS::editPCB, m_active_project );
|
||||
m_launcher->Toggle( KICAD_MANAGER_ACTIONS::editFootprints, m_active_project );
|
||||
m_launcher->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
|
|||
|
||||
UpdateFileHistory( aProjectFileName.GetFullPath(), &PgmTop().GetFileHistory() );
|
||||
|
||||
m_LeftWin->ReCreateTreePrj();
|
||||
m_leftWin->ReCreateTreePrj();
|
||||
|
||||
// Rebuild the list of watched paths.
|
||||
// however this is possible only when the main loop event handler is running,
|
||||
|
|
|
@ -40,10 +40,19 @@ public:
|
|||
static TOOL_ACTION newProject;
|
||||
static TOOL_ACTION newFromTemplate;
|
||||
static TOOL_ACTION openProject;
|
||||
static TOOL_ACTION importEagle;
|
||||
|
||||
static TOOL_ACTION archiveProject;
|
||||
static TOOL_ACTION unarchiveProject;
|
||||
static TOOL_ACTION editSchematic;
|
||||
static TOOL_ACTION editSymbols;
|
||||
static TOOL_ACTION editPCB;
|
||||
static TOOL_ACTION editFootprints;
|
||||
static TOOL_ACTION viewGerbers;
|
||||
static TOOL_ACTION convertImage;
|
||||
static TOOL_ACTION showCalculator;
|
||||
static TOOL_ACTION editWorksheet;
|
||||
static TOOL_ACTION openTextEditor;
|
||||
|
||||
static TOOL_ACTION editOtherSch;
|
||||
static TOOL_ACTION editOtherPCB;
|
||||
|
||||
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
|
||||
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override
|
||||
|
|
|
@ -17,17 +17,20 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <kicad_manager_frame.h>
|
||||
#include <bitmaps.h>
|
||||
#include <gestfich.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <executable_names.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiway.h>
|
||||
#include <kicad_manager_frame.h>
|
||||
#include <confirm.h>
|
||||
#include <bitmaps.h>
|
||||
#include <tool/selection.h>
|
||||
#include <tool/tool_event.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/kicad_manager_actions.h>
|
||||
#include <tools/kicad_manager_control.h>
|
||||
#include <confirm.h>
|
||||
#include <dialogs/dialog_template_selector.h>
|
||||
#include <pgm_base.h>
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::newProject( "kicad.Control.newProject",
|
||||
AS_GLOBAL,
|
||||
|
@ -47,6 +50,66 @@ TOOL_ACTION KICAD_MANAGER_ACTIONS::openProject( "kicad.Control.openProject",
|
|||
_( "Open Project..." ), _( "Open an existing project" ),
|
||||
open_project_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::editSchematic( "kicad.Control.editSchematic",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'E', LEGACY_HK_NAME( "Run Eeschema" ),
|
||||
_( "Edit Schematic" ), "",
|
||||
icon_eeschema_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::editSymbols( "kicad.Control.editSymbols",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'L', LEGACY_HK_NAME( "Run LibEdit" ),
|
||||
_( "Edit Schematic Symbols" ), "",
|
||||
icon_libedit_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::editPCB( "kicad.Control.editPCB",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'P', LEGACY_HK_NAME( "Run Pcbnew" ),
|
||||
_( "Edit PCB" ), "",
|
||||
icon_pcbnew_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::editFootprints( "kicad.Control.editFootprints",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'F', LEGACY_HK_NAME( "Run FpEditor" ),
|
||||
_( "Edit PCB Footprints" ), "",
|
||||
icon_modedit_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::viewGerbers( "kicad.Control.viewGerbers",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'G', LEGACY_HK_NAME( "Run Gerbview" ),
|
||||
_( "View Gerber Files" ), "",
|
||||
icon_gerbview_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::convertImage( "kicad.Control.convertImage",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'B', LEGACY_HK_NAME( "Run Bitmap2Component" ),
|
||||
_( "Convert Image" ), _( "Convert bitmap images to schematic or PCB components" ),
|
||||
icon_bitmap2component_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::showCalculator( "kicad.Control.showCalculator",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'A', LEGACY_HK_NAME( "Run PcbCalculator" ),
|
||||
_( "Calculator Tools" ), _( "Run component calculations, track width calculations, etc." ),
|
||||
icon_pcbcalculator_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::editWorksheet( "kicad.Control.editWorksheet",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'Y', LEGACY_HK_NAME( "Run PlEditor" ),
|
||||
_( "Edit Worksheet" ), _( "Edit worksheet graphics and text" ),
|
||||
icon_pagelayout_editor_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::openTextEditor( "kicad.Control.openTextEditor",
|
||||
AS_GLOBAL,
|
||||
0, "",
|
||||
_( "Open Text Editor" ), _( "Launch preferred text editor" ),
|
||||
editor_xpm );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::editOtherSch( "kicad.Control.editOtherSch",
|
||||
AS_GLOBAL );
|
||||
|
||||
TOOL_ACTION KICAD_MANAGER_ACTIONS::editOtherPCB( "kicad.Control.editOtherPCB",
|
||||
AS_GLOBAL );
|
||||
|
||||
|
||||
///> Helper widget to select whether a new directory should be created for a project
|
||||
class DIR_CHECKBOX : public wxPanel
|
||||
|
@ -183,11 +246,10 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent )
|
|||
if( ps->ShowModal() != wxID_OK )
|
||||
return -1;
|
||||
|
||||
if( ps->GetSelectedTemplate() == NULL )
|
||||
if( !ps->GetSelectedTemplate() )
|
||||
{
|
||||
wxMessageBox( _( "No project template was selected. Cannot generate new project." ),
|
||||
_( "Error" ),
|
||||
wxOK | wxICON_ERROR, m_frame );
|
||||
_( "Error" ), wxOK | wxICON_ERROR, m_frame );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -336,11 +398,188 @@ int KICAD_MANAGER_CONTROL::Refresh( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
FRAME_T playerType = FRAME_SCH_VIEWER;
|
||||
|
||||
if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editSchematic ) )
|
||||
playerType = FRAME_SCH;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editSymbols ) )
|
||||
playerType = FRAME_SCH_LIB_EDITOR;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editPCB ) )
|
||||
playerType = FRAME_PCB;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editFootprints ) )
|
||||
playerType = FRAME_PCB_MODULE_EDITOR;
|
||||
else
|
||||
wxFAIL_MSG( "ShowPlayer(): unexpected request" );
|
||||
|
||||
KIWAY_PLAYER* player;
|
||||
|
||||
try
|
||||
{
|
||||
player = m_frame->Kiway().Player( playerType, true );
|
||||
}
|
||||
catch( const IO_ERROR& err )
|
||||
{
|
||||
wxMessageBox( _( "Application failed to load:\n" ) + err.What(), _( "KiCad Error" ),
|
||||
wxOK | wxICON_ERROR, m_frame );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !player->IsVisible() ) // A hidden frame might not have the document loaded.
|
||||
{
|
||||
wxString filepath;
|
||||
|
||||
if( playerType == FRAME_SCH )
|
||||
{
|
||||
filepath = m_frame->SchFileName();
|
||||
}
|
||||
else if( playerType == FRAME_PCB )
|
||||
{
|
||||
wxFileName kicad_board( m_frame->PcbFileName() );
|
||||
wxFileName legacy_board( m_frame->PcbLegacyFileName() );
|
||||
|
||||
if( !legacy_board.FileExists() || kicad_board.FileExists() )
|
||||
filepath = kicad_board.GetFullPath();
|
||||
else
|
||||
filepath = legacy_board.GetFullPath();
|
||||
}
|
||||
|
||||
if( !filepath.IsEmpty() )
|
||||
{
|
||||
if( !player->OpenProjectFiles( std::vector<wxString>( 1, filepath ) ) )
|
||||
return -1;
|
||||
}
|
||||
|
||||
player->Show( true );
|
||||
}
|
||||
|
||||
// Needed on Windows, other platforms do not use it, but it creates no issue
|
||||
if( player->IsIconized() )
|
||||
player->Iconize( false );
|
||||
|
||||
player->Raise();
|
||||
|
||||
// Raising the window does not set the focus on Linux. This should work on
|
||||
// any platform.
|
||||
if( wxWindow::FindFocus() != player )
|
||||
player->SetFocus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
class TERMINATE_HANDLER : public wxProcess
|
||||
{
|
||||
private:
|
||||
wxString m_appName;
|
||||
|
||||
public:
|
||||
TERMINATE_HANDLER( const wxString& appName ) :
|
||||
m_appName( appName )
|
||||
{
|
||||
}
|
||||
|
||||
void OnTerminate( int pid, int status ) override
|
||||
{
|
||||
wxString msg = wxString::Format( _( "%s closed [pid=%d]\n" ),
|
||||
m_appName,
|
||||
pid );
|
||||
|
||||
wxWindow* window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
|
||||
|
||||
if( window ) // Should always happen.
|
||||
{
|
||||
// Be sure the kicad frame manager is found
|
||||
// This dynamic cast is not really mandatory, but ...
|
||||
KICAD_MANAGER_FRAME* frame = dynamic_cast<KICAD_MANAGER_FRAME*>( window );
|
||||
|
||||
if( frame )
|
||||
frame->PrintMsg( msg );
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxString execFile;
|
||||
wxString params;
|
||||
|
||||
if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::viewGerbers ) )
|
||||
execFile = GERBVIEW_EXE;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::convertImage ) )
|
||||
execFile = BITMAPCONVERTER_EXE;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::showCalculator ) )
|
||||
execFile = PCB_CALCULATOR_EXE;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editWorksheet ) )
|
||||
execFile = PL_EDITOR_EXE;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::openTextEditor ) )
|
||||
execFile = Pgm().GetEditorName();
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherSch ) )
|
||||
execFile = EESCHEMA_EXE;
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherPCB ) )
|
||||
execFile = PCBNEW_EXE;
|
||||
else
|
||||
wxFAIL_MSG( "Execute(): unexpected request" );
|
||||
|
||||
if( execFile.IsEmpty() )
|
||||
return 0;
|
||||
|
||||
if( aEvent.Parameter<wxString*>() )
|
||||
params = *aEvent.Parameter<wxString*>();
|
||||
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::viewGerbers ) )
|
||||
params = m_frame->Prj().GetProjectPath();
|
||||
|
||||
if( !params.empty() )
|
||||
AddDelimiterString( params );
|
||||
|
||||
TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
|
||||
|
||||
long pid = ExecuteFile( m_frame, execFile, params, callback );
|
||||
|
||||
if( pid > 0 )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ),
|
||||
execFile,
|
||||
params,
|
||||
pid );
|
||||
m_frame->PrintMsg( msg );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile );
|
||||
system( msg.c_str() );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
delete callback;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_CONTROL::setTransitions()
|
||||
{
|
||||
Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newProject.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newProject.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::NewFromTemplate, KICAD_MANAGER_ACTIONS::newFromTemplate.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::OpenProject, KICAD_MANAGER_ACTIONS::openProject.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::OpenProject, KICAD_MANAGER_ACTIONS::openProject.MakeEvent() );
|
||||
|
||||
Go( &KICAD_MANAGER_CONTROL::Refresh, ACTIONS::zoomRedraw.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Refresh, ACTIONS::zoomRedraw.MakeEvent() );
|
||||
|
||||
Go( &KICAD_MANAGER_CONTROL::ShowPlayer, KICAD_MANAGER_ACTIONS::editSchematic.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::ShowPlayer, KICAD_MANAGER_ACTIONS::editSymbols.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::ShowPlayer, KICAD_MANAGER_ACTIONS::editPCB.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::ShowPlayer, KICAD_MANAGER_ACTIONS::editFootprints.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::viewGerbers.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::convertImage.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::showCalculator.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::editWorksheet.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::openTextEditor.MakeEvent() );
|
||||
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::editOtherSch.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::editOtherPCB.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ public:
|
|||
|
||||
int Refresh( const TOOL_EVENT& aEvent );
|
||||
|
||||
int ShowPlayer( const TOOL_EVENT& aEvent );
|
||||
int Execute( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Sets up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
||||
|
|
|
@ -1129,5 +1129,5 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
|
|||
|
||||
void KICAD_MANAGER_FRAME::OnChangeWatchedPaths( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_LeftWin->FileWatcherReset();
|
||||
m_leftWin->FileWatcherReset();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include <gestfich.h>
|
||||
#include <executable_names.h>
|
||||
#include <kiway.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/kicad_manager_actions.h>
|
||||
#include "treeprojectfiles.h"
|
||||
#include "pgm_kicad.h"
|
||||
#include "tree_project_frame.h"
|
||||
|
@ -104,10 +106,9 @@ bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
|
|||
|
||||
if( check && !ext.IsEmpty() && !reg.Matches( newFile ) )
|
||||
{
|
||||
wxMessageDialog dialog( m_parent, _(
|
||||
"Changing file extension will change file type.\n Do you want to continue ?" ),
|
||||
_( "Rename File" ),
|
||||
wxYES_NO | wxICON_QUESTION );
|
||||
wxMessageDialog dialog( m_parent, _( "Changing file extension will change file type.\n"
|
||||
"Do you want to continue ?" ),
|
||||
_( "Rename File" ), wxYES_NO | wxICON_QUESTION );
|
||||
|
||||
if( wxID_YES != dialog.ShowModal() )
|
||||
return false;
|
||||
|
@ -115,8 +116,8 @@ bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
|
|||
|
||||
if( !wxRenameFile( GetFileName(), newFile, false ) )
|
||||
{
|
||||
wxMessageDialog( m_parent, _( "Unable to rename file ... " ),
|
||||
_( "Permission error ?" ), wxICON_ERROR | wxOK );
|
||||
wxMessageDialog( m_parent, _( "Unable to rename file ... " ), _( "Permission error?" ),
|
||||
wxICON_ERROR | wxOK );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -128,13 +129,8 @@ bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
|
|||
|
||||
bool TREEPROJECT_ITEM::Delete( bool check )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Do you really want to delete \"%s\"" ),
|
||||
GetChars( GetFileName() )
|
||||
);
|
||||
|
||||
wxMessageDialog dialog( m_parent, msg,
|
||||
_( "Delete File" ), wxYES_NO | wxICON_QUESTION );
|
||||
wxString msg = wxString::Format( _( "Are you sure you want to delete '%s'?" ), GetFileName() );
|
||||
wxMessageDialog dialog( m_parent, msg, _( "Delete File" ), wxYES_NO | wxICON_QUESTION );
|
||||
|
||||
if( !check || wxID_YES == dialog.ShowModal() )
|
||||
{
|
||||
|
@ -166,11 +162,13 @@ bool TREEPROJECT_ITEM::Delete( bool check )
|
|||
|
||||
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
||||
{
|
||||
wxString sep = wxFileName().GetPathSeparator();
|
||||
wxString fullFileName = GetFileName();
|
||||
wxTreeItemId id = GetId();
|
||||
wxString sep = wxFileName::GetPathSeparator();
|
||||
wxString fullFileName = GetFileName();
|
||||
wxTreeItemId id = GetId();
|
||||
std::string packet;
|
||||
|
||||
KICAD_MANAGER_FRAME* frame = aTreePrjFrame->m_Parent;
|
||||
TOOL_MANAGER* toolMgr = frame->GetToolManager();
|
||||
KIWAY& kiway = frame->Kiway();
|
||||
|
||||
switch( GetType() )
|
||||
|
@ -188,18 +186,12 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
case TREE_SCHEMA:
|
||||
if( fullFileName == frame->SchFileName() )
|
||||
{
|
||||
// the project's schematic is opened using the *.kiface as part of this process.
|
||||
// We do not call frame->RunEeschema( fullFileName ),
|
||||
// because after the double click, for some reason,
|
||||
// the tree project frame is brought to the foreground after Eeschema is called from here.
|
||||
// Instead, we post an event, equivalent to click on the eeschema tool in command frame
|
||||
wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_SCH );
|
||||
wxPostEvent( frame, evt );
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editSchematic, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// schematics not part of the project are opened in a separate process.
|
||||
frame->Execute( m_parent, EESCHEMA_EXE, fullFileName );
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editOtherSch, true, &fullFileName );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -207,18 +199,12 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
case TREE_SEXP_PCB:
|
||||
if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() )
|
||||
{
|
||||
// the project's BOARD is opened using the *.kiface as part of this process.
|
||||
// We do not call frame->RunPcbNew( fullFileName ),
|
||||
// because after the double click, for some reason,
|
||||
// the tree project frame is brought to the foreground after PcbNew is called from here.
|
||||
// Instead, we post an event, equivalent to simple click on the pcb editor tool in command frame
|
||||
wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_PCB );
|
||||
wxPostEvent( frame, evt );
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editPCB, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// boards not part of the project are opened in a separate process.
|
||||
frame->Execute( m_parent, PCBNEW_EXE, fullFileName );
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editOtherPCB, true, &fullFileName );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -226,7 +212,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
case TREE_DRILL:
|
||||
case TREE_DRILL_NC:
|
||||
case TREE_DRILL_XNC:
|
||||
frame->Execute( m_parent, GERBVIEW_EXE, fullFileName );
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::viewGerbers, true, &fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_HTML:
|
||||
|
@ -240,36 +226,23 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
case TREE_NET:
|
||||
case TREE_TXT:
|
||||
case TREE_REPORT:
|
||||
{
|
||||
wxString editorname = Pgm().GetEditorName();
|
||||
|
||||
if( !editorname.IsEmpty() )
|
||||
frame->Execute( m_parent, editorname, fullFileName );
|
||||
}
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::openTextEditor, true, &fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_PAGE_LAYOUT_DESCR:
|
||||
frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName );
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editWorksheet, true, &fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_FOOTPRINT_FILE:
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
frame->OnRunPcbFpEditor( dummy );
|
||||
|
||||
std::string packet = fullFileName.ToStdString();
|
||||
kiway.ExpressMail( FRAME_PCB_MODULE_EDITOR, MAIL_FP_EDIT, packet );
|
||||
}
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editFootprints, true );
|
||||
packet = fullFileName.ToStdString();
|
||||
kiway.ExpressMail( FRAME_PCB_MODULE_EDITOR, MAIL_FP_EDIT, packet );
|
||||
break;
|
||||
|
||||
case TREE_SCHEMATIC_LIBFILE:
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
frame->OnRunSchLibEditor( dummy );
|
||||
|
||||
std::string packet = fullFileName.ToStdString();
|
||||
kiway.ExpressMail( FRAME_SCH_LIB_EDITOR, MAIL_LIB_EDIT, packet );
|
||||
}
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editSymbols, true );
|
||||
packet = fullFileName.ToStdString();
|
||||
kiway.ExpressMail( FRAME_SCH_LIB_EDITOR, MAIL_LIB_EDIT, packet );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue