KiCad PCB EDA Suite
menubar_libedit.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-2018 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 
31 #include <menus_helpers.h>
32 #include <pgm_base.h>
33 
34 #include "eeschema_id.h"
35 #include "general.h"
36 #include "help_common_strings.h"
37 #include "hotkeys.h"
38 #include "lib_edit_frame.h"
39 
40 
42 {
43  // wxWidgets handles the Mac Application menu behind the scenes, but that means
44  // we always have to start from scratch with a new wxMenuBar.
45  wxMenuBar* oldMenuBar = GetMenuBar();
46  wxMenuBar* menuBar = new wxMenuBar();
47  wxString text;
48 
49  // Recreate all menus:
50 
51  // Menu File:
52  wxMenu* fileMenu = new wxMenu;
53 
54  AddMenuItem( fileMenu,
56  _( "New Library..." ),
57  _( "Creates an empty library" ),
58  KiBitmap( new_library_xpm ) );
59 
60  AddMenuItem( fileMenu,
62  _( "Add Library..." ),
63  _( "Adds a previously created library" ),
64  KiBitmap( add_library_xpm ) );
65 
66  text = AddHotkeyName( _( "&New Symbol..." ), m_hotkeysDescrList, HK_NEW );
67  AddMenuItem( fileMenu,
69  text,
70  _( "Create a new symbol" ),
71  KiBitmap( new_component_xpm ) );
72 
73  fileMenu->AppendSeparator();
74 
75  text = AddHotkeyName( _( "&Save" ), g_Libedit_Hokeys_Descr, HK_SAVE );
76  AddMenuItem( fileMenu,
78  text,
79  _( "Save changes" ),
80  KiBitmap( save_xpm ) );
81 
82  text = AddHotkeyName( _( "Save &As..." ), g_Libedit_Hokeys_Descr, HK_SAVEAS );
83  AddMenuItem( fileMenu,
85  text,
86  _( "Save a copy to a new name and/or location" ),
87  KiBitmap( save_as_xpm ) );
88 
89  AddMenuItem( fileMenu,
91  _( "Save All" ),
92  _( "Save all library and symbol changes" ),
93  KiBitmap( save_xpm ) );
94 
95  AddMenuItem( fileMenu,
97  _( "&Revert" ),
98  _( "Throw away changes" ),
99  KiBitmap( undo_xpm ) );
100 
101  fileMenu->AppendSeparator();
102 
103  AddMenuItem( fileMenu,
105  _( "&Import Symbol..." ),
106  _( "Import a symbol to the current library" ),
107  KiBitmap( import_part_xpm ) );
108 
109  AddMenuItem( fileMenu,
111  _( "&Export Symbol..." ),
112  _( "Create a library file containing only the current symbol" ),
113  KiBitmap( export_part_xpm ) );
114 
115  AddMenuItem( fileMenu,
117  _( "Export View as PNG..." ),
118  _( "Create a PNG file from the current view" ),
119  KiBitmap( plot_xpm ) );
120 
121  AddMenuItem( fileMenu,
123  _( "Export Symbol as SVG..." ),
124  _( "Create a SVG file from the current symbol" ),
125  KiBitmap( plot_svg_xpm ) );
126 
127  fileMenu->AppendSeparator();
128 
129  AddMenuItem( fileMenu,
130  wxID_EXIT,
131  _( "&Quit" ),
132  _( "Quit Library Editor" ),
133  KiBitmap( exit_xpm ) );
134 
135  // Edit menu
136  wxMenu* editMenu = new wxMenu;
137 
138  text = AddHotkeyName( _( "&Undo" ), g_Libedit_Hokeys_Descr, HK_UNDO );
139  AddMenuItem( editMenu,
140  wxID_UNDO,
141  text,
142  _( "Undo last edit" ),
143  KiBitmap( undo_xpm ) );
144 
145  text = AddHotkeyName( _( "&Redo" ), g_Libedit_Hokeys_Descr, HK_REDO );
146  AddMenuItem( editMenu,
147  wxID_REDO,
148  text,
149  _( "Redo the last undo command" ),
150  KiBitmap( redo_xpm ) );
151 
152  editMenu->AppendSeparator();
153 
154  AddMenuItem( editMenu,
156  _( "&Properties..." ),
157  _( "Edit symbol properties" ),
158  KiBitmap( part_properties_xpm ) );
159 
160  AddMenuItem( editMenu,
162  _( "Pin &Table..." ),
163  _( "Show pin table" ),
164  KiBitmap( pin_table_xpm ) );
165 
166  // Menu View:
167  wxMenu* viewMenu = new wxMenu;
168 
169  AddMenuItem( viewMenu,
171  _( "Library Browser" ),
172  _( "Open the symbol viewer" ),
173  KiBitmap( library_browse_xpm ) );
174 
175  viewMenu->AppendSeparator();
176 
190  // Zoom in
191  text = _( "Zoom &In" );
192  AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
193 
194  // Zoom out
195  text = _( "Zoom &Out" );
196  AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
197 
198  // Fit on screen
199  text = AddHotkeyName( _( "&Zoom to Fit" ), g_Libedit_Hokeys_Descr, HK_ZOOM_AUTO );
200  AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit symbol" ),
201  KiBitmap( zoom_fit_in_page_xpm ) );
202 
203  text = AddHotkeyName( _( "Zoom to Selection" ),
205  AddMenuItem( viewMenu, ID_MENU_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
206 
207  // Redraw
208  text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW );
209  AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
210 
211  viewMenu->AppendSeparator();
212 
214  _( "Show &Grid" ), wxEmptyString,
215  KiBitmap( grid_xpm ), wxITEM_CHECK );
216 
217  AddMenuItem( viewMenu, ID_GRID_SETTINGS,
218  _( "Grid Settings..." ), wxEmptyString,
219  KiBitmap( grid_xpm ) );
220 
221  // Separator
222  viewMenu->AppendSeparator();
223 
224  AddMenuItem( viewMenu,
226  _( "&Search Tree" ),
227  _( "Toggles the search tree visibility" ),
228  KiBitmap( search_tree_xpm ), wxITEM_CHECK );
229 
230  // Menu Place:
231  wxMenu* placeMenu = new wxMenu;
232 
233  // Pin
234  AddMenuItem( placeMenu,
236  _( "&Pin" ),
237  HELP_ADD_PIN,
238  KiBitmap( pin_xpm ) );
239 
240  // Graphic text
241  AddMenuItem( placeMenu,
243  _( "Graphic &Text" ),
245  KiBitmap( text_xpm ) );
246 
247  // Graphic rectangle
248  AddMenuItem( placeMenu,
250  _( "&Rectangle" ),
252  KiBitmap( add_rectangle_xpm ) );
253 
254  // Graphic Circle
255  AddMenuItem( placeMenu,
257  _( "&Circle" ),
259  KiBitmap( add_circle_xpm ) );
260 
261  // Graphic Arc
262  AddMenuItem( placeMenu,
264  _( "&Arc" ),
266  KiBitmap( add_arc_xpm ) );
267 
268  // Graphic Line or Polygon
269  AddMenuItem( placeMenu,
271  _( "&Line or Polygon" ),
273  KiBitmap( add_polygon_xpm ) );
274 
275  // Menu Inspect:
276  wxMenu* inspectMenu = new wxMenu;
277 
278 
279  text = AddHotkeyName( _( "Show Datasheet" ), g_Libedit_Hokeys_Descr, HK_LIBEDIT_VIEW_DOC );
280  AddMenuItem( inspectMenu,
282  text,
283  _( "Open associated datasheet in web browser" ),
284  KiBitmap( datasheet_xpm ) );
285 
286  AddMenuItem( inspectMenu,
288  _( "Electrical Rules &Checker" ),
289  _( "Check duplicate and off grid pins" ),
290  KiBitmap( erc_xpm ) );
291 
292  // Menu Preferences:
293  wxMenu* preferencesMenu = new wxMenu;
294 
295  // Environment varialbes
296  AddMenuItem( preferencesMenu,
298  _( "&Configure Paths..." ),
299  _( "Edit path configuration environment variables" ),
300  KiBitmap( path_xpm ) );
301 
302  // Library list
303  AddMenuItem( preferencesMenu,
305  _( "Manage &Symbol Libraries..." ),
306  _( "Edit the global and project symbol library tables." ),
307  KiBitmap( library_table_xpm ) );
308 
309  preferencesMenu->AppendSeparator();
310 
311  // Default values and options
312  AddMenuItem( preferencesMenu,
313  wxID_PREFERENCES,
314  _( "&Preferences..." ),
315  _( "Show preferences for all open tools" ),
316  KiBitmap( preference_xpm ) );
317 
318  // Language submenu
319  Pgm().AddMenuLanguageList( preferencesMenu );
320 
321  // Menu Help:
322  wxMenu* helpMenu = new wxMenu;
323 
324  // Contents
325  AddMenuItem( helpMenu,
326  wxID_HELP,
327  _( "Eeschema &Manual" ),
328  _( "Open the Eeschema Manual" ),
329  KiBitmap( online_help_xpm ) );
330 
331  AddMenuItem( helpMenu,
332  wxID_INDEX,
333  _( "&Getting Started in KiCad" ),
334  _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
335  KiBitmap( help_xpm ) );
336 
337  text = AddHotkeyName( _( "&List Hotkeys..." ), g_Libedit_Hokeys_Descr, HK_HELP );
338  AddMenuItem( helpMenu,
340  text,
341  _( "Displays the current hotkeys list and corresponding commands" ),
342  KiBitmap( hotkeys_xpm ) );
343 
344  helpMenu->AppendSeparator();
346  _( "Get &Involved" ),
347  _( "Contribute to KiCad (opens a web browser)" ),
348  KiBitmap( info_xpm ) );
349 
350  // About Eeschema
351  helpMenu->AppendSeparator();
352 
353  AddMenuItem( helpMenu, wxID_ABOUT, _( "&About KiCad" ), KiBitmap( about_xpm ) );
354 
355  // Create the menubar and append all submenus
356  menuBar->Append( fileMenu, _( "&File" ) );
357  menuBar->Append( editMenu, _( "&Edit" ) );
358  menuBar->Append( viewMenu, _( "&View" ) );
359  menuBar->Append( placeMenu, _( "&Place" ) );
360  menuBar->Append( inspectMenu, _( "&Inspect" ) );
361  menuBar->Append( preferencesMenu, _( "P&references" ) );
362  menuBar->Append( helpMenu, _( "&Help" ) );
363 
364  SetMenuBar( menuBar );
365  delete oldMenuBar;
366 }
#define HELP_ADD_BODYRECT
#define HELP_ADD_BODYCIRCLE
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
Definition: id.h:241
struct EDA_HOTKEY_CONFIG g_Libedit_Hokeys_Descr[]
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
#define HELP_ZOOM_OUT
Pcbnew hotkeys.
#define HELP_ZOOM_REDRAW
#define HELP_ADD_BODYPOLYGON
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:105
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
#define HELP_ADD_BODYTEXT
#define HELP_ADD_BODYARC
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
see class PGM_BASE
#define HELP_ADD_PIN
#define HELP_ZOOM_IN
Definition of class LIB_EDIT_FRAME.
VTBL_ENTRY void AddMenuLanguageList(wxMenu *MasterMenu)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
Definition: pgm_base.cpp:800
static const char * text_xpm[]
strings common to toolbars and menubar
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]