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 
45 {
46  // wxWidgets handles the Mac Application menu behind the scenes, but that means
47  // we always have to start from scratch with a new wxMenuBar.
48  wxMenuBar* oldMenuBar = GetMenuBar();
49  wxMenuBar* menuBar = new wxMenuBar();
50  wxString text;
51 
52  // Recreate all menus:
53 
54  // Menu File:
55  wxMenu* fileMenu = new wxMenu;
56 
57  // Creating/loading libraries
58  AddMenuItem( fileMenu,
60  _( "&New Library..." ),
61  _( "Creates an empty library" ),
62  KiBitmap( new_library_xpm ) );
63 
64  AddMenuItem( fileMenu,
66  _( "&Add Library..." ),
67  _( "Adds a previously created library" ),
68  KiBitmap( add_library_xpm ) );
69 
70  // Separator
71  fileMenu->AppendSeparator();
72 
73  // Save library variants
74  AddMenuItem( fileMenu,
76  _( "&Save Library" ),
77  _( "Save the current active library" ),
78  KiBitmap( save_library_xpm ) );
79 
80  AddMenuItem( fileMenu,
82  _( "Save Library As..." ),
83  _( "Save the current library to a new file" ),
84  KiBitmap( save_as_xpm ) );
85 
86  text = AddHotkeyName( _( "Save All &Libraries" ), g_Libedit_Hokeys_Descr, HK_SAVE_ALL_LIBS );
87  AddMenuItem( fileMenu, ID_LIBEDIT_SAVE_ALL_LIBS, text, _( "Save all library changes" ),
88  KiBitmap( save_xpm ) );
89 
90  // Separator
91  fileMenu->AppendSeparator();
92 
93  // Export as png file
94  AddMenuItem( fileMenu,
96  _( "Export Current View as &PNG..." ),
97  _( "Create a PNG file from the current view" ),
98  KiBitmap( plot_xpm ) );
99 
100  // Export as SVG file
101  AddMenuItem( fileMenu,
103  _( "Create S&VG File..." ),
104  _( "Create a SVG file from the current symbol" ),
105  KiBitmap( plot_svg_xpm ) );
106 
107  // Separator
108  fileMenu->AppendSeparator();
109 
110  // Quit
111  AddMenuItem( fileMenu,
112  wxID_EXIT,
113  _( "&Quit" ),
114  _( "Quit Library Editor" ),
115  KiBitmap( exit_xpm ) );
116 
117  // Edit menu
118  wxMenu* editMenu = new wxMenu;
119 
120  // Undo
121  text = AddHotkeyName( _( "&Undo" ), g_Libedit_Hokeys_Descr, HK_UNDO );
122 
123  AddMenuItem( editMenu,
124  wxID_UNDO,
125  text,
126  _( "Undo last edit" ),
127  KiBitmap( undo_xpm ) );
128 
129  // Redo
130  text = AddHotkeyName( _( "&Redo" ), g_Libedit_Hokeys_Descr, HK_REDO );
131  AddMenuItem( editMenu,
132  wxID_REDO,
133  text,
134  _( "Redo the last undo command" ),
135  KiBitmap( redo_xpm ) );
136 
137  // Menu View:
138  wxMenu* viewMenu = new wxMenu;
139 
153  // Zoom in
154  text = _( "Zoom &In" );
155  AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
156 
157  // Zoom out
158  text = _( "Zoom &Out" );
159  AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
160 
161  // Fit on screen
162  text = AddHotkeyName( _( "&Zoom to Fit" ), g_Libedit_Hokeys_Descr, HK_ZOOM_AUTO );
163  AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit symbol" ),
164  KiBitmap( zoom_fit_in_page_xpm ) );
165 
166  text = AddHotkeyName( _( "Zoom to Selection" ),
168  AddMenuItem( viewMenu, ID_MENU_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
169 
170  // Redraw
171  text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW );
172  AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
173 
174  // Separator
175  viewMenu->AppendSeparator();
176 
177  AddMenuItem( viewMenu,
179  _( "&Search Tree" ),
180  _( "Toggles the search tree visibility" ),
181  KiBitmap( search_tree_xpm ) );
182 
183  // Menu Part:
184  wxMenu* partMenu = new wxMenu;
185 
186  AddMenuItem( partMenu,
188  _( "&New Symbol..." ),
189  _( "Create a new empty symbol" ),
190  KiBitmap( new_component_xpm ) );
191 
192  AddMenuItem( partMenu,
194  _( "&Save Symbol" ),
195  _( "Saves the current symbol to the library" ),
196  KiBitmap( save_part_xpm ) );
197 
198  partMenu->AppendSeparator();
199 
200  AddMenuItem( partMenu,
202  _( "&Import Symbol..." ),
203  _( "Import a symbol to the current library" ),
204  KiBitmap( import_part_xpm ) );
205 
206  AddMenuItem( partMenu,
208  _( "&Export Symbol..." ),
209  _( "Export the current symbol" ),
210  KiBitmap( export_part_xpm ) );
211 
212  partMenu->AppendSeparator();
213 
214  AddMenuItem( partMenu,
216  _( "&Properties..." ),
217  _( "Edit symbol properties" ),
218  KiBitmap( part_properties_xpm ) );
219 
220  AddMenuItem( partMenu,
222  _( "&Fields..." ),
223  _( "Edit field properties" ),
224  KiBitmap( edit_text_xpm ) );
225 
226  partMenu->AppendSeparator();
227 
228  AddMenuItem( partMenu,
230  _( "Pi&n Table..." ),
231  _( "Show pin table" ),
232  KiBitmap( pin_table_xpm ) );
233 
234  AddMenuItem( partMenu,
236  _( "Electrical Rules Checker" ),
237  _( "Check duplicate and off grid pins" ),
238  KiBitmap( erc_xpm ) );
239 
240  // Menu Place:
241  wxMenu* placeMenu = new wxMenu;
242 
243  // Pin
244  AddMenuItem( placeMenu,
246  _( "&Pin" ),
247  HELP_ADD_PIN,
248  KiBitmap( pin_xpm ) );
249 
250  // Graphic text
251  AddMenuItem( placeMenu,
253  _( "Graphic &Text" ),
255  KiBitmap( text_xpm ) );
256 
257  // Graphic rectangle
258  AddMenuItem( placeMenu,
260  _( "&Rectangle" ),
262  KiBitmap( add_rectangle_xpm ) );
263 
264  // Graphic Circle
265  AddMenuItem( placeMenu,
267  _( "&Circle" ),
269  KiBitmap( add_circle_xpm ) );
270 
271  // Graphic Arc
272  AddMenuItem( placeMenu,
274  _( "&Arc" ),
276  KiBitmap( add_arc_xpm ) );
277 
278  // Graphic Line or Polygon
279  AddMenuItem( placeMenu,
281  _( "&Line or Polygon" ),
283  KiBitmap( add_polygon_xpm ) );
284 
285  // Menu Preferences:
286  wxMenu* preferencesMenu = new wxMenu;
287 
288  // Library list
289  AddMenuItem( preferencesMenu,
291  _( "Manage Symbol Libraries..." ),
292  _( "Edit the global and project symbol library tables." ),
293  KiBitmap( library_table_xpm ) );
294 
295  // Default values and options
296  AddMenuItem( preferencesMenu,
297  wxID_PREFERENCES,
298  _( "General &Options..." ),
299  _( "Set Symbol Editor default values and options" ),
300  KiBitmap( preference_xpm ) );
301 
302  // Language submenu
303  Pgm().AddMenuLanguageList( preferencesMenu );
304 
305  // Hotkey submenu
306  AddHotkeyConfigMenu( preferencesMenu );
307 
308  // Menu Help:
309  wxMenu* helpMenu = new wxMenu;
310 
311  // Contents
312  AddMenuItem( helpMenu,
313  wxID_HELP,
314  _( "Eeschema &Manual" ),
315  _( "Open the Eeschema Manual" ),
316  KiBitmap( online_help_xpm ) );
317 
318  AddMenuItem( helpMenu,
319  wxID_INDEX,
320  _( "&Getting Started in KiCad" ),
321  _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
322  KiBitmap( help_xpm ) );
323 
324  text = AddHotkeyName( _( "&List Hotkeys..." ), g_Eeschema_Hokeys_Descr, HK_HELP );
325  AddMenuItem( helpMenu,
327  text,
328  _( "Displays the current hotkeys list and corresponding commands" ),
329  KiBitmap( hotkeys_xpm ) );
330 
331  helpMenu->AppendSeparator();
333  _( "Get &Involved" ),
334  _( "Contribute to KiCad (opens a web browser)" ),
335  KiBitmap( info_xpm ) );
336 
337  // About Eeschema
338  helpMenu->AppendSeparator();
339 
340  AddMenuItem( helpMenu,
341  wxID_ABOUT,
342  _( "&About KiCad" ),
343  _( "About KiCad" ),
344  KiBitmap( about_xpm ) );
345 
346  // Create the menubar and append all submenus
347  menuBar->Append( fileMenu, _( "&File" ) );
348  menuBar->Append( editMenu, _( "&Edit" ) );
349  menuBar->Append( viewMenu, _( "&View" ) );
350  menuBar->Append( partMenu, _( "&Symbol" ) );
351  menuBar->Append( placeMenu, _( "&Place" ) );
352  menuBar->Append( preferencesMenu, _( "P&references" ) );
353  menuBar->Append( helpMenu, _( "&Help" ) );
354 
355  SetMenuBar( menuBar );
356  delete oldMenuBar;
357 }
#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:174
Definition: id.h:242
struct EDA_HOTKEY_CONFIG g_Libedit_Hokeys_Descr[]
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
#define HELP_ZOOM_OUT
#define HELP_ZOOM_REDRAW
#define HELP_ADD_BODYPOLYGON
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
void ReCreateMenuBar() override
(Re)Create the menubar for the part editor frame
strings common to toolbars and menubar
struct EDA_HOTKEY_CONFIG g_Eeschema_Hokeys_Descr[]
#define HELP_ADD_BODYTEXT
void AddHotkeyConfigMenu(wxMenu *aMenu)
#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:831
static const char * text_xpm[]
struct EDA_HOTKEY_CONFIG g_Schematic_Hokeys_Descr[]