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 <menus_helpers.h>
28#include <tool/action_menu.h>
29#include <tool/tool_manager.h>
30#include <tools/ee_actions.h>
33#include "symbol_edit_frame.h"
34#include <widgets/wx_menubar.h>
35
36
38{
40 // wxWidgets handles the Mac Application menu behind the scenes, but that means
41 // we always have to start from scratch with a new wxMenuBar.
42 wxMenuBar* oldMenuBar = GetMenuBar();
43 WX_MENUBAR* menuBar = new WX_MENUBAR();
44
45 //-- File menu -----------------------------------------------
46 //
47 ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
48
49 fileMenu->Add( ACTIONS::newLibrary );
50 fileMenu->Add( ACTIONS::addLibrary );
51 fileMenu->Add( EE_ACTIONS::saveLibraryAs );
52 fileMenu->Add( EE_ACTIONS::newSymbol );
53
54 fileMenu->AppendSeparator();
55 fileMenu->Add( ACTIONS::save );
56 fileMenu->Add( EE_ACTIONS::saveSymbolAs );
57
59 fileMenu->Add( ACTIONS::saveAll );
60
61 fileMenu->Add( ACTIONS::revert );
62
63 fileMenu->AppendSeparator();
64 fileMenu->Add( EE_ACTIONS::importSymbol );
65
66 // Export submenu
67 ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
68 submenuExport->SetTitle( _( "Export" ) );
69 submenuExport->SetIcon( BITMAPS::export_file );
70 submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
71 submenuExport->Add( EE_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) );
72 submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) );
73 fileMenu->Add( submenuExport );
74
75 fileMenu->AppendSeparator();
77
78 fileMenu->AppendSeparator();
79 fileMenu->AddClose( _( "Library Editor" ) );
80
81
82 //-- Edit menu -----------------------------------------------
83 //
84 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
85
86 editMenu->Add( ACTIONS::undo );
87 editMenu->Add( ACTIONS::redo );
88
89 editMenu->AppendSeparator();
90 editMenu->Add( ACTIONS::cut );
91 editMenu->Add( ACTIONS::copy );
92 editMenu->Add( ACTIONS::paste );
93 editMenu->Add( ACTIONS::doDelete );
94 editMenu->Add( ACTIONS::duplicate );
95
96 editMenu->AppendSeparator();
97 editMenu->Add( ACTIONS::selectAll );
98 editMenu->Add( ACTIONS::unselectAll );
99
100 editMenu->AppendSeparator();
101 editMenu->Add( EE_ACTIONS::pinTable );
104
105
106 //-- View menu -----------------------------------------------
107 //
108 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
109
110 viewMenu->Add( ACTIONS::showSymbolBrowser );
112
113 viewMenu->AppendSeparator();
114 viewMenu->Add( ACTIONS::zoomInCenter );
115 viewMenu->Add( ACTIONS::zoomOutCenter );
116 viewMenu->Add( ACTIONS::zoomFitScreen );
117 viewMenu->Add( ACTIONS::zoomTool );
118 viewMenu->Add( ACTIONS::zoomRedraw );
119
120 viewMenu->AppendSeparator();
122
123
124 //-- Place menu -----------------------------------------------
125 //
126 ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
127
128 placeMenu->Add( EE_ACTIONS::placeSymbolPin );
129 placeMenu->Add( EE_ACTIONS::placeSymbolText );
131 placeMenu->Add( EE_ACTIONS::drawRectangle );
132 placeMenu->Add( EE_ACTIONS::drawCircle );
133 placeMenu->Add( EE_ACTIONS::drawArc );
134 placeMenu->Add( EE_ACTIONS::drawSymbolLines );
136
137
138 //-- Inspect menu -----------------------------------------------
139 //
140 ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
141
142 inspectMenu->Add( EE_ACTIONS::showDatasheet );
143
144 inspectMenu->AppendSeparator();
145 inspectMenu->Add( EE_ACTIONS::checkSymbol );
146
147
148 //-- Preferences menu -----------------------------------------------
149 //
150 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
151
152 prefsMenu->Add( ACTIONS::configurePaths );
153 prefsMenu->Add( ACTIONS::showSymbolLibTable );
154 prefsMenu->Add( ACTIONS::openPreferences );
155
156 prefsMenu->AppendSeparator();
157 AddMenuLanguageList( prefsMenu, selTool );
158
159
160 //-- Menubar -------------------------------------------------------------
161 //
162 menuBar->Append( fileMenu, _( "&File" ) );
163 menuBar->Append( editMenu, _( "&Edit" ) );
164 menuBar->Append( viewMenu, _( "&View" ) );
165 menuBar->Append( placeMenu, _( "&Place" ) );
166 menuBar->Append( inspectMenu, _( "&Inspect" ) );
167 menuBar->Append( prefsMenu, _( "P&references" ) );
168 AddStandardHelpMenu( menuBar );
169
170 SetMenuBar( menuBar );
171 delete oldMenuBar;
172}
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION zoomRedraw
Definition: actions.h:94
static TOOL_ACTION unselectAll
Definition: actions.h:72
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION zoomOutCenter
Definition: actions.h:98
static TOOL_ACTION addLibrary
Definition: actions.h:49
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION showSymbolLibTable
Definition: actions.h:189
static TOOL_ACTION showSymbolBrowser
Definition: actions.h:171
static TOOL_ACTION openPreferences
Definition: actions.h:187
static TOOL_ACTION saveAll
Definition: actions.h:54
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION doDelete
Definition: actions.h:74
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:100
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION zoomTool
Definition: actions.h:103
static TOOL_ACTION showProperties
Definition: actions.h:177
static TOOL_ACTION zoomInCenter
Definition: actions.h:97
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION configurePaths
Definition: actions.h:188
static TOOL_ACTION selectAll
Definition: actions.h:71
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
static constexpr bool CHECK
Definition: action_menu.h:198
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:87
static constexpr bool NORMAL
Definition: action_menu.h:197
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
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:154
static TOOL_ACTION saveSymbolAs
Definition: ee_actions.h:197
static TOOL_ACTION drawSymbolPolygon
Definition: ee_actions.h:113
static TOOL_ACTION newSymbol
Definition: ee_actions.h:198
static TOOL_ACTION drawCircle
Definition: ee_actions.h:96
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:196
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:110
static TOOL_ACTION exportSymbolAsSVG
Definition: ee_actions.h:249
static TOOL_ACTION importSymbol
Definition: ee_actions.h:207
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:148
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:153
static TOOL_ACTION checkSymbol
Definition: ee_actions.h:163
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:95
static TOOL_ACTION setUnitDisplayName
Definition: ee_actions.h:210
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:111
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:112
static TOOL_ACTION drawArc
Definition: ee_actions.h:97
static TOOL_ACTION exportSymbol
Definition: ee_actions.h:208
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:245
static TOOL_ACTION updateSymbolFields
Definition: ee_actions.h:209
static TOOL_ACTION exportSymbolView
Definition: ee_actions.h:248
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:109
bool IsSymbolFromSchematic() const
void doReCreateMenuBar() override
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:165
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:46
#define _(s)
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
Macros and inline functions to create menus items in menubars or popup menus.