kicad-source/eeschema/menubar.cpp

361 lines
13 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
2019-08-14 09:28:07 +01:00
* Copyright (C) 2019 CERN
*
* 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>
2022-12-28 22:03:03 +00:00
#include <file_history.h>
2021-09-14 23:45:14 +01:00
#include <kiface_base.h>
#include <schematic.h>
#include <tool/action_manager.h>
#include <tool/action_menu.h>
#include <tool/tool_manager.h>
2025-03-12 14:41:25 +00:00
#include <tools/sch_selection_tool.h>
#include <tools/sch_actions.h>
#include "eeschema_id.h"
2018-01-30 11:49:51 +01:00
#include "sch_edit_frame.h"
#include <widgets/wx_menubar.h>
#include <advanced_config.h>
2015-06-21 16:30:33 -04:00
void SCH_EDIT_FRAME::doReCreateMenuBar()
{
2025-03-12 14:41:25 +00:00
SCH_SELECTION_TOOL* selTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
2025-02-06 09:47:00 -05:00
// wxWidgets handles the Mac Application menu behind the scenes, but that means
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
WX_MENUBAR* menuBar = new WX_MENUBAR();
//-- File menu -----------------------------------------------------------
2019-05-13 22:49:05 +01:00
//
ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
static ACTION_MENU* openRecentMenu;
if( Kiface().IsSingle() ) // When not under a project mgr
{
2020-05-16 22:47:01 +01:00
FILE_HISTORY& fileHistory = GetFileHistory();
// Add this menu to the list of menus managed by the file history
// (the file history will be updated when adding/removing files in history)
if( !openRecentMenu )
{
openRecentMenu = new ACTION_MENU( false, selTool );
openRecentMenu->SetIcon( BITMAPS::recent );
fileHistory.UseMenu( openRecentMenu );
fileHistory.AddFilesToMenu( openRecentMenu );
}
// Ensure the title is up to date after changing language
openRecentMenu->SetTitle( _( "Open Recent" ) );
fileHistory.UpdateClearText( openRecentMenu, _( "Clear Recent Files" ) );
fileMenu->Add( ACTIONS::doNew );
fileMenu->Add( ACTIONS::open );
wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
// Add the file menu condition here since it needs the item ID for the submenu
ACTION_CONDITIONS cond;
cond.Enable( FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
RegisterUIUpdateHandler( item->GetId(), cond );
fileMenu->AppendSeparator();
}
fileMenu->Add( ACTIONS::save );
if( Kiface().IsSingle() )
fileMenu->Add( ACTIONS::saveAs );
else
2025-03-12 14:41:25 +00:00
fileMenu->Add( SCH_ACTIONS::saveCurrSheetCopyAs );
fileMenu->Add( ACTIONS::revert );
fileMenu->AppendSeparator();
// Import submenu
ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( BITMAPS::import );
submenuImport->Add( _( "Non-KiCad Schematic..." ),
_( "Replace current schematic sheet with one imported from another application" ),
ID_IMPORT_NON_KICAD_SCH,
BITMAPS::import_document );
2025-03-12 14:41:25 +00:00
submenuImport->Add( SCH_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) );
submenuImport->Add( SCH_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
fileMenu->Add( submenuImport );
// Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( BITMAPS::export_file );
2025-03-12 14:41:25 +00:00
submenuExport->Add( SCH_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );
submenuExport->Add( SCH_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
submenuExport->Add( SCH_ACTIONS::exportSymbolsToLibrary, ACTION_MENU::NORMAL, _( "Symbols to Library..." ) );
submenuExport->Add( SCH_ACTIONS::exportSymbolsToNewLibrary, ACTION_MENU::NORMAL, _( "Symbols to New Library..." ) );
fileMenu->Add( submenuExport );
fileMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
fileMenu->Add( SCH_ACTIONS::schematicSetup );
fileMenu->AppendSeparator();
fileMenu->Add( ACTIONS::pageSettings );
fileMenu->Add( ACTIONS::print );
fileMenu->Add( ACTIONS::plot );
fileMenu->AppendSeparator();
fileMenu->AddQuitOrClose( &Kiface(), _( "Schematic Editor" ) );
//-- Edit menu -----------------------------------------------------------
2019-05-13 22:49:05 +01:00
//
ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
editMenu->Add( ACTIONS::undo );
editMenu->Add( ACTIONS::redo );
editMenu->AppendSeparator();
editMenu->Add( ACTIONS::cut );
editMenu->Add( ACTIONS::copy );
editMenu->Add( ACTIONS::copyAsText );
editMenu->Add( ACTIONS::paste );
editMenu->Add( ACTIONS::pasteSpecial );
editMenu->Add( ACTIONS::doDelete );
editMenu->AppendSeparator();
editMenu->Add( ACTIONS::selectAll );
2023-09-06 23:44:39 +00:00
editMenu->Add( ACTIONS::unselectAll );
editMenu->AppendSeparator();
editMenu->Add( ACTIONS::find );
editMenu->Add( ACTIONS::findAndReplace );
editMenu->AppendSeparator();
editMenu->Add( ACTIONS::deleteTool );
2025-03-12 14:41:25 +00:00
editMenu->Add( SCH_ACTIONS::editTextAndGraphics );
editMenu->Add( SCH_ACTIONS::changeSymbols );
editMenu->Add( SCH_ACTIONS::editPageNumber );
ACTION_MENU* submenuAttributes = new ACTION_MENU( false, selTool );
submenuAttributes->SetTitle( _( "Attributes" ) );
2025-03-12 14:41:25 +00:00
submenuAttributes->Add( SCH_ACTIONS::setExcludeFromSimulation, ACTION_MENU::CHECK );
submenuAttributes->Add( SCH_ACTIONS::setExcludeFromBOM, ACTION_MENU::CHECK );
submenuAttributes->Add( SCH_ACTIONS::setExcludeFromBoard, ACTION_MENU::CHECK );
submenuAttributes->Add( SCH_ACTIONS::setDNP, ACTION_MENU::CHECK );
editMenu->Add( submenuAttributes );
//-- View menu -----------------------------------------------------------
2019-05-13 22:49:05 +01:00
//
ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
2024-10-02 19:31:05 +01:00
// Show / Hide Panels submenu
ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
2024-10-02 20:29:54 +01:00
showHidePanels->SetTitle( _( "Panels" ) );
2024-10-02 19:31:05 +01:00
showHidePanels->Add( ACTIONS::showProperties, ACTION_MENU::CHECK );
showHidePanels->Add( ACTIONS::showSearch, ACTION_MENU::CHECK );
2025-03-12 14:41:25 +00:00
showHidePanels->Add( SCH_ACTIONS::showHierarchy, ACTION_MENU::CHECK );
if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
2025-03-12 14:41:25 +00:00
showHidePanels->Add( SCH_ACTIONS::showNetNavigator, ACTION_MENU::CHECK );
if( ADVANCED_CFG::GetCfg().m_EnableDesignBlocks )
2025-03-12 14:41:25 +00:00
showHidePanels->Add( SCH_ACTIONS::showDesignBlockPanel, ACTION_MENU::CHECK,
2025-02-06 09:47:00 -05:00
_( "Design Blocks" ) );
2024-10-02 19:31:05 +01:00
viewMenu->Add( showHidePanels );
viewMenu->AppendSeparator();
2024-10-02 19:31:05 +01:00
viewMenu->Add( ACTIONS::showSymbolBrowser );
viewMenu->AppendSeparator();
viewMenu->Add( ACTIONS::zoomInCenter );
viewMenu->Add( ACTIONS::zoomOutCenter );
viewMenu->Add( ACTIONS::zoomFitScreen );
viewMenu->Add( ACTIONS::zoomFitObjects );
viewMenu->Add( ACTIONS::zoomTool );
viewMenu->Add( ACTIONS::zoomRedraw );
2024-10-02 19:31:05 +01:00
viewMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
viewMenu->Add( SCH_ACTIONS::navigateBack );
viewMenu->Add( SCH_ACTIONS::navigateUp );
viewMenu->Add( SCH_ACTIONS::navigateForward );
viewMenu->Add( SCH_ACTIONS::navigatePrevious );
viewMenu->Add( SCH_ACTIONS::navigateNext );
2024-10-02 19:31:05 +01:00
viewMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
viewMenu->Add( SCH_ACTIONS::toggleHiddenPins, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::toggleHiddenFields, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::toggleDirectiveLabels, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::toggleERCErrors, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::toggleERCWarnings, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::toggleERCExclusions, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::markSimExclusions, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::toggleOPVoltages, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::toggleOPCurrents, ACTION_MENU::CHECK );
viewMenu->Add( SCH_ACTIONS::togglePinAltIcons, ACTION_MENU::CHECK );
2019-05-13 22:49:05 +01:00
#ifdef __APPLE__
viewMenu->AppendSeparator();
2019-05-13 22:49:05 +01:00
#endif
//-- Place menu -----------------------------------------------------------
2019-05-13 22:49:05 +01:00
//
ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
2025-03-12 14:41:25 +00:00
placeMenu->Add( SCH_ACTIONS::placeSymbol );
placeMenu->Add( SCH_ACTIONS::placePower );
placeMenu->Add( SCH_ACTIONS::drawWire );
placeMenu->Add( SCH_ACTIONS::drawBus );
placeMenu->Add( SCH_ACTIONS::placeBusWireEntry );
placeMenu->Add( SCH_ACTIONS::placeNoConnect );
placeMenu->Add( SCH_ACTIONS::placeJunction );
placeMenu->Add( SCH_ACTIONS::placeLabel );
placeMenu->Add( SCH_ACTIONS::placeGlobalLabel );
placeMenu->Add( SCH_ACTIONS::placeClassLabel );
placeMenu->Add( SCH_ACTIONS::drawRuleArea );
placeMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
placeMenu->Add( SCH_ACTIONS::placeHierLabel );
placeMenu->Add( SCH_ACTIONS::drawSheet );
placeMenu->Add( SCH_ACTIONS::placeSheetPin );
placeMenu->Add( SCH_ACTIONS::syncAllSheetsPins );
placeMenu->Add( SCH_ACTIONS::importSheet );
placeMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
placeMenu->Add( SCH_ACTIONS::placeSchematicText );
placeMenu->Add( SCH_ACTIONS::drawTextBox );
placeMenu->Add( SCH_ACTIONS::drawTable );
placeMenu->Add( SCH_ACTIONS::drawRectangle );
placeMenu->Add( SCH_ACTIONS::drawCircle );
placeMenu->Add( SCH_ACTIONS::drawArc );
placeMenu->Add( SCH_ACTIONS::drawBezier );
placeMenu->Add( SCH_ACTIONS::drawLines );
placeMenu->Add( SCH_ACTIONS::placeImage );
//-- Inspect menu -----------------------------------------------
2019-05-13 22:49:05 +01:00
//
ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
2025-03-12 14:41:25 +00:00
inspectMenu->Add( SCH_ACTIONS::showBusSyntaxHelp );
inspectMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
inspectMenu->Add( SCH_ACTIONS::runERC );
inspectMenu->Add( ACTIONS::prevMarker );
inspectMenu->Add( ACTIONS::nextMarker );
inspectMenu->Add( ACTIONS::excludeMarker );
inspectMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
inspectMenu->Add( SCH_ACTIONS::diffSymbol );
inspectMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
inspectMenu->Add( SCH_ACTIONS::showSimulator );
//-- Tools menu -----------------------------------------------
2019-05-13 22:49:05 +01:00
//
ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
wxMenuItem* update = toolsMenu->Add( ACTIONS::updatePcbFromSchematic );
update->Enable( !Kiface().IsSingle() );
2025-03-12 14:41:25 +00:00
toolsMenu->Add( SCH_ACTIONS::showPcbNew );
if( !Kiface().IsSingle() )
toolsMenu->Add( ACTIONS::showProjectManager );
toolsMenu->AppendSeparator();
toolsMenu->Add( ACTIONS::showSymbolEditor );
2025-03-12 14:41:25 +00:00
toolsMenu->Add( SCH_ACTIONS::updateSymbols );
toolsMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
toolsMenu->Add( SCH_ACTIONS::rescueSymbols );
toolsMenu->Add( SCH_ACTIONS::remapSymbols );
if( ADVANCED_CFG::GetCfg().m_ShowRepairSchematic )
2025-03-12 14:41:25 +00:00
toolsMenu->Add( SCH_ACTIONS::repairSchematic );
toolsMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
toolsMenu->Add( SCH_ACTIONS::editSymbolFields );
toolsMenu->Add( SCH_ACTIONS::editSymbolLibraryLinks );
toolsMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
toolsMenu->Add( SCH_ACTIONS::annotate );
toolsMenu->Add( SCH_ACTIONS::incrementAnnotations );
toolsMenu->AppendSeparator();
2025-03-12 14:41:25 +00:00
toolsMenu->Add( SCH_ACTIONS::assignFootprints );
toolsMenu->Add( SCH_ACTIONS::generateBOM );
toolsMenu->Add( SCH_ACTIONS::generateBOMLegacy );
toolsMenu->AppendSeparator();
update = toolsMenu->Add( ACTIONS::updateSchematicFromPcb );
update->Enable( !Kiface().IsSingle() );
#ifdef KICAD_IPC_API
toolsMenu->AppendSeparator();
toolsMenu->Add( ACTIONS::pluginsReload );
#endif
//-- Preferences menu -----------------------------------------------
//
ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showSymbolLibTable );
if( ADVANCED_CFG::GetCfg().m_EnableDesignBlocks )
prefsMenu->Add( ACTIONS::showDesignBlockLibTable );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool );
//-- Menubar -------------------------------------------------------------
//
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( toolsMenu, _( "&Tools" ) );
menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar );
delete oldMenuBar;
}