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 (C) 1992-2022 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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <bitmaps.h>
27#include <tool/action_menu.h>
28#include <tool/tool_manager.h>
29#include <tools/ee_actions.h>
32#include "symbol_edit_frame.h"
33#include <widgets/wx_menubar.h>
34
35
37{
39 // wxWidgets handles the Mac Application menu behind the scenes, but that means
40 // we always have to start from scratch with a new wxMenuBar.
41 wxMenuBar* oldMenuBar = GetMenuBar();
42 WX_MENUBAR* menuBar = new WX_MENUBAR();
43
44 //-- File menu -----------------------------------------------
45 //
46 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
47
48 fileMenu->Add( ACTIONS::newLibrary );
49 fileMenu->Add( ACTIONS::addLibrary );
50 fileMenu->Add( EE_ACTIONS::saveLibraryAs );
51 fileMenu->Add( EE_ACTIONS::newSymbol );
52
53 fileMenu->AppendSeparator();
54 fileMenu->Add( ACTIONS::save );
56
58 fileMenu->Add( ACTIONS::saveAll );
59
60 fileMenu->Add( ACTIONS::revert );
61
62 fileMenu->AppendSeparator();
63
64 ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
65 submenuImport->SetTitle( _( "Import" ) );
66 submenuImport->SetIcon( BITMAPS::import );
67
68 submenuImport->Add( EE_ACTIONS::importSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
69 submenuImport->Add( EE_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
70
71 fileMenu->Add( submenuImport );
72
73 // Export submenu
74 ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
75 submenuExport->SetTitle( _( "Export" ) );
76 submenuExport->SetIcon( BITMAPS::export_file );
77 submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
78 submenuExport->Add( EE_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) );
79 submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) );
80 fileMenu->Add( submenuExport );
81
82 fileMenu->AppendSeparator();
84
85 fileMenu->AppendSeparator();
86 fileMenu->AddClose( _( "Library Editor" ) );
87
88
89 //-- Edit menu -----------------------------------------------
90 //
91 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
92
93 editMenu->Add( ACTIONS::undo );
94 editMenu->Add( ACTIONS::redo );
95
96 editMenu->AppendSeparator();
97 editMenu->Add( ACTIONS::cut );
98 editMenu->Add( ACTIONS::copy );
99 editMenu->Add( ACTIONS::paste );
100 editMenu->Add( ACTIONS::doDelete );
101 editMenu->Add( ACTIONS::duplicate );
102
103 editMenu->AppendSeparator();
104 editMenu->Add( ACTIONS::selectAll );
105 editMenu->Add( ACTIONS::unselectAll );
106
107 editMenu->AppendSeparator();
108 editMenu->Add( EE_ACTIONS::pinTable );
111
112
113 //-- View menu -----------------------------------------------
114 //
115 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
116
117 viewMenu->Add( ACTIONS::showSymbolBrowser );
119
120 viewMenu->AppendSeparator();
121 viewMenu->Add( ACTIONS::zoomInCenter );
122 viewMenu->Add( ACTIONS::zoomOutCenter );
123 viewMenu->Add( ACTIONS::zoomFitScreen );
124 viewMenu->Add( ACTIONS::zoomTool );
125 viewMenu->Add( ACTIONS::zoomRedraw );
126
127 viewMenu->AppendSeparator();
131
132
133 //-- Place menu -----------------------------------------------
134 //
135 ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
136
137 placeMenu->Add( EE_ACTIONS::placeSymbolPin );
138 placeMenu->Add( EE_ACTIONS::placeSymbolText );
140 placeMenu->Add( EE_ACTIONS::drawRectangle );
141 placeMenu->Add( EE_ACTIONS::drawCircle );
142 placeMenu->Add( EE_ACTIONS::drawArc );
143 placeMenu->Add( EE_ACTIONS::drawSymbolLines );
145
146
147 //-- Inspect menu -----------------------------------------------
148 //
149 ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
150
151 inspectMenu->Add( EE_ACTIONS::showDatasheet );
152
153 inspectMenu->AppendSeparator();
154 inspectMenu->Add( EE_ACTIONS::checkSymbol );
155
156
157 //-- Preferences menu -----------------------------------------------
158 //
159 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
160
161 prefsMenu->Add( ACTIONS::configurePaths );
162 prefsMenu->Add( ACTIONS::showSymbolLibTable );
163 prefsMenu->Add( ACTIONS::openPreferences );
164
165 prefsMenu->AppendSeparator();
166 AddMenuLanguageList( prefsMenu, selTool );
167
168
169 //-- Menubar -------------------------------------------------------------
170 //
171 menuBar->Append( fileMenu, _( "&File" ) );
172 menuBar->Append( editMenu, _( "&Edit" ) );
173 menuBar->Append( viewMenu, _( "&View" ) );
174 menuBar->Append( placeMenu, _( "&Place" ) );
175 menuBar->Append( inspectMenu, _( "&Inspect" ) );
176 menuBar->Append( prefsMenu, _( "P&references" ) );
177 AddStandardHelpMenu( menuBar );
178
179 SetMenuBar( menuBar );
180 delete oldMenuBar;
181}
static TOOL_ACTION paste
Definition: actions.h:70
static TOOL_ACTION zoomRedraw
Definition: actions.h:114
static TOOL_ACTION unselectAll
Definition: actions.h:73
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION zoomOutCenter
Definition: actions.h:118
static TOOL_ACTION addLibrary
Definition: actions.h:49
static TOOL_ACTION copy
Definition: actions.h:69
static TOOL_ACTION showSymbolLibTable
Definition: actions.h:213
static TOOL_ACTION showSymbolBrowser
Definition: actions.h:195
static TOOL_ACTION openPreferences
Definition: actions.h:211
static TOOL_ACTION saveAll
Definition: actions.h:54
static TOOL_ACTION undo
Definition: actions.h:66
static TOOL_ACTION duplicate
Definition: actions.h:74
static TOOL_ACTION doDelete
Definition: actions.h:75
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:124
static TOOL_ACTION redo
Definition: actions.h:67
static TOOL_ACTION zoomTool
Definition: actions.h:127
static TOOL_ACTION showProperties
Definition: actions.h:201
static TOOL_ACTION zoomInCenter
Definition: actions.h:117
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION cut
Definition: actions.h:68
static TOOL_ACTION configurePaths
Definition: actions.h:212
static TOOL_ACTION selectAll
Definition: actions.h:72
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
static constexpr bool CHECK
Definition: action_menu.h:201
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.
Definition: action_menu.cpp:92
static constexpr bool NORMAL
Definition: action_menu.h:200
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:78
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)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
void SetMenuBar(wxMenuBar *menu_bar) override
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
static TOOL_ACTION pinTable
Definition: ee_actions.h:156
static TOOL_ACTION showHiddenFields
Definition: ee_actions.h:237
static TOOL_ACTION drawSymbolPolygon
Definition: ee_actions.h:116
static TOOL_ACTION newSymbol
Definition: ee_actions.h:202
static TOOL_ACTION drawCircle
Definition: ee_actions.h:101
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:200
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:113
static TOOL_ACTION importGraphics
Definition: ee_actions.h:255
static TOOL_ACTION exportSymbolAsSVG
Definition: ee_actions.h:257
static TOOL_ACTION importSymbol
Definition: ee_actions.h:211
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:150
static TOOL_ACTION saveSymbolCopyAs
Definition: ee_actions.h:201
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:155
static TOOL_ACTION checkSymbol
Definition: ee_actions.h:165
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:100
static TOOL_ACTION setUnitDisplayName
Definition: ee_actions.h:214
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:114
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:115
static TOOL_ACTION drawArc
Definition: ee_actions.h:102
static TOOL_ACTION exportSymbol
Definition: ee_actions.h:212
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:252
static TOOL_ACTION showHiddenPins
Definition: ee_actions.h:236
static TOOL_ACTION updateSymbolFields
Definition: ee_actions.h:213
static TOOL_ACTION exportSymbolView
Definition: ee_actions.h:256
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:112
bool IsSymbolFromSchematic() const
void doReCreateMenuBar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:47
#define _(s)