2011-04-06 13:52:47 +00:00
|
|
|
/**
|
|
|
|
* @file gerbview/menubar.cpp
|
|
|
|
* @brief (Re)Create the main menubar for GerbView
|
|
|
|
*/
|
2010-09-13 14:45:19 +00:00
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "appl_wxstruct.h"
|
|
|
|
#include "common.h"
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2010-09-13 14:45:19 +00:00
|
|
|
#include "gerbview.h"
|
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "gerbview_id.h"
|
|
|
|
#include "hotkeys.h"
|
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
/**
|
|
|
|
* @brief (Re)Create the menubar for the gerbview frame
|
|
|
|
*/
|
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();
|
|
|
|
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
|
|
|
|
ADD_MENUITEM_WITH_HELP( fileMenu,
|
|
|
|
wxID_FILE,
|
|
|
|
_( "Load &Gerber File" ),
|
|
|
|
_( "Load a new Gerber file on the current layer. Previous data will be deleted" ),
|
2011-03-19 20:39:18 +00:00
|
|
|
gerber_file_xpm );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Excellon
|
|
|
|
ADD_MENUITEM_WITH_HELP( fileMenu,
|
|
|
|
ID_GERBVIEW_LOAD_DRILL_FILE,
|
2011-03-18 12:54:49 +00:00
|
|
|
_( "Load &EXCELLON Drill File" ),
|
2011-03-17 19:14:45 +00:00
|
|
|
_( "Load excellon drill file" ),
|
2011-03-19 20:39:18 +00:00
|
|
|
gerbview_drill_file_xpm );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Dcodes
|
|
|
|
ADD_MENUITEM_WITH_HELP( fileMenu, ID_GERBVIEW_LOAD_DCODE_FILE,
|
2011-03-18 12:54:49 +00:00
|
|
|
_( "Load &DCodes" ),
|
|
|
|
_( "Load D-Codes definition file" ),
|
2011-03-20 12:33:28 +00:00
|
|
|
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;
|
|
|
|
// Add this menu to list menu managed by m_fileHistory
|
|
|
|
// (the file history will be updated when adding/removing files in history
|
|
|
|
if( openRecentGbrMenu )
|
|
|
|
wxGetApp().m_fileHistory.RemoveMenu( openRecentGbrMenu );
|
|
|
|
openRecentGbrMenu = new wxMenu();
|
|
|
|
wxGetApp().m_fileHistory.UseMenu( openRecentGbrMenu );
|
|
|
|
wxGetApp().m_fileHistory.AddFilesToMenu();
|
2011-04-06 13:52:47 +00:00
|
|
|
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( fileMenu, openRecentGbrMenu,
|
|
|
|
wxID_ANY,
|
|
|
|
_( "Open &Recent Gerber File" ),
|
2011-03-17 19:14:45 +00:00
|
|
|
_( "Open a recent opened Gerber file" ),
|
2011-03-23 15:18:44 +00:00
|
|
|
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;
|
|
|
|
if( openRecentDrlMenu )
|
2011-04-23 18:35:40 +00:00
|
|
|
m_drillFileHistory.RemoveMenu( openRecentDrlMenu );
|
|
|
|
openRecentDrlMenu = new wxMenu();
|
|
|
|
m_drillFileHistory.UseMenu( openRecentDrlMenu );
|
2011-04-17 13:54:17 +00:00
|
|
|
m_drillFileHistory.AddFilesToMenu( );
|
2011-04-06 13:52:47 +00:00
|
|
|
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( fileMenu, openRecentDrlMenu,
|
2011-04-17 13:54:17 +00:00
|
|
|
wxID_ANY,
|
2011-04-06 13:52:47 +00:00
|
|
|
_( "Open Recent &Drill File" ),
|
2011-03-17 19:14:45 +00:00
|
|
|
_( "Open a recent opened drill file" ),
|
|
|
|
open_project_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
|
|
|
|
ADD_MENUITEM_WITH_HELP( fileMenu,
|
|
|
|
ID_GERBVIEW_ERASE_ALL,
|
2011-03-17 19:14:45 +00:00
|
|
|
_( "&Clear All" ),
|
|
|
|
_( "Clear all layers. All data will be deleted" ),
|
2011-03-19 20:39:18 +00:00
|
|
|
gerbview_clear_layers_xpm );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
|
|
|
|
// Export to pcbnew
|
|
|
|
ADD_MENUITEM_WITH_HELP( fileMenu,
|
|
|
|
ID_GERBVIEW_EXPORT_TO_PCBNEW,
|
2011-03-18 12:54:49 +00:00
|
|
|
_( "Export to &Pcbnew" ),
|
2011-03-17 19:14:45 +00:00
|
|
|
_( "Export data in pcbnew format" ),
|
|
|
|
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
|
|
|
|
ADD_MENUITEM_WITH_HELP( fileMenu,
|
|
|
|
wxID_PRINT,
|
2011-03-17 19:14:45 +00:00
|
|
|
_( "P&rint" ),
|
|
|
|
_( "Print gerber" ),
|
|
|
|
print_button );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
fileMenu->AppendSeparator();
|
|
|
|
|
|
|
|
// Exit
|
|
|
|
ADD_MENUITEM_WITH_HELP( fileMenu,
|
|
|
|
wxID_EXIT,
|
2011-03-17 19:14:45 +00:00
|
|
|
_( "E&xit" ),
|
|
|
|
_( "Quit Gerbview" ),
|
|
|
|
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
|
|
|
|
ADD_MENUITEM_WITH_HELP( configMenu,
|
|
|
|
ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
|
2010-09-13 14:45:19 +00:00
|
|
|
_( "Hide &Layers Manager" ),
|
|
|
|
_( "Show/hide the layers manager toolbar" ),
|
|
|
|
layers_manager_xpm );
|
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Options (Preferences on WXMAC)
|
|
|
|
ADD_MENUITEM_WITH_HELP( configMenu,
|
|
|
|
wxID_PREFERENCES,
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
_( "Preferences..." ),
|
|
|
|
#else
|
2010-10-09 11:03:03 +00:00
|
|
|
_( "&Options" ),
|
2011-04-06 13:52:47 +00:00
|
|
|
#endif // __WXMAC__
|
2010-10-09 11:03:03 +00:00
|
|
|
_( "Set options to draw items" ),
|
|
|
|
preference_xpm );
|
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
|
|
|
|
ADD_MENUITEM_WITH_HELP( miscellaneousMenu,
|
|
|
|
ID_GERBVIEW_SHOW_LIST_DCODES,
|
2010-09-13 14:45:19 +00:00
|
|
|
_( "&List DCodes" ),
|
2011-04-06 13:52:47 +00:00
|
|
|
_( "List and edit D-codes" ),
|
|
|
|
show_dcodenumber_xpm );
|
|
|
|
|
|
|
|
// Show source
|
|
|
|
ADD_MENUITEM_WITH_HELP( miscellaneousMenu,
|
|
|
|
ID_GERBVIEW_SHOW_SOURCE,
|
2010-09-13 14:45:19 +00:00
|
|
|
_( "&Show Source" ),
|
|
|
|
_( "Show source file for the current layer" ),
|
|
|
|
tools_xpm );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
miscellaneousMenu->AppendSeparator();
|
|
|
|
|
|
|
|
// Clear layer
|
|
|
|
ADD_MENUITEM_WITH_HELP( miscellaneousMenu,
|
|
|
|
ID_GERBVIEW_GLOBAL_DELETE,
|
2010-11-01 18:33:44 +00:00
|
|
|
_( "&Clear Layer" ),
|
2011-04-06 13:52:47 +00:00
|
|
|
_( "Clear current layer" ),
|
|
|
|
general_deletions_xpm );
|
2010-09-13 14:45:19 +00:00
|
|
|
|
2011-04-06 13:52:47 +00:00
|
|
|
// Separator
|
|
|
|
miscellaneousMenu->AppendSeparator();
|
|
|
|
|
|
|
|
// Text editor
|
|
|
|
ADD_MENUITEM_WITH_HELP( miscellaneousMenu,
|
|
|
|
ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
|
2011-03-13 18:03:43 +00:00
|
|
|
_( "&Text Editor" ),
|
|
|
|
_( "Select your preferred text editor" ),
|
|
|
|
editor_xpm );
|
|
|
|
|
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
|
|
|
|
ADD_MENUITEM_WITH_HELP( helpMenu,
|
2011-04-17 13:54:17 +00:00
|
|
|
wxID_HELP,
|
2011-04-06 13:52:47 +00:00
|
|
|
_( "&Contents" ),
|
2011-04-17 13:54:17 +00:00
|
|
|
_( "Open the Gerbview handbook" ),
|
2011-04-06 13:52:47 +00:00
|
|
|
help_xpm );
|
|
|
|
|
|
|
|
// About gerbview
|
|
|
|
ADD_MENUITEM_WITH_HELP( helpMenu,
|
|
|
|
wxID_ABOUT,
|
|
|
|
_( "&About GerbView" ),
|
2010-09-13 14:45:19 +00:00
|
|
|
_( "About gerbview gerber and drill viewer" ),
|
|
|
|
online_help_xpm );
|
|
|
|
|
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
|
|
|
}
|