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>
|
2020-10-18 20:30:37 +00:00
|
|
|
* Copyright (C) 1992-2020 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
|
|
|
|
*/
|
|
|
|
|
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>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include <pgm_base.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.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 )
|
|
|
|
{
|
2020-02-25 15:46:56 +00:00
|
|
|
openRecentMenu = new ACTION_MENU( false );
|
2019-11-23 16:54:48 +00:00
|
|
|
openRecentMenu->SetTool( selTool );
|
|
|
|
openRecentMenu->SetTitle( _( "Open Recent" ) );
|
|
|
|
openRecentMenu->SetIcon( recent_xpm );
|
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,
|
|
|
|
add_document_xpm );
|
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
|
2019-06-15 00:29:42 +00:00
|
|
|
ACTION_MENU* submenuImport = new ACTION_MENU( false );
|
2019-05-24 23:36:31 +00:00
|
|
|
submenuImport->SetTool( selTool );
|
|
|
|
submenuImport->SetTitle( _( "Import" ) );
|
|
|
|
submenuImport->SetIcon( import_xpm );
|
2020-05-06 21:37:40 +00:00
|
|
|
submenuImport->Add( _( "Import Non KiCad Schematic..." ),
|
|
|
|
_( "Replace current schematic sheet with one imported from another application" ),
|
2020-08-06 23:03:58 +00:00
|
|
|
ID_IMPORT_NON_KICAD_SCH,
|
|
|
|
import_document_xpm );
|
2020-05-06 21:37:40 +00:00
|
|
|
|
2019-06-16 16:07:15 +00:00
|
|
|
submenuImport->Add( EE_ACTIONS::importFPAssignments );
|
2020-08-06 23:03:58 +00:00
|
|
|
fileMenu->Add( submenuImport );
|
2019-05-24 23:36:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Export submenu
|
2019-06-15 00:29:42 +00:00
|
|
|
ACTION_MENU* submenuExport = new ACTION_MENU( false );
|
2019-05-24 23:36:31 +00:00
|
|
|
submenuExport->SetTool( selTool );
|
|
|
|
submenuExport->SetTitle( _( "Export" ) );
|
|
|
|
submenuExport->SetIcon( export_xpm );
|
2019-06-16 16:07:15 +00:00
|
|
|
submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard );
|
2019-06-16 13:42:40 +00:00
|
|
|
submenuExport->Add( EE_ACTIONS::exportNetlist );
|
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();
|
2019-08-13 23:34:05 +00:00
|
|
|
fileMenu->AddQuitOrClose( &Kiface(), _( "Eeschema" ) );
|
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 );
|
|
|
|
editMenu->Add( ACTIONS::duplicate );
|
|
|
|
|
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" ) );
|
2019-05-14 19:21:10 +00:00
|
|
|
unitsSubMenu->SetIcon( unit_mm_xpm );
|
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 );
|
2019-06-01 18:36:49 +00:00
|
|
|
#ifdef KICAD_SPICE
|
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
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
toolsMenu->Add( ACTIONS::updatePcbFromSchematic );
|
|
|
|
toolsMenu->Add( ACTIONS::updateSchematicFromPcb );
|
|
|
|
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 -----------------------------------------------
|
2019-05-13 21:49:05 +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 );
|
|
|
|
prefsMenu->Add( _( "Preferences...\tCTRL+," ),
|
|
|
|
_( "Show preferences for all open tools" ),
|
|
|
|
wxID_PREFERENCES,
|
|
|
|
preference_xpm );
|
|
|
|
|
|
|
|
prefsMenu->AppendSeparator();
|
2019-06-16 18:35:32 +00:00
|
|
|
AddMenuLanguageList( prefsMenu, selTool );
|
2019-05-28 13:51:47 +00:00
|
|
|
|
2020-08-31 17:47:44 +00:00
|
|
|
#ifndef __WXMAC__
|
2020-08-06 23:03:58 +00:00
|
|
|
prefsMenu->AppendSeparator();
|
|
|
|
prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK );
|
|
|
|
prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK );
|
2020-08-31 17:47:44 +00:00
|
|
|
#endif
|
2018-02-22 19:05:10 +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
|
|
|
|