2011-12-16 20:12:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2019-06-16 18:35:32 +00:00
|
|
|
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-16 20:12:49 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
#include <bitmaps.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <menus_helpers.h>
|
2019-06-02 18:58:09 +00:00
|
|
|
#include <tool/actions.h>
|
2019-06-10 22:17:45 +00:00
|
|
|
#include <tool/common_control.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <tool/conditional_menu.h>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
|
|
|
|
#include <cvpcb_mainframe.h>
|
|
|
|
#include <tools/cvpcb_actions.h>
|
2012-02-01 19:49:37 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::ReCreateMenuBar()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-06-10 22:17:45 +00:00
|
|
|
COMMON_CONTROL* tool = m_toolManager->GetTool<COMMON_CONTROL>();
|
2018-04-07 13:13:38 +00:00
|
|
|
// wxWidgets handles the Mac Application menu behind the scenes, but that means
|
|
|
|
// we always have to start from scratch with a new wxMenuBar.
|
|
|
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
|
|
|
wxMenuBar* menuBar = new wxMenuBar();
|
2010-12-17 20:34:29 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
//-- File menu -----------------------------------------------------------
|
|
|
|
//
|
|
|
|
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, tool );
|
2009-04-21 17:56:27 +00:00
|
|
|
|
2019-12-19 15:35:11 +00:00
|
|
|
auto enableSaveCondition = [ this ] ( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
return IsContentModified();
|
|
|
|
};
|
|
|
|
|
|
|
|
fileMenu->AddItem( CVPCB_ACTIONS::saveAssociations, enableSaveCondition );
|
2019-08-10 09:17:42 +00:00
|
|
|
fileMenu->AddSeparator();
|
2019-08-13 23:34:05 +00:00
|
|
|
fileMenu->AddClose( _( "Assign Footprints" ) );
|
2019-06-16 18:35:32 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
fileMenu->Resolve();
|
2009-04-21 17:56:27 +00:00
|
|
|
|
2019-07-26 18:58:20 +00:00
|
|
|
//-- Preferences menu -----------------------------------------------
|
|
|
|
//
|
|
|
|
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, tool );
|
|
|
|
|
|
|
|
auto enableUndoCondition = [ this ] ( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
return m_undoList.size() > 0;
|
|
|
|
};
|
|
|
|
auto enableRedoCondition = [ this ] ( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
return m_redoList.size() > 0;
|
|
|
|
};
|
|
|
|
|
2019-08-09 22:13:17 +00:00
|
|
|
editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
|
|
|
|
editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
|
|
|
|
editMenu->AddSeparator();
|
|
|
|
editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::ShowAlways );
|
|
|
|
editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::ShowAlways );
|
|
|
|
editMenu->AddItem( ACTIONS::paste, SELECTION_CONDITIONS::ShowAlways );
|
2019-07-26 18:58:20 +00:00
|
|
|
|
|
|
|
editMenu->Resolve();
|
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
//-- Preferences menu -----------------------------------------------
|
|
|
|
//
|
|
|
|
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool );
|
2010-01-18 19:33:45 +00:00
|
|
|
|
2019-07-18 21:47:01 +00:00
|
|
|
prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways );
|
|
|
|
prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways );
|
2019-06-10 22:17:45 +00:00
|
|
|
prefsMenu->AddItem( wxID_PREFERENCES,
|
|
|
|
_( "Preferences...\tCTRL+," ),
|
|
|
|
_( "Show preferences for all open tools" ),
|
2019-07-18 21:47:01 +00:00
|
|
|
preference_xpm, SELECTION_CONDITIONS::ShowAlways );
|
2019-06-10 22:17:45 +00:00
|
|
|
prefsMenu->AddSeparator();
|
2019-07-18 21:47:01 +00:00
|
|
|
prefsMenu->AddItem( CVPCB_ACTIONS::showEquFileTable, SELECTION_CONDITIONS::ShowAlways );
|
2015-03-29 21:22:53 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
prefsMenu->AddSeparator();
|
2019-06-16 18:35:32 +00:00
|
|
|
AddMenuLanguageList( prefsMenu, tool );
|
2018-05-01 20:46:05 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
prefsMenu->Resolve();
|
2015-01-11 17:22:45 +00:00
|
|
|
|
2019-06-10 22:17:45 +00:00
|
|
|
//-- Menubar -------------------------------------------------------------
|
|
|
|
//
|
|
|
|
menuBar->Append( fileMenu, _( "&File" ) );
|
2019-07-26 18:58:20 +00:00
|
|
|
menuBar->Append( editMenu, _( "&Edit" ) );
|
2019-06-10 22:17:45 +00:00
|
|
|
menuBar->Append( prefsMenu, _( "&Preferences" ) );
|
2019-05-18 10:27:36 +00:00
|
|
|
AddStandardHelpMenu( menuBar );
|
2009-04-21 17:56:27 +00:00
|
|
|
|
2018-04-07 13:13:38 +00:00
|
|
|
SetMenuBar( menuBar );
|
|
|
|
delete oldMenuBar;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|