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>
35 #include <tools/pcb_selection_tool.h>
36 #include <widgets/wx_menubar.h>
37
38
ReCreateMenuBar()39 void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
40 {
41 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
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" ),
80 ID_FPEDIT_SAVE_PNG,
81 BITMAPS::export_png );
82
83 fileMenu->Add( submenuExport );
84
85 fileMenu->AppendSeparator();
86 fileMenu->Add( PCB_ACTIONS::footprintProperties );
87
88 fileMenu->AppendSeparator();
89 fileMenu->Add( ACTIONS::print );
90
91 fileMenu->AppendSeparator();
92 fileMenu->AddClose( _( "Footprint Editor" ) );
93
94
95 //-- Edit menu -------------------------------------------------------
96 //
97 ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
98
99 editMenu->Add( ACTIONS::undo );
100 editMenu->Add( ACTIONS::redo );
101
102 editMenu->AppendSeparator();
103 editMenu->Add( ACTIONS::cut );
104 editMenu->Add( ACTIONS::copy );
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
112 editMenu->AppendSeparator();
113 editMenu->Add( PCB_ACTIONS::defaultPadProperties );
114
115
116 //-- View menu -------------------------------------------------------
117 //
118 ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
119
120 viewMenu->Add( ACTIONS::showFootprintBrowser );
121 viewMenu->Add( ACTIONS::show3DViewer );
122
123 viewMenu->AppendSeparator();
124 viewMenu->Add( ACTIONS::zoomInCenter );
125 viewMenu->Add( ACTIONS::zoomOutCenter );
126 viewMenu->Add( ACTIONS::zoomFitScreen );
127 viewMenu->Add( ACTIONS::zoomTool );
128 viewMenu->Add( ACTIONS::zoomRedraw );
129
130 viewMenu->AppendSeparator();
131 viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
132 viewMenu->Add( ACTIONS::gridProperties );
133 viewMenu->Add( PCB_ACTIONS::togglePolarCoords, ACTION_MENU::CHECK );
134
135 // Units submenu
136 ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
137 unitsSubMenu->SetTitle( _( "&Units" ) );
138 unitsSubMenu->SetIcon( BITMAPS::unit_mm );
139 unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
140 unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
141 unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
142 viewMenu->Add( unitsSubMenu );
143
144 viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
145
146 viewMenu->AppendSeparator();
147 // Drawing Mode Submenu
148 ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
149 drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
150 drawingModeSubMenu->SetIcon( BITMAPS::add_zone );
151
152 drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
153 drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
154 drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
155 viewMenu->Add( drawingModeSubMenu );
156
157 // Contrast Mode Submenu
158 ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
159 contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
160 contrastModeSubMenu->SetIcon( BITMAPS::contrast_mode );
161
162 contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
163 contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
164 contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
165 viewMenu->Add( contrastModeSubMenu );
166
167 viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
168
169 viewMenu->AppendSeparator();
170 viewMenu->Add( PCB_ACTIONS::showFootprintTree, ACTION_MENU::CHECK );
171 viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
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" ),
210 ID_LOAD_FOOTPRINT_FROM_BOARD,
211 BITMAPS::load_module_board );
212
213 toolsMenu->Add( _( "&Insert Footprint on PCB" ),
214 _( "Insert footprint onto current board" ),
215 ID_ADD_FOOTPRINT_TO_BOARD,
216 BITMAPS::insert_module_board );
217
218 toolsMenu->AppendSeparator();
219 toolsMenu->Add( PCB_ACTIONS::cleanupGraphics );
220 toolsMenu->Add( PCB_ACTIONS::repairFootprint );
221
222
223 //-- Preferences menu -------------------------------------------------
224 //
225 ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
226
227 prefsMenu->Add( ACTIONS::configurePaths );
228 prefsMenu->Add( ACTIONS::showFootprintLibTable );
229
230 // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
231 // Mac, and it needs the wxID_PREFERENCES id to find it.
232 prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
233 _( "Show preferences for all open tools" ),
234 wxID_PREFERENCES,
235 BITMAPS::preference );
236
237 prefsMenu->AppendSeparator();
238 AddMenuLanguageList( prefsMenu, selTool );
239
240 //--MenuBar -----------------------------------------------------------
241 //
242 menuBar->Append( fileMenu, _( "&File" ) );
243 menuBar->Append( editMenu, _( "&Edit" ) );
244 menuBar->Append( viewMenu, _( "&View" ) );
245 menuBar->Append( placeMenu, _( "&Place" ) );
246 menuBar->Append( inspectMenu, _( "&Inspect" ) );
247 menuBar->Append( toolsMenu, _( "&Tools" ) );
248 menuBar->Append( prefsMenu, _( "P&references" ) );
249 AddStandardHelpMenu( menuBar );
250
251 SetMenuBar( menuBar );
252 delete oldMenuBar;
253 }
254