-
-
Notifications
You must be signed in to change notification settings - Fork 491
/
menubar.cpp
376 lines (295 loc) · 13.9 KB
/
menubar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009 Wayne Stambaugh <[email protected]>
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019 CERN
*
* 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
*/
#include <bitmaps.h>
#include <file_history.h>
#include <kiface_base.h>
#include <schematic.h>
#include <tool/action_manager.h>
#include <tool/action_menu.h>
#include <tool/tool_manager.h>
#include <tools/ee_selection_tool.h>
#include <tools/ee_actions.h>
#include "eeschema_id.h"
#include "sch_edit_frame.h"
#include <widgets/wx_menubar.h>
#include <advanced_config.h>
void SCH_EDIT_FRAME::doReCreateMenuBar()
{
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
// wxWidgets handles the Mac Application menu behind the scenes, but that means
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
WX_MENUBAR* menuBar = new WX_MENUBAR();
//-- File menu -----------------------------------------------------------
//
ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
static ACTION_MENU* openRecentMenu;
if( Kiface().IsSingle() ) // When not under a project mgr
{
FILE_HISTORY& fileHistory = GetFileHistory();
// 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)
if( !openRecentMenu )
{
openRecentMenu = new ACTION_MENU( false, selTool );
openRecentMenu->SetIcon( BITMAPS::recent );
fileHistory.UseMenu( openRecentMenu );
fileHistory.AddFilesToMenu( openRecentMenu );
}
// Ensure the title is up to date after changing language
openRecentMenu->SetTitle( _( "Open Recent" ) );
fileHistory.UpdateClearText( openRecentMenu, _( "Clear Recent Files" ) );
fileMenu->Add( ACTIONS::doNew );
fileMenu->Add( ACTIONS::open );
wxMenuItem* item = fileMenu->Add( openRecentMenu->Clone() );
// 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();
}
fileMenu->Add( ACTIONS::save );
if( Kiface().IsSingle() )
fileMenu->Add( ACTIONS::saveAs );
else
fileMenu->Add( EE_ACTIONS::saveCurrSheetCopyAs );
fileMenu->Add( ACTIONS::revert );
fileMenu->AppendSeparator();
// Import submenu
ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( BITMAPS::import );
submenuImport->Add( _( "Non-KiCad Schematic..." ),
_( "Replace current schematic sheet with one imported from another application" ),
ID_IMPORT_NON_KICAD_SCH,
BITMAPS::import_document );
submenuImport->Add( EE_ACTIONS::importFPAssignments, ACTION_MENU::NORMAL,
_( "Footprint Assignments..." ) );
submenuImport->Add( EE_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
fileMenu->Add( submenuImport );
// Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( BITMAPS::export_file );
submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL,
_( "Drawing to Clipboard" ) );
submenuExport->Add( EE_ACTIONS::exportNetlist, ACTION_MENU::NORMAL, _( "Netlist..." ) );
submenuExport->Add( EE_ACTIONS::exportSymbolsToLibrary, ACTION_MENU::NORMAL,
_( "Symbols to Library..." ) );
submenuExport->Add( EE_ACTIONS::exportSymbolsToNewLibrary, ACTION_MENU::NORMAL,
_( "Symbols to New Library..." ) );
fileMenu->Add( submenuExport );
fileMenu->AppendSeparator();
fileMenu->Add( EE_ACTIONS::schematicSetup );
fileMenu->AppendSeparator();
fileMenu->Add( ACTIONS::pageSettings );
fileMenu->Add( ACTIONS::print );
fileMenu->Add( ACTIONS::plot );
fileMenu->AppendSeparator();
fileMenu->AddQuitOrClose( &Kiface(), _( "Schematic Editor" ) );
//-- Edit menu -----------------------------------------------------------
//
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::copyAsText );
editMenu->Add( ACTIONS::paste );
editMenu->Add( ACTIONS::pasteSpecial );
editMenu->Add( ACTIONS::doDelete );
editMenu->AppendSeparator();
editMenu->Add( ACTIONS::selectAll );
editMenu->Add( ACTIONS::unselectAll );
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 );
editMenu->Add( EE_ACTIONS::editPageNumber );
ACTION_MENU* submenuAttributes = new ACTION_MENU( false, selTool );
submenuAttributes->SetTitle( _( "Attributes" ) );
submenuAttributes->Add( EE_ACTIONS::setExcludeFromSimulation );
submenuAttributes->Add( EE_ACTIONS::unsetExcludeFromSimulation );
submenuAttributes->Add( EE_ACTIONS::toggleExcludeFromSimulation );
submenuAttributes->AppendSeparator();
submenuAttributes->Add( EE_ACTIONS::setExcludeFromBOM );
submenuAttributes->Add( EE_ACTIONS::unsetExcludeFromBOM );
submenuAttributes->Add( EE_ACTIONS::toggleExcludeFromBOM );
submenuAttributes->AppendSeparator();
submenuAttributes->Add( EE_ACTIONS::setExcludeFromBoard );
submenuAttributes->Add( EE_ACTIONS::unsetExcludeFromBoard );
submenuAttributes->Add( EE_ACTIONS::toggleExcludeFromBoard );
submenuAttributes->AppendSeparator();
submenuAttributes->Add( EE_ACTIONS::setDNP );
submenuAttributes->Add( EE_ACTIONS::unsetDNP );
submenuAttributes->Add( EE_ACTIONS::toggleDNP );
editMenu->Add( submenuAttributes );
//-- View menu -----------------------------------------------------------
//
ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
// Show / Hide Panels submenu
ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
showHidePanels->SetTitle( _( "Panels" ) );
showHidePanels->Add( ACTIONS::showProperties, ACTION_MENU::CHECK );
showHidePanels->Add( ACTIONS::showSearch, ACTION_MENU::CHECK );
showHidePanels->Add( EE_ACTIONS::showHierarchy, ACTION_MENU::CHECK );
if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
showHidePanels->Add( EE_ACTIONS::showNetNavigator, ACTION_MENU::CHECK );
if( ADVANCED_CFG::GetCfg().m_EnableDesignBlocks )
showHidePanels->Add( EE_ACTIONS::showDesignBlockPanel, ACTION_MENU::CHECK, _( "Design Blocks" ) );
viewMenu->Add( showHidePanels );
viewMenu->AppendSeparator();
viewMenu->Add( ACTIONS::showSymbolBrowser );
viewMenu->AppendSeparator();
viewMenu->Add( ACTIONS::zoomInCenter );
viewMenu->Add( ACTIONS::zoomOutCenter );
viewMenu->Add( ACTIONS::zoomFitScreen );
viewMenu->Add( ACTIONS::zoomFitObjects );
viewMenu->Add( ACTIONS::zoomTool );
viewMenu->Add( ACTIONS::zoomRedraw );
viewMenu->AppendSeparator();
viewMenu->Add( EE_ACTIONS::navigateBack );
viewMenu->Add( EE_ACTIONS::navigateUp );
viewMenu->Add( EE_ACTIONS::navigateForward );
viewMenu->Add( EE_ACTIONS::navigatePrevious );
viewMenu->Add( EE_ACTIONS::navigateNext );
viewMenu->AppendSeparator();
viewMenu->Add( EE_ACTIONS::toggleHiddenPins, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::toggleHiddenFields, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::toggleDirectiveLabels, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::toggleERCErrors, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::toggleERCWarnings, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::toggleERCExclusions, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::markSimExclusions, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::toggleOPVoltages, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::toggleOPCurrents, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::togglePinAltIcons, ACTION_MENU::CHECK );
#ifdef __APPLE__
viewMenu->AppendSeparator();
#endif
//-- Place menu -----------------------------------------------------------
//
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->Add( EE_ACTIONS::placeClassLabel );
placeMenu->Add( EE_ACTIONS::drawRuleArea );
placeMenu->AppendSeparator();
placeMenu->Add( EE_ACTIONS::placeHierLabel );
placeMenu->Add( EE_ACTIONS::drawSheet );
placeMenu->Add( EE_ACTIONS::placeSheetPin );
placeMenu->Add( EE_ACTIONS::syncAllSheetsPins );
placeMenu->Add( EE_ACTIONS::importSheet );
placeMenu->AppendSeparator();
placeMenu->Add( EE_ACTIONS::placeSchematicText );
placeMenu->Add( EE_ACTIONS::drawTextBox );
placeMenu->Add( EE_ACTIONS::drawTable );
placeMenu->Add( EE_ACTIONS::drawRectangle );
placeMenu->Add( EE_ACTIONS::drawCircle );
placeMenu->Add( EE_ACTIONS::drawArc );
placeMenu->Add( EE_ACTIONS::drawBezier );
placeMenu->Add( EE_ACTIONS::drawLines );
placeMenu->Add( EE_ACTIONS::placeImage );
//-- Inspect menu -----------------------------------------------
//
ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
inspectMenu->Add( EE_ACTIONS::showBusSyntaxHelp );
inspectMenu->AppendSeparator();
inspectMenu->Add( EE_ACTIONS::runERC );
inspectMenu->Add( ACTIONS::prevMarker );
inspectMenu->Add( ACTIONS::nextMarker );
inspectMenu->Add( ACTIONS::excludeMarker );
inspectMenu->AppendSeparator();
inspectMenu->Add( EE_ACTIONS::diffSymbol );
inspectMenu->AppendSeparator();
inspectMenu->Add( EE_ACTIONS::showSimulator );
//-- Tools menu -----------------------------------------------
//
ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
wxMenuItem* update = toolsMenu->Add( ACTIONS::updatePcbFromSchematic );
update->Enable( !Kiface().IsSingle() );
toolsMenu->Add( EE_ACTIONS::showPcbNew );
if( !Kiface().IsSingle() )
toolsMenu->Add( ACTIONS::showProjectManager );
toolsMenu->AppendSeparator();
toolsMenu->Add( ACTIONS::showSymbolEditor );
toolsMenu->Add( EE_ACTIONS::updateSymbols );
toolsMenu->AppendSeparator();
toolsMenu->Add( EE_ACTIONS::rescueSymbols );
toolsMenu->Add( EE_ACTIONS::remapSymbols );
if( ADVANCED_CFG::GetCfg().m_ShowRepairSchematic )
toolsMenu->Add( EE_ACTIONS::repairSchematic );
toolsMenu->AppendSeparator();
toolsMenu->Add( EE_ACTIONS::editSymbolFields );
toolsMenu->Add( EE_ACTIONS::editSymbolLibraryLinks );
toolsMenu->AppendSeparator();
toolsMenu->Add( EE_ACTIONS::annotate );
toolsMenu->Add( EE_ACTIONS::incrementAnnotations );
toolsMenu->AppendSeparator();
toolsMenu->Add( EE_ACTIONS::assignFootprints );
toolsMenu->Add( EE_ACTIONS::generateBOM );
toolsMenu->Add( EE_ACTIONS::generateBOMLegacy );
toolsMenu->AppendSeparator();
update = toolsMenu->Add( ACTIONS::updateSchematicFromPcb );
update->Enable( !Kiface().IsSingle() );
#ifdef KICAD_IPC_API
toolsMenu->AppendSeparator();
toolsMenu->Add( ACTIONS::pluginsReload );
#endif
//-- Preferences menu -----------------------------------------------
//
ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showSymbolLibTable );
if( ADVANCED_CFG::GetCfg().m_EnableDesignBlocks )
prefsMenu->Add( ACTIONS::showDesignBlockLibTable );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool );
//-- Menubar -------------------------------------------------------------
//
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( toolsMenu, _( "&Tools" ) );
menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar );
delete oldMenuBar;
}