menubar_modedit.cpp 12.4 KB
Newer Older
1

Wayne Stambaugh's avatar
Wayne Stambaugh committed
2 3 4
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
5 6 7 8
 * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
 * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
 * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
9
*
Wayne Stambaugh's avatar
Wayne Stambaugh committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

28 29 30 31
/**
 * @file pcbnew/menubar_modedit.cpp
 * @brief (Re)Create the main menubar for the module editor
 */
32
#include <fctsys.h>
33
#include <pgm_base.h>
34

35 36 37
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <module_editor_frame.h>
38
#include <menus_helpers.h>
39

40
#include <pcbnew_id.h>
41
#include <hotkeys.h>
42
#include <help_common_strings.h>
43

44 45

void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
46
{
47
    // Create and try to get the current menubar
48
    wxMenuBar* menuBar = GetMenuBar();
49

50
    if( !menuBar )
51
        menuBar = new wxMenuBar();
52

53 54 55
    // Delete all existing menus so they can be rebuilt.
    // This allows language changes of the menu text on the fly.
    menuBar->Freeze();
56

57
    while( menuBar->GetMenuCount() )
58
        delete menuBar->Remove( 0 );
59 60

    // Recreate all menus:
61
    wxString text;
62

63
    // Menu File:
64 65
    wxMenu* fileMenu = new wxMenu;

66
    // Active library selection
67
    AddMenuItem( fileMenu, ID_MODEDIT_SELECT_CURRENT_LIB, _("Set Acti&ve Library"),
68 69 70 71
                           _( "Select active library" ),
                           KiBitmap( open_library_xpm ) );
    fileMenu->AppendSeparator();

72
    // New module
73
    AddMenuItem( fileMenu, ID_MODEDIT_NEW_MODULE,
74
                 _( "&New Footprint" ), _( "Create new footprint" ),
75
                 KiBitmap( new_footprint_xpm ) );
76

77
    // Open submenu
78 79
    wxMenu* openSubmenu = new wxMenu;

80
    // from File
81
    AddMenuItem( openSubmenu, ID_MODEDIT_IMPORT_PART,
82
                 _( "&Import Footprint From File" ),
83
                 _( "Import footprint from an existing file" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
84
                 KiBitmap( import_module_xpm ) );
85

86
    // from Library
87
    AddMenuItem( openSubmenu, ID_MODEDIT_LOAD_MODULE,
88 89
                 _( "Load Footprint From Current Li&brary" ),
                 _( "Open a footprint from library" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
90
                 KiBitmap( module_xpm ) );
91

92
    // from current Board
93
    AddMenuItem( openSubmenu, ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
94 95
                 _( "Load Footprint From &Current Board" ),
                 _( "Load a footprint from the current board" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
96
                 KiBitmap( load_module_board_xpm ) );
97 98

    /* Append openSubmenu to fileMenu */
99
    AddMenuItem( fileMenu, openSubmenu, -1,
100 101
                 _( "&Load Footprint" ),
                 _( "Load footprint" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
102
                 KiBitmap( open_document_xpm ) );
103
    fileMenu->AppendSeparator();
104

105
    // Save the currently loaded legacy library as an s-expression library.
106
    AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBRARY_AS,
107
                 _( "Save &Current Library As..." ),
108
                 _( "Save entire current library under a new name." ),
109
                 KiBitmap( copy_library_xpm ) );
110

111
    // Save module
112
    text = AddHotkeyName( _( "&Save Footprint in Active Library" ),
113
                          g_Module_Editor_Hokeys_Descr, HK_SAVE_MODULE );
114

115
    AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBMODULE, text,
116
                 _( "Save footprint in active library" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
117
                 KiBitmap( save_library_xpm ) );
118

119
    // Save module in new lib
120
    AddMenuItem( fileMenu, ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
121
                 _( "S&ave Footprint in New Library" ),
122
                 _( "Create a new library and save current module into it" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
123
                 KiBitmap( new_library_xpm ) );
124

125
    // Export module
126
    AddMenuItem( fileMenu, ID_MODEDIT_EXPORT_PART,
127 128
                 _( "&Export Footprint" ),
                 _( "Save currently loaded footprint into file" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
129
                 KiBitmap( export_module_xpm ) );
130 131 132 133 134 135 136

    // Import DXF File
    AddMenuItem( fileMenu, ID_GEN_IMPORT_DXF_FILE,
                 _( "&Import DXF File" ),
                 _( "Import a 2D Drawing DXF file to Pcbnew on the Drawings layer" ),
                 KiBitmap( import_xpm ) );

137 138
    fileMenu->AppendSeparator();

139
    // Print
140
    AddMenuItem( fileMenu, wxID_PRINT,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
141
                 _( "&Print" ),
142
                 _( "Print current footprint" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
143
                 KiBitmap( plot_xpm ) );
144

145
    // Separator
146 147
    fileMenu->AppendSeparator();

148
    // Close editor
149
    AddMenuItem( fileMenu, wxID_EXIT,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
150
                 _( "Cl&ose" ),
151
                 _( "Close footprint editor" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
152
                 KiBitmap( exit_xpm ) );
153

154
    //----- Edit menu ------------------
155 156
    wxMenu* editMenu = new wxMenu;

157
    // Undo
158
    text = AddHotkeyName( _( "&Undo" ), g_Module_Editor_Hokeys_Descr, HK_UNDO );
159
    AddMenuItem( editMenu, wxID_UNDO,
160
                 text, _( "Undo last action" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
161
                 KiBitmap( undo_xpm ) );
162

163
    // Redo
164
    text = AddHotkeyName( _( "&Redo" ), g_Module_Editor_Hokeys_Descr, HK_REDO );
165
    AddMenuItem( editMenu, wxID_REDO,
166
                 text, _( "Redo last action" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
167
                 KiBitmap( redo_xpm ) );
168

169
    // Delete items
170
    AddMenuItem( editMenu, ID_MODEDIT_DELETE_TOOL,
171
                 _( "&Delete" ), _( "Delete objects with eraser" ),
172
                 KiBitmap( delete_xpm ) );
173

174
    // Separator
175 176
    editMenu->AppendSeparator();

177
    // Properties
178
    AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES,
179
                 _( "Edit &Properties" ),
180
                 _( "Edit footprint properties" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
181
                 KiBitmap( module_options_xpm ) );
182

183
    // Dimensions submenu
184 185
    wxMenu* dimensions_Submenu = new wxMenu;

186
    // Sizes and Widths
187
    AddMenuItem( dimensions_Submenu, ID_PCB_DRAWINGS_WIDTHS_SETUP,
188
                 _( "&Size and Width" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
189 190
                 _( "Adjust width for texts and drawings" ),
                 KiBitmap( options_text_xpm ) );
191

192
    // Pad settings
193
    AddMenuItem( dimensions_Submenu, ID_MODEDIT_PAD_SETTINGS,
194
                 _( "&Pad Setting" ), _( "Edit settings for new pads" ),
195
                 KiBitmap( pad_dimensions_xpm ) );
196

197
    // User grid size
198
    AddMenuItem( dimensions_Submenu, ID_PCB_USER_GRID_SETUP,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
199 200
                 _( "&User Grid Size" ), _( "Adjust user grid" ),
                 KiBitmap( grid_xpm ) );
201

202
    //--------- View menu ----------------
203 204
    wxMenu* viewMenu = new wxMenu;

205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
    /* Important Note for ZOOM IN and ZOOM OUT commands from menubar:
     * we cannot add hotkey info here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT
     * events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command:
     * zoom in and out from hotkeys are equivalent to the pop up menu zoom
     * From here, zooming is made around the screen center
     * From hotkeys, zooming is made around the mouse cursor position
     * (obviously not possible from the toolbar or menubar command)
     *
     * in other words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators
     * for Zoom in and Zoom out sub menus
     */
    text = AddHotkeyName( _( "Zoom &In" ), g_Module_Editor_Hokeys_Descr,
                          HK_ZOOM_IN, IS_ACCELERATOR );
    AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );

    text = AddHotkeyName( _( "Zoom &Out" ), g_Module_Editor_Hokeys_Descr,
                          HK_ZOOM_OUT, IS_ACCELERATOR );
    AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );

    text = AddHotkeyName( _( "&Fit on Screen" ), g_Module_Editor_Hokeys_Descr,
                          HK_ZOOM_AUTO  );
    AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
227
                 KiBitmap( zoom_fit_in_page_xpm ) );
228

229 230 231
    text = AddHotkeyName( _( "&Redraw" ), g_Module_Editor_Hokeys_Descr, HK_ZOOM_REDRAW );
    AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text,
                 HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
232

233
    viewMenu->AppendSeparator();
234

235
    // 3D view
236
    text = AddHotkeyName( _( "&3D Viewer" ), g_Module_Editor_Hokeys_Descr, HK_3D_VIEWER );
237
    AddMenuItem( viewMenu, ID_MENU_PCB_SHOW_3D_FRAME, text, _( "Show footprint in 3D viewer" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
238
                 KiBitmap( three_d_xpm ) );
239

240
    //-------- Place menu --------------------
241 242
    wxMenu* placeMenu = new wxMenu;

243
    // Pad
244
    AddMenuItem( placeMenu, ID_MODEDIT_PAD_TOOL,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
245 246
                 _( "&Pad" ), _( "Add pad" ),
                 KiBitmap( pad_xpm ) );
247 248 249

    placeMenu->AppendSeparator();

250
    // Circle
251
    AddMenuItem( placeMenu, ID_MODEDIT_CIRCLE_TOOL,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
252 253
                 _( "&Circle" ), _( "Add graphic circle" ),
                 KiBitmap( add_circle_xpm ) );
254

255
    // Line or Polygon
256
    AddMenuItem( placeMenu, ID_MODEDIT_LINE_TOOL,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
257 258 259
                 _( "&Line or Polygon" ),
                 _( "Add graphic line or polygon" ),
                 KiBitmap( add_polygon_xpm ) );
260

261
    // Arc
262
    AddMenuItem( placeMenu, ID_MODEDIT_ARC_TOOL,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
263 264
                 _( "&Arc" ), _( "Add graphic arc" ),
                 KiBitmap( add_arc_xpm ) );
265

266
    // Text
267
    AddMenuItem( placeMenu, ID_MODEDIT_TEXT_TOOL,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
268 269
                 _( "&Text" ), _( "Add graphic text" ),
                 KiBitmap( add_text_xpm ) );
270 271

    placeMenu->AppendSeparator();
Wayne Stambaugh's avatar
Wayne Stambaugh committed
272 273

    // Anchor
274
    AddMenuItem( placeMenu, ID_MODEDIT_ANCHOR_TOOL,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
275
                 _( "A&nchor" ),
276
                 _( "Place footprint reference anchor" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
277
                 KiBitmap( anchor_xpm ) );
278

279 280 281 282

    //----- Preferences menu -----------------
    wxMenu* prefs_menu = new wxMenu;

283 284 285 286
    AddMenuItem( prefs_menu, ID_PCB_LIB_WIZARD,
                _( "&Footprint Libraries Wizard" ), _( "Add footprint libraries with wizard" ),
                KiBitmap( wizard_add_fplib_small_xpm ) );

287
    AddMenuItem( prefs_menu, ID_PCB_LIB_TABLE_EDIT,
288
                _( "Footprint Li&braries Manager" ), _( "Configure footprint libraries" ),
289 290
                KiBitmap( library_table_xpm ) );

291 292 293 294 295 296 297
    // Path configuration edit dialog.
    AddMenuItem( prefs_menu,
                 ID_PREFERENCES_CONFIGURE_PATHS,
                 _( "Configure Pa&ths" ),
                 _( "Edit path configuration environment variables" ),
                 KiBitmap( editor_xpm ) );

298 299 300 301 302 303 304 305 306 307 308 309
    // Settings
    AddMenuItem( prefs_menu, wxID_PREFERENCES,
                 _( "&Settings" ), _( "Select default parameters values in Footprint Editor" ),
                 KiBitmap( preference_xpm ) );

    // Language submenu
    Pgm().AddMenuLanguageList( prefs_menu );

    // Hotkey submenu
    AddHotkeyConfigMenu( prefs_menu );

    //----- Help menu --------------------
310 311
    wxMenu* helpMenu = new wxMenu;

312
    // Version info
313 314
    AddHelpVersionInfoMenuEntry( helpMenu );

315
    // Contents
316
    AddMenuItem( helpMenu, wxID_HELP,
317 318
                 _( "P&cbnew Manual" ),
                 _( "Open the Pcbnew manual" ),
Wayne Stambaugh's avatar
Wayne Stambaugh committed
319 320
                 KiBitmap( online_help_xpm ) );

321
    AddMenuItem( helpMenu, wxID_INDEX,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
322 323 324
                 _( "&Getting Started in KiCad" ),
                 _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
                 KiBitmap( help_xpm ) );
325

326
    // About Pcbnew
327
    helpMenu->AppendSeparator();
328
    AddMenuItem( helpMenu, wxID_ABOUT,
Wayne Stambaugh's avatar
Wayne Stambaugh committed
329 330 331
                 _( "&About Pcbnew" ),
                 _( "About Pcbnew PCB designer" ),
                 KiBitmap( info_xpm ) );
332

333
    // Append menus to the menubar
334 335 336
    menuBar->Append( fileMenu, _( "&File" ) );
    menuBar->Append( editMenu, _( "&Edit" ) );
    menuBar->Append( viewMenu, _( "&View" ) );
337
    menuBar->Append( placeMenu, _( "&Place" ) );
338 339
    menuBar->Append( prefs_menu, _( "P&references" ) );
    menuBar->Append( dimensions_Submenu, _( "Di&mensions" ) );
340
    menuBar->Append( helpMenu, _( "&Help" ) );
341

342 343 344 345 346 347 348
    menuBar->Thaw();

    // Associate the menu bar with the frame, if no previous menubar
    if( GetMenuBar() == NULL )
        SetMenuBar( menuBar );
    else
        menuBar->Refresh();
349
}