2011-10-18 19:59:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-04-01 19:09:52 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-10-22 00:48:25 +00:00
|
|
|
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
|
2021-05-29 16:09:49 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2011-10-18 19:59:19 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2021-03-07 20:31:19 +00:00
|
|
|
#include <bitmaps.h>
|
2019-11-23 16:54:48 +00:00
|
|
|
#include <filehistory.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include <kiface_i.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2021-06-06 17:26:26 +00:00
|
|
|
#include <tool/action_manager.h>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/action_menu.h>
|
2019-05-13 20:42:40 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/ee_selection_tool.h>
|
|
|
|
#include <tools/ee_actions.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include "eeschema_id.h"
|
2018-01-30 10:49:51 +00:00
|
|
|
#include "sch_edit_frame.h"
|
2020-06-06 17:42:04 +00:00
|
|
|
#include <widgets/wx_menubar.h>
|
2015-06-21 20:30:33 +00:00
|
|
|
|
2016-11-20 11:57:16 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::ReCreateMenuBar()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-05-13 20:42:40 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
2018-04-07 13:13:38 +00:00
|
|
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
|
|
|
// we always have to start from scratch with a new wxMenuBar.
|
2020-06-06 17:42:04 +00:00
|
|
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
|
|
|
WX_MENUBAR* menuBar = new WX_MENUBAR();
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
//-- File menu -----------------------------------------------------------
|
2019-05-13 21:49:05 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00:00
|
|
|
ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
|
2020-02-25 15:46:56 +00:00
|
|
|
static ACTION_MENU* openRecentMenu;
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
if( Kiface().IsSingle() ) // When not under a project mgr
|
2019-05-24 23:36:31 +00:00
|
|
|
{
|
2020-05-16 21:47:01 +00:00
|
|
|
FILE_HISTORY& fileHistory = GetFileHistory();
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
// 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)
|
2019-11-23 16:54:48 +00:00
|
|
|
if( !openRecentMenu )
|
|
|
|
{
|
2021-03-27 19:16:58 +00:00
|
|
|
openRecentMenu = new ACTION_MENU( false, selTool );
|
2019-11-23 16:54:48 +00:00
|
|
|
openRecentMenu->SetTitle( _( "Open Recent" ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
openRecentMenu->SetIcon( BITMAPS::recent );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
|
|
|
fileHistory.UseMenu( openRecentMenu );
|
|
|
|
fileHistory.AddFilesToMenu( openRecentMenu );
|
2019-11-23 16:54:48 +00:00
|
|
|
}
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->Add( ACTIONS::doNew );
|
|
|
|
fileMenu->Add( ACTIONS::open );
|
|
|
|
|
|
|
|
wxMenuItem* item = fileMenu->Add( openRecentMenu );
|
|
|
|
|
|
|
|
// 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();
|
2019-05-24 23:36:31 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->Add( ACTIONS::save );
|
|
|
|
fileMenu->Add( ACTIONS::saveAs );
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->Add( _( "Append Schematic Sheet Content..." ),
|
|
|
|
_( "Append schematic sheet content from another project to the current sheet" ),
|
|
|
|
ID_APPEND_PROJECT,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::add_document );
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2019-05-24 23:36:31 +00:00
|
|
|
|
|
|
|
// Import submenu
|
2021-03-27 19:16:58 +00:00
|
|
|
ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
|
2019-05-24 23:36:31 +00:00
|
|
|
submenuImport->SetTitle( _( "Import" ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
submenuImport->SetIcon( BITMAPS::import );
|
2021-03-27 18:47:48 +00:00
|
|
|
submenuImport->Add( _( "Non-KiCad Schematic..." ),
|
2020-05-06 21:37:40 +00:00
|
|
|
_( "Replace current schematic sheet with one imported from another application" ),
|
2020-08-06 23:03:58 +00:00
|
|
|
ID_IMPORT_NON_KICAD_SCH,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::import_document );
|
2020-05-06 21:37:40 +00:00
|
|
|
|
2021-03-27 18:47:48 +00:00
|
|
|
submenuImport->Add( EE_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->Add( submenuImport );
|
2019-05-24 23:36:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Export submenu
|
2021-03-27 19:16:58 +00:00
|
|
|
ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
|
2019-05-24 23:36:31 +00:00
|
|
|
submenuExport->SetTitle( _( "Export" ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
submenuExport->SetIcon( BITMAPS::export_file );
|
2021-03-27 18:47:48 +00:00
|
|
|
submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );
|
|
|
|
submenuExport->Add( EE_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->Add( submenuExport );
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
fileMenu->Add( EE_ACTIONS::schematicSetup );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
fileMenu->Add( ACTIONS::pageSettings );
|
|
|
|
fileMenu->Add( ACTIONS::print );
|
|
|
|
fileMenu->Add( ACTIONS::plot );
|
2019-05-24 23:36:31 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2021-02-18 15:49:35 +00:00
|
|
|
fileMenu->AddQuitOrClose( &Kiface(), _( "Schematic Editor" ) );
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
//-- Edit menu -----------------------------------------------------------
|
2019-05-13 21:49:05 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00: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::paste );
|
|
|
|
editMenu->Add( ACTIONS::pasteSpecial );
|
|
|
|
editMenu->Add( ACTIONS::doDelete );
|
|
|
|
|
2020-08-20 23:05:21 +00:00
|
|
|
editMenu->AppendSeparator();
|
|
|
|
editMenu->Add( ACTIONS::selectAll );
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
editMenu->AppendSeparator();
|
|
|
|
editMenu->Add( ACTIONS::find );
|
|
|
|
editMenu->Add( ACTIONS::findAndReplace );
|
|
|
|
|
|
|
|
editMenu->AppendSeparator();
|
|
|
|
editMenu->Add( ACTIONS::deleteTool );
|
|
|
|
editMenu->Add( EE_ACTIONS::editTextAndGraphics );
|
|
|
|
editMenu->Add( EE_ACTIONS::changeSymbols );
|
2020-10-18 20:30:37 +00:00
|
|
|
editMenu->Add( EE_ACTIONS::editPageNumber );
|
2019-06-02 11:57:29 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
//-- View menu -----------------------------------------------------------
|
2019-05-13 21:49:05 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00:00
|
|
|
ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
|
|
|
|
|
|
|
|
viewMenu->Add( ACTIONS::showSymbolBrowser );
|
|
|
|
viewMenu->Add( EE_ACTIONS::navigateHierarchy );
|
|
|
|
viewMenu->Add( EE_ACTIONS::leaveSheet );
|
|
|
|
|
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
viewMenu->Add( ACTIONS::zoomInCenter );
|
|
|
|
viewMenu->Add( ACTIONS::zoomOutCenter );
|
|
|
|
viewMenu->Add( ACTIONS::zoomFitScreen );
|
2020-09-11 07:51:00 +00:00
|
|
|
viewMenu->Add( ACTIONS::zoomFitObjects );
|
2020-08-06 23:03:58 +00:00
|
|
|
viewMenu->Add( ACTIONS::zoomTool );
|
|
|
|
viewMenu->Add( ACTIONS::zoomRedraw );
|
|
|
|
|
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( ACTIONS::gridProperties );
|
2019-05-13 21:49:05 +00:00
|
|
|
|
|
|
|
// Units submenu
|
2020-08-06 23:03:58 +00:00
|
|
|
ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
|
2019-05-13 21:49:05 +00:00
|
|
|
unitsSubMenu->SetTitle( _( "&Units" ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
unitsSubMenu->SetIcon( BITMAPS::unit_mm );
|
2020-10-03 23:34:23 +00:00
|
|
|
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
|
|
|
|
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
|
|
|
|
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
|
2020-08-06 23:03:58 +00:00
|
|
|
viewMenu->Add( unitsSubMenu );
|
2019-05-13 21:49:05 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
|
2019-05-13 21:49:05 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
viewMenu->Add( EE_ACTIONS::toggleHiddenPins, ACTION_MENU::CHECK );
|
2019-05-13 21:49:05 +00:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2020-08-06 23:03:58 +00:00
|
|
|
viewMenu->AppendSeparator();
|
2019-05-13 21:49:05 +00:00
|
|
|
#endif
|
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
//-- Place menu -----------------------------------------------------------
|
2019-05-13 21:49:05 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00:00
|
|
|
ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
|
|
|
|
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeSymbol );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placePower );
|
|
|
|
placeMenu->Add( EE_ACTIONS::drawWire );
|
|
|
|
placeMenu->Add( EE_ACTIONS::drawBus );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeBusWireEntry );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeNoConnect );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeJunction );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeLabel );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeGlobalLabel );
|
|
|
|
|
|
|
|
placeMenu->AppendSeparator();
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeHierLabel );
|
|
|
|
placeMenu->Add( EE_ACTIONS::drawSheet );
|
|
|
|
placeMenu->Add( EE_ACTIONS::importSheetPin );
|
|
|
|
|
|
|
|
placeMenu->AppendSeparator();
|
|
|
|
placeMenu->Add( EE_ACTIONS::drawLines );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeSchematicText );
|
|
|
|
placeMenu->Add( EE_ACTIONS::placeImage );
|
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
//-- Inspect menu -----------------------------------------------
|
2019-05-13 21:49:05 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00:00
|
|
|
ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
inspectMenu->Add( EE_ACTIONS::runERC );
|
2020-12-01 22:35:11 +00:00
|
|
|
inspectMenu->Add( ACTIONS::prevMarker );
|
|
|
|
inspectMenu->Add( ACTIONS::nextMarker );
|
|
|
|
inspectMenu->Add( ACTIONS::excludeMarker );
|
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
#ifdef KICAD_SPICE
|
2020-12-01 22:35:11 +00:00
|
|
|
inspectMenu->AppendSeparator();
|
2020-08-06 23:03:58 +00:00
|
|
|
inspectMenu->Add( EE_ACTIONS::runSimulation );
|
2019-06-01 18:36:49 +00:00
|
|
|
#endif
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
//-- Tools menu -----------------------------------------------
|
2019-05-13 21:49:05 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00:00
|
|
|
ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2021-02-22 22:45:29 +00:00
|
|
|
wxMenuItem* update = toolsMenu->Add( ACTIONS::updatePcbFromSchematic );
|
|
|
|
update->Enable( !Kiface().IsSingle() );
|
|
|
|
update = toolsMenu->Add( ACTIONS::updateSchematicFromPcb );
|
|
|
|
update->Enable( !Kiface().IsSingle() );
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
toolsMenu->Add( EE_ACTIONS::showPcbNew );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
toolsMenu->AppendSeparator();
|
|
|
|
toolsMenu->Add( ACTIONS::showSymbolEditor );
|
2020-09-02 13:41:50 +00:00
|
|
|
toolsMenu->Add( EE_ACTIONS::updateSymbols );
|
2020-08-06 23:03:58 +00:00
|
|
|
toolsMenu->Add( EE_ACTIONS::rescueSymbols );
|
|
|
|
toolsMenu->Add( EE_ACTIONS::remapSymbols );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
toolsMenu->AppendSeparator();
|
|
|
|
toolsMenu->Add( EE_ACTIONS::editSymbolFields );
|
|
|
|
toolsMenu->Add( EE_ACTIONS::editSymbolLibraryLinks );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
toolsMenu->AppendSeparator();
|
|
|
|
toolsMenu->Add( EE_ACTIONS::annotate );
|
|
|
|
toolsMenu->Add( EE_ACTIONS::showBusManager );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
toolsMenu->AppendSeparator();
|
|
|
|
toolsMenu->Add( EE_ACTIONS::assignFootprints );
|
|
|
|
toolsMenu->Add( EE_ACTIONS::generateBOM );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
//-- Preferences menu -----------------------------------------------
|
2021-06-07 19:45:17 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00:00
|
|
|
ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
|
|
|
|
|
|
|
|
prefsMenu->Add( ACTIONS::configurePaths );
|
|
|
|
prefsMenu->Add( ACTIONS::showSymbolLibTable );
|
2021-06-07 19:45:17 +00:00
|
|
|
|
|
|
|
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
|
|
|
|
// Mac, and it needs the wxID_PREFERENCES id to find it.
|
|
|
|
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
|
|
|
|
_( "Show preferences for all open tools" ),
|
|
|
|
wxID_PREFERENCES,
|
|
|
|
BITMAPS::preference );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
prefsMenu->AppendSeparator();
|
2019-06-16 18:35:32 +00:00
|
|
|
AddMenuLanguageList( prefsMenu, selTool );
|
2019-05-28 13:51:47 +00:00
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
|
|
|
|
//-- Menubar -------------------------------------------------------------
|
2019-05-28 13:51:47 +00:00
|
|
|
//
|
2020-08-06 23:03:58 +00:00
|
|
|
menuBar->Append( fileMenu, _( "&File" ) );
|
|
|
|
menuBar->Append( editMenu, _( "&Edit" ) );
|
|
|
|
menuBar->Append( viewMenu, _( "&View" ) );
|
|
|
|
menuBar->Append( placeMenu, _( "&Place" ) );
|
2018-02-22 19:05:10 +00:00
|
|
|
menuBar->Append( inspectMenu, _( "&Inspect" ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
menuBar->Append( toolsMenu, _( "&Tools" ) );
|
|
|
|
menuBar->Append( prefsMenu, _( "P&references" ) );
|
2019-05-18 10:27:36 +00:00
|
|
|
AddStandardHelpMenu( menuBar );
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2018-04-07 13:13:38 +00:00
|
|
|
SetMenuBar( menuBar );
|
|
|
|
delete oldMenuBar;
|
2016-11-20 11:57:16 +00:00
|
|
|
}
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
|