2011-10-18 19:59:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-03-02 13:46:18 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-03-13 21:59:46 +00:00
|
|
|
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-04-11 07:11:26 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
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
|
|
|
|
*/
|
2021-03-07 20:31:19 +00:00
|
|
|
|
2018-12-12 14:16:50 +00:00
|
|
|
#include "gerbview_frame.h"
|
2016-03-11 16:40:24 +00:00
|
|
|
|
2021-03-07 20:31:19 +00:00
|
|
|
#include <bitmaps.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include "gerbview_id.h"
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2016-05-25 09:45:55 +00:00
|
|
|
#include <menus_helpers.h>
|
2021-06-06 17:26:26 +00:00
|
|
|
#include <tool/action_manager.h>
|
2020-07-29 23:50:25 +00:00
|
|
|
#include <tool/action_menu.h>
|
2019-05-15 22:49:48 +00:00
|
|
|
#include <tool/actions.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-05-15 22:49:48 +00:00
|
|
|
#include <tools/gerbview_actions.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tools/gerbview_selection_tool.h>
|
2020-06-06 17:42:04 +00:00
|
|
|
#include <widgets/wx_menubar.h>
|
2011-09-30 18:15:37 +00:00
|
|
|
|
2019-06-16 18:35:32 +00:00
|
|
|
|
2022-12-16 21:37:32 +00:00
|
|
|
void GERBVIEW_FRAME::doReCreateMenuBar()
|
2010-09-13 14:45:19 +00:00
|
|
|
{
|
2019-05-15 22:49:48 +00:00
|
|
|
GERBVIEW_SELECTION_TOOL* selTool = m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>();
|
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.
|
2020-06-06 17:42:04 +00:00
|
|
|
wxMenuBar* oldMenuBar = GetMenuBar();
|
|
|
|
WX_MENUBAR* menuBar = new WX_MENUBAR();
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
//-- File menu -------------------------------------------------------
|
2019-05-28 09:14:53 +00:00
|
|
|
//
|
2020-07-29 23:50:25 +00:00
|
|
|
ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
|
2020-02-25 15:46:56 +00:00
|
|
|
static ACTION_MENU* openRecentGbrMenu;
|
|
|
|
static ACTION_MENU* openRecentDrlMenu;
|
|
|
|
static ACTION_MENU* openRecentJobMenu;
|
|
|
|
static ACTION_MENU* openRecentZipMenu;
|
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
FILE_HISTORY& recentGbrFiles = GetFileHistory();
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
#define FileHistoryCond( x ) ACTION_CONDITIONS().Enable( FILE_HISTORY::FileHistoryNotEmpty( x ) )
|
2019-11-23 16:54:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Create the gerber file menu if it does not exist. Adding a file to/from the history
|
|
|
|
// will automatically refresh the menu.
|
|
|
|
if( !openRecentGbrMenu )
|
|
|
|
{
|
2021-03-27 19:16:58 +00:00
|
|
|
openRecentGbrMenu = new ACTION_MENU( false, selTool );
|
2021-03-08 02:59:07 +00:00
|
|
|
openRecentGbrMenu->SetIcon( BITMAPS::recent );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
recentGbrFiles.SetClearText( _( "Clear Recent Gerber Files" ) );
|
2022-04-11 07:11:26 +00:00
|
|
|
recentGbrFiles.UseMenu( openRecentGbrMenu );
|
2020-02-25 15:46:56 +00:00
|
|
|
recentGbrFiles.AddFilesToMenu();
|
2019-11-23 16:54:48 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 07:11:26 +00:00
|
|
|
// Ensure the title is up to date after changing language
|
|
|
|
openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) );
|
|
|
|
recentGbrFiles.UpdateClearText( openRecentGbrMenu, _( "Clear Recent Gerber Files" ) );
|
|
|
|
|
2021-08-16 18:42:46 +00:00
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::openAutodetected );
|
2020-07-29 23:50:25 +00:00
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::openGerber );
|
2022-04-11 22:59:51 +00:00
|
|
|
wxMenuItem* gbrItem = fileMenu->Add( openRecentGbrMenu->Clone() );
|
2020-07-29 23:50:25 +00:00
|
|
|
RegisterUIUpdateHandler( gbrItem->GetId(), FileHistoryCond( recentGbrFiles) );
|
|
|
|
|
|
|
|
|
2019-11-23 16:54:48 +00:00
|
|
|
// Create the drill file menu if it does not exist. Adding a file to/from the history
|
|
|
|
// will automatically refresh the menu.
|
|
|
|
if( !openRecentDrlMenu )
|
|
|
|
{
|
2021-03-27 19:16:58 +00:00
|
|
|
openRecentDrlMenu = new ACTION_MENU( false, selTool );
|
2019-11-23 16:54:48 +00:00
|
|
|
openRecentDrlMenu->SetTitle( _( "Open Recent Drill File" ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
openRecentDrlMenu->SetIcon( BITMAPS::recent );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
|
|
|
m_drillFileHistory.UseMenu( openRecentDrlMenu );
|
2020-07-29 23:50:25 +00:00
|
|
|
m_drillFileHistory.SetClearText( _( "Clear Recent Drill Files" ) );
|
2020-02-25 15:46:56 +00:00
|
|
|
m_drillFileHistory.AddFilesToMenu();
|
2019-11-23 16:54:48 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 07:11:26 +00:00
|
|
|
// Ensure the title is up to date after changing language
|
|
|
|
openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) );
|
|
|
|
m_drillFileHistory.UpdateClearText( openRecentDrlMenu, _( "Clear Recent Drill Files" ) );
|
|
|
|
|
2020-08-19 10:33:40 +00:00
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::openDrillFile );
|
2022-04-11 22:59:51 +00:00
|
|
|
wxMenuItem* drillItem = fileMenu->Add( openRecentDrlMenu->Clone() );
|
2020-07-29 23:50:25 +00:00
|
|
|
RegisterUIUpdateHandler( drillItem->GetId(), FileHistoryCond( m_drillFileHistory ) );
|
|
|
|
|
|
|
|
|
2019-11-23 16:54:48 +00:00
|
|
|
// Create the job file menu if it does not exist. Adding a file to/from the history
|
|
|
|
// will automatically refresh the menu.
|
|
|
|
if( !openRecentJobMenu )
|
|
|
|
{
|
2021-03-27 19:16:58 +00:00
|
|
|
openRecentJobMenu = new ACTION_MENU( false, selTool );
|
2021-03-08 02:59:07 +00:00
|
|
|
openRecentJobMenu->SetIcon( BITMAPS::recent );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
m_jobFileHistory.SetClearText( _( "Clear Recent Job Files" ) );
|
2022-04-11 07:11:26 +00:00
|
|
|
m_jobFileHistory.UseMenu( openRecentJobMenu );
|
2020-02-25 15:46:56 +00:00
|
|
|
m_jobFileHistory.AddFilesToMenu();
|
2019-11-23 16:54:48 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 07:11:26 +00:00
|
|
|
// Ensure the title is up to date after changing language
|
|
|
|
openRecentJobMenu->SetTitle( _( "Open Recent Job File" ) );
|
|
|
|
m_jobFileHistory.UpdateClearText( openRecentJobMenu, _( "Clear Recent Job Files" ) );
|
|
|
|
|
2020-08-19 10:33:40 +00:00
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::openJobFile );
|
2022-04-11 22:59:51 +00:00
|
|
|
wxMenuItem* jobItem = fileMenu->Add( openRecentJobMenu->Clone() );
|
2020-07-29 23:50:25 +00:00
|
|
|
RegisterUIUpdateHandler( jobItem->GetId(), FileHistoryCond( m_jobFileHistory ) );
|
|
|
|
|
|
|
|
|
2019-11-23 16:54:48 +00:00
|
|
|
// Create the zip file menu if it does not exist. Adding a file to/from the history
|
|
|
|
// will automatically refresh the menu.
|
|
|
|
if( !openRecentZipMenu )
|
|
|
|
{
|
2021-03-27 19:16:58 +00:00
|
|
|
openRecentZipMenu = new ACTION_MENU( false, selTool );
|
2021-03-08 02:59:07 +00:00
|
|
|
openRecentZipMenu->SetIcon( BITMAPS::recent );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
|
|
|
m_zipFileHistory.UseMenu( openRecentZipMenu );
|
2020-07-29 23:50:25 +00:00
|
|
|
m_zipFileHistory.SetClearText( _( "Clear Recent Zip Files" ) );
|
2020-02-25 15:46:56 +00:00
|
|
|
m_zipFileHistory.AddFilesToMenu();
|
2019-11-23 16:54:48 +00:00
|
|
|
}
|
2019-06-02 07:31:06 +00:00
|
|
|
|
2022-04-11 07:11:26 +00:00
|
|
|
// Ensure the title is up to date after changing language
|
|
|
|
openRecentZipMenu->SetTitle( _( "Open Recent Zip File" ) );
|
|
|
|
m_zipFileHistory.UpdateClearText( openRecentZipMenu, _( "Clear Recent Zip Files" ) );
|
|
|
|
|
2020-08-19 10:33:40 +00:00
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::openZipFile );
|
2022-04-11 22:59:51 +00:00
|
|
|
wxMenuItem* zipItem = fileMenu->Add( openRecentZipMenu->Clone() );
|
2020-07-29 23:50:25 +00:00
|
|
|
RegisterUIUpdateHandler( zipItem->GetId(), FileHistoryCond( m_zipFileHistory ) );
|
2020-05-03 22:02:07 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
#undef FileHistoryCond
|
2020-05-03 22:02:07 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2020-10-08 23:51:05 +00:00
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::clearAllLayers );
|
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::reloadAllLayers );
|
2019-05-28 09:14:53 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2020-10-08 22:59:16 +00:00
|
|
|
fileMenu->Add( GERBVIEW_ACTIONS::exportToPcbnew );
|
2019-05-28 09:14:53 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
fileMenu->Add( ACTIONS::print );
|
2019-05-28 09:14:53 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
fileMenu->AppendSeparator();
|
2021-02-18 15:49:35 +00:00
|
|
|
fileMenu->AddQuitOrClose( &Kiface(), _( "Gerber Viewer" ) );
|
2019-05-28 09:14:53 +00:00
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
|
|
|
|
//-- View menu -------------------------------------------------------
|
2019-05-28 09:14:53 +00:00
|
|
|
//
|
2020-07-29 23:50:25 +00:00
|
|
|
ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
|
2011-04-06 13:52:47 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
viewMenu->Add( ACTIONS::zoomInCenter );
|
|
|
|
viewMenu->Add( ACTIONS::zoomOutCenter );
|
|
|
|
viewMenu->Add( ACTIONS::zoomFitScreen );
|
|
|
|
viewMenu->Add( ACTIONS::zoomTool );
|
|
|
|
viewMenu->Add( ACTIONS::zoomRedraw );
|
|
|
|
|
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( ACTIONS::togglePolarCoords, ACTION_MENU::CHECK );
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
// Add a separator only on macOS because the OS adds menu items to the view menu after ours
|
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
#endif
|
2018-03-13 21:59:46 +00:00
|
|
|
|
|
|
|
// Units submenu
|
2020-07-29 23:50:25 +00:00
|
|
|
ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
|
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
unitsSubMenu->SetTitle( _( "&Units" ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
unitsSubMenu->SetIcon( BITMAPS::unit_mm );
|
2020-10-03 23:34:23 +00:00
|
|
|
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
|
|
|
|
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
|
|
|
|
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2022-04-11 02:33:43 +00:00
|
|
|
viewMenu->Add( unitsSubMenu );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::flashedDisplayOutlines, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::linesDisplayOutlines, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::polygonsDisplayOutlines, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::dcodeDisplay, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::negativeObjectDisplay, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::toggleDiffMode, ACTION_MENU::CHECK );
|
2022-11-17 15:42:12 +00:00
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::toggleXORMode, ACTION_MENU::CHECK );
|
2020-07-29 23:50:25 +00:00
|
|
|
viewMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::flipGerberView, ACTION_MENU::CHECK );
|
|
|
|
|
2023-01-22 01:04:17 +00:00
|
|
|
viewMenu->AppendSeparator();
|
|
|
|
viewMenu->Add( GERBVIEW_ACTIONS::toggleLayerManager, ACTION_MENU::CHECK );
|
2019-06-02 11:57:29 +00:00
|
|
|
|
|
|
|
//-- Tools menu -------------------------------------------------------
|
2019-05-28 09:14:53 +00:00
|
|
|
//
|
2020-10-08 17:31:06 +00:00
|
|
|
ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
|
2019-05-28 09:14:53 +00:00
|
|
|
|
2020-10-08 22:59:16 +00:00
|
|
|
toolsMenu->Add( GERBVIEW_ACTIONS::showDCodes );
|
|
|
|
toolsMenu->Add( GERBVIEW_ACTIONS::showSource );
|
2019-05-28 09:14:53 +00:00
|
|
|
|
2019-06-03 01:46:08 +00:00
|
|
|
toolsMenu->Add( ACTIONS::measureTool );
|
2019-05-28 09:14:53 +00:00
|
|
|
|
2019-06-02 18:58:09 +00:00
|
|
|
toolsMenu->AppendSeparator();
|
2020-10-08 23:51:05 +00:00
|
|
|
toolsMenu->Add( GERBVIEW_ACTIONS::clearLayer );
|
2020-10-08 22:59:16 +00:00
|
|
|
|
2019-05-28 09:14:53 +00:00
|
|
|
|
|
|
|
//-- Preferences menu -----------------------------------------------
|
|
|
|
//
|
2020-07-29 23:50:25 +00:00
|
|
|
ACTION_MENU* preferencesMenu = new ACTION_MENU( false, selTool );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2021-06-07 19:45:17 +00:00
|
|
|
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
|
|
|
|
// Mac, and it needs the wxID_PREFERENCES id to find it.
|
2022-02-05 19:31:22 +00:00
|
|
|
preferencesMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ),
|
2021-06-07 19:45:17 +00:00
|
|
|
_( "Show preferences for all open tools" ),
|
|
|
|
wxID_PREFERENCES,
|
|
|
|
BITMAPS::preference );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
preferencesMenu->AppendSeparator();
|
2019-06-16 18:35:32 +00:00
|
|
|
AddMenuLanguageList( preferencesMenu, selTool );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2019-06-02 11:57:29 +00:00
|
|
|
//-- Menubar -------------------------------------------------------------
|
2019-05-18 10:27:36 +00:00
|
|
|
//
|
2020-07-29 23:50:25 +00:00
|
|
|
menuBar->Append( fileMenu, _( "&File" ) );
|
|
|
|
menuBar->Append( viewMenu, _( "&View" ) );
|
|
|
|
menuBar->Append( toolsMenu, _( "&Tools" ) );
|
2019-05-28 09:14:53 +00:00
|
|
|
menuBar->Append( preferencesMenu, _( "&Preferences" ) );
|
2019-05-18 10:27:36 +00:00
|
|
|
AddStandardHelpMenu( menuBar );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
// Associate the menu bar with the frame, if no previous menubar
|
2018-04-07 13:13:38 +00:00
|
|
|
SetMenuBar( menuBar );
|
|
|
|
delete oldMenuBar;
|
2010-09-13 14:45:19 +00:00
|
|
|
}
|