2011-10-18 19:59:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-11-20 16:14:25 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-08-31 15:15:20 +00:00
|
|
|
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
|
2020-07-27 22:42:23 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2011-10-18 19:59:19 +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
|
|
|
|
*/
|
|
|
|
|
2016-02-24 21:36:52 +00:00
|
|
|
#include <bitmaps.h>
|
2019-11-23 16:54:48 +00:00
|
|
|
#include <filehistory.h>
|
2016-02-24 21:36:52 +00:00
|
|
|
#include <menus_helpers.h>
|
2020-07-27 22:42:23 +00:00
|
|
|
#include <tool/action_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2020-07-27 22:42:23 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-06-09 13:12:44 +00:00
|
|
|
#include <tools/kicad_manager_control.h>
|
|
|
|
#include <tools/kicad_manager_actions.h>
|
2019-06-09 10:10:19 +00:00
|
|
|
#include "kicad_manager_frame.h"
|
2016-02-24 21:36:52 +00:00
|
|
|
#include "pgm_kicad.h"
|
2019-05-25 19:39:42 +00:00
|
|
|
#include "kicad_id.h"
|
2020-06-06 17:42:04 +00:00
|
|
|
#include <widgets/wx_menubar.h>
|
2016-02-24 21:36:52 +00:00
|
|
|
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
2008-11-02 22:53:38 +00:00
|
|
|
{
|
2019-06-09 13:12:44 +00:00
|
|
|
KICAD_MANAGER_CONTROL* controlTool = m_toolManager->GetTool<KICAD_MANAGER_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();
|
2020-06-06 17:42:04 +00:00
|
|
|
WX_MENUBAR* menuBar = new WX_MENUBAR();
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
//-- File menu -----------------------------------------------------------
|
|
|
|
//
|
2020-07-27 22:42:23 +00:00
|
|
|
ACTION_MENU* fileMenu = new ACTION_MENU( false, controlTool );
|
|
|
|
FILE_HISTORY& fileHistory = GetFileHistory();
|
2020-02-25 15:46:56 +00:00
|
|
|
|
|
|
|
fileHistory.SetClearText( _( "Clear Recent Projects" ) );
|
|
|
|
|
|
|
|
static ACTION_MENU* openRecentMenu;
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2019-11-23 16:54:48 +00:00
|
|
|
// Create the menu if it does not exist. Adding a file to/from the history
|
|
|
|
// will automatically refresh the menu.
|
|
|
|
if( !openRecentMenu )
|
|
|
|
{
|
2020-07-27 22:42:23 +00:00
|
|
|
openRecentMenu = new ACTION_MENU( false, controlTool );
|
2019-11-23 16:54:48 +00:00
|
|
|
openRecentMenu->SetTitle( _( "Open Recent" ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
openRecentMenu->SetIcon( BITMAPS::recent );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
|
|
|
fileHistory.UseMenu( openRecentMenu );
|
|
|
|
fileHistory.AddFilesToMenu();
|
2019-11-23 16:54:48 +00:00
|
|
|
}
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
fileMenu->Add( KICAD_MANAGER_ACTIONS::newProject );
|
|
|
|
fileMenu->Add( KICAD_MANAGER_ACTIONS::newFromTemplate );
|
|
|
|
fileMenu->Add( KICAD_MANAGER_ACTIONS::openProject );
|
2019-06-16 18:35:32 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
wxMenuItem* item = fileMenu->Add( openRecentMenu );
|
2020-08-15 16:43:54 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
// Add the file menu condition here since it needs the item ID for the submenu
|
|
|
|
ACTION_CONDITIONS cond;
|
2020-08-05 22:00:26 +00:00
|
|
|
cond.Enable( FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
|
2020-07-27 22:42:23 +00:00
|
|
|
RegisterUIUpdateHandler( item->GetId(), cond );
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2021-01-15 21:07:31 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2020-07-27 22:42:23 +00:00
|
|
|
fileMenu->Add( KICAD_MANAGER_ACTIONS::closeProject );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
fileMenu->Add( ACTIONS::saveAs );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2020-09-27 17:12:32 +00:00
|
|
|
|
|
|
|
//Import Sub-menu
|
|
|
|
ACTION_MENU* importMenu = new ACTION_MENU( false, controlTool );
|
|
|
|
importMenu->SetTitle( _( "Import Non-KiCad Project..." ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
importMenu->SetIcon( BITMAPS::import_project );
|
2020-09-27 17:12:32 +00:00
|
|
|
|
|
|
|
importMenu->Add( _( "Import CADSTAR Project..." ),
|
|
|
|
_( "Import CADSTAR Archive Schematic and PCB (*.csa, *.cpa)" ),
|
|
|
|
ID_IMPORT_CADSTAR_ARCHIVE_PROJECT,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::import_project );
|
2020-09-27 17:12:32 +00:00
|
|
|
|
|
|
|
importMenu->Add( _( "Import EAGLE Project..." ),
|
|
|
|
_( "Import EAGLE CAD XML schematic and board" ),
|
|
|
|
ID_IMPORT_EAGLE_PROJECT,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::import_project );
|
2020-09-27 17:12:32 +00:00
|
|
|
|
|
|
|
fileMenu->Add( importMenu );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
fileMenu->Add( _( "&Archive Project..." ),
|
|
|
|
_( "Archive all needed project files into zip archive" ),
|
|
|
|
ID_SAVE_AND_ZIP_FILES,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::zip );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
fileMenu->Add( _( "&Unarchive Project..." ),
|
|
|
|
_( "Unarchive project files from zip archive" ),
|
|
|
|
ID_READ_ZIP_ARCHIVE,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::unzip );
|
2020-07-27 22:42:23 +00:00
|
|
|
|
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
fileMenu->AddQuitOrClose( nullptr, "KiCad" );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
|
|
|
//-- View menu -----------------------------------------------------------
|
|
|
|
//
|
2020-07-27 22:42:23 +00:00
|
|
|
ACTION_MENU* viewMenu = new ACTION_MENU( false, controlTool );
|
2019-06-16 18:35:32 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
viewMenu->Add( ACTIONS::zoomRedraw );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
viewMenu->Add( KICAD_MANAGER_ACTIONS::openTextEditor );
|
|
|
|
viewMenu->Add( _( "Browse Project Files" ),
|
|
|
|
_( "Open project directory in file browser" ),
|
|
|
|
ID_BROWSE_IN_FILE_EXPLORER,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::directory_browser );
|
2017-09-06 14:54:15 +00:00
|
|
|
|
2018-02-22 17:50:32 +00:00
|
|
|
#ifdef __APPLE__
|
2020-07-27 22:42:23 +00:00
|
|
|
// Add a separator only on macOS because the OS adds menu items to the view menu after ours
|
|
|
|
viewMenu->AppendSeparator();
|
2018-02-22 17:50:32 +00:00
|
|
|
#endif
|
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
//-- Tools menu -----------------------------------------------
|
|
|
|
//
|
2020-07-27 22:42:23 +00:00
|
|
|
ACTION_MENU* toolsMenu = new ACTION_MENU( false, controlTool );
|
2019-06-10 14:23:37 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::editSchematic );
|
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::editSymbols );
|
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::editPCB );
|
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::editFootprints );
|
2019-06-10 14:23:37 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
toolsMenu->AppendSeparator();
|
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::viewGerbers );
|
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::convertImage );
|
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::showCalculator );
|
2021-02-22 16:37:43 +00:00
|
|
|
toolsMenu->Add( KICAD_MANAGER_ACTIONS::editDrawingSheet );
|
2019-06-16 18:35:32 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
toolsMenu->AppendSeparator();
|
|
|
|
toolsMenu->Add( _( "Edit Local File..." ),
|
|
|
|
_( "Edit local file in text editor" ),
|
|
|
|
ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::editor );
|
2015-03-02 17:29:18 +00:00
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
//-- Preferences menu -----------------------------------------------
|
|
|
|
//
|
2020-07-27 22:42:23 +00:00
|
|
|
ACTION_MENU* prefsMenu = new ACTION_MENU( false, controlTool );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
prefsMenu->Add( ACTIONS::configurePaths );
|
|
|
|
prefsMenu->Add( ACTIONS::showSymbolLibTable );
|
|
|
|
prefsMenu->Add( ACTIONS::showFootprintLibTable );
|
2020-11-04 01:28:55 +00:00
|
|
|
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
|
2020-07-27 22:42:23 +00:00
|
|
|
_( "Show preferences for all open tools" ),
|
|
|
|
wxID_PREFERENCES,
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS::preference );
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
prefsMenu->AppendSeparator();
|
2019-06-16 18:35:32 +00:00
|
|
|
AddMenuLanguageList( prefsMenu, controlTool );
|
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
|
|
|
|
//-- Menubar -------------------------------------------------------------
|
|
|
|
//
|
2020-07-27 22:42:23 +00:00
|
|
|
menuBar->Append( fileMenu, _( "&File" ) );
|
|
|
|
menuBar->Append( viewMenu, _( "&View" ) );
|
2017-09-06 14:54:15 +00:00
|
|
|
menuBar->Append( toolsMenu, _( "&Tools" ) );
|
2019-06-09 13:12:44 +00:00
|
|
|
menuBar->Append( prefsMenu, _( "&Preferences" ) );
|
2019-05-18 10:27:36 +00:00
|
|
|
AddStandardHelpMenu( menuBar );
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2018-04-07 13:13:38 +00:00
|
|
|
SetMenuBar( menuBar );
|
|
|
|
delete oldMenuBar;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-02 22:53:38 +00:00
|
|
|
/**
|
2010-02-14 14:59:43 +00:00
|
|
|
* @brief (Re)Create the horizontal toolbar
|
2008-11-02 22:53:38 +00:00
|
|
|
*/
|
2011-04-17 13:54:17 +00:00
|
|
|
void KICAD_MANAGER_FRAME::RecreateBaseHToolbar()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2018-01-08 04:05:03 +00:00
|
|
|
if( m_mainToolBar )
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
2020-06-23 10:42:23 +00:00
|
|
|
m_mainToolBar->ClearToolbar();
|
2020-09-26 23:55:59 +00:00
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
else
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
2019-06-09 13:12:44 +00:00
|
|
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
2020-09-26 23:55:59 +00:00
|
|
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
|
|
|
}
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// New
|
2019-06-09 13:12:44 +00:00
|
|
|
m_mainToolBar->Add( KICAD_MANAGER_ACTIONS::newProject );
|
|
|
|
m_mainToolBar->Add( KICAD_MANAGER_ACTIONS::openProject );
|
2008-11-02 22:53:38 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2011-12-16 13:32:23 +00:00
|
|
|
m_mainToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxEmptyString,
|
2021-03-08 02:59:07 +00:00
|
|
|
KiScaledBitmap( BITMAPS::zip, this ),
|
2011-12-16 13:32:23 +00:00
|
|
|
_( "Archive all project files" ) );
|
2008-11-02 22:53:38 +00:00
|
|
|
|
2017-09-06 14:54:15 +00:00
|
|
|
m_mainToolBar->AddTool( ID_READ_ZIP_ARCHIVE, wxEmptyString,
|
2021-03-08 02:59:07 +00:00
|
|
|
KiScaledBitmap( BITMAPS::unzip, this ),
|
2017-09-06 14:54:15 +00:00
|
|
|
_( "Unarchive project files from zip archive" ) );
|
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2019-06-09 13:12:44 +00:00
|
|
|
m_mainToolBar->Add( ACTIONS::zoomRedraw );
|
2008-11-02 22:53:38 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2018-11-02 12:51:13 +00:00
|
|
|
m_mainToolBar->AddTool( ID_BROWSE_IN_FILE_EXPLORER, wxEmptyString,
|
2021-03-08 02:59:07 +00:00
|
|
|
KiScaledBitmap( BITMAPS::directory_browser, this ),
|
2019-07-17 10:57:12 +00:00
|
|
|
#ifdef __APPLE__
|
2020-04-08 21:34:18 +00:00
|
|
|
_( "Reveal project folder in Finder" ) );
|
2019-07-17 10:57:12 +00:00
|
|
|
#else
|
2018-11-02 12:51:13 +00:00
|
|
|
_( "Open project directory in file explorer" ) );
|
2019-07-17 10:57:12 +00:00
|
|
|
#endif
|
2018-11-02 12:51:13 +00:00
|
|
|
|
2011-12-16 13:32:23 +00:00
|
|
|
// Create m_mainToolBar
|
|
|
|
m_mainToolBar->Realize();
|
2008-11-02 22:53:38 +00:00
|
|
|
}
|