2
* This program source code file is part of KiCad, a free EDA CAD application.
4
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, you may find one here:
19
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20
* or you may search the http://www.gnu.org website for the version 2 license,
21
* or you may write to the Free Software Foundation, Inc.,
22
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26
* @file pl_editor/menubar.cpp
27
* @brief (Re)Create the main menubar for Pl_Editor
31
#include <appl_wxstruct.h>
33
#include <pl_editor_frame.h>
34
#include <pl_editor_id.h>
36
#include <menus_helpers.h>
39
void PL_EDITOR_FRAME::ReCreateMenuBar( void )
41
// Create and try to get the current menubar
42
wxMenuBar* menuBar = GetMenuBar();
45
menuBar = new wxMenuBar();
47
// Delete all existing menus so they can be rebuilt.
48
// This allows language changes of the menu text on the fly.
51
while( menuBar->GetMenuCount() )
52
delete menuBar->Remove( 0 );
54
// Recreate all menus:
57
wxMenu* fileMenu = new wxMenu;
60
AddMenuItem( fileMenu, wxID_NEW,
61
_( "&New Page Layout Design" ),
62
wxEmptyString, KiBitmap( pagelayout_new_xpm ) );
63
AddMenuItem( fileMenu, wxID_OPEN,
64
_( "Load &Page Layout File" ),
65
wxEmptyString, KiBitmap( pagelayout_load_xpm ) );
66
AddMenuItem( fileMenu, ID_LOAD_DEFAULT_PAGE_LAYOUT,
67
_( "Load &Default Page Layout" ),
68
wxEmptyString, KiBitmap( pagelayout_load_default_xpm ) );
70
// Recent gerber files
71
static wxMenu* openRecentMenu;
73
// Add this menu to list menu managed by m_fileHistory
74
// (the file history will be updated when adding/removing files in history
76
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
78
openRecentMenu = new wxMenu();
79
wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
80
wxGetApp().GetFileHistory().AddFilesToMenu();
81
AddMenuItem( fileMenu, openRecentMenu,
82
wxID_ANY, _( "Open &Recent Page Layout File" ),
83
wxEmptyString, KiBitmap( pagelayout_recent_xpm ) );
85
fileMenu->AppendSeparator();
87
AddMenuItem( fileMenu, wxID_SAVE,
88
_( "&Save Page Layout Design" ),
89
wxEmptyString, KiBitmap( save_xpm ) );
91
// Save current sheet as
92
AddMenuItem( fileMenu, wxID_SAVEAS,
93
_( "Save Page Layout Design &As" ),
94
wxEmptyString, KiBitmap( save_as_xpm ) );
97
fileMenu->AppendSeparator();
98
AddMenuItem( fileMenu, wxID_PRINT, _( "&Print" ),
99
wxEmptyString, KiBitmap( print_button_xpm ) );
100
AddMenuItem( fileMenu, wxID_PREVIEW, _( "Print Pre&view" ),
101
wxEmptyString, KiBitmap( print_button_xpm ) );
104
fileMenu->AppendSeparator();
107
AddMenuItem( fileMenu, wxID_EXIT,
109
_( "Quit Pl_Editor" ),
110
KiBitmap( exit_xpm ) );
112
// Menu for preferences
113
wxMenu* preferencesMenu = new wxMenu;
115
AddMenuItem( preferencesMenu,
116
ID_MENU_SWITCH_BGCOLOR,
117
g_DrawBgColor == WHITE ?
118
_( "&BackGround Black" ) : _( "&BackGround White" ),
119
wxEmptyString, KiBitmap( palette_xpm ) );
121
AddMenuItem( preferencesMenu,
123
IsGridVisible() ? _( "Hide &Grid" ) : _( "Show &Grid" ),
124
wxEmptyString, KiBitmap( grid_xpm ) );
126
// Text editor selection
127
AddMenuItem( preferencesMenu,
128
ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR,
130
_( "Select your preferred text editor" ),
131
KiBitmap( editor_xpm ) );
134
wxGetApp().AddMenuLanguageList( preferencesMenu );
137
AddHotkeyConfigMenu( preferencesMenu );
140
wxMenu* helpMenu = new wxMenu;
143
AddHelpVersionInfoMenuEntry( helpMenu );
146
AddMenuItem( helpMenu,
149
_( "Open the GerbView handbook" ),
150
KiBitmap( help_xpm ) );
153
AddMenuItem( helpMenu,
155
_( "&About Pl_Editor" ),
156
_( "About page layout description editor" ),
157
KiBitmap( online_help_xpm ) );
159
// Append menus to the menubar
160
menuBar->Append( fileMenu, _( "&File" ) );
161
menuBar->Append( preferencesMenu, _( "&Preferences" ) );
162
menuBar->Append( helpMenu, _( "&Help" ) );
166
// Associate the menu bar with the frame, if no previous menubar
167
if( GetMenuBar() == NULL )
168
SetMenuBar( menuBar );