Exemplo n.º 1
0
/**
 * @brief (Re)Create the menubar for the CvPcb mainframe
 */
void CVPCB_MAINFRAME::ReCreateMenuBar()
{
    // Create and try to get the current  menubar
    wxMenuItem* item;
    wxMenuBar*  menuBar = GetMenuBar();

    if( ! menuBar )     // Delete all menus
        menuBar = new wxMenuBar();

    // 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() )
        delete menuBar->Remove( 0 );

    // Recreate all menus:

    // Menu File:
    wxMenu* filesMenu = new wxMenu;

    // Open
    AddMenuItem( filesMenu,
                 ID_LOAD_PROJECT,
                 _( "&Open" ), LOAD_FILE_HELP, KiBitmap( open_document_xpm ) );

    // Open Recent submenu
    static wxMenu* openRecentMenu;

    // Add this menu to list menu managed by m_fileHistory
    // (the file history will be updated when adding/removing files in history
    if( openRecentMenu )
        wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );

    openRecentMenu = new wxMenu();
    wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
    wxGetApp().GetFileHistory().AddFilesToMenu();
    AddMenuItem( filesMenu, openRecentMenu, -1,
                 _( "Open &Recent" ),
                 _( "Open a recent opened netlist document" ),
                 KiBitmap( open_project_xpm ) );

    // Separator
    filesMenu->AppendSeparator();

    // Save the .cmp file
    AddMenuItem( filesMenu,
                 wxID_SAVE,
                 _( "&Save\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) );

    // Save as the .cmp file
    AddMenuItem( filesMenu,
                 wxID_SAVEAS,
                 _( "Save &As..." ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );

    // Separator
    filesMenu->AppendSeparator();

    // Quit
    AddMenuItem( filesMenu,
                 wxID_EXIT,
                 _( "&Quit" ),
                 _( "Quit CvPcb" ),
                 KiBitmap( exit_xpm ) );

    // Menu Preferences:
    wxMenu* preferencesMenu = new wxMenu;

    // Libraries to load
    AddMenuItem( preferencesMenu, wxID_PREFERENCES,
                 _( "&Libraries" ),
                 _( "Set footprint libraries to load and library search paths" ),
                 KiBitmap( config_xpm ) );

    // Language submenu
    wxGetApp().AddMenuLanguageList( preferencesMenu );

    // Keep open on save
    item = new wxMenuItem( preferencesMenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
                           _( "Keep Open On Save" ),
                           _( "Prevent CvPcb from exiting after saving netlist file" ),
                           wxITEM_CHECK );
    preferencesMenu->Append( item );
    SETBITMAPS( window_close_xpm );

    // Separator
    preferencesMenu->AppendSeparator();
    AddMenuItem( preferencesMenu, ID_SAVE_PROJECT,
                 _( "&Save Project File" ),
                 _( "Save changes to the project configuration file" ),
                 KiBitmap( save_setup_xpm ) );

    AddMenuItem( preferencesMenu, ID_SAVE_PROJECT_AS,
                 _( "&Save Project File As" ),
                 _( "Save changes to the project configuration to a new file" ),
                 KiBitmap( save_setup_xpm ) );

    // Menu Help:
    wxMenu* helpMenu = new wxMenu;

    // Version info
    AddHelpVersionInfoMenuEntry( helpMenu );

    // Contents
    AddMenuItem( helpMenu, wxID_HELP, _( "&Contents" ),
                 _( "Open the CvPcb handbook" ),
                 KiBitmap( online_help_xpm ) );

    // About
    AddMenuItem( helpMenu, wxID_ABOUT,
                 _( "&About CvPcb" ),
                 _( "About CvPcb footprint selector" ),
                 KiBitmap( info_xpm ) );

    // Create the menubar and append all submenus
    menuBar->Append( filesMenu, _( "&File" ) );
    menuBar->Append( preferencesMenu, _( "&Preferences" ) );
    menuBar->Append( helpMenu, _( "&Help" ) );

    menuBar->Thaw();

    // Associate the menu bar with the frame, if no previous menubar
    if( GetMenuBar() == NULL )
        SetMenuBar( menuBar );
    else
        menuBar->Refresh();
}
Exemplo n.º 2
0
wxMenu * WinEDA_App::SetLanguageList(wxMenu * MasterMenu)
/*********************************************************/
/* Create menu list for language choice.
*/
{
wxMenuItem * item;

	if ( m_Language_Menu == NULL )
	{
		m_Language_Menu = new wxMenu;
		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_DEFAULT,
				_("Default"), wxEmptyString, wxITEM_CHECK );
		SETBITMAPS(lang_def_xpm);
		m_Language_Menu->Append(item);

		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_ENGLISH,
			wxT("English"), wxEmptyString, wxITEM_CHECK);
		SETBITMAPS(lang_en_xpm);
		m_Language_Menu->Append(item);

		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_FRENCH,
			_("French"), wxEmptyString, wxITEM_CHECK);
		SETBITMAPS(lang_fr_xpm);
		m_Language_Menu->Append(item);

		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_SPANISH,
			_("Spanish"), wxEmptyString, wxITEM_CHECK);
		SETBITMAPS(lang_es_xpm);
		m_Language_Menu->Append(item);

		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_PORTUGUESE,
			_("Portuguese"), wxEmptyString, wxITEM_CHECK);
		SETBITMAPS(lang_pt_xpm);
		m_Language_Menu->Append(item);


		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_ITALIAN,
			_("Italian"), wxEmptyString, wxITEM_CHECK);
//		SETBITMAPS(apply_xpm, lang_it_xpm);	TODO
		m_Language_Menu->Append(item);

		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_DUTCH,
			_("Dutch"), wxEmptyString, wxITEM_CHECK);
//		item->SETBITMAPS(apply_xpm, lang_de_xpm);	TODO
		m_Language_Menu->Append(item);

		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_SLOVENIAN,
			_("Slovenian"), wxEmptyString, wxITEM_CHECK);
//		item->SETBITMAPS(apply_xpm, lang_de_xpm);	TODO
		m_Language_Menu->Append(item);

#if 0
		item = new wxMenuItem(m_Language_Menu, ID_LANGUAGE_RUSSIAN,
			_("Russian"), wxEmptyString, wxITEM_CHECK);
		SETBITMAPS(lang_pt_xpm);
		m_Language_Menu->Append(item);
#endif
	}

	m_Language_Menu->Check(ID_LANGUAGE_SLOVENIAN, FALSE);
	m_Language_Menu->Check(ID_LANGUAGE_ITALIAN, FALSE);
	m_Language_Menu->Check(ID_LANGUAGE_PORTUGUESE, FALSE);
	m_Language_Menu->Check(ID_LANGUAGE_SPANISH, FALSE);
	m_Language_Menu->Check(ID_LANGUAGE_FRENCH, FALSE);
	m_Language_Menu->Check(ID_LANGUAGE_ENGLISH, FALSE);
	m_Language_Menu->Check(ID_LANGUAGE_DEFAULT, FALSE);

	switch ( m_LanguageId )
	{
		case wxLANGUAGE_RUSSIAN:
			m_Language_Menu->Check(ID_LANGUAGE_RUSSIAN, TRUE);
			break;
		case wxLANGUAGE_DUTCH:
			m_Language_Menu->Check(ID_LANGUAGE_DUTCH, TRUE);
			break;
		case wxLANGUAGE_FRENCH:
			m_Language_Menu->Check(ID_LANGUAGE_FRENCH, TRUE);
			break;
		case wxLANGUAGE_ENGLISH:
			m_Language_Menu->Check(ID_LANGUAGE_ENGLISH, TRUE);
			break;
		case wxLANGUAGE_SPANISH:
			m_Language_Menu->Check(ID_LANGUAGE_SPANISH, TRUE);
			break;
		case wxLANGUAGE_PORTUGUESE:
			m_Language_Menu->Check(ID_LANGUAGE_PORTUGUESE, TRUE);
			break;

		case wxLANGUAGE_ITALIAN:
			m_Language_Menu->Check(ID_LANGUAGE_ITALIAN, TRUE);
			break;

		case wxLANGUAGE_SLOVENIAN:
			m_Language_Menu->Check(wxLANGUAGE_SLOVENIAN, TRUE);
			break;
		default:
			m_Language_Menu->Check(ID_LANGUAGE_DEFAULT, TRUE);
			break;
	}

	if ( MasterMenu )
	{
		ADD_MENUITEM_WITH_HELP_AND_SUBMENU(MasterMenu, m_Language_Menu,
			ID_LANGUAGE_CHOICE,  _("Language"),
			wxT("For test only, use Default setup for normal use"),
			language_xpm);
	}
	return m_Language_Menu;
}
Exemplo n.º 3
0
/**
 * @brief (Re)Create the menubar
 */
void KICAD_MANAGER_FRAME::ReCreateMenuBar()
{
    static wxMenu* openRecentMenu;  // Open Recent submenu,
                                    // static to remember this menu

    // Create and try to get the current  menubar
    wxMenuItem* item;
    wxMenuBar*  menuBar = GetMenuBar();

    if( !menuBar )
        menuBar = new wxMenuBar();

    // Delete all existing menus so they can be rebuilt.
    // This allows language changes of the menu text on the fly.
    menuBar->Freeze();

    // Before deleting, remove the menus managed by m_fileHistory
    // (the file history will be updated when adding/removing files in history)
    if( openRecentMenu )
        wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );

    // Delete all existing menus
    while( menuBar->GetMenuCount() )
        delete menuBar->Remove( 0 );

    // Recreate all menus:

    // Menu File:
    wxMenu* fileMenu = new wxMenu;

    // Open
    AddMenuItem( fileMenu,
                 ID_LOAD_PROJECT,
                 _( "&Open\tCtrl+O" ),
                 _( "Open an existing project" ),
                 KiBitmap( open_project_xpm ) );

    // File history
    openRecentMenu = new wxMenu();
    wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
    wxGetApp().GetFileHistory().AddFilesToMenu( );
    AddMenuItem( fileMenu, openRecentMenu,
                 wxID_ANY,
                 _( "Open &Recent" ),
                 _( "Open a recent opened schematic project" ),
                 KiBitmap( open_project_xpm ) );

    // New
    wxMenu* newMenu = new wxMenu();
    AddMenuItem( newMenu, ID_NEW_PROJECT,
                 _( "&Blank\tCtrl+N" ),
                 _( "Start a blank project" ),
                 KiBitmap( new_project_xpm ) );

    AddMenuItem( newMenu, ID_NEW_PROJECT_FROM_TEMPLATE,
                 _( "New from &Template\tCtrl+T" ),
                 _( "Start a new project from a template" ),
                 KiBitmap( new_project_with_template_xpm ) );

    AddMenuItem( fileMenu, newMenu,
                 wxID_ANY,
                 _( "New" ),
                 _( "Start a new project" ),
                 KiBitmap( new_project_xpm ) );

    // Save
    AddMenuItem( fileMenu,
                 ID_SAVE_PROJECT,
                 _( "&Save\tCtrl+S" ),
                 _( "Save current project" ),
                 KiBitmap( save_project_xpm ) );

    // Archive
    fileMenu->AppendSeparator();
    AddMenuItem( fileMenu,
                 ID_SAVE_AND_ZIP_FILES,
                 _( "&Archive" ),
                 _( "Archive project files in zip archive" ),
                 KiBitmap( zip_xpm ) );

    // Unarchive
    AddMenuItem( fileMenu,
                 ID_READ_ZIP_ARCHIVE,
                 _( "&Unarchive" ),
                 _( "Unarchive project files from zip file" ),
                 KiBitmap( unzip_xpm ) );

    // Separator
    fileMenu->AppendSeparator();

    // Quit
    AddMenuItem( fileMenu,
                 wxID_EXIT,
                 _( "&Quit" ),
                 _( "Quit KiCad" ),
                 KiBitmap( exit_xpm ) );

    // Menu Browse:
    wxMenu* browseMenu = new wxMenu();

    // Text editor
    AddMenuItem( browseMenu,
                 ID_TO_EDITOR,
                 _( "Text E&ditor" ),
                 _( "Launch preferred text editor" ),
                 KiBitmap( editor_xpm ) );

    // View file
    AddMenuItem( browseMenu,
                 ID_BROWSE_AN_SELECT_FILE,
                 _( "&View File" ),
                 _( "View, read or edit file with a text editor" ),
                 KiBitmap( browse_files_xpm ) );

    // Menu Preferences:
    wxMenu* preferencesMenu = new wxMenu;

    // Text editor
    AddMenuItem( preferencesMenu,
                 ID_SELECT_PREFERED_EDITOR,
                 _( "&Text Editor" ),
                 _( "Select your preferred text editor" ),
                 KiBitmap( editor_xpm ) );

    // PDF Viewer submenu:System browser or user defined checkbox
    wxMenu* SubMenuPdfBrowserChoice = new wxMenu;

    // Default
    item = new wxMenuItem( SubMenuPdfBrowserChoice,
                           ID_SELECT_DEFAULT_PDF_BROWSER,
                           _( "&Default" ),
                           _( "Use system default PDF viewer used to browse datasheets" ),
                           wxITEM_CHECK );

    SETBITMAPS( datasheet_xpm );

    SubMenuPdfBrowserChoice->Append( item );
    SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER,
                                    wxGetApp().UseSystemPdfBrowser() );

    // Favourite
    item = new wxMenuItem( SubMenuPdfBrowserChoice,
                           ID_SELECT_PREFERED_PDF_BROWSER,
                           _( "&Favourite" ),
                           _( "Use your favourite PDF viewer used to browse datasheets" ),
                           wxITEM_CHECK );

    SETBITMAPS( preference_xpm );

    SubMenuPdfBrowserChoice->Append( item );
    SubMenuPdfBrowserChoice->AppendSeparator();
    SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER,
                                    !wxGetApp().UseSystemPdfBrowser() );

    // Append PDF Viewer submenu to preferences
    AddMenuItem( SubMenuPdfBrowserChoice,
                 ID_SELECT_PREFERED_PDF_BROWSER_NAME,
                 _( "&PDF Viewer" ),
                 _( "Select your favourite PDF viewer used to browse datasheets" ),
                 KiBitmap( datasheet_xpm ) );

    // PDF viewer submenu
    AddMenuItem( preferencesMenu,
                 SubMenuPdfBrowserChoice, -1,
                 _( "&PDF Viewer" ),
                 _( "PDF viewer preferences" ),
                 KiBitmap( datasheet_xpm ) );

    // Language submenu
    preferencesMenu->AppendSeparator();
    wxGetApp().AddMenuLanguageList( preferencesMenu );

    // Menu Help:
    wxMenu* helpMenu = new wxMenu;

    // Version info
    AddHelpVersionInfoMenuEntry( helpMenu );

    // Contents
    AddMenuItem( helpMenu,
                 wxID_HELP,
                 _( "&Contents" ),
                 _( "Open the KiCad handbook" ),
                 KiBitmap( online_help_xpm ) );

    AddMenuItem( helpMenu,
                 wxID_INDEX,
                 _( "&Getting Started in KiCad" ),
                 _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
                 KiBitmap( help_xpm ) );

    // Separator
    helpMenu->AppendSeparator();

    // About
    AddMenuItem( helpMenu,
                 wxID_ABOUT,
                 _( "&About KiCad" ),
                 _( "About KiCad project manager" ),
                 KiBitmap( info_xpm ) );

    // Create the menubar and append all submenus
    menuBar->Append( fileMenu, _( "&File" ) );
    menuBar->Append( browseMenu, _( "&Browse" ) );
    menuBar->Append( preferencesMenu, _( "&Preferences" ) );
    menuBar->Append( helpMenu, _( "&Help" ) );

    menuBar->Thaw();

    // Associate the menu bar with the frame, if no previous menubar
    if( GetMenuBar() == NULL )
        SetMenuBar( menuBar );
    else
        menuBar->Refresh();
}