~cern-kicad/kicad/kicad-pns-tom

« back to all changes in this revision

Viewing changes to pagelayout_editor/menubar.cpp

  • Committer: Maciej Suminski
  • Date: 2013-08-02 13:57:24 UTC
  • mfrom: (4024.1.238 kicad)
  • mto: This revision was merged to the branch mainline in revision 4221.
  • Revision ID: maciej.suminski@cern.ch-20130802135724-gix6orezshkukodv
Upstream merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This program source code file is part of KiCad, a free EDA CAD application.
 
3
 *
 
4
 * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
 
5
 * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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
 
23
 */
 
24
 
 
25
/**
 
26
 * @file pl_editor/menubar.cpp
 
27
 * @brief (Re)Create the main menubar for Pl_Editor
 
28
 */
 
29
#include <fctsys.h>
 
30
 
 
31
#include <appl_wxstruct.h>
 
32
 
 
33
#include <pl_editor_frame.h>
 
34
#include <pl_editor_id.h>
 
35
#include <hotkeys.h>
 
36
#include <menus_helpers.h>
 
37
 
 
38
 
 
39
void PL_EDITOR_FRAME::ReCreateMenuBar( void )
 
40
{
 
41
    // Create and try to get the current menubar
 
42
    wxMenuBar* menuBar = GetMenuBar();
 
43
 
 
44
    if( !menuBar )
 
45
        menuBar = new wxMenuBar();
 
46
 
 
47
    // Delete all existing menus so they can be rebuilt.
 
48
    // This allows language changes of the menu text on the fly.
 
49
    menuBar->Freeze();
 
50
 
 
51
    while( menuBar->GetMenuCount() )
 
52
        delete menuBar->Remove( 0 );
 
53
 
 
54
    // Recreate all menus:
 
55
 
 
56
    // Menu File:
 
57
    wxMenu* fileMenu = new wxMenu;
 
58
 
 
59
    // Load
 
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 ) );
 
69
 
 
70
    // Recent gerber files
 
71
    static wxMenu* openRecentMenu;
 
72
 
 
73
    // Add this menu to list menu managed by m_fileHistory
 
74
    // (the file history will be updated when adding/removing files in history
 
75
    if( openRecentMenu )
 
76
        wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
 
77
 
 
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 ) );
 
84
 
 
85
     fileMenu->AppendSeparator();
 
86
    // Save current sheet
 
87
    AddMenuItem( fileMenu, wxID_SAVE,
 
88
                 _( "&Save Page Layout Design" ),
 
89
                 wxEmptyString, KiBitmap( save_xpm ) );
 
90
 
 
91
    // Save current sheet as
 
92
    AddMenuItem( fileMenu, wxID_SAVEAS,
 
93
                 _( "Save Page Layout Design &As" ),
 
94
                 wxEmptyString, KiBitmap( save_as_xpm ) );
 
95
 
 
96
    // Print
 
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 ) );
 
102
 
 
103
    // Separator
 
104
    fileMenu->AppendSeparator();
 
105
 
 
106
    // Exit
 
107
    AddMenuItem( fileMenu, wxID_EXIT,
 
108
                 _( "E&xit" ),
 
109
                 _( "Quit Pl_Editor" ),
 
110
                 KiBitmap( exit_xpm ) );
 
111
 
 
112
    // Menu for preferences
 
113
    wxMenu* preferencesMenu = new wxMenu;
 
114
 
 
115
    AddMenuItem( preferencesMenu,
 
116
                 ID_MENU_SWITCH_BGCOLOR,
 
117
                 g_DrawBgColor == WHITE ?
 
118
                 _( "&BackGround Black" ) : _( "&BackGround White" ),
 
119
                 wxEmptyString, KiBitmap( palette_xpm ) );
 
120
 
 
121
    AddMenuItem( preferencesMenu,
 
122
                 ID_MENU_GRID_ONOFF,
 
123
                 IsGridVisible() ? _( "Hide &Grid" ) :  _( "Show &Grid" ),
 
124
                 wxEmptyString, KiBitmap( grid_xpm ) );
 
125
 
 
126
    // Text editor selection
 
127
    AddMenuItem( preferencesMenu,
 
128
                 ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR,
 
129
                 _( "&Text Editor" ),
 
130
                 _( "Select your preferred text editor" ),
 
131
                 KiBitmap( editor_xpm ) );
 
132
 
 
133
    // Language submenu
 
134
    wxGetApp().AddMenuLanguageList( preferencesMenu );
 
135
 
 
136
    // Hotkey submenu
 
137
    AddHotkeyConfigMenu( preferencesMenu );
 
138
 
 
139
    // Menu Help
 
140
    wxMenu* helpMenu = new wxMenu;
 
141
 
 
142
    // Version info
 
143
    AddHelpVersionInfoMenuEntry( helpMenu );
 
144
 
 
145
    // Contents
 
146
    AddMenuItem( helpMenu,
 
147
                 wxID_HELP,
 
148
                 _( "&Contents" ),
 
149
                 _( "Open the GerbView handbook" ),
 
150
                 KiBitmap( help_xpm ) );
 
151
 
 
152
    // About GerbView
 
153
    AddMenuItem( helpMenu,
 
154
                 wxID_ABOUT,
 
155
                 _( "&About Pl_Editor" ),
 
156
                 _( "About page layout description editor" ),
 
157
                 KiBitmap( online_help_xpm ) );
 
158
 
 
159
    // Append menus to the menubar
 
160
    menuBar->Append( fileMenu, _( "&File" ) );
 
161
    menuBar->Append( preferencesMenu, _( "&Preferences" ) );
 
162
    menuBar->Append( helpMenu, _( "&Help" ) );
 
163
 
 
164
    menuBar->Thaw();
 
165
 
 
166
    // Associate the menu bar with the frame, if no previous menubar
 
167
    if( GetMenuBar() == NULL )
 
168
        SetMenuBar( menuBar );
 
169
    else
 
170
        menuBar->Refresh();
 
171
}