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-2019 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 #include <bitmaps.h>
26 #include <menus_helpers.h>
27 #include <tool/actions.h>
28 #include <tool/common_control.h>
29 #include <tool/conditional_menu.h>
30 #include <tool/tool_manager.h>
31 
32 #include <cvpcb_mainframe.h>
33 #include <tools/cvpcb_actions.h>
34 
35 
37 {
39  // wxWidgets handles the Mac Application menu behind the scenes, but that means
40  // we always have to start from scratch with a new wxMenuBar.
41  wxMenuBar* oldMenuBar = GetMenuBar();
42  wxMenuBar* menuBar = new wxMenuBar();
43 
44  //-- File menu -----------------------------------------------------------
45  //
46  CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, tool );
47 
48  auto enableSaveCondition = [ this ] ( const SELECTION& sel )
49  {
50  return IsContentModified();
51  };
52 
53  fileMenu->AddItem( CVPCB_ACTIONS::saveAssociations, enableSaveCondition );
54  fileMenu->AddSeparator();
55  fileMenu->AddClose( _( "Assign Footprints" ) );
56 
57  fileMenu->Resolve();
58 
59  //-- Preferences menu -----------------------------------------------
60  //
61  CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, tool );
62 
63  auto enableUndoCondition = [ this ] ( const SELECTION& sel )
64  {
65  return m_undoList.size() > 0;
66  };
67  auto enableRedoCondition = [ this ] ( const SELECTION& sel )
68  {
69  return m_redoList.size() > 0;
70  };
71 
72  editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
73  editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
74  editMenu->AddSeparator();
78 
79  editMenu->Resolve();
80 
81  //-- Preferences menu -----------------------------------------------
82  //
83  CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool );
84 
87  prefsMenu->AddItem( wxID_PREFERENCES,
88  _( "Preferences...\tCTRL+," ),
89  _( "Show preferences for all open tools" ),
91  prefsMenu->AddSeparator();
93 
94  prefsMenu->AddSeparator();
95  AddMenuLanguageList( prefsMenu, tool );
96 
97  prefsMenu->Resolve();
98 
99  //-- Menubar -------------------------------------------------------------
100  //
101  menuBar->Append( fileMenu, _( "&File" ) );
102  menuBar->Append( editMenu, _( "&Edit" ) );
103  menuBar->Append( prefsMenu, _( "&Preferences" ) );
104  AddStandardHelpMenu( menuBar );
105 
106  SetMenuBar( menuBar );
107  delete oldMenuBar;
108 }
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
static TOOL_ACTION showEquFileTable
Definition: cvpcb_actions.h:60
bool IsContentModified() override
Get if the current associations have been modified but not saved.
static TOOL_ACTION copy
Definition: actions.h:70
static TOOL_ACTION showFootprintLibTable
Definition: actions.h:164
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
static TOOL_ACTION cut
Definition: actions.h:69
void ReCreateMenuBar() override
Recreates the menu bar.
CVPCB_UNDO_REDO_LIST m_undoList
static TOOL_ACTION saveAssociations
Management actions.
Definition: cvpcb_actions.h:59
COMMON_CONTROL.
void Resolve()
Function Resolve()
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
static TOOL_ACTION redo
Definition: actions.h:68
void AddClose(wxString aAppname="")
Function AddClose()
void AddMenuLanguageList(CONDITIONAL_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
#define _(s)
Definition: 3d_actions.cpp:31
CVPCB_UNDO_REDO_LIST m_redoList
static TOOL_ACTION undo
Definition: actions.h:67
TOOL_MANAGER * m_toolManager
const BITMAP_OPAQUE preference_xpm[1]
Definition: preference.cpp:66
static TOOL_ACTION configurePaths
Definition: actions.h:162
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION paste
Definition: actions.h:71