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( SCH_ACTIONS::importNonKicadSchematic, ACTION_MENU::NORMAL, _( "Non-KiCad Schematic..." ) );
105 submenuImport->Add( SCH_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) );
106 submenuImport->Add( SCH_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
107
108 fileMenu->Add( submenuImport );
109
110
111 // Export submenu
112 ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
113 submenuExport->SetTitle( _( "Export" ) );
114 submenuExport->SetIcon( BITMAPS::export_file );
115 submenuExport->Add( SCH_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );
116 submenuExport->Add( SCH_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
117 submenuExport->Add( SCH_ACTIONS::exportSymbolsToLibrary, ACTION_MENU::NORMAL, _( "Symbols..." ) );
118 fileMenu->Add( submenuExport );
119
120 fileMenu->AppendSeparator();
121 fileMenu->Add( SCH_ACTIONS::schematicSetup );
122
123 fileMenu->AppendSeparator();
124 fileMenu->Add( ACTIONS::pageSettings );
125 fileMenu->Add( ACTIONS::print );
126 fileMenu->Add( ACTIONS::plot );
127
128 fileMenu->AppendSeparator();
129 fileMenu->AddQuitOrClose( &Kiface(), _( "Schematic Editor" ) );
130
131
132 //-- Edit menu -----------------------------------------------------------
133 //
134 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
135
136 editMenu->Add( ACTIONS::undo );
137 editMenu->Add( ACTIONS::redo );
138
139 editMenu->AppendSeparator();
140 editMenu->Add( ACTIONS::cut );
141 editMenu->Add( ACTIONS::copy );
142 editMenu->Add( ACTIONS::copyAsText );
143 editMenu->Add( ACTIONS::paste );
144 editMenu->Add( ACTIONS::pasteSpecial );
145 editMenu->Add( ACTIONS::doDelete );
146
147 editMenu->AppendSeparator();
148 editMenu->Add( ACTIONS::selectAll );
149 editMenu->Add( ACTIONS::unselectAll );
150
151 editMenu->AppendSeparator();
152 editMenu->Add( ACTIONS::find );
153 editMenu->Add( ACTIONS::findAndReplace );
154
155 editMenu->AppendSeparator();
156 editMenu->Add( ACTIONS::deleteTool );
158 editMenu->Add( SCH_ACTIONS::changeSymbols );
159 editMenu->Add( SCH_ACTIONS::editPageNumber );
160
161 ACTION_MENU* submenuAttributes = new ACTION_MENU( false, selTool );
162 submenuAttributes->SetTitle( _( "Attributes" ) );
163
167 submenuAttributes->Add( SCH_ACTIONS::setDNP, ACTION_MENU::CHECK );
168
169 editMenu->Add( submenuAttributes );
170
171 //-- View menu -----------------------------------------------------------
172 //
173 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
174
175 // Show / Hide Panels submenu
176 ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
177 showHidePanels->SetTitle( _( "Panels" ) );
178
180 showHidePanels->Add( ACTIONS::showSearch, ACTION_MENU::CHECK );
182
183 if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
185
186 showHidePanels->Add( SCH_ACTIONS::showDesignBlockPanel, ACTION_MENU::CHECK, _( "Design Blocks" ) );
187 wxMenuItem* remoteSymbolItem = showHidePanels->Add( SCH_ACTIONS::showRemoteSymbolPanel, ACTION_MENU::CHECK, _( "Remote Symbols" ) );
188
189 if( m_remoteSymbolPane && !m_remoteSymbolPane->HasDataSources() )
190 {
191 remoteSymbolItem->Enable( false );
192 remoteSymbolItem->SetHelp( _( "Search signed-in remote symbol providers and download verified libraries." ) );
193 }
194
195 viewMenu->Add( showHidePanels );
196
197 viewMenu->AppendSeparator();
198 viewMenu->Add( ACTIONS::showSymbolBrowser );
199
200 viewMenu->AppendSeparator();
201 viewMenu->Add( ACTIONS::zoomInCenter );
202 viewMenu->Add( ACTIONS::zoomOutCenter );
203 viewMenu->Add( ACTIONS::zoomFitScreen );
204 viewMenu->Add( ACTIONS::zoomFitObjects );
205 viewMenu->Add( ACTIONS::zoomFitSelection );
206 viewMenu->Add( ACTIONS::zoomTool );
207 viewMenu->Add( ACTIONS::zoomRedraw );
208
209 viewMenu->AppendSeparator();
210 viewMenu->Add( SCH_ACTIONS::navigateBack );
211 viewMenu->Add( SCH_ACTIONS::navigateUp );
214 viewMenu->Add( SCH_ACTIONS::navigateNext );
215
216
217
218 viewMenu->AppendSeparator();
229
230#ifdef __APPLE__
231 viewMenu->AppendSeparator();
232#endif
233
234 //-- Place menu -----------------------------------------------------------
235 //
236 ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
237
238 placeMenu->Add( SCH_ACTIONS::placeSymbol );
239 placeMenu->Add( SCH_ACTIONS::placePower );
240 placeMenu->Add( SCH_ACTIONS::drawWire );
241 placeMenu->Add( SCH_ACTIONS::drawBus );
243 placeMenu->Add( SCH_ACTIONS::placeNoConnect );
244 placeMenu->Add( SCH_ACTIONS::placeJunction );
245 placeMenu->Add( SCH_ACTIONS::placeLabel );
247 placeMenu->Add( SCH_ACTIONS::placeClassLabel );
248 placeMenu->Add( SCH_ACTIONS::drawRuleArea );
249
250 placeMenu->AppendSeparator();
251 placeMenu->Add( SCH_ACTIONS::placeHierLabel );
252 placeMenu->Add( SCH_ACTIONS::drawSheet );
253 placeMenu->Add( SCH_ACTIONS::placeSheetPin );
255 placeMenu->Add( SCH_ACTIONS::importSheet );
256
257 placeMenu->AppendSeparator();
259 placeMenu->Add( SCH_ACTIONS::drawTextBox );
260 placeMenu->Add( SCH_ACTIONS::drawTable );
261 placeMenu->Add( SCH_ACTIONS::drawRectangle );
262 placeMenu->Add( SCH_ACTIONS::drawCircle );
263 placeMenu->Add( SCH_ACTIONS::drawArc );
264 placeMenu->Add( SCH_ACTIONS::drawBezier );
265 placeMenu->Add( SCH_ACTIONS::drawLines );
266 placeMenu->Add( SCH_ACTIONS::placeImage );
267
268
269 //-- Inspect menu -----------------------------------------------
270 //
271 ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
272
273 inspectMenu->Add( SCH_ACTIONS::showBusSyntaxHelp );
274
275 inspectMenu->AppendSeparator();
276 inspectMenu->Add( SCH_ACTIONS::runERC );
277 inspectMenu->Add( ACTIONS::prevMarker );
278 inspectMenu->Add( ACTIONS::nextMarker );
279 inspectMenu->Add( ACTIONS::excludeMarker );
280
281 inspectMenu->AppendSeparator();
282 inspectMenu->Add( SCH_ACTIONS::diffSymbol );
283
284 inspectMenu->AppendSeparator();
285 inspectMenu->Add( SCH_ACTIONS::showSimulator );
286
287
288 //-- Tools menu -----------------------------------------------
289 //
290 ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
291
292 toolsMenu->Add( ACTIONS::updatePcbFromSchematic )->Enable( !Kiface().IsSingle() );
293 toolsMenu->Add( SCH_ACTIONS::showPcbNew );
294
295 if( !Kiface().IsSingle() )
296 toolsMenu->Add( ACTIONS::showProjectManager );
297
298 toolsMenu->Add( ACTIONS::showCalculatorTools );
299
300 toolsMenu->AppendSeparator();
301 toolsMenu->Add( ACTIONS::showSymbolEditor );
302 toolsMenu->Add( SCH_ACTIONS::updateSymbols );
303
304 toolsMenu->AppendSeparator();
305 toolsMenu->Add( SCH_ACTIONS::rescueSymbols );
306 toolsMenu->Add( SCH_ACTIONS::remapSymbols );
307
308 toolsMenu->AppendSeparator();
311
312 toolsMenu->AppendSeparator();
313 toolsMenu->Add( SCH_ACTIONS::annotate );
315
316 toolsMenu->AppendSeparator();
318 toolsMenu->Add( SCH_ACTIONS::generateBOM );
320
321 toolsMenu->AppendSeparator();
322 toolsMenu->Add( ACTIONS::updateSchematicFromPcb )->Enable( !Kiface().IsSingle() );
323
324 toolsMenu->AppendSeparator();
325 ACTION_MENU* submenuVariants = new ACTION_MENU( false, selTool );
326 submenuVariants->SetTitle( _( "Variants" ) );
327 submenuVariants->Add( SCH_ACTIONS::addVariant );
328 submenuVariants->Add( SCH_ACTIONS::removeVariant );
329 submenuVariants->Add( SCH_ACTIONS::editVariantDescription );
330 toolsMenu->Add( submenuVariants );
331
332#ifdef KICAD_IPC_API
333 toolsMenu->AppendSeparator();
334 toolsMenu->Add( ACTIONS::pluginsReload );
335#endif
336
337 //-- Preferences menu -----------------------------------------------
338 //
339 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
340
341 prefsMenu->Add( ACTIONS::configurePaths );
342 prefsMenu->Add( ACTIONS::showSymbolLibTable );
344 prefsMenu->Add( ACTIONS::openPreferences );
345
346 prefsMenu->AppendSeparator();
347 AddMenuLanguageList( prefsMenu, selTool );
348
349
350 //-- Menubar -------------------------------------------------------------
351 //
352 menuBar->Append( fileMenu, _( "&File" ) );
353 menuBar->Append( editMenu, _( "&Edit" ) );
354 menuBar->Append( viewMenu, _( "&View" ) );
355 menuBar->Append( placeMenu, _( "&Place" ) );
356 menuBar->Append( inspectMenu, _( "&Inspect" ) );
357 menuBar->Append( toolsMenu, _( "&Tools" ) );
358 menuBar->Append( prefsMenu, _( "P&references" ) );
359 AddStandardHelpMenu( menuBar );
360
361 SetMenuBar( menuBar );
362 delete oldMenuBar;
363}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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 editVariantDescription
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 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 setExcludeFromSim
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 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 importNonKicadSchematic
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)
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)