KiCad PCB EDA Suite
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, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2020 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 <pgm_base.h>
29 #include <tool/action_menu.h>
30 #include <tool/tool_manager.h>
31 #include <tools/ee_actions.h>
33 #include <symbol_library_manager.h>
34 #include "symbol_edit_frame.h"
35 #include <widgets/wx_menubar.h>
36 
37 
39 {
41  // wxWidgets handles the Mac Application menu behind the scenes, but that means
42  // we always have to start from scratch with a new wxMenuBar.
43  wxMenuBar* oldMenuBar = GetMenuBar();
44  WX_MENUBAR* menuBar = new WX_MENUBAR();
45 
46  //-- File menu -----------------------------------------------
47  //
48  ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
49 
50  fileMenu->Add( ACTIONS::newLibrary );
51  fileMenu->Add( ACTIONS::addLibrary );
52  fileMenu->Add( EE_ACTIONS::saveLibraryAs );
53  fileMenu->Add( EE_ACTIONS::newSymbol );
54 
55  fileMenu->AppendSeparator();
56  fileMenu->Add( ACTIONS::save );
57  fileMenu->Add( EE_ACTIONS::saveSymbolAs );
58 
59  if( !IsSymbolFromSchematic() )
60  fileMenu->Add( ACTIONS::saveAll );
61 
62  fileMenu->Add( ACTIONS::revert );
63 
64  fileMenu->AppendSeparator();
65  fileMenu->Add( EE_ACTIONS::importSymbol );
66 
67  // Export submenu
68  ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
69  submenuExport->SetTitle( _( "Export" ) );
70  submenuExport->SetIcon( BITMAPS::export_file );
71  submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
72  submenuExport->Add( EE_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) );
73  submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) );
74  fileMenu->Add( submenuExport );
75 
76  fileMenu->AppendSeparator();
77  fileMenu->AddClose( _( "Library Editor" ) );
78 
79 
80  //-- Edit menu -----------------------------------------------
81  //
82  ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
83 
84  editMenu->Add( ACTIONS::undo );
85  editMenu->Add( ACTIONS::redo );
86 
87  editMenu->AppendSeparator();
88  editMenu->Add( ACTIONS::cut );
89  editMenu->Add( ACTIONS::copy );
90  editMenu->Add( ACTIONS::paste );
91  editMenu->Add( ACTIONS::doDelete );
92  editMenu->Add( ACTIONS::duplicate );
93 
94  editMenu->AppendSeparator();
95  editMenu->Add( ACTIONS::selectAll );
96 
97  editMenu->AppendSeparator();
98  editMenu->Add( EE_ACTIONS::symbolProperties );
99  editMenu->Add( EE_ACTIONS::pinTable );
100  editMenu->Add( EE_ACTIONS::updateSymbolFields );
101 
102 
103  //-- View menu -----------------------------------------------
104  //
105  ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
106 
107  viewMenu->Add( ACTIONS::showSymbolBrowser );
108 
109  viewMenu->AppendSeparator();
110  viewMenu->Add( ACTIONS::zoomInCenter );
111  viewMenu->Add( ACTIONS::zoomOutCenter );
112  viewMenu->Add( ACTIONS::zoomFitScreen );
113  viewMenu->Add( ACTIONS::zoomTool );
114  viewMenu->Add( ACTIONS::zoomRedraw );
115 
116  viewMenu->AppendSeparator();
118  viewMenu->Add( ACTIONS::gridProperties );
119 
120  // Units submenu
121  ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
122  unitsSubMenu->SetTitle( _( "&Units" ) );
123  unitsSubMenu->SetIcon( BITMAPS::unit_mm );
124  unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
125  unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
127  viewMenu->Add( unitsSubMenu );
128 
130 
131  viewMenu->AppendSeparator();
133 
134 
135  //-- Place menu -----------------------------------------------
136  //
137  ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
138 
139  placeMenu->Add( EE_ACTIONS::placeSymbolPin );
140  placeMenu->Add( EE_ACTIONS::placeSymbolText );
141  placeMenu->Add( EE_ACTIONS::drawSymbolRectangle );
142  placeMenu->Add( EE_ACTIONS::drawSymbolCircle );
143  placeMenu->Add( EE_ACTIONS::drawSymbolArc );
144  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( _( "Preferences..." ) + "\tCtrl+,",
164  _( "Show preferences for all open tools" ),
165  wxID_PREFERENCES,
167 
168  prefsMenu->AppendSeparator();
169  AddMenuLanguageList( prefsMenu, selTool );
170 
171 
172  //-- Menubar -------------------------------------------------------------
173  //
174  menuBar->Append( fileMenu, _( "&File" ) );
175  menuBar->Append( editMenu, _( "&Edit" ) );
176  menuBar->Append( viewMenu, _( "&View" ) );
177  menuBar->Append( placeMenu, _( "&Place" ) );
178  menuBar->Append( inspectMenu, _( "&Inspect" ) );
179  menuBar->Append( prefsMenu, _( "P&references" ) );
180  AddStandardHelpMenu( menuBar );
181 
182  SetMenuBar( menuBar );
183  delete oldMenuBar;
184 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:143
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:137
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:99
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:103
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:47
static TOOL_ACTION doDelete
Definition: actions.h:75
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:72
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:201
static TOOL_ACTION zoomTool
Definition: actions.h:102
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION showSymbolLibTable
Definition: actions.h:176
static constexpr bool NORMAL
Definition: action_menu.h:181
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:45
static TOOL_ACTION checkSymbol
Definition: ee_actions.h:153
static TOOL_ACTION updateSymbolFields
Definition: ee_actions.h:178
bool IsSymbolFromSchematic() const
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
static TOOL_ACTION drawSymbolRectangle
Definition: ee_actions.h:100
static TOOL_ACTION copy
Definition: actions.h:70
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:98
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:142
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
static TOOL_ACTION cut
Definition: actions.h:69
static TOOL_ACTION drawSymbolCircle
Definition: ee_actions.h:101
static TOOL_ACTION addLibrary
Definition: actions.h:52
static TOOL_ACTION importSymbol
Definition: ee_actions.h:176
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 ReCreateMenuBar() override
Recreates the menu bar.
static TOOL_ACTION newLibrary
Definition: actions.h:51
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION exportSymbolView
Definition: ee_actions.h:205
static TOOL_ACTION newSymbol
Definition: ee_actions.h:169
static TOOL_ACTION exportSymbol
Definition: ee_actions.h:177
static TOOL_ACTION saveSymbolAs
Definition: ee_actions.h:168
static TOOL_ACTION redo
Definition: actions.h:68
static constexpr bool CHECK
Definition: action_menu.h:182
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:90
see class PGM_BASE
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
static TOOL_ACTION drawSymbolArc
Definition: ee_actions.h:102
static TOOL_ACTION gridProperties
Definition: actions.h:144
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
static TOOL_ACTION saveAll
Definition: actions.h:57
static TOOL_ACTION showSymbolBrowser
Definition: actions.h:162
static TOOL_ACTION configurePaths
Definition: actions.h:175
static TOOL_ACTION exportSymbolAsSVG
Definition: ee_actions.h:206
static TOOL_ACTION selectAll
Definition: actions.h:73
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION duplicate
Definition: actions.h:74
static TOOL_ACTION revert
Definition: actions.h:58
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:167
void AddClose(wxString aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.