KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema/menubar.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2009 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 * Copyright (C) 2019 CERN
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <bitmaps.h>
28#include <file_history.h>
29#include <kiface_base.h>
30#include <schematic.h>
31#include <tool/action_manager.h>
32#include <tool/action_menu.h>
33#include <tool/tool_manager.h>
35#include <tools/sch_actions.h>
36#include "eeschema_id.h"
37#include "sch_edit_frame.h"
38#include <widgets/wx_menubar.h>
40#include <advanced_config.h>
41
42
44{
46
47 // wxWidgets handles the Mac Application menu behind the scenes, but that means
48 // we always have to start from scratch with a new wxMenuBar.
49 wxMenuBar* oldMenuBar = GetMenuBar();
50 WX_MENUBAR* menuBar = new WX_MENUBAR();
51
52 //-- File menu -----------------------------------------------------------
53 //
54 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
55 static ACTION_MENU* openRecentMenu;
56
57 if( Kiface().IsSingle() ) // When not under a project mgr
58 {
59 FILE_HISTORY& fileHistory = GetFileHistory();
60
61 // Add this menu to the list of menus managed by the file history
62 // (the file history will be updated when adding/removing files in history)
63 if( !openRecentMenu )
64 {
65 openRecentMenu = new ACTION_MENU( false, selTool );
66 openRecentMenu->SetIcon( BITMAPS::recent );
67
68 fileHistory.UseMenu( openRecentMenu );
69 fileHistory.AddFilesToMenu( openRecentMenu );
70 }
71
72 // Ensure the title is up to date after changing language
73 openRecentMenu->SetTitle( _( "Open Recent" ) );
74 fileHistory.UpdateClearText( openRecentMenu, _( "Clear Recent Files" ) );
75
76 fileMenu->Add( ACTIONS::doNew );
77 fileMenu->Add( ACTIONS::open );
78
79 wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
80
81 // Add the file menu condition here since it needs the item ID for the submenu
83 cond.Enable( FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
84 RegisterUIUpdateHandler( item->GetId(), cond );
85 fileMenu->AppendSeparator();
86 }
87
88 fileMenu->Add( ACTIONS::save );
89
90 if( Kiface().IsSingle() )
91 fileMenu->Add( ACTIONS::saveAs );
92 else
94
95 fileMenu->Add( ACTIONS::revert );
96
97 fileMenu->AppendSeparator();
98
99 // Import submenu
100 ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
101 submenuImport->SetTitle( _( "Import" ) );
102 submenuImport->SetIcon( BITMAPS::import );
103
104 submenuImport->Add( _( "Non-KiCad Schematic..." ),
105 _( "Replace current schematic sheet with one imported from another application" ),
108
109 submenuImport->Add( SCH_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) );
110 submenuImport->Add( SCH_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
111
112 fileMenu->Add( submenuImport );
113
114
115 // Export submenu
116 ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
117 submenuExport->SetTitle( _( "Export" ) );
118 submenuExport->SetIcon( BITMAPS::export_file );
119 submenuExport->Add( SCH_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );
120 submenuExport->Add( SCH_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
121 submenuExport->Add( SCH_ACTIONS::exportSymbolsToLibrary, ACTION_MENU::NORMAL, _( "Symbols..." ) );
122 fileMenu->Add( submenuExport );
123
124 fileMenu->AppendSeparator();
125 fileMenu->Add( SCH_ACTIONS::schematicSetup );
126
127 fileMenu->AppendSeparator();
128 fileMenu->Add( ACTIONS::pageSettings );
129 fileMenu->Add( ACTIONS::print );
130 fileMenu->Add( ACTIONS::plot );
131
132 fileMenu->AppendSeparator();
133 fileMenu->AddQuitOrClose( &Kiface(), _( "Schematic Editor" ) );
134
135
136 //-- Edit menu -----------------------------------------------------------
137 //
138 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
139
140 editMenu->Add( ACTIONS::undo );
141 editMenu->Add( ACTIONS::redo );
142
143 editMenu->AppendSeparator();
144 editMenu->Add( ACTIONS::cut );
145 editMenu->Add( ACTIONS::copy );
146 editMenu->Add( ACTIONS::copyAsText );
147 editMenu->Add( ACTIONS::paste );
148 editMenu->Add( ACTIONS::pasteSpecial );
149 editMenu->Add( ACTIONS::doDelete );
150
151 editMenu->AppendSeparator();
152 editMenu->Add( ACTIONS::selectAll );
153 editMenu->Add( ACTIONS::unselectAll );
154
155 editMenu->AppendSeparator();
156 editMenu->Add( ACTIONS::find );
157 editMenu->Add( ACTIONS::findAndReplace );
158
159 editMenu->AppendSeparator();
160 editMenu->Add( ACTIONS::deleteTool );
162 editMenu->Add( SCH_ACTIONS::changeSymbols );
163 editMenu->Add( SCH_ACTIONS::editPageNumber );
164
165 ACTION_MENU* submenuAttributes = new ACTION_MENU( false, selTool );
166 submenuAttributes->SetTitle( _( "Attributes" ) );
167
171 submenuAttributes->Add( SCH_ACTIONS::setDNP, ACTION_MENU::CHECK );
172
173 editMenu->Add( submenuAttributes );
174
175 //-- View menu -----------------------------------------------------------
176 //
177 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
178
179 // Show / Hide Panels submenu
180 ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
181 showHidePanels->SetTitle( _( "Panels" ) );
182
184 showHidePanels->Add( ACTIONS::showSearch, ACTION_MENU::CHECK );
186
187 if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
189
190 showHidePanels->Add( SCH_ACTIONS::showDesignBlockPanel, ACTION_MENU::CHECK, _( "Design Blocks" ) );
191 wxMenuItem* remoteSymbolItem = showHidePanels->Add( SCH_ACTIONS::showRemoteSymbolPanel, ACTION_MENU::CHECK, _( "Remote Symbols" ) );
192
193 if( m_remoteSymbolPane && !m_remoteSymbolPane->HasDataSources() )
194 {
195 remoteSymbolItem->Enable( false );
196 remoteSymbolItem->SetHelp( _( "Install a remote symbol server using the Plugin and Content Manger to enable" ) );
197 }
198
199 viewMenu->Add( showHidePanels );
200
201 viewMenu->AppendSeparator();
202 viewMenu->Add( ACTIONS::showSymbolBrowser );
203
204 viewMenu->AppendSeparator();
205 viewMenu->Add( ACTIONS::zoomInCenter );
206 viewMenu->Add( ACTIONS::zoomOutCenter );
207 viewMenu->Add( ACTIONS::zoomFitScreen );
208 viewMenu->Add( ACTIONS::zoomFitObjects );
209 viewMenu->Add( ACTIONS::zoomFitSelection );
210 viewMenu->Add( ACTIONS::zoomTool );
211 viewMenu->Add( ACTIONS::zoomRedraw );
212
213 viewMenu->AppendSeparator();
214 viewMenu->Add( SCH_ACTIONS::navigateBack );
215 viewMenu->Add( SCH_ACTIONS::navigateUp );
218 viewMenu->Add( SCH_ACTIONS::navigateNext );
219
220
221
222 viewMenu->AppendSeparator();
233
234#ifdef __APPLE__
235 viewMenu->AppendSeparator();
236#endif
237
238 //-- Place menu -----------------------------------------------------------
239 //
240 ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
241
242 placeMenu->Add( SCH_ACTIONS::placeSymbol );
243 placeMenu->Add( SCH_ACTIONS::placePower );
244 placeMenu->Add( SCH_ACTIONS::drawWire );
245 placeMenu->Add( SCH_ACTIONS::drawBus );
247 placeMenu->Add( SCH_ACTIONS::placeNoConnect );
248 placeMenu->Add( SCH_ACTIONS::placeJunction );
249 placeMenu->Add( SCH_ACTIONS::placeLabel );
251 placeMenu->Add( SCH_ACTIONS::placeClassLabel );
252 placeMenu->Add( SCH_ACTIONS::drawRuleArea );
253
254 placeMenu->AppendSeparator();
255 placeMenu->Add( SCH_ACTIONS::placeHierLabel );
256 placeMenu->Add( SCH_ACTIONS::drawSheet );
257 placeMenu->Add( SCH_ACTIONS::placeSheetPin );
259 placeMenu->Add( SCH_ACTIONS::importSheet );
260
261 placeMenu->AppendSeparator();
263 placeMenu->Add( SCH_ACTIONS::drawTextBox );
264 placeMenu->Add( SCH_ACTIONS::drawTable );
265 placeMenu->Add( SCH_ACTIONS::drawRectangle );
266 placeMenu->Add( SCH_ACTIONS::drawCircle );
267 placeMenu->Add( SCH_ACTIONS::drawArc );
268 placeMenu->Add( SCH_ACTIONS::drawBezier );
269 placeMenu->Add( SCH_ACTIONS::drawLines );
270 placeMenu->Add( SCH_ACTIONS::placeImage );
271
272
273 //-- Inspect menu -----------------------------------------------
274 //
275 ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
276
277 inspectMenu->Add( SCH_ACTIONS::showBusSyntaxHelp );
278
279 inspectMenu->AppendSeparator();
280 inspectMenu->Add( SCH_ACTIONS::runERC );
281 inspectMenu->Add( ACTIONS::prevMarker );
282 inspectMenu->Add( ACTIONS::nextMarker );
283 inspectMenu->Add( ACTIONS::excludeMarker );
284
285 inspectMenu->AppendSeparator();
286 inspectMenu->Add( SCH_ACTIONS::diffSymbol );
287
288 inspectMenu->AppendSeparator();
289 inspectMenu->Add( SCH_ACTIONS::showSimulator );
290
291
292 //-- Tools menu -----------------------------------------------
293 //
294 ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
295
296 toolsMenu->Add( ACTIONS::updatePcbFromSchematic )->Enable( !Kiface().IsSingle() );
297 toolsMenu->Add( SCH_ACTIONS::showPcbNew );
298
299 if( !Kiface().IsSingle() )
300 toolsMenu->Add( ACTIONS::showProjectManager );
301
302 toolsMenu->Add( ACTIONS::showCalculatorTools );
303
304 toolsMenu->AppendSeparator();
305 toolsMenu->Add( ACTIONS::showSymbolEditor );
306 toolsMenu->Add( SCH_ACTIONS::updateSymbols );
307
308 toolsMenu->AppendSeparator();
309 toolsMenu->Add( SCH_ACTIONS::rescueSymbols );
310 toolsMenu->Add( SCH_ACTIONS::remapSymbols );
311
312 if( ADVANCED_CFG::GetCfg().m_ShowRepairSchematic )
313 toolsMenu->Add( SCH_ACTIONS::repairSchematic );
314
315 toolsMenu->AppendSeparator();
318
319 toolsMenu->AppendSeparator();
320 toolsMenu->Add( SCH_ACTIONS::annotate );
322
323 toolsMenu->AppendSeparator();
325 toolsMenu->Add( SCH_ACTIONS::generateBOM );
327
328 toolsMenu->AppendSeparator();
329 toolsMenu->Add( ACTIONS::updateSchematicFromPcb )->Enable( !Kiface().IsSingle() );
330
331 if( ADVANCED_CFG::GetCfg().m_EnableVariantsUI )
332 {
333 toolsMenu->AppendSeparator();
334 ACTION_MENU* submenuVariants = new ACTION_MENU( false, selTool );
335 submenuVariants->SetTitle( _( "Variants" ) );
336 submenuVariants->Add( SCH_ACTIONS::addVariant );
337 submenuVariants->Add( SCH_ACTIONS::removeVariant );
338 toolsMenu->Add( submenuVariants );
339 }
340
341#ifdef KICAD_IPC_API
342 toolsMenu->AppendSeparator();
343 toolsMenu->Add( ACTIONS::pluginsReload );
344#endif
345
346 //-- Preferences menu -----------------------------------------------
347 //
348 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
349
350 prefsMenu->Add( ACTIONS::configurePaths );
351 prefsMenu->Add( ACTIONS::showSymbolLibTable );
353 prefsMenu->Add( ACTIONS::openPreferences );
354
355 prefsMenu->AppendSeparator();
356 AddMenuLanguageList( prefsMenu, selTool );
357
358
359 //-- Menubar -------------------------------------------------------------
360 //
361 menuBar->Append( fileMenu, _( "&File" ) );
362 menuBar->Append( editMenu, _( "&Edit" ) );
363 menuBar->Append( viewMenu, _( "&View" ) );
364 menuBar->Append( placeMenu, _( "&Place" ) );
365 menuBar->Append( inspectMenu, _( "&Inspect" ) );
366 menuBar->Append( toolsMenu, _( "&Tools" ) );
367 menuBar->Append( prefsMenu, _( "P&references" ) );
368 AddStandardHelpMenu( menuBar );
369
370 SetMenuBar( menuBar );
371 delete oldMenuBar;
372}
373
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ import_document
static TOOL_ACTION showCalculatorTools
Definition actions.h:263
static TOOL_ACTION updatePcbFromSchematic
Definition actions.h:264
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION excludeMarker
Definition actions.h:129
static TOOL_ACTION nextMarker
Definition actions.h:128
static TOOL_ACTION zoomRedraw
Definition actions.h:132
static TOOL_ACTION unselectAll
Definition actions.h:83
static TOOL_ACTION revert
Definition actions.h:62
static TOOL_ACTION zoomOutCenter
Definition actions.h:136
static TOOL_ACTION saveAs
Definition actions.h:59
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION pluginsReload
Definition actions.h:294
static TOOL_ACTION showSymbolLibTable
Definition actions.h:282
static TOOL_ACTION showSymbolEditor
Definition actions.h:260
static TOOL_ACTION showSymbolBrowser
Definition actions.h:259
static TOOL_ACTION pasteSpecial
Definition actions.h:81
static TOOL_ACTION zoomFitSelection
Definition actions.h:144
static TOOL_ACTION findAndReplace
Definition actions.h:118
static TOOL_ACTION openPreferences
Definition actions.h:280
static TOOL_ACTION plot
Definition actions.h:65
static TOOL_ACTION open
Definition actions.h:57
static TOOL_ACTION pageSettings
Definition actions.h:63
static TOOL_ACTION showSearch
Definition actions.h:116
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION prevMarker
Definition actions.h:127
static TOOL_ACTION doDelete
Definition actions.h:85
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:146
static TOOL_ACTION updateSchematicFromPcb
Definition actions.h:265
static TOOL_ACTION showDesignBlockLibTable
Definition actions.h:284
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION doNew
Definition actions.h:54
static TOOL_ACTION zoomFitObjects
Definition actions.h:143
static TOOL_ACTION zoomInCenter
Definition actions.h:135
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION configurePaths
Definition actions.h:281
static TOOL_ACTION showProjectManager
Definition actions.h:257
static TOOL_ACTION copyAsText
Definition actions.h:79
static TOOL_ACTION selectAll
Definition actions.h:82
static TOOL_ACTION find
Definition actions.h:117
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:47
void AddQuitOrClose(KIFACE_BASE *aKiface, wxString aAppname="")
Add either a standard Quit or Close item to the menu.
static constexpr bool CHECK
ACTION_MENU * Clone() const
Create a deep, recursive copy of this ACTION_MENU.
void SetTitle(const wxString &aTitle) override
Set title for the menu.
static constexpr bool NORMAL
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Create a menu list for language choice, and add it as submenu to MasterMenu.
FILE_HISTORY & GetFileHistory()
Get the frame's main file history.
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Add the standard KiCad help menu to the menubar.
This class implements a file history object to store a list of files, that can then be added to a men...
static SELECTION_CONDITION FileHistoryNotEmpty(const FILE_HISTORY &aHistory)
Create a SELECTION_CONDITION that can be used to enable a menu item when the file history has items i...
void UpdateClearText(wxMenu *aMenu, wxString aClearText)
Update the text displayed on the menu item that clears the entire menu.
void AddFilesToMenu() override
Add the files to all registered menus.
static TOOL_ACTION showPcbNew
static TOOL_ACTION placeClassLabel
Definition sch_actions.h:79
static TOOL_ACTION placeSheetPin
Definition sch_actions.h:85
static TOOL_ACTION setExcludeFromBOM
static TOOL_ACTION assignFootprints
static TOOL_ACTION toggleOPCurrents
static TOOL_ACTION showBusSyntaxHelp
static TOOL_ACTION placeGlobalLabel
Definition sch_actions.h:80
static TOOL_ACTION removeVariant
static TOOL_ACTION editSymbolFields
static TOOL_ACTION importFPAssignments
static TOOL_ACTION changeSymbols
static TOOL_ACTION drawTextBox
Definition sch_actions.h:93
static TOOL_ACTION syncAllSheetsPins
Definition sch_actions.h:91
static TOOL_ACTION drawArc
Definition sch_actions.h:97
static TOOL_ACTION drawSheet
Definition sch_actions.h:82
static TOOL_ACTION toggleERCWarnings
static TOOL_ACTION navigateBack
static TOOL_ACTION schematicSetup
static TOOL_ACTION toggleDirectiveLabels
static TOOL_ACTION toggleHiddenFields
static TOOL_ACTION drawRectangle
Definition sch_actions.h:95
static TOOL_ACTION drawLines
Definition sch_actions.h:99
static TOOL_ACTION saveCurrSheetCopyAs
Definition sch_actions.h:43
static TOOL_ACTION placeHierLabel
Definition sch_actions.h:81
static TOOL_ACTION placeLabel
Definition sch_actions.h:78
static TOOL_ACTION drawCircle
Definition sch_actions.h:96
static TOOL_ACTION navigateNext
static TOOL_ACTION importGraphics
static TOOL_ACTION placeBusWireEntry
Definition sch_actions.h:77
static TOOL_ACTION showRemoteSymbolPanel
static TOOL_ACTION repairSchematic
static TOOL_ACTION drawBezier
Definition sch_actions.h:98
static TOOL_ACTION drawWire
Definition sch_actions.h:72
static TOOL_ACTION remapSymbols
static TOOL_ACTION editSymbolLibraryLinks
static TOOL_ACTION importSheet
Definition sch_actions.h:87
static TOOL_ACTION generateBOM
static TOOL_ACTION showHierarchy
static TOOL_ACTION showNetNavigator
static TOOL_ACTION placeJunction
Definition sch_actions.h:76
static TOOL_ACTION setDNP
static TOOL_ACTION markSimExclusions
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeSymbol
Definition sch_actions.h:66
static TOOL_ACTION placeImage
static TOOL_ACTION navigateForward
static TOOL_ACTION toggleERCErrors
static TOOL_ACTION incrementAnnotations
static TOOL_ACTION navigatePrevious
static TOOL_ACTION rescueSymbols
static TOOL_ACTION generateBOMLegacy
static TOOL_ACTION showSimulator
static TOOL_ACTION toggleOPVoltages
static TOOL_ACTION drawBus
Definition sch_actions.h:73
static TOOL_ACTION setExcludeFromSimulation
static TOOL_ACTION runERC
Inspection and Editing.
static TOOL_ACTION drawTable
Definition sch_actions.h:94
static TOOL_ACTION placeSchematicText
Definition sch_actions.h:92
static TOOL_ACTION annotate
static TOOL_ACTION showDesignBlockPanel
static TOOL_ACTION updateSymbols
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION toggleERCExclusions
static TOOL_ACTION editTextAndGraphics
static TOOL_ACTION exportNetlist
static TOOL_ACTION placeNoConnect
Definition sch_actions.h:75
static TOOL_ACTION editPageNumber
static TOOL_ACTION drawSheetOnClipboard
static TOOL_ACTION exportSymbolsToLibrary
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION setExcludeFromBoard
static TOOL_ACTION addVariant
static TOOL_ACTION diffSymbol
static TOOL_ACTION placePower
Definition sch_actions.h:68
static TOOL_ACTION navigateUp
void doReCreateMenuBar() override
PANEL_REMOTE_SYMBOL * m_remoteSymbolPane
TOOL_MANAGER * m_toolManager
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition wx_menubar.h:47
#define _(s)
@ ID_IMPORT_NON_KICAD_SCH
Definition eeschema_id.h:62
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)