KiCad PCB EDA Suite
Loading...
Searching...
No Matches
menubar_symbol_editor.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) 2007 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2009 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <bitmaps.h>
23#include <pgm_base.h>
25#include <tool/action_menu.h>
26#include <tool/tool_manager.h>
27#include <tool/actions.h>
28#include <tools/sch_actions.h>
31#include "symbol_edit_frame.h"
32#include <widgets/wx_menubar.h>
33
34
36{
38 // wxWidgets handles the Mac Application menu behind the scenes, but that means
39 // we always have to start from scratch with a new wxMenuBar.
40 wxMenuBar* oldMenuBar = GetMenuBar();
41 WX_MENUBAR* menuBar = new WX_MENUBAR();
42
43 //-- File menu -----------------------------------------------
44 //
45 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
46
47 fileMenu->Add( ACTIONS::newLibrary );
48 fileMenu->Add( ACTIONS::addLibrary );
50 fileMenu->Add( SCH_ACTIONS::newSymbol );
52
53 fileMenu->AppendSeparator();
54 fileMenu->Add( ACTIONS::save );
55 fileMenu->Add( SCH_ACTIONS::saveSymbolAs );
57
59 fileMenu->Add( ACTIONS::saveAll );
60
61 fileMenu->Add( ACTIONS::revert );
62
63 fileMenu->AppendSeparator();
64
65 ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
66 submenuImport->SetTitle( _( "Import" ) );
67 submenuImport->SetIcon( BITMAPS::import );
68
69 submenuImport->Add( SCH_ACTIONS::importSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
70 submenuImport->Add( SCH_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
71
72 fileMenu->Add( submenuImport );
73
74 // Export submenu
75 ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
76 submenuExport->SetTitle( _( "Export" ) );
77 submenuExport->SetIcon( BITMAPS::export_file );
78 submenuExport->Add( SCH_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
79 submenuExport->Add( SCH_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) );
80 submenuExport->Add( SCH_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) );
81 submenuExport->Add( ACTIONS::exportForOlderVersion, ACTION_MENU::NORMAL, _( "For Older KiCad Version..." ) );
82 fileMenu->Add( submenuExport );
83
84 fileMenu->AppendSeparator();
86
87 fileMenu->AppendSeparator();
89
90 fileMenu->AppendSeparator();
91 fileMenu->AddClose( _( "Symbol Editor" ) );
92
93
94 //-- Edit menu -----------------------------------------------
95 //
96 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
97
98 editMenu->Add( ACTIONS::undo );
99 editMenu->Add( ACTIONS::redo );
100
101 editMenu->AppendSeparator();
102 editMenu->Add( ACTIONS::cut );
103 editMenu->Add( ACTIONS::copy );
104 editMenu->Add( ACTIONS::copyAsText );
105 editMenu->Add( ACTIONS::paste );
106 editMenu->Add( ACTIONS::doDelete );
107 editMenu->Add( ACTIONS::duplicate );
108
109 editMenu->AppendSeparator();
110 editMenu->Add( ACTIONS::selectAll );
111 editMenu->Add( ACTIONS::unselectAll );
112
113 editMenu->AppendSeparator();
114 editMenu->Add( ACTIONS::find );
115 editMenu->Add( ACTIONS::findAndReplace );
116
117 editMenu->AppendSeparator();
118 editMenu->Add( SCH_ACTIONS::pinTable );
121
122
123 //-- View menu -----------------------------------------------
124 //
125 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
126
127 ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
128 showHidePanels->SetTitle( _( "Panels" ) );
131 viewMenu->Add( showHidePanels );
132 viewMenu->AppendSeparator();
133
134 viewMenu->Add( ACTIONS::showSymbolBrowser );
135
136 viewMenu->AppendSeparator();
137 viewMenu->Add( ACTIONS::zoomInCenter );
138 viewMenu->Add( ACTIONS::zoomOutCenter );
139 viewMenu->Add( ACTIONS::zoomFitScreen );
140 viewMenu->Add( ACTIONS::zoomTool );
141 viewMenu->Add( ACTIONS::zoomRedraw );
142
143 viewMenu->AppendSeparator();
147
148 viewMenu->AppendSeparator();
149 viewMenu->Add( SCH_ACTIONS::nextSymbolTab );
150 viewMenu->Add( SCH_ACTIONS::prevSymbolTab );
151 viewMenu->Add( SCH_ACTIONS::closeSymbolTab );
152
153
154 //-- Place menu -----------------------------------------------
155 //
156 ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
157
158 placeMenu->Add( SCH_ACTIONS::placeSymbolPin );
159 placeMenu->Add( SCH_ACTIONS::placeSymbolText );
161 placeMenu->Add( SCH_ACTIONS::drawRectangle );
162 placeMenu->Add( SCH_ACTIONS::drawCircle );
163 placeMenu->Add( SCH_ACTIONS::drawEllipse );
164 placeMenu->Add( SCH_ACTIONS::drawEllipseArc );
165 placeMenu->Add( SCH_ACTIONS::drawArc );
166 placeMenu->Add( SCH_ACTIONS::drawBezier );
167 placeMenu->Add( SCH_ACTIONS::drawSymbolLines );
169
170
171 //-- Inspect menu -----------------------------------------------
172 //
173 ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
174
175 inspectMenu->Add( ACTIONS::showDatasheet );
176
177 inspectMenu->AppendSeparator();
178 inspectMenu->Add( SCH_ACTIONS::checkSymbol );
179
180
181 //-- Preferences menu -----------------------------------------------
182 //
183 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
184
185 prefsMenu->Add( ACTIONS::configurePaths );
186 prefsMenu->Add( ACTIONS::showSymbolLibTable );
187 prefsMenu->Add( ACTIONS::openPreferences );
188
189 prefsMenu->AppendSeparator();
190 AddMenuLanguageList( prefsMenu, selTool );
191
192 //-- Tools menu -----------------------------------------------
193 //
194 ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
195
196 ACTION_MENU* submenuActionPlugins = new ACTION_MENU( false, selTool );
197 submenuActionPlugins->SetTitle( _( "External Plugins" ) );
198 submenuActionPlugins->SetIcon( BITMAPS::puzzle_piece );
199
200 if( Pgm().GetCommonSettings()->m_Api.enable_server && AddApiPluginMenuItems( submenuActionPlugins ) > 0 )
201 submenuActionPlugins->AppendSeparator();
202
203 submenuActionPlugins->Add( ACTIONS::pluginsReload );
204 submenuActionPlugins->Add( ACTIONS::pluginsShowFolder );
205
206 toolsMenu->Add( submenuActionPlugins );
207
208 //-- Menubar -------------------------------------------------------------
209 //
210 menuBar->Append( fileMenu, _( "&File" ) );
211 menuBar->Append( editMenu, _( "&Edit" ) );
212 menuBar->Append( viewMenu, _( "&View" ) );
213 menuBar->Append( placeMenu, _( "&Place" ) );
214 menuBar->Append( toolsMenu, _( "&Tools" ) );
215 menuBar->Append( inspectMenu, _( "&Inspect" ) );
216 menuBar->Append( prefsMenu, _( "P&references" ) );
217 AddStandardHelpMenu( menuBar );
218
219 SetMenuBar( menuBar );
220 delete oldMenuBar;
221}
static TOOL_ACTION paste
Definition actions.h:77
static TOOL_ACTION zoomRedraw
Definition actions.h:129
static TOOL_ACTION unselectAll
Definition actions.h:80
static TOOL_ACTION revert
Definition actions.h:58
static TOOL_ACTION showLibraryTree
Definition actions.h:161
static TOOL_ACTION zoomOutCenter
Definition actions.h:133
static TOOL_ACTION exportForOlderVersion
Definition actions.h:60
static TOOL_ACTION addLibrary
Definition actions.h:52
static TOOL_ACTION copy
Definition actions.h:75
static TOOL_ACTION pluginsReload
Definition actions.h:295
static TOOL_ACTION showSymbolLibTable
Definition actions.h:283
static TOOL_ACTION showSymbolBrowser
Definition actions.h:256
static TOOL_ACTION showDatasheet
Definition actions.h:265
static TOOL_ACTION pluginsShowFolder
Definition actions.h:296
static TOOL_ACTION findAndReplace
Definition actions.h:115
static TOOL_ACTION openPreferences
Definition actions.h:281
static TOOL_ACTION saveAll
Definition actions.h:57
static TOOL_ACTION undo
Definition actions.h:72
static TOOL_ACTION duplicate
Definition actions.h:81
static TOOL_ACTION doDelete
Definition actions.h:82
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION zoomFitScreen
Definition actions.h:139
static TOOL_ACTION redo
Definition actions.h:73
static TOOL_ACTION zoomTool
Definition actions.h:143
static TOOL_ACTION showProperties
Definition actions.h:263
static TOOL_ACTION zoomInCenter
Definition actions.h:132
static TOOL_ACTION newLibrary
Definition actions.h:51
static TOOL_ACTION cut
Definition actions.h:74
static TOOL_ACTION configurePaths
Definition actions.h:282
static TOOL_ACTION copyAsText
Definition actions.h:76
static TOOL_ACTION selectAll
Definition actions.h:79
static TOOL_ACTION find
Definition actions.h:114
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:43
static constexpr bool CHECK
void AddClose(const wxString &aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.
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.
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Create a menu list for language choice, and add it as submenu to MasterMenu.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Add the standard KiCad help menu to the menubar.
size_t AddApiPluginMenuItems(ACTION_MENU *aMenu)
Append actions from API plugins to the given menu.
static TOOL_ACTION editSymbolPinMaps
static TOOL_ACTION importSymbol
static TOOL_ACTION newSymbol
static TOOL_ACTION saveLibraryAs
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION checkSymbol
static TOOL_ACTION editLibSymbolWithLibEdit
static TOOL_ACTION drawArc
static TOOL_ACTION pinTable
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION placeSymbolPin
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION exportSymbolAsSVG
static TOOL_ACTION drawRectangle
static TOOL_ACTION drawEllipse
static TOOL_ACTION drawCircle
static TOOL_ACTION importGraphics
static TOOL_ACTION closeSymbolTab
static TOOL_ACTION drawBezier
static TOOL_ACTION compareLibraryWithFile
static TOOL_ACTION saveSymbolCopyAs
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION showHiddenFields
static TOOL_ACTION prevSymbolTab
static TOOL_ACTION showHiddenPins
static TOOL_ACTION exportSymbolView
static TOOL_ACTION symbolProperties
static TOOL_ACTION placeSymbolText
static TOOL_ACTION nextSymbolTab
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION updateSymbolFields
static TOOL_ACTION exportSymbol
static TOOL_ACTION saveSymbolAs
bool IsSymbolFromSchematic() const
void doReCreateMenuBar() override
TOOL_MANAGER * m_toolManager
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition wx_menubar.h:43
#define _(s)
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE