KiCad PCB EDA Suite
menubar_footprint_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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
8 *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include "footprint_edit_frame.h"
28 #include "pcbnew_id.h"
29 #include <bitmaps.h>
30 #include <menus_helpers.h>
31 #include <tool/actions.h>
32 #include <tool/action_menu.h>
33 #include <tool/tool_manager.h>
34 #include <tools/pcb_actions.h>
36 #include <widgets/wx_menubar.h>
37 
38 
40 {
42  // wxWidgets handles the Mac Application menu behind the scenes, but that means
43  // we always have to start from scratch with a new wxMenuBar.
44  wxMenuBar* oldMenuBar = GetMenuBar();
45  WX_MENUBAR* menuBar = new WX_MENUBAR();
46 
47  //-- File menu ----------------------------------------------------------
48  //
49  ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
50 
51  fileMenu->Add( ACTIONS::newLibrary );
52  fileMenu->Add( ACTIONS::addLibrary );
53  fileMenu->Add( PCB_ACTIONS::newFootprint );
54  fileMenu->Add( PCB_ACTIONS::createFootprint );
55 
56  fileMenu->AppendSeparator();
57 
58  fileMenu->Add( ACTIONS::save );
59  fileMenu->Add( ACTIONS::saveAs );
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( PCB_ACTIONS::importFootprint, ACTION_MENU::NORMAL, _( "Footprint..." ) );
69  submenuImport->Add( PCB_ACTIONS::placeImportedGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
70 
71  fileMenu->Add( submenuImport );
72 
73  ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
74  submenuExport->SetTitle( _( "Export" ) );
75  submenuExport->SetIcon( BITMAPS::export_file );
76 
77  submenuExport->Add( PCB_ACTIONS::exportFootprint, ACTION_MENU::NORMAL, _( "Footprint..." ) );
78  submenuExport->Add( _( "View as &PNG..." ),
79  _( "Create a PNG file from the current view" ),
82 
83  fileMenu->Add( submenuExport );
84 
85  fileMenu->AppendSeparator();
86  fileMenu->Add( ACTIONS::print );
87 
88  fileMenu->AppendSeparator();
89  fileMenu->AddClose( _( "Footprint Editor" ) );
90 
91 
92  //-- Edit menu -------------------------------------------------------
93  //
94  ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
95 
96  editMenu->Add( ACTIONS::undo );
97  editMenu->Add( ACTIONS::redo );
98 
99  editMenu->AppendSeparator();
100  editMenu->Add( ACTIONS::cut );
101  editMenu->Add( ACTIONS::copy );
102  editMenu->Add( ACTIONS::paste );
103  editMenu->Add( ACTIONS::doDelete );
104  editMenu->Add( ACTIONS::duplicate );
105 
106  editMenu->AppendSeparator();
107  editMenu->Add( ACTIONS::selectAll );
108 
109  editMenu->AppendSeparator();
112 
113  editMenu->AppendSeparator();
114  editMenu->Add( PCB_ACTIONS::cleanupGraphics );
115 
116 
117  //-- View menu -------------------------------------------------------
118  //
119  ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
120 
121  viewMenu->Add( ACTIONS::showFootprintBrowser );
122  viewMenu->Add( ACTIONS::show3DViewer );
123 
124  viewMenu->AppendSeparator();
125  viewMenu->Add( ACTIONS::zoomInCenter );
126  viewMenu->Add( ACTIONS::zoomOutCenter );
127  viewMenu->Add( ACTIONS::zoomFitScreen );
128  viewMenu->Add( ACTIONS::zoomTool );
129  viewMenu->Add( ACTIONS::zoomRedraw );
130 
131  viewMenu->AppendSeparator();
133  viewMenu->Add( ACTIONS::gridProperties );
135 
136  // Units submenu
137  ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
138  unitsSubMenu->SetTitle( _( "&Units" ) );
139  unitsSubMenu->SetIcon( BITMAPS::unit_mm );
140  unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
141  unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
143  viewMenu->Add( unitsSubMenu );
144 
146 
147  viewMenu->AppendSeparator();
148  // Drawing Mode Submenu
149  ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
150  drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
151  drawingModeSubMenu->SetIcon( BITMAPS::add_zone );
152 
153  drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
154  drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
155  drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
156  viewMenu->Add( drawingModeSubMenu );
157 
158  // Contrast Mode Submenu
159  ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
160  contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
161  contrastModeSubMenu->SetIcon( BITMAPS::contrast_mode );
162 
163  contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
164  contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
165  contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
166  viewMenu->Add( contrastModeSubMenu );
167 
169 
170  viewMenu->AppendSeparator();
172 
173 
174  //-- Place menu -------------------------------------------------------
175  //
176  ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
177 
178  placeMenu->Add( PCB_ACTIONS::placePad );
179 
180  placeMenu->AppendSeparator();
181  placeMenu->Add( PCB_ACTIONS::placeText );
182  placeMenu->Add( PCB_ACTIONS::drawLine );
183  placeMenu->Add( PCB_ACTIONS::drawArc );
184  placeMenu->Add( PCB_ACTIONS::drawRectangle );
185  placeMenu->Add( PCB_ACTIONS::drawCircle );
186  placeMenu->Add( PCB_ACTIONS::drawPolygon );
187  placeMenu->Add( PCB_ACTIONS::drawRuleArea );
188 
189  placeMenu->AppendSeparator();
190  placeMenu->Add( PCB_ACTIONS::setAnchor );
191  placeMenu->Add( ACTIONS::gridSetOrigin );
192 
193 
194  //-- Inspect menu ------------------------------------------------------
195  //
196  ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
197 
198  inspectMenu->Add( ACTIONS::measureTool );
199 
200  inspectMenu->AppendSeparator();
201  inspectMenu->Add( PCB_ACTIONS::checkFootprint );
202 
203 
204  //-- Tools menu --------------------------------------------------------
205  //
206  ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
207 
208  toolsMenu->Add( _( "&Load Footprint from PCB..." ),
209  _( "Load a footprint from the current board into the editor" ),
212 
213  toolsMenu->Add( _( "&Insert Footprint on PCB" ),
214  _( "Insert footprint onto current board" ),
217 
218  toolsMenu->AppendSeparator();
219  toolsMenu->Add( PCB_ACTIONS::repairFootprint );
220 
221 
222  //-- Preferences menu -------------------------------------------------
223  //
224  ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
225 
226  prefsMenu->Add( ACTIONS::configurePaths );
227  prefsMenu->Add( ACTIONS::showFootprintLibTable );
228 
229  // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
230  // Mac, and it needs the wxID_PREFERENCES id to find it.
231  prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
232  _( "Show preferences for all open tools" ),
233  wxID_PREFERENCES,
235 
236  prefsMenu->AppendSeparator();
237  AddMenuLanguageList( prefsMenu, selTool );
238 
239  //--MenuBar -----------------------------------------------------------
240  //
241  menuBar->Append( fileMenu, _( "&File" ) );
242  menuBar->Append( editMenu, _( "&Edit" ) );
243  menuBar->Append( viewMenu, _( "&View" ) );
244  menuBar->Append( placeMenu, _( "&Place" ) );
245  menuBar->Append( inspectMenu, _( "&Inspect" ) );
246  menuBar->Append( toolsMenu, _( "&Tools" ) );
247  menuBar->Append( prefsMenu, _( "P&references" ) );
248  AddStandardHelpMenu( menuBar );
249 
250  SetMenuBar( menuBar );
251  delete oldMenuBar;
252 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:142
static TOOL_ACTION show3DViewer
Definition: actions.h:158
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:161
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:373
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:443
static TOOL_ACTION zoomInCenter
Definition: actions.h:93
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
static TOOL_ACTION doDelete
Definition: actions.h:72
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:376
static TOOL_ACTION drawArc
Definition: pcb_actions.h:146
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:321
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:286
static TOOL_ACTION zoomTool
Definition: actions.h:99
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:285
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:143
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:379
static constexpr bool NORMAL
Definition: action_menu.h:182
static TOOL_ACTION print
Definition: actions.h:57
Wrapper around a wxMenuBar object that prevents the accelerator table from being used.
Definition: wx_menubar.h:45
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:162
static TOOL_ACTION placeText
Definition: pcb_actions.h:147
static TOOL_ACTION zoomOutCenter
Definition: actions.h:94
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:358
static TOOL_ACTION measureTool
Definition: actions.h:154
void ReCreateMenuBar() override
(Re)Create the menubar for the Footprint Editor frame
static TOOL_ACTION copy
Definition: actions.h:67
static TOOL_ACTION showFootprintLibTable
Definition: actions.h:175
static TOOL_ACTION toggleGrid
Definition: actions.h:140
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:371
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:161
static TOOL_ACTION inchesUnits
Definition: actions.h:144
static TOOL_ACTION save
Definition: actions.h:51
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
static TOOL_ACTION togglePolarCoords
Definition: actions.h:149
static TOOL_ACTION cut
Definition: actions.h:66
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:144
static TOOL_ACTION addLibrary
Definition: actions.h:49
#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...
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION milsUnits
Definition: actions.h:145
static TOOL_ACTION importFootprint
Definition: pcb_actions.h:370
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:145
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:391
static TOOL_ACTION redo
Definition: actions.h:65
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:374
static constexpr bool CHECK
Definition: action_menu.h:183
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:154
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:350
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION zoomRedraw
Definition: actions.h:90
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
The selection tool: currently supports:
static TOOL_ACTION gridProperties
Definition: actions.h:141
static TOOL_ACTION undo
Definition: actions.h:64
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:291
static TOOL_ACTION gridSetOrigin
Definition: actions.h:137
static TOOL_ACTION configurePaths
Definition: actions.h:173
static TOOL_ACTION highContrastMode
Definition: actions.h:103
static TOOL_ACTION selectAll
Definition: actions.h:70
static TOOL_ACTION paste
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:71
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:355
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:394
void AddClose(const wxString &aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.