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>
39#include <advanced_config.h>
40
41
43{
45
46 // wxWidgets handles the Mac Application menu behind the scenes, but that means
47 // we always have to start from scratch with a new wxMenuBar.
48 wxMenuBar* oldMenuBar = GetMenuBar();
49 WX_MENUBAR* menuBar = new WX_MENUBAR();
50
51 //-- File menu -----------------------------------------------------------
52 //
53 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
54 static ACTION_MENU* openRecentMenu;
55
56 if( Kiface().IsSingle() ) // When not under a project mgr
57 {
58 FILE_HISTORY& fileHistory = GetFileHistory();
59
60 // Add this menu to the list of menus managed by the file history
61 // (the file history will be updated when adding/removing files in history)
62 if( !openRecentMenu )
63 {
64 openRecentMenu = new ACTION_MENU( false, selTool );
65 openRecentMenu->SetIcon( BITMAPS::recent );
66
67 fileHistory.UseMenu( openRecentMenu );
68 fileHistory.AddFilesToMenu( openRecentMenu );
69 }
70
71 // Ensure the title is up to date after changing language
72 openRecentMenu->SetTitle( _( "Open Recent" ) );
73 fileHistory.UpdateClearText( openRecentMenu, _( "Clear Recent Files" ) );
74
75 fileMenu->Add( ACTIONS::doNew );
76 fileMenu->Add( ACTIONS::open );
77
78 wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
79
80 // Add the file menu condition here since it needs the item ID for the submenu
82 cond.Enable( FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
83 RegisterUIUpdateHandler( item->GetId(), cond );
84 fileMenu->AppendSeparator();
85 }
86
87 fileMenu->Add( ACTIONS::save );
88
89 if( Kiface().IsSingle() )
90 fileMenu->Add( ACTIONS::saveAs );
91 else
93
94 fileMenu->Add( ACTIONS::revert );
95
96 fileMenu->AppendSeparator();
97
98 // Import submenu
99 ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
100 submenuImport->SetTitle( _( "Import" ) );
101 submenuImport->SetIcon( BITMAPS::import );
102
103 submenuImport->Add( _( "Non-KiCad Schematic..." ),
104 _( "Replace current schematic sheet with one imported from another application" ),
107
108 submenuImport->Add( SCH_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL, _( "Footprint Assignments..." ) );
109 submenuImport->Add( SCH_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
110
111 fileMenu->Add( submenuImport );
112
113
114 // Export submenu
115 ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
116 submenuExport->SetTitle( _( "Export" ) );
117 submenuExport->SetIcon( BITMAPS::export_file );
118 submenuExport->Add( SCH_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );
119 submenuExport->Add( SCH_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
120 submenuExport->Add( SCH_ACTIONS::exportSymbolsToLibrary, ACTION_MENU::NORMAL, _( "Symbols..." ) );
121 fileMenu->Add( submenuExport );
122
123 fileMenu->AppendSeparator();
124 fileMenu->Add( SCH_ACTIONS::schematicSetup );
125
126 fileMenu->AppendSeparator();
127 fileMenu->Add( ACTIONS::pageSettings );
128 fileMenu->Add( ACTIONS::print );
129 fileMenu->Add( ACTIONS::plot );
130
131 fileMenu->AppendSeparator();
132 fileMenu->AddQuitOrClose( &Kiface(), _( "Schematic Editor" ) );
133
134
135 //-- Edit menu -----------------------------------------------------------
136 //
137 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
138
139 editMenu->Add( ACTIONS::undo );
140 editMenu->Add( ACTIONS::redo );
141
142 editMenu->AppendSeparator();
143 editMenu->Add( ACTIONS::cut );
144 editMenu->Add( ACTIONS::copy );
145 editMenu->Add( ACTIONS::copyAsText );
146 editMenu->Add( ACTIONS::paste );
147 editMenu->Add( ACTIONS::pasteSpecial );
148 editMenu->Add( ACTIONS::doDelete );
149
150 editMenu->AppendSeparator();
151 editMenu->Add( ACTIONS::selectAll );
152 editMenu->Add( ACTIONS::unselectAll );
153
154 editMenu->AppendSeparator();
155 editMenu->Add( ACTIONS::find );
156 editMenu->Add( ACTIONS::findAndReplace );
157
158 editMenu->AppendSeparator();
159 editMenu->Add( ACTIONS::deleteTool );
161 editMenu->Add( SCH_ACTIONS::changeSymbols );
162 editMenu->Add( SCH_ACTIONS::editPageNumber );
163
164 ACTION_MENU* submenuAttributes = new ACTION_MENU( false, selTool );
165 submenuAttributes->SetTitle( _( "Attributes" ) );
166
170 submenuAttributes->Add( SCH_ACTIONS::setDNP, ACTION_MENU::CHECK );
171
172 editMenu->Add( submenuAttributes );
173
174 //-- View menu -----------------------------------------------------------
175 //
176 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
177
178 // Show / Hide Panels submenu
179 ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
180 showHidePanels->SetTitle( _( "Panels" ) );
181
183 showHidePanels->Add( ACTIONS::showSearch, ACTION_MENU::CHECK );
185
186 if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
188
189 showHidePanels->Add( SCH_ACTIONS::showDesignBlockPanel, ACTION_MENU::CHECK, _( "Design Blocks" ) );
190
191 viewMenu->Add( showHidePanels );
192
193 viewMenu->AppendSeparator();
194 viewMenu->Add( ACTIONS::showSymbolBrowser );
195
196 viewMenu->AppendSeparator();
197 viewMenu->Add( ACTIONS::zoomInCenter );
198 viewMenu->Add( ACTIONS::zoomOutCenter );
199 viewMenu->Add( ACTIONS::zoomFitScreen );
200 viewMenu->Add( ACTIONS::zoomFitObjects );
201 viewMenu->Add( ACTIONS::zoomFitSelection );
202 viewMenu->Add( ACTIONS::zoomTool );
203 viewMenu->Add( ACTIONS::zoomRedraw );
204
205 viewMenu->AppendSeparator();
206 viewMenu->Add( SCH_ACTIONS::navigateBack );
207 viewMenu->Add( SCH_ACTIONS::navigateUp );
210 viewMenu->Add( SCH_ACTIONS::navigateNext );
211
212
213
214 viewMenu->AppendSeparator();
225
226#ifdef __APPLE__
227 viewMenu->AppendSeparator();
228#endif
229
230 //-- Place menu -----------------------------------------------------------
231 //
232 ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
233
234 placeMenu->Add( SCH_ACTIONS::placeSymbol );
235 placeMenu->Add( SCH_ACTIONS::placePower );
236 placeMenu->Add( SCH_ACTIONS::drawWire );
237 placeMenu->Add( SCH_ACTIONS::drawBus );
239 placeMenu->Add( SCH_ACTIONS::placeNoConnect );
240 placeMenu->Add( SCH_ACTIONS::placeJunction );
241 placeMenu->Add( SCH_ACTIONS::placeLabel );
243 placeMenu->Add( SCH_ACTIONS::placeClassLabel );
244 placeMenu->Add( SCH_ACTIONS::drawRuleArea );
245
246 placeMenu->AppendSeparator();
247 placeMenu->Add( SCH_ACTIONS::placeHierLabel );
248 placeMenu->Add( SCH_ACTIONS::drawSheet );
249 placeMenu->Add( SCH_ACTIONS::placeSheetPin );
251 placeMenu->Add( SCH_ACTIONS::importSheet );
252
253 placeMenu->AppendSeparator();
255 placeMenu->Add( SCH_ACTIONS::drawTextBox );
256 placeMenu->Add( SCH_ACTIONS::drawTable );
257 placeMenu->Add( SCH_ACTIONS::drawRectangle );
258 placeMenu->Add( SCH_ACTIONS::drawCircle );
259 placeMenu->Add( SCH_ACTIONS::drawArc );
260 placeMenu->Add( SCH_ACTIONS::drawBezier );
261 placeMenu->Add( SCH_ACTIONS::drawLines );
262 placeMenu->Add( SCH_ACTIONS::placeImage );
263
264
265 //-- Inspect menu -----------------------------------------------
266 //
267 ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
268
269 inspectMenu->Add( SCH_ACTIONS::showBusSyntaxHelp );
270
271 inspectMenu->AppendSeparator();
272 inspectMenu->Add( SCH_ACTIONS::runERC );
273 inspectMenu->Add( ACTIONS::prevMarker );
274 inspectMenu->Add( ACTIONS::nextMarker );
275 inspectMenu->Add( ACTIONS::excludeMarker );
276
277 inspectMenu->AppendSeparator();
278 inspectMenu->Add( SCH_ACTIONS::diffSymbol );
279
280 inspectMenu->AppendSeparator();
281 inspectMenu->Add( SCH_ACTIONS::showSimulator );
282
283
284 //-- Tools menu -----------------------------------------------
285 //
286 ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
287
288 toolsMenu->Add( ACTIONS::updatePcbFromSchematic )->Enable( !Kiface().IsSingle() );
289 toolsMenu->Add( SCH_ACTIONS::showPcbNew );
290
291 if( !Kiface().IsSingle() )
292 toolsMenu->Add( ACTIONS::showProjectManager );
293
294 toolsMenu->Add( ACTIONS::showCalculatorTools );
295
296 toolsMenu->AppendSeparator();
297 toolsMenu->Add( ACTIONS::showSymbolEditor );
298 toolsMenu->Add( SCH_ACTIONS::updateSymbols );
299
300 toolsMenu->AppendSeparator();
301 toolsMenu->Add( SCH_ACTIONS::rescueSymbols );
302 toolsMenu->Add( SCH_ACTIONS::remapSymbols );
303
304 if( ADVANCED_CFG::GetCfg().m_ShowRepairSchematic )
305 toolsMenu->Add( SCH_ACTIONS::repairSchematic );
306
307 toolsMenu->AppendSeparator();
310
311 toolsMenu->AppendSeparator();
312 toolsMenu->Add( SCH_ACTIONS::annotate );
314
315 toolsMenu->AppendSeparator();
317 toolsMenu->Add( SCH_ACTIONS::generateBOM );
319
320 toolsMenu->AppendSeparator();
321 toolsMenu->Add( ACTIONS::updateSchematicFromPcb )->Enable( !Kiface().IsSingle() );
322
323#ifdef KICAD_IPC_API
324 toolsMenu->AppendSeparator();
325 toolsMenu->Add( ACTIONS::pluginsReload );
326#endif
327
328 //-- Preferences menu -----------------------------------------------
329 //
330 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
331
332 prefsMenu->Add( ACTIONS::configurePaths );
333 prefsMenu->Add( ACTIONS::showSymbolLibTable );
335 prefsMenu->Add( ACTIONS::openPreferences );
336
337 prefsMenu->AppendSeparator();
338 AddMenuLanguageList( prefsMenu, selTool );
339
340
341 //-- Menubar -------------------------------------------------------------
342 //
343 menuBar->Append( fileMenu, _( "&File" ) );
344 menuBar->Append( editMenu, _( "&Edit" ) );
345 menuBar->Append( viewMenu, _( "&View" ) );
346 menuBar->Append( placeMenu, _( "&Place" ) );
347 menuBar->Append( inspectMenu, _( "&Inspect" ) );
348 menuBar->Append( toolsMenu, _( "&Tools" ) );
349 menuBar->Append( prefsMenu, _( "P&references" ) );
350 AddStandardHelpMenu( menuBar );
351
352 SetMenuBar( menuBar );
353 delete oldMenuBar;
354}
355
356
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ import_document
static TOOL_ACTION showCalculatorTools
Definition actions.h:262
static TOOL_ACTION updatePcbFromSchematic
Definition actions.h:263
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION excludeMarker
Definition actions.h:128
static TOOL_ACTION nextMarker
Definition actions.h:127
static TOOL_ACTION zoomRedraw
Definition actions.h:131
static TOOL_ACTION unselectAll
Definition actions.h:83
static TOOL_ACTION revert
Definition actions.h:62
static TOOL_ACTION zoomOutCenter
Definition actions.h:135
static TOOL_ACTION saveAs
Definition actions.h:59
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION pluginsReload
Definition actions.h:295
static TOOL_ACTION showSymbolLibTable
Definition actions.h:283
static TOOL_ACTION showSymbolEditor
Definition actions.h:259
static TOOL_ACTION showSymbolBrowser
Definition actions.h:258
static TOOL_ACTION pasteSpecial
Definition actions.h:81
static TOOL_ACTION zoomFitSelection
Definition actions.h:143
static TOOL_ACTION findAndReplace
Definition actions.h:117
static TOOL_ACTION openPreferences
Definition actions.h:281
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:115
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION prevMarker
Definition actions.h:126
static TOOL_ACTION doDelete
Definition actions.h:85
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION updateSchematicFromPcb
Definition actions.h:264
static TOOL_ACTION showDesignBlockLibTable
Definition actions.h:285
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION showProperties
Definition actions.h:265
static TOOL_ACTION doNew
Definition actions.h:54
static TOOL_ACTION zoomFitObjects
Definition actions.h:142
static TOOL_ACTION zoomInCenter
Definition actions.h:134
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION configurePaths
Definition actions.h:282
static TOOL_ACTION showProjectManager
Definition actions.h:256
static TOOL_ACTION copyAsText
Definition actions.h:79
static TOOL_ACTION selectAll
Definition actions.h:82
static TOOL_ACTION find
Definition actions.h:116
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 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 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 diffSymbol
static TOOL_ACTION placePower
Definition sch_actions.h:68
static TOOL_ACTION navigateUp
void doReCreateMenuBar() override
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)