KiCad PCB EDA Suite
cvpcb/menubar.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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2004-2016 KiCad Developers, see change_log.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 
30 #include <common_help_msg.h>
31 #include <kiface_i.h>
32 #include <menus_helpers.h>
33 #include <pgm_base.h>
34 
35 #include "cvpcb.h"
36 #include "cvpcb_id.h"
37 #include "cvpcb_mainframe.h"
38 
39 
44 {
45  // Create the current menubar if it does not yet exist
46  wxMenuBar* menuBar = GetMenuBar();
47 
48  if( ! menuBar ) // Delete all menus
49  menuBar = new wxMenuBar();
50 
51  // Delete all existing menus so they can be rebuilt.
52  // This allows language changes of the menu text on the fly.
53  menuBar->Freeze();
54 
55  while( menuBar->GetMenuCount() )
56  delete menuBar->Remove( 0 );
57 
58  // Recreate all menus:
59 
60  // Menu File:
61  wxMenu* filesMenu = new wxMenu;
62 
63  // Save the footprints back into eeschema
64  AddMenuItem( filesMenu, wxID_SAVE,
65  _( "&Save Footprint Associations\tCtrl+S" ),
66  _( "Save footprint association in schematic component footprint fields" ),
67  KiBitmap( save_xpm ) );
68 
69  // Separator
70  filesMenu->AppendSeparator();
71 
72  // Quit
73  AddMenuItem( filesMenu, wxID_EXIT,
74  _( "&Close" ), _( "Close CvPcb" ),
75  KiBitmap( exit_xpm ) );
76 
77  // Preferences Menu :
78  wxMenu* preferencesMenu = new wxMenu;
79 
80  AddMenuItem( preferencesMenu, ID_CVPCB_LIB_TABLE_EDIT,
81  _( "Footprint Li&braries" ), _( "Configure footprint libraries" ),
82  KiBitmap( library_table_xpm ) );
83 
84  // Path configuration edit dialog.
85  AddMenuItem( preferencesMenu,
87  _( "Configure Pa&ths" ),
88  _( "Edit path configuration environment variables" ),
89  KiBitmap( editor_xpm ) );
90 
91  preferencesMenu->AppendSeparator();
92  AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT,
93  _( "&Edit Footprint Association File" ),
94  _( "Modify footprint association file (.equ). This is the file which "
95  "assigns the footprint name by the component value" ),
96  KiBitmap( library_table_xpm ) );
97  preferencesMenu->AppendSeparator();
98 
99  // Language submenu
100  Pgm().AddMenuLanguageList( preferencesMenu );
101 
102  // Keep open on save data
103  preferencesMenu->AppendSeparator();
105  _( "&Keep Open On Save" ),
106  _( "Prevent CvPcb from exiting after saving netlist file" ),
107  KiBitmap( exit_xpm ),
108  wxITEM_CHECK );
109 
110  // Menu Help:
111  wxMenu* helpMenu = new wxMenu;
112 
113  // Manual Contents
114  AddMenuItem( helpMenu, wxID_HELP, _( "CvPcb &Manual" ),
115  _( "Open CvPcb Manual" ),
116  KiBitmap( online_help_xpm ) );
117 
118  AddMenuItem( helpMenu,
119  wxID_INDEX,
120  _( "&Getting Started in KiCad" ),
121  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
122  KiBitmap( help_xpm ) );
123 
124  // About CvPcb
125  AddMenuItem( helpMenu, wxID_ABOUT,
126  _( "&About Kicad" ),
127  _( "About KiCad" ),
128  KiBitmap( info_xpm ) );
129 
130  // Create the menubar and append all submenus
131  menuBar->Append( filesMenu, _( "&Save" ) );
132  menuBar->Append( preferencesMenu, _( "&Preferences" ) );
133  menuBar->Append( helpMenu, _( "&Help" ) );
134 
135  menuBar->Thaw();
136 
137  // Associate the menu bar with the frame, if no previous menubar
138  if( GetMenuBar() == NULL )
139  SetMenuBar( menuBar );
140  else
141  menuBar->Refresh();
142 }
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
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
virtual void ReCreateMenuBar() override
(Re)Create the menubar for the CvPcb mainframe
see class PGM_BASE
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:795