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-2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2017 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 "libeditframe.h"
39 
40 extern int CreateNewLibAndSavePartId;
41 
42 
47 {
48  // Create and try to get the current menubar
49  wxString text;
50  wxMenuBar* menuBar = GetMenuBar();
51 
52  if( !menuBar )
53  menuBar = new wxMenuBar();
54 
55  // Delete all existing menus so they can be rebuilt.
56  // This allows language changes of the menu text on the fly.
57  menuBar->Freeze();
58 
59  while( menuBar->GetMenuCount() )
60  delete menuBar->Remove( 0 );
61 
62  // Recreate all menus:
63 
64  // Menu File:
65  wxMenu* fileMenu = new wxMenu;
66 
67  // Select current library
68  AddMenuItem( fileMenu,
70  _( "Select &Current Library" ),
71  _( "Select working library" ),
72  KiBitmap( library_xpm ) );
73  fileMenu->AppendSeparator();
74 
75  // Save current library
76  text = AddHotkeyName( _( "&Save Current Library" ), g_Libedit_Hokeys_Descr, HK_SAVE_LIB );
77  AddMenuItem( fileMenu,
79  _( "Save the current active library" ),
80  KiBitmap( save_xpm ) );
81 
82  // Save current library as...
83  AddMenuItem( fileMenu,
85  _( "Save Current Library &As..." ),
86  _( "Save current active library as..." ),
87  KiBitmap( save_as_xpm ) );
88 
89  AddMenuItem( fileMenu,
91  _( "Create &New Library and Save Current Component" ),
92  _( "Save current component to new library" ),
93  KiBitmap( new_library_xpm ) );
94 
95  // Separator
96  fileMenu->AppendSeparator();
97 
98  // Export as png file
99  AddMenuItem( fileMenu,
101  _( "Create &PNG File from Screen..." ),
102  _( "Create a PNG file from the component displayed on screen" ),
103  KiBitmap( plot_xpm ) );
104 
105  // Export as SVG file
106  AddMenuItem( fileMenu,
108  _( "Create S&VG File..." ),
109  _( "Create a SVG file from the current loaded component" ),
110  KiBitmap( plot_svg_xpm ) );
111 
112  // Separator
113  fileMenu->AppendSeparator();
114 
115  // Quit
116  AddMenuItem( fileMenu,
117  wxID_EXIT,
118  _( "&Quit" ),
119  _( "Quit Library Editor" ),
120  KiBitmap( exit_xpm ) );
121 
122  // Edit menu
123  wxMenu* editMenu = new wxMenu;
124 
125  // Undo
126  text = AddHotkeyName( _( "&Undo" ), g_Libedit_Hokeys_Descr, HK_UNDO );
127 
128  AddMenuItem( editMenu,
129  wxID_UNDO,
130  text,
131  _( "Undo last edit" ),
132  KiBitmap( undo_xpm ) );
133 
134  // Redo
135  text = AddHotkeyName( _( "&Redo" ), g_Libedit_Hokeys_Descr, HK_REDO );
136  AddMenuItem( editMenu,
137  wxID_REDO,
138  text,
139  _( "Redo the last undo command" ),
140  KiBitmap( redo_xpm ) );
141 
142  // Separator
143  editMenu->AppendSeparator();
144 
145  // Delete
146  AddMenuItem( editMenu,
148  _( "&Delete" ),
150  KiBitmap( delete_xpm ) );
151 
152  // Menu View:
153  wxMenu* viewMenu = new wxMenu;
154 
168  // Zoom in
169  text = _( "Zoom &In" );
170  AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
171 
172  // Zoom out
173  text = _( "Zoom &Out" );
174  AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
175 
176  // Fit on screen
177  text = AddHotkeyName( _( "&Fit on Screen" ), g_Libedit_Hokeys_Descr, HK_ZOOM_AUTO );
178  AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT, KiBitmap( zoom_fit_in_page_xpm ) );
179 
180  // Separator
181  viewMenu->AppendSeparator();
182 
183  // Redraw
184  text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW );
185  AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
186 
187  // Menu Place:
188  wxMenu* placeMenu = new wxMenu;
189 
190  // Pin
191  AddMenuItem( placeMenu,
193  _( "&Pin" ),
194  HELP_ADD_PIN,
195  KiBitmap( pin_xpm ) );
196 
197  // Graphic text
198  AddMenuItem( placeMenu,
200  _( "Graphic &Text" ),
202  KiBitmap( text_xpm ) );
203 
204  // Graphic rectangle
205  AddMenuItem( placeMenu,
207  _( "&Rectangle" ),
209  KiBitmap( add_rectangle_xpm ) );
210 
211  // Graphic Circle
212  AddMenuItem( placeMenu,
214  _( "&Circle" ),
216  KiBitmap( add_circle_xpm ) );
217 
218  // Graphic Arc
219  AddMenuItem( placeMenu,
221  _( "&Arc" ),
223  KiBitmap( add_arc_xpm ) );
224 
225  // Graphic Line or Polygon
226  AddMenuItem( placeMenu,
228  _( "&Line or Polygon" ),
230  KiBitmap( add_polygon_xpm ) );
231 
232  // Menu Preferences:
233  wxMenu* preferencesMenu = new wxMenu;
234 
235  // Library list
236  AddMenuItem( preferencesMenu,
238  _( "Component &Libraries" ),
239  _( "Configure component libraries and paths" ),
240  KiBitmap( library_xpm ) );
241 
242  AddMenuItem( preferencesMenu,
244  _( "Symbol Library &Table" ),
245  _( "Edit the symbol library table." ),
246  KiBitmap( library_xpm ) );
247 
248  // Default values and options
249  AddMenuItem( preferencesMenu,
250  wxID_PREFERENCES,
251  _( "Component Editor &Options" ),
252  _( "Set Component Editor default values and options" ),
253  KiBitmap( preference_xpm ) );
254 
255  // Language submenu
256  Pgm().AddMenuLanguageList( preferencesMenu );
257 
258  // Hotkey submenu
259  AddHotkeyConfigMenu( preferencesMenu );
260 
261  // Menu Help:
262  wxMenu* helpMenu = new wxMenu;
263 
264  // Contents
265  AddMenuItem( helpMenu,
266  wxID_HELP,
267  _( "Eeschema &Manual" ),
268  _( "Open the Eeschema Manual" ),
269  KiBitmap( online_help_xpm ) );
270 
271  AddMenuItem( helpMenu,
272  wxID_INDEX,
273  _( "&Getting Started in KiCad" ),
274  _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
275  KiBitmap( help_xpm ) );
276 
277  AddMenuItem( helpMenu,
279  _( "&List Hotkeys" ),
280  _( "Displays the current hotkeys list and corresponding commands" ),
281  KiBitmap( hotkeys_xpm ) );
282 
283  helpMenu->AppendSeparator();
285  _( "Get &Involved" ),
286  _( "Contribute to KiCad (opens a web browser)" ),
287  KiBitmap( info_xpm ) );
288 
289  // About Eeschema
290  helpMenu->AppendSeparator();
291 
292  AddMenuItem( helpMenu,
293  wxID_ABOUT,
294  _( "&About KiCad" ),
295  _( "About KiCad" ),
296  KiBitmap( about_xpm ) );
297 
298  // Create the menubar and append all submenus
299  menuBar->Append( fileMenu, _( "&File" ) );
300  menuBar->Append( editMenu, _( "&Edit" ) );
301  menuBar->Append( viewMenu, _( "&View" ) );
302  menuBar->Append( placeMenu, _( "&Place" ) );
303  menuBar->Append( preferencesMenu, _( "P&references" ) );
304  menuBar->Append( helpMenu, _( "&Help" ) );
305 
306  menuBar->Thaw();
307 
308  // Associate the menu bar with the frame, if no previous menubar
309  if( GetMenuBar() == NULL )
310  SetMenuBar( menuBar );
311  else
312  menuBar->Refresh();
313 }
#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:55
#define HELP_ZOOM_FIT
Definition: id.h:232
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:36
void ReCreateMenuBar() override
(Re)Create the menubar for the component editor frame
strings common to toolbars and menubar
#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
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:822
static const char * text_xpm[]
#define HELP_DELETE_ITEMS
Definition of class LIB_EDIT_FRAME.