2011-10-18 19:59:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2009-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
/**
|
|
|
|
* @file gerbview/menubar.cpp
|
|
|
|
* @brief (Re)Create the main menubar for GerbView
|
|
|
|
*/
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <appl_wxstruct.h>
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
|
|
|
#include <gerbview_id.h>
|
|
|
|
#include <hotkeys.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::ReCreateMenuBar( void )
|
2010-09-13 14:45:19 +00:00
|
|
|
{
|
2011-04-06 13:52:47 +00:00
|
|
|
// Create and try to get the current menubar
|
2011-03-17 19:14:45 +00:00
|
|
|
wxMenuBar* menuBar = GetMenuBar();
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
if( !menuBar )
|
2010-12-17 20:34:29 +00:00
|
|
|
menuBar = new wxMenuBar();
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
// Delete all existing menus so they can be rebuilt.
|
|
|
|
// This allows language changes of the menu text on the fly.
|
|
|
|
menuBar->Freeze();
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
while( menuBar->GetMenuCount() )
|
2011-03-17 19:14:45 +00:00
|
|
|
delete menuBar->Remove( 0 );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
// Recreate all menus:
|
2011-04-06 13:52:47 +00:00
|
|
|
|
|
|
|
// Menu File:
|
|
|
|
wxMenu* fileMenu = new wxMenu;
|
|
|
|
|
|
|
|
// Load
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu,
|
|
|
|
wxID_FILE,
|
|
|
|
_( "Load &Gerber File" ),
|
|
|
|
_( "Load a new Gerber file on the current layer. Previous data will be deleted" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( gerber_file_xpm ) );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Excellon
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu,
|
|
|
|
ID_GERBVIEW_LOAD_DRILL_FILE,
|
|
|
|
_( "Load &EXCELLON Drill File" ),
|
|
|
|
_( "Load excellon drill file" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( gerbview_drill_file_xpm ) );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Dcodes
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu, ID_GERBVIEW_LOAD_DCODE_FILE,
|
|
|
|
_( "Load &DCodes" ),
|
|
|
|
_( "Load D-Codes definition file" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( gerber_open_dcode_file_xpm ) );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Recent gerber files
|
2011-04-17 13:54:17 +00:00
|
|
|
static wxMenu* openRecentGbrMenu;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
// Add this menu to list menu managed by m_fileHistory
|
|
|
|
// (the file history will be updated when adding/removing files in history
|
|
|
|
if( openRecentGbrMenu )
|
2011-12-16 20:12:49 +00:00
|
|
|
wxGetApp().GetFileHistory().RemoveMenu( openRecentGbrMenu );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
openRecentGbrMenu = new wxMenu();
|
2011-12-16 20:12:49 +00:00
|
|
|
wxGetApp().GetFileHistory().UseMenu( openRecentGbrMenu );
|
|
|
|
wxGetApp().GetFileHistory().AddFilesToMenu();
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu, openRecentGbrMenu,
|
|
|
|
wxID_ANY,
|
|
|
|
_( "Open &Recent Gerber File" ),
|
|
|
|
_( "Open a recent opened Gerber file" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( gerber_recent_files_xpm ) );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Recent drill files
|
2011-04-17 13:54:17 +00:00
|
|
|
static wxMenu* openRecentDrlMenu;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
if( openRecentDrlMenu )
|
2011-04-23 18:35:40 +00:00
|
|
|
m_drillFileHistory.RemoveMenu( openRecentDrlMenu );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-04-23 18:35:40 +00:00
|
|
|
openRecentDrlMenu = new wxMenu();
|
|
|
|
m_drillFileHistory.UseMenu( openRecentDrlMenu );
|
2011-04-17 13:54:17 +00:00
|
|
|
m_drillFileHistory.AddFilesToMenu( );
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu, openRecentDrlMenu,
|
|
|
|
wxID_ANY,
|
2011-10-18 19:59:19 +00:00
|
|
|
_( "Open Recent Dri&ll File" ),
|
2011-09-01 12:54:34 +00:00
|
|
|
_( "Open a recent opened drill file" ),
|
2011-12-17 21:21:03 +00:00
|
|
|
KiBitmap( gerbview_open_recent_drill_files_xpm ) );
|
2011-03-16 20:51:20 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
fileMenu->AppendSeparator();
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Clear all
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu,
|
|
|
|
ID_GERBVIEW_ERASE_ALL,
|
|
|
|
_( "&Clear All" ),
|
|
|
|
_( "Clear all layers. All data will be deleted" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( gerbview_clear_layers_xpm ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Export to Pcbnew
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu,
|
|
|
|
ID_GERBVIEW_EXPORT_TO_PCBNEW,
|
2011-10-18 19:59:19 +00:00
|
|
|
_( "E&xport to Pcbnew" ),
|
2011-09-30 18:15:37 +00:00
|
|
|
_( "Export data in Pcbnew format" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( export_xpm ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
fileMenu->AppendSeparator();
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Print
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu,
|
|
|
|
wxID_PRINT,
|
2011-10-18 19:59:19 +00:00
|
|
|
_( "&Print" ),
|
2011-09-01 12:54:34 +00:00
|
|
|
_( "Print gerber" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( print_button_xpm ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
|
|
|
|
// Exit
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( fileMenu,
|
|
|
|
wxID_EXIT,
|
|
|
|
_( "E&xit" ),
|
2011-10-16 08:02:36 +00:00
|
|
|
_( "Quit GerbView" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( exit_xpm ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Menu for configuration and preferences
|
|
|
|
wxMenu* configMenu = new wxMenu;
|
|
|
|
|
|
|
|
// Hide layer manager
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( configMenu,
|
|
|
|
ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
|
|
|
|
_( "Hide &Layers Manager" ),
|
2011-10-17 16:49:14 +00:00
|
|
|
m_show_layer_manager_tools ?
|
|
|
|
_( "Hide &Layers Manager" ) : _("Show &Layers Manager" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( layers_manager_xpm ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Options (Preferences on WXMAC)
|
2011-08-30 13:54:22 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
#ifdef __WXMAC__
|
2011-09-08 05:58:45 +00:00
|
|
|
configMenu->Append(wxID_PREFERENCES);
|
2011-04-06 13:52:47 +00:00
|
|
|
#else
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( configMenu,
|
|
|
|
wxID_PREFERENCES,
|
|
|
|
_( "&Options" ),
|
|
|
|
_( "Set options to draw items" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( preference_xpm ) );
|
2011-08-30 13:54:22 +00:00
|
|
|
#endif // __WXMAC__
|
|
|
|
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Language submenu
|
|
|
|
wxGetApp().AddMenuLanguageList( configMenu );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Hotkey submenu
|
|
|
|
AddHotkeyConfigMenu( configMenu );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Menu miscellaneous
|
|
|
|
wxMenu* miscellaneousMenu = new wxMenu;
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// List dcodes
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( miscellaneousMenu,
|
|
|
|
ID_GERBVIEW_SHOW_LIST_DCODES,
|
|
|
|
_( "&List DCodes" ),
|
|
|
|
_( "List and edit D-codes" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( show_dcodenumber_xpm ) );
|
2011-04-06 13:52:47 +00:00
|
|
|
|
|
|
|
// Show source
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( miscellaneousMenu,
|
|
|
|
ID_GERBVIEW_SHOW_SOURCE,
|
|
|
|
_( "&Show Source" ),
|
|
|
|
_( "Show source file for the current layer" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( tools_xpm ) );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
miscellaneousMenu->AppendSeparator();
|
|
|
|
|
|
|
|
// Clear layer
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( miscellaneousMenu,
|
|
|
|
ID_GERBVIEW_GLOBAL_DELETE,
|
|
|
|
_( "&Clear Layer" ),
|
|
|
|
_( "Clear current layer" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( general_deletions_xpm ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
miscellaneousMenu->AppendSeparator();
|
|
|
|
|
|
|
|
// Text editor
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( miscellaneousMenu,
|
|
|
|
ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
|
|
|
|
_( "&Text Editor" ),
|
|
|
|
_( "Select your preferred text editor" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( editor_xpm ) );
|
2011-03-13 18:03:43 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Menu Help
|
2010-09-13 14:45:19 +00:00
|
|
|
wxMenu* helpMenu = new wxMenu;
|
2011-04-06 13:52:47 +00:00
|
|
|
|
|
|
|
// Version info
|
2010-09-13 14:45:19 +00:00
|
|
|
AddHelpVersionInfoMenuEntry( helpMenu );
|
2011-04-06 13:52:47 +00:00
|
|
|
|
|
|
|
// Contents
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( helpMenu,
|
|
|
|
wxID_HELP,
|
|
|
|
_( "&Contents" ),
|
2011-10-16 08:02:36 +00:00
|
|
|
_( "Open the GerbView handbook" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( help_xpm ) );
|
2011-04-06 13:52:47 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// About GerbView
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( helpMenu,
|
|
|
|
wxID_ABOUT,
|
|
|
|
_( "&About GerbView" ),
|
2011-09-30 18:15:37 +00:00
|
|
|
_( "About GerbView gerber and drill viewer" ),
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( online_help_xpm ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Append menus to the menubar
|
|
|
|
menuBar->Append( fileMenu, _( "&File" ) );
|
|
|
|
menuBar->Append( configMenu, _( "&Preferences" ) );
|
|
|
|
menuBar->Append( miscellaneousMenu, _( "&Miscellaneous" ) );
|
2010-09-13 14:45:19 +00:00
|
|
|
menuBar->Append( helpMenu, _( "&Help" ) );
|
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
menuBar->Thaw();
|
|
|
|
|
|
|
|
// Associate the menu bar with the frame, if no previous menubar
|
|
|
|
if( GetMenuBar() == NULL )
|
|
|
|
SetMenuBar( menuBar );
|
|
|
|
else
|
|
|
|
menuBar->Refresh();
|
2010-09-13 14:45:19 +00:00
|
|
|
}
|