void wxFrame::PositionToolBar() { // TODO: we want to do something different in WinCE, because the toolbar // should be associated with the commandbar, instead of being // independent window. #if !defined(WINCE_WITHOUT_COMMANDBAR) wxToolBar *toolbar = GetToolBar(); if ( toolbar && toolbar->IsShown() ) { // don't call our (or even wxTopLevelWindow) version because we want // the real (full) client area size, not excluding the tool/status bar int width, height; wxWindow::DoGetClientSize(&width, &height); #if wxUSE_STATUSBAR wxStatusBar *statbar = GetStatusBar(); if ( statbar && statbar->IsShown() ) { height -= statbar->GetClientSize().y; } #endif // wxUSE_STATUSBAR int tx, ty, tw, th; toolbar->GetPosition( &tx, &ty ); toolbar->GetSize( &tw, &th ); int x, y; if ( toolbar->HasFlag(wxTB_BOTTOM) ) { x = 0; y = height - th; } else if ( toolbar->HasFlag(wxTB_RIGHT) ) { x = width - tw; y = 0; } else // left or top { x = 0; y = 0; } #if defined(WINCE_WITH_COMMANDBAR) // We're using a commandbar - so we have to allow for it. if (GetMenuBar() && GetMenuBar()->GetCommandBar()) { RECT rect; ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); y = rect.bottom - rect.top; } #endif // WINCE_WITH_COMMANDBAR if ( toolbar->HasFlag(wxTB_BOTTOM) ) { if ( ty < 0 && ( -ty == th ) ) ty = height - th; if ( tx < 0 && (-tx == tw ) ) tx = 0; } else if ( toolbar->HasFlag(wxTB_RIGHT) ) { if( ty < 0 && ( -ty == th ) ) ty = 0; if( tx < 0 && ( -tx == tw ) ) tx = width - tw; } else // left or top { if (ty < 0 && (-ty == th)) ty = 0; if (tx < 0 && (-tx == tw)) tx = 0; } int desiredW, desiredH; if ( toolbar->IsVertical() ) { desiredW = tw; desiredH = height; } else { desiredW = width; desiredH = th; } // use the 'real' MSW position here, don't offset relatively to the // client area origin toolbar->SetSize(x, y, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS); } #endif // !WINCE_WITH_COMMANDBAR }
// OnMenu handles all events which don't have their own event handler void LifeFrame::OnMenu(wxCommandEvent& event) { switch (event.GetId()) { case wxID_NEW: { // stop if it was running OnStop(); m_life->Clear(); m_canvas->Recenter(0, 0); m_tics = 0; UpdateInfoText(); break; } case wxID_ABOUT: { LifeAboutDialog dialog(this); dialog.ShowModal(); break; } case wxID_EXIT: { // true is to force the frame to close Close(true); break; } case ID_SHOWNAV: { bool checked = GetMenuBar()->GetMenu(1)->IsChecked(ID_SHOWNAV); if (m_navigator) m_navigator->Show(checked); break; } case ID_INFO: { wxString desc = m_life->GetDescription(); if ( desc.empty() ) desc = _("Not available"); // should we make the description editable here? wxMessageBox(desc, _("Description"), wxOK | wxICON_INFORMATION); break; } case ID_START : OnStart(); break; case ID_STEP : OnStep(); break; case wxID_STOP : OnStop(); break; case ID_TOPSPEED: { m_running = true; m_topspeed = true; UpdateUI(); while (m_running && m_topspeed) { OnStep(); wxYield(); } break; } } }
/** * @brief (Re)Create the menubar for the CvPcb mainframe */ void CVPCB_MAINFRAME::ReCreateMenuBar() { // Create the current menubar if it does not yet exist 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; // Save the footprints back into eeschema AddMenuItem( filesMenu, wxID_SAVE, _( "&Save Footprint Association\tCtrl+S" ), _( "Save footprint association in schematic component footprint fields" ), KiBitmap( save_xpm ) ); // Separator filesMenu->AppendSeparator(); // Quit AddMenuItem( filesMenu, wxID_EXIT, _( "&Close" ), _( "Close CvPcb" ), KiBitmap( exit_xpm ) ); // Preferences Menu : wxMenu* preferencesMenu = new wxMenu; AddMenuItem( preferencesMenu, ID_CVPCB_LIB_TABLE_EDIT, _( "Footprint Li&braries" ), _( "Configure footprint libraries" ), KiBitmap( library_table_xpm ) ); // Path configuration edit dialog. AddMenuItem( preferencesMenu, ID_PREFERENCES_CONFIGURE_PATHS, _( "Configure Pa&ths" ), _( "Edit path configuration environment variables" ), KiBitmap( editor_xpm ) ); preferencesMenu->AppendSeparator(); AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT, _( "Edit &Equ Files List" ), _( "Setup equ files list (.equ files)\n" "They are files which give the footprint name from the component value"), KiBitmap( library_table_xpm ) ); preferencesMenu->AppendSeparator(); // Language submenu Pgm().AddMenuLanguageList( preferencesMenu ); // Keep open on save data preferencesMenu->AppendSeparator(); AddMenuItem( preferencesMenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, _( "&Keep Open On Save" ), _( "Prevent CvPcb from exiting after saving netlist file" ), KiBitmap( exit_xpm ), wxITEM_CHECK ); // Menu Help: wxMenu* helpMenu = new wxMenu; // Version info AddHelpVersionInfoMenuEntry( helpMenu ); // Manual Contents AddMenuItem( helpMenu, wxID_HELP, _( "CvPcb &Manual" ), _( "Open CvPcb Manual" ), KiBitmap( online_help_xpm ) ); AddMenuItem( helpMenu, wxID_INDEX, _( "&Getting Started in KiCad" ), _( "Open \"Getting Started in KiCad\" guide for beginners" ), KiBitmap( help_xpm ) ); // About CvPcb AddMenuItem( helpMenu, wxID_ABOUT, _( "&About Kicad" ), _( "About KiCad" ), KiBitmap( info_xpm ) ); // Create the menubar and append all submenus menuBar->Append( filesMenu, _( "&Save" ) ); 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(); }
void GridFrame::ToggleGridLines( wxCommandEvent& WXUNUSED(ev) ) { grid->EnableGridLines( GetMenuBar()->IsChecked( ID_TOGGLEGRIDLINES ) ); }
void EDA_3D_FRAME::SetMenuBarOptionsState() { wxMenuBar* menuBar = GetMenuBar(); if( menuBar == NULL ) return; wxMenuItem* item; // Set the state of toggle menus according to the current display options item = menuBar->FindItem( ID_MENU3D_REALISTIC_MODE ); item->Check( GetPrm3DVisu().IsRealisticMode() ); item = menuBar->FindItem( ID_MENU3D_COMMENTS_ONOFF ); item->Enable( !GetPrm3DVisu().IsRealisticMode() ); item = menuBar->FindItem( ID_MENU3D_ECO_ONOFF ); item->Enable( !GetPrm3DVisu().IsRealisticMode() ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SHADOWS ) ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHADOWS ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SHADOWS ) ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES ) ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_TEXTURES ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_TEXTURES ) ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SMOOTH_NORMALS ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SMOOTH_NORMALS ) ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_USE_MODEL_NORMALS ) ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_MATERIAL ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_MATERIAL ) ); item = menuBar->FindItem( ID_MENU3D_FL_RENDER_SHOW_MODEL_BBOX ); item->Check( GetPrm3DVisu().GetFlag( FL_RENDER_SHOW_MODEL_BBOX ) ); item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY ); item->Check( GetPrm3DVisu().GetFlag( FL_SHOW_BOARD_BODY ) ); item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS ); item->Check( GetPrm3DVisu().GetFlag( FL_USE_COPPER_THICKNESS ) ); item = menuBar->FindItem( ID_MENU3D_MODULE_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_MODULE ) ); item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_ZONE ) ); item = menuBar->FindItem( ID_MENU3D_AXIS_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_AXIS ) ); item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_ADHESIVE ) ); item = menuBar->FindItem( ID_MENU3D_SILKSCREEN_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_SILKSCREEN ) ); item = menuBar->FindItem( ID_MENU3D_SOLDER_MASK_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_SOLDERMASK ) ); item = menuBar->FindItem( ID_MENU3D_SOLDER_PASTE_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_SOLDERPASTE ) ); item = menuBar->FindItem( ID_MENU3D_COMMENTS_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_COMMENTS ) ); item = menuBar->FindItem( ID_MENU3D_ECO_ONOFF ); item->Check( GetPrm3DVisu().GetFlag( FL_ECO )); }
void GridFrame::ToggleEditing( wxCommandEvent& WXUNUSED(ev) ) { grid->EnableEditing( GetMenuBar()->IsChecked( ID_TOGGLEEDIT ) ); }
void GridFrame::ToggleGridSizing( wxCommandEvent& WXUNUSED(ev) ) { grid->EnableDragGridSize( GetMenuBar()->IsChecked( ID_TOGGLEGRIDSIZING ) ); }
wxMenuItem *wxFrameBase::FindItemInMenuBar(int menuId) const { const wxMenuBar * const menuBar = GetMenuBar(); return menuBar ? menuBar->FindItem(menuId) : NULL; }
void MainEmuFrame::DispatchEvent( const CoreThreadStatus& status ) { if( !pxAssertMsg( GetMenuBar()!=NULL, "Mainframe menu bar is NULL!" ) ) return; ApplyCoreStatus(); }
// append a new item or submenu to the menu bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { #if wxUSE_ACCEL UpdateAccel(pItem); #endif // wxUSE_ACCEL // we should support disabling the item even prior to adding it to the menu UINT flags = pItem->IsEnabled() ? MF_ENABLED : MF_GRAYED; // if "Break" has just been called, insert a menu break before this item // (and don't forget to reset the flag) if ( m_doBreak ) { flags |= MF_MENUBREAK; m_doBreak = false; } if ( pItem->IsSeparator() ) { flags |= MF_SEPARATOR; } // id is the numeric id for normal menu items and HMENU for submenus as // required by ::AppendMenu() API UINT_PTR id; wxMenu *submenu = pItem->GetSubMenu(); if ( submenu != NULL ) { wxASSERT_MSG( submenu->GetHMenu(), wxT("invalid submenu") ); submenu->SetParent(this); id = (UINT_PTR)submenu->GetHMenu(); flags |= MF_POPUP; } else { id = pItem->GetMSWId(); } // prepare to insert the item in the menu wxString itemText = pItem->GetItemLabel(); LPCTSTR pData = NULL; if ( pos == (size_t)-1 ) { // append at the end (note that the item is already appended to // internal data structures) pos = GetMenuItemCount() - 1; } // Update radio groups data if we're inserting a new radio item. // // NB: If we supported inserting non-radio items in the middle of existing // radio groups to break them into two subgroups, we'd need to update // m_radioData in this case too but currently this is not supported. bool checkInitially = false; if ( pItem->GetKind() == wxITEM_RADIO ) { if ( !m_radioData ) m_radioData = new wxMenuRadioItemsData; if ( m_radioData->UpdateOnInsert(pos) ) checkInitially = true; } // Also handle the case of check menu items that had been checked before // being attached to the menu: we don't need to actually call Check() on // them, so we don't use checkInitially in this case, but we do need to // make them checked at Windows level too. Notice that we shouldn't ask // Windows for the checked state here, as wxMenuItem::IsChecked() does, as // the item is not attached yet, so explicitly call the base class version. if ( pItem->IsCheck() && pItem->wxMenuItemBase::IsChecked() ) flags |= MF_CHECKED; // adjust position to account for the title of a popup menu, if any if ( !GetMenuBar() && !m_title.empty() ) pos += 2; // for the title itself and its separator BOOL ok = false; #if wxUSE_OWNER_DRAWN // Under older systems mixing owner-drawn and non-owner-drawn items results // in inconsistent margins, so we force this one to be owner-drawn if any // other items already are. if ( m_ownerDrawn ) pItem->SetOwnerDrawn(true); // check if we have something more than a simple text item bool makeItemOwnerDrawn = false; #endif // wxUSE_OWNER_DRAWN if ( #if wxUSE_OWNER_DRAWN !pItem->IsOwnerDrawn() && #endif !pItem->IsSeparator() ) { #if wxUSE_MENUITEMINFO WinStruct<MENUITEMINFO> mii; mii.fMask = MIIM_STRING | MIIM_DATA; // don't set hbmpItem for the checkable items as it would // be used for both checked and unchecked state if ( pItem->IsCheckable() ) { mii.fMask |= MIIM_CHECKMARKS; mii.hbmpChecked = pItem->GetHBitmapForMenu(true); mii.hbmpUnchecked = pItem->GetHBitmapForMenu(false); } else if ( pItem->GetBitmap().IsOk() ) { mii.fMask |= MIIM_BITMAP; mii.hbmpItem = pItem->GetHBitmapForMenu(); } mii.cch = itemText.length(); mii.dwTypeData = wxMSW_CONV_LPTSTR(itemText); if ( flags & MF_POPUP ) { mii.fMask |= MIIM_SUBMENU; mii.hSubMenu = GetHmenuOf(pItem->GetSubMenu()); } else { mii.fMask |= MIIM_ID; mii.wID = id; } if ( flags & MF_CHECKED ) { mii.fMask |= MIIM_STATE; mii.fState = MFS_CHECKED; } mii.dwItemData = reinterpret_cast<ULONG_PTR>(pItem); ok = ::InsertMenuItem(GetHmenu(), pos, TRUE /* by pos */, &mii); if ( !ok ) { wxLogLastError(wxT("InsertMenuItem()")); #if wxUSE_OWNER_DRAWN // In case of failure switch new item to the owner-drawn mode. makeItemOwnerDrawn = true; #endif } else // InsertMenuItem() ok { // we need to remove the extra indent which is reserved for // the checkboxes by default as it looks ugly unless check // boxes are used together with bitmaps and this is not the // case in wx API WinStruct<MENUINFO> mi; // don't call SetMenuInfo() directly, this would prevent // the app from starting up under Windows 95/NT 4 typedef BOOL (WINAPI *SetMenuInfo_t)(HMENU, MENUINFO *); wxDynamicLibrary dllUser(wxT("user32")); wxDYNLIB_FUNCTION(SetMenuInfo_t, SetMenuInfo, dllUser); if ( pfnSetMenuInfo ) { mi.fMask = MIM_STYLE; mi.dwStyle = MNS_CHECKORBMP; if ( !(*pfnSetMenuInfo)(GetHmenu(), &mi) ) { wxLogLastError(wxT("SetMenuInfo(MNS_NOCHECK)")); } } } #else if ( pItem->GetBitmap().IsOk() ) { flags |= MF_BITMAP; pData = reinterpret_cast<LPCTSTR>(pItem->GetHBitmapForMenu()); } else { flags |= MF_STRING; #ifdef __WXWINCE__ itemText = wxMenuItem::GetLabelText(itemText); pData = itemText.t_str(); #else pData = wxMSW_CONV_LPTSTR(itemText); #endif } #endif // wxUSE_MENUITEMINFO / !wxUSE_MENUITEMINFO } #if wxUSE_OWNER_DRAWN if ( pItem->IsOwnerDrawn() || makeItemOwnerDrawn ) { // item draws itself, pass pointer to it in data parameter flags |= MF_OWNERDRAW; pData = (LPCTSTR)pItem; bool updateAllMargins = false; // get size of bitmap always return valid value (0 for invalid bitmap), // so we don't needed check if bitmap is valid ;) int uncheckedW = pItem->GetBitmap(false).GetWidth(); int checkedW = pItem->GetBitmap(true).GetWidth(); if ( m_maxBitmapWidth < uncheckedW ) { m_maxBitmapWidth = uncheckedW; updateAllMargins = true; } if ( m_maxBitmapWidth < checkedW ) { m_maxBitmapWidth = checkedW; updateAllMargins = true; } // make other item ownerdrawn and update margin width for equals alignment if ( !m_ownerDrawn || updateAllMargins ) { // we must use position in SetOwnerDrawnMenuItem because // all separators have the same id int pos = 0; wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); while (node) { wxMenuItem* item = node->GetData(); if ( !item->IsOwnerDrawn()) { item->SetOwnerDrawn(true); SetOwnerDrawnMenuItem(GetHmenu(), pos, reinterpret_cast<ULONG_PTR>(item), TRUE); } item->SetMarginWidth(m_maxBitmapWidth); node = node->GetNext(); pos++; } // set menu as ownerdrawn m_ownerDrawn = true; ResetMaxAccelWidth(); } // only update our margin for equals alignment to other item else if ( !updateAllMargins ) { pItem->SetMarginWidth(m_maxBitmapWidth); } } #endif // wxUSE_OWNER_DRAWN // item might have already been inserted by InsertMenuItem() above if ( !ok ) { if ( !::InsertMenu(GetHmenu(), pos, flags | MF_BYPOSITION, id, pData) ) { wxLogLastError(wxT("InsertMenu[Item]()")); return false; } #if wxUSE_OWNER_DRAWN if ( makeItemOwnerDrawn ) { pItem->SetOwnerDrawn(true); SetOwnerDrawnMenuItem(GetHmenu(), pos, reinterpret_cast<ULONG_PTR>(pItem), TRUE); } #endif } // Check the item if it should be initially checked. if ( checkInitially ) pItem->Check(true); // if we just appended the title, highlight it if ( id == (UINT_PTR)idMenuTitle ) { // visually select the menu title SetDefaultMenuItem(GetHmenu(), id); } // if we're already attached to the menubar, we must update it if ( IsAttached() && GetMenuBar()->IsAttached() ) { GetMenuBar()->Refresh(); } return true; }
/** * @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(); }
void wxMenu::UpdateAccel(wxMenuItem *item) { if ( item->IsSubMenu() ) { wxMenu *submenu = item->GetSubMenu(); wxMenuItemList::compatibility_iterator node = submenu->GetMenuItems().GetFirst(); while ( node ) { UpdateAccel(node->GetData()); node = node->GetNext(); } } else if ( !item->IsSeparator() ) { // recurse upwards: we should only modify m_accels of the top level // menus, not of the submenus as wxMenuBar doesn't look at them // (alternative and arguable cleaner solution would be to recurse // downwards in GetAccelCount() and CopyAccels()) if ( GetParent() ) { GetParent()->UpdateAccel(item); return; } // find the (new) accel for this item wxAcceleratorEntry *accel = wxAcceleratorEntry::Create(item->GetItemLabel()); if ( accel ) accel->m_command = item->GetId(); // find the old one int n = FindAccel(item->GetId()); if ( n == wxNOT_FOUND ) { // no old, add new if any if ( accel ) m_accels.Add(accel); else return; // skipping RebuildAccelTable() below } else { // replace old with new or just remove the old one if no new delete m_accels[n]; if ( accel ) m_accels[n] = accel; else m_accels.RemoveAt(n); } if ( IsAttached() ) { GetMenuBar()->RebuildAccelTable(); } #if wxUSE_OWNER_DRAWN ResetMaxAccelWidth(); #endif } //else: it is a separator, they can't have accels, nothing to do }
/** * @brief (Re)Create the menubar for the schematic frame */ void SCH_EDIT_FRAME::ReCreateMenuBar() { // Create and try to get the current menubar wxString text; 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(); while( menuBar->GetMenuCount() ) delete menuBar->Remove( 0 ); // Recreate all menus: // Menu File: wxMenu* fileMenu = new wxMenu; // New AddMenuItem( fileMenu, ID_NEW_PROJECT, _( "&New" ), _( "New schematic project" ), KiBitmap( new_xpm ) ); // Open text = AddHotkeyName( _( "&Open" ), s_Schematic_Hokeys_Descr, HK_LOAD_SCH ); AddMenuItem( fileMenu, ID_LOAD_PROJECT, text, _( "Open an existing schematic project" ), 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( openRecentMenu ); AddMenuItem( fileMenu, openRecentMenu, wxID_ANY, _( "Open &Recent" ), _( "Open a recent opened schematic project" ), KiBitmap( open_project_xpm ) ); // Import AddMenuItem( fileMenu, ID_APPEND_PROJECT, _( "&Append Schematic" ), _( "Append another schematic project to the current loaded schematic" ), KiBitmap( open_document_xpm ) ); // Separator fileMenu->AppendSeparator(); // Save schematic project text = AddHotkeyName( _( "&Save Whole Schematic Project" ), s_Schematic_Hokeys_Descr, HK_SAVE_SCH ); AddMenuItem( fileMenu, ID_SAVE_PROJECT, text, _( "Save all sheets in the schematic project" ), KiBitmap( save_project_xpm ) ); // Save current sheet AddMenuItem( fileMenu, ID_UPDATE_ONE_SHEET, _( "Save &Current Sheet Only" ), _( "Save only current schematic sheet" ), KiBitmap( save_xpm ) ); // Save current sheet as AddMenuItem( fileMenu, ID_SAVE_ONE_SHEET_UNDER_NEW_NAME, _( "Save Current Sheet &As" ), _( "Save current schematic sheet as..." ), KiBitmap( save_as_xpm ) ); // Separator fileMenu->AppendSeparator(); // Page settings AddMenuItem( fileMenu, ID_SHEET_SET, _( "Pa&ge Settings" ), _( "Settigns for page size and information" ), KiBitmap( sheetset_xpm ) ); // Print AddMenuItem( fileMenu, wxID_PRINT, _( "Pri&nt" ), _( "Print schematic" ), KiBitmap( print_button_xpm ) ); #ifdef __WINDOWS__ // __WINDOWS__ // Plot submenu wxMenu* choice_plot_fmt = new wxMenu; AddMenuItem( choice_plot_fmt, ID_GEN_PLOT_SCHEMATIC, _( "&Plot" ), _( "Plot schematic sheet in PostScript, PDF, SVG, DXF or HPGL format" ), KiBitmap( plot_xpm ) ); // Plot to Clipboard (Windows only) AddMenuItem( choice_plot_fmt, ID_GEN_COPY_SHEET_TO_CLIPBOARD, _( "Plot to &Clipboard" ), _( "Export drawings to clipboard" ), KiBitmap( copy_button_xpm ) ); // Plot AddMenuItem( fileMenu, choice_plot_fmt, ID_GEN_PLOT, _( "&Plot" ), _( "Plot schematic sheet in HPGL, PostScript or SVG format" ), KiBitmap( plot_xpm ) ); #else // Other // Plot AddMenuItem( fileMenu, ID_GEN_PLOT_SCHEMATIC, _( "&Plot" ), _( "Plot schematic sheet in HPGL, PostScript or SVG format" ), KiBitmap( plot_xpm ) ); #endif // Separator fileMenu->AppendSeparator(); // Quit AddMenuItem( fileMenu, wxID_EXIT, _( "&Quit" ), _( "Quit Eeschema" ), KiBitmap( exit_xpm ) ); // Menu Edit: wxMenu* editMenu = new wxMenu; // Undo text = AddHotkeyName( _( "&Undo" ), s_Schematic_Hokeys_Descr, HK_UNDO ); AddMenuItem( editMenu, wxID_UNDO, text, HELP_UNDO, KiBitmap( undo_xpm ) ); // Redo text = AddHotkeyName( _( "&Redo" ), s_Schematic_Hokeys_Descr, HK_REDO ); AddMenuItem( editMenu, wxID_REDO, text, HELP_REDO, KiBitmap( redo_xpm ) ); // Delete editMenu->AppendSeparator(); AddMenuItem( editMenu, ID_SCHEMATIC_DELETE_ITEM_BUTT, _( "&Delete" ), HELP_DELETE_ITEMS, KiBitmap( delete_xpm ) ); // Find editMenu->AppendSeparator(); text = AddHotkeyName( _( "&Find" ), s_Schematic_Hokeys_Descr, HK_FIND_ITEM ); AddMenuItem( editMenu, ID_FIND_ITEMS, text, HELP_FIND, KiBitmap( find_xpm ) ); // Find/Replace AddMenuItem( editMenu, wxID_REPLACE, _( "Find and Re&place\tCtrl+Shift+F" ), HELP_REPLACE, KiBitmap( find_replace_xpm ) ); // Import footprint association from the CvPcb cmp file: editMenu->AppendSeparator(); AddMenuItem( editMenu, ID_BACKANNO_ITEMS, _( "Import Footprint Selection" ), HELP_IMPORT_FOOTPRINTS, KiBitmap( import_footprint_names_xpm ) ); // Menu View: wxMenu* viewMenu = new wxMenu; /** * Important Note for ZOOM IN and ZOOM OUT commands from menubar: * we cannot add hotkey shortcut here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT * events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command: * zoom in and out from hotkeys are equivalent to the pop up menu zoom * From here, zooming is made around the screen center * From hotkeys, zooming is made around the mouse cursor position * (obviously not possible from the toolbar or menubar command) * * in others words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators * for Zoom in and Zoom out sub menus * SO WE ADD THE NAME OF THE CORRESPONDING HOTKEY AS A COMMENT, NOT AS A SHORTCUT * using in AddHotkeyName call the option "false" (not a shortcut) */ // Zoom in text = AddHotkeyName( _( "Zoom &In" ), s_Schematic_Hokeys_Descr, HK_ZOOM_IN, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) ); // Zoom out text = AddHotkeyName( _( "Zoom &Out" ), s_Schematic_Hokeys_Descr, HK_ZOOM_OUT, IS_ACCELERATOR ); // add accelerator, not a shortcut AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) ); // Fit on screen text = AddHotkeyName( _( "&Fit on Screen" ), s_Schematic_Hokeys_Descr, HK_ZOOM_AUTO ); AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT, KiBitmap( zoom_fit_in_page_xpm ) ); // Separator viewMenu->AppendSeparator(); // Hierarchy AddMenuItem( viewMenu, ID_HIERARCHY, _( "&Hierarchy" ), _( "Navigate schematic hierarchy" ), KiBitmap( hierarchy_nav_xpm ) ); // Redraw text = AddHotkeyName( _( "&Redraw" ), s_Schematic_Hokeys_Descr, HK_ZOOM_REDRAW ); AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) ); // Menu place: // @todo unify IDs wxMenu* placeMenu = new wxMenu; // Component text = AddHotkeyName( _( "&Component" ), s_Schematic_Hokeys_Descr, HK_ADD_NEW_COMPONENT, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_SCH_PLACE_COMPONENT, text, HELP_PLACE_COMPONENTS, KiBitmap( add_component_xpm ) ); // Power port text = AddHotkeyName( _( "&Power Port" ), s_Schematic_Hokeys_Descr, HK_ADD_NEW_POWER, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_PLACE_POWER_BUTT, text, HELP_PLACE_POWERPORT, KiBitmap( add_power_xpm ) ); // Wire text = AddHotkeyName( _( "&Wire" ), s_Schematic_Hokeys_Descr, HK_BEGIN_WIRE, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_WIRE_BUTT, text, HELP_PLACE_WIRE, KiBitmap( add_line_xpm ) ); // Bus text = AddHotkeyName( _( "&Bus" ), s_Schematic_Hokeys_Descr, HK_BEGIN_BUS, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_BUS_BUTT, text, HELP_PLACE_BUS, KiBitmap( add_bus_xpm ) ); // Wire to Bus entry text = AddHotkeyName( _( "Wire to Bus &Entry" ), s_Schematic_Hokeys_Descr, HK_ADD_WIRE_ENTRY, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_WIRETOBUS_ENTRY_BUTT, text, HELP_PLACE_WIRE2BUS_ENTRY, KiBitmap( add_line2bus_xpm ) ); // Bus to Bus entry text = AddHotkeyName( _( "Bus &to Bus Entry" ), s_Schematic_Hokeys_Descr, HK_ADD_BUS_ENTRY, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_BUSTOBUS_ENTRY_BUTT, text, HELP_PLACE_BUS2BUS_ENTRY, KiBitmap( add_bus2bus_xpm ) ); // No Connect Flag text = AddHotkeyName( _( "&No Connect Flag" ), s_Schematic_Hokeys_Descr, HK_ADD_NOCONN_FLAG, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_NOCONN_BUTT, text, HELP_PLACE_NC_FLAG, KiBitmap( noconn_xpm ) ); // Net name text = AddHotkeyName( _( "&Label" ), s_Schematic_Hokeys_Descr, HK_ADD_LABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_LABEL_BUTT, text, HELP_PLACE_NETLABEL, KiBitmap( add_line_label_xpm ) ); // Global label text = AddHotkeyName( _( "Gl&obal Label" ), s_Schematic_Hokeys_Descr, HK_ADD_GLABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_GLABEL_BUTT, text, HELP_PLACE_GLOBALLABEL, KiBitmap( add_glabel_xpm ) ); // Junction text = AddHotkeyName( _( "&Junction" ), s_Schematic_Hokeys_Descr, HK_ADD_JUNCTION, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_JUNCTION_BUTT, text, HELP_PLACE_JUNCTION, KiBitmap( add_junction_xpm ) ); // Separator placeMenu->AppendSeparator(); // Hierarchical label text = AddHotkeyName( _( "&Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_ADD_HLABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_HIERLABEL_BUTT, text, HELP_PLACE_HIER_LABEL, KiBitmap( add_hierarchical_label_xpm ) ); // Hierarchical sheet text = AddHotkeyName( _( "H&ierarchical &Sheet" ), s_Schematic_Hokeys_Descr, HK_ADD_HIER_SHEET, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_SHEET_SYMBOL_BUTT, text, HELP_PLACE_SHEET, KiBitmap( add_hierarchical_subsheet_xpm ) ); // Import hierarchical sheet AddMenuItem( placeMenu, ID_IMPORT_HLABEL_BUTT, _( "I&mport Hierarchical Label" ), HELP_IMPORT_SHEETPIN, KiBitmap( import_hierarchical_label_xpm ) ); // Add hierarchical Pin to Sheet AddMenuItem( placeMenu, ID_SHEET_PIN_BUTT, _( "Hierarchical Pi&n to Sheet" ), HELP_PLACE_SHEETPIN, KiBitmap( add_hierar_pin_xpm ) ); // Separator placeMenu->AppendSeparator(); // Graphic line or polygon text = AddHotkeyName( _( "Graphic Polyline" ), s_Schematic_Hokeys_Descr, HK_ADD_GRAPHIC_POLYLINE, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_LINE_COMMENT_BUTT, text, HELP_PLACE_GRAPHICLINES, KiBitmap( add_dashed_line_xpm ) ); // Graphic text text = AddHotkeyName( _( "Graphic Text" ), s_Schematic_Hokeys_Descr, HK_ADD_GRAPHIC_TEXT, IS_ACCELERATOR ); // add an accelerator, not a shortcut AddMenuItem( placeMenu, ID_TEXT_COMMENT_BUTT, text, HELP_PLACE_GRAPHICTEXTS, KiBitmap( add_text_xpm ) ); // Graphic image AddMenuItem( placeMenu, ID_ADD_IMAGE_BUTT, _( "Image" ), HELP_PLACE_GRAPHICIMAGES, KiBitmap( image_xpm ) ); // Menu Preferences: wxMenu* preferencesMenu = new wxMenu; // Library AddMenuItem( preferencesMenu, ID_CONFIG_REQ, _( "&Library" ), _( "Library preferences" ), KiBitmap( library_xpm ) ); // Colors AddMenuItem( preferencesMenu, ID_COLORS_SETUP, _( "&Colors" ), _( "Color preferences" ), KiBitmap( palette_xpm ) ); // Options (Preferences on WXMAC) #ifdef __WXMAC__ preferencesMenu->Append( wxID_PREFERENCES ); #else AddMenuItem( preferencesMenu, wxID_PREFERENCES, _( "&Options" ), _( "Eeschema preferences" ), KiBitmap( preference_xpm ) ); #endif // __WXMAC__ // Language submenu wxGetApp().AddMenuLanguageList( preferencesMenu ); // Hotkey submenu AddHotkeyConfigMenu( preferencesMenu ); // Separator preferencesMenu->AppendSeparator(); // Save preferences AddMenuItem( preferencesMenu, ID_CONFIG_SAVE, _( "&Save Preferences" ), _( "Save application preferences" ), KiBitmap( save_setup_xpm ) ); // Read preferences AddMenuItem( preferencesMenu, ID_CONFIG_READ, _( "&Read Preferences" ), _( "Read application preferences" ), KiBitmap( read_setup_xpm ) ); // Menu Tools: wxMenu* toolsMenu = new wxMenu; // Library editor AddMenuItem( toolsMenu, ID_TO_LIBRARY, _( "Library &Editor" ), HELP_RUN_LIB_EDITOR, KiBitmap( libedit_xpm ) ); // Library viewer AddMenuItem( toolsMenu, ID_TO_LIBVIEW, _( "Library &Browser" ), HELP_RUN_LIB_VIEWER, KiBitmap( library_browse_xpm ) ); // Separator toolsMenu->AppendSeparator(); // Annotate AddMenuItem( toolsMenu, ID_GET_ANNOTATE, _( "&Annotate" ), HELP_ANNOTATE, KiBitmap( annotate_xpm ) ); // ERC AddMenuItem( toolsMenu, ID_GET_ERC, _( "ER&C" ), _( "Perform electrical rule check" ), KiBitmap( erc_xpm ) ); // Generate netlist AddMenuItem( toolsMenu, ID_GET_NETLIST, _( "Generate &Netlist" ), _( "Generate the component netlist" ), KiBitmap( netlist_xpm ) ); // Generate bill of materials AddMenuItem( toolsMenu, ID_GET_TOOLS, _( "Generate Bill of &Materials" ), HELP_GENERATE_BOM, KiBitmap( bom_xpm ) ); // Separator toolsMenu->AppendSeparator(); //Run CvPcb AddMenuItem( toolsMenu, ID_TO_CVPCB, _( "A&ssign Component Footprints" ), _( "Run CvPcb" ), KiBitmap( cvpcb_xpm ) ); // Run Pcbnew AddMenuItem( toolsMenu, ID_TO_PCB, _( "&Layout Printed Circuit Board" ), _( "Run Pcbnew" ), KiBitmap( pcbnew_xpm ) ); // Help Menu: wxMenu* helpMenu = new wxMenu; // Version info AddHelpVersionInfoMenuEntry( helpMenu ); // Contents AddMenuItem( helpMenu, wxID_HELP, _( "&Contents" ), _( "Open the Eeschema 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 ) ); // About Eeschema helpMenu->AppendSeparator(); AddMenuItem( helpMenu, wxID_ABOUT, _( "&About Eeschema" ), _( "About Eeschema schematic designer" ), KiBitmap( info_xpm ) ); // Create the menubar and append all submenus menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( preferencesMenu, _( "P&references" ) ); menuBar->Append( toolsMenu, _( "&Tools" ) ); 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(); }
void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxFileName fn; switch( id ) { case ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG: m_show_layer_manager_tools = ! m_show_layer_manager_tools; m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, m_show_layer_manager_tools ? _("Hide &Layers Manager" ) : _("Show &Layers Manager" )); break; case ID_PCB_LAYERS_SETUP: InstallDialogLayerSetup(); break; case ID_CONFIG_REQ: InstallConfigFrame(); break; case ID_PCB_MASK_CLEARANCE: { DIALOG_PADS_MASK_CLEARANCE dlg( this ); dlg.ShowModal(); } break; case wxID_PREFERENCES: { Dialog_GeneralOptions dlg( this ); dlg.ShowModal(); } break; case ID_PCB_PAD_SETUP: InstallPadOptionsFrame( NULL ); break; case ID_CONFIG_SAVE: SaveProjectSettings(); break; case ID_CONFIG_READ: { fn = GetScreen()->GetFileName(); fn.SetExt( ProjectFileExtension ); wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) break; if( !wxFileExists( dlg.GetPath() ) ) { wxString msg; msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); DisplayError( this, msg ); break; } LoadProjectSettings( dlg.GetPath() ); } break; // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for Pcbnew. DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; // Macros IDs case ID_PREFRENCES_MACROS_SAVE: SaveMacros(); break; case ID_PREFRENCES_MACROS_READ: ReadMacros(); break; default: DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); } }
/** * @brief (Re)Create the menubar for the component editor frame */ void LIB_EDIT_FRAME::ReCreateMenuBar() { // Create and try to get the current menubar wxString text; 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(); while( menuBar->GetMenuCount() ) delete menuBar->Remove( 0 ); // Recreate all menus: // Menu File: wxMenu* fileMenu = new wxMenu; // Select current library AddMenuItem( fileMenu, ID_LIBEDIT_SELECT_CURRENT_LIB, _( "&Current Library" ), _( "Select working library" ), KiBitmap( library_xpm ) ); fileMenu->AppendSeparator(); // Save current library AddMenuItem( fileMenu, ID_LIBEDIT_SAVE_CURRENT_LIB, _( "&Save Current Library\tCtrl+S" ), _( "Save the current active library" ), KiBitmap( save_xpm ) ); // Save current library as... AddMenuItem( fileMenu, ID_LIBEDIT_SAVE_CURRENT_LIB_AS, _( "Save Current Library &As" ), _( "Save current active library as..." ), KiBitmap( save_as_xpm ) ); // Separator fileMenu->AppendSeparator(); // Export as png file AddMenuItem( fileMenu, ID_LIBEDIT_GEN_PNG_FILE, _( "Create &PNG File from Screen" ), _( "Create a PNG file from the component displayed on screen" ), KiBitmap( plot_xpm ) ); // Export as SVG file AddMenuItem( fileMenu, ID_LIBEDIT_GEN_SVG_FILE, _( "Create S&VG File" ), _( "Create a SVG file from the current loaded component" ), KiBitmap( plot_svg_xpm ) ); // Separator fileMenu->AppendSeparator(); // Quit AddMenuItem( fileMenu, wxID_EXIT, _( "&Quit" ), _( "Quit Library Editor" ), KiBitmap( exit_xpm ) ); // Edit menu wxMenu* editMenu = new wxMenu; // Undo text = AddHotkeyName( _( "&Undo" ), g_Libedit_Hokeys_Descr, HK_UNDO ); AddMenuItem( editMenu, wxID_UNDO, text, _( "Undo last edit" ), KiBitmap( undo_xpm ) ); // Redo text = AddHotkeyName( _( "&Redo" ), g_Libedit_Hokeys_Descr, HK_REDO ); AddMenuItem( editMenu, wxID_REDO, text, _( "Redo the last undo command" ), KiBitmap( redo_xpm ) ); // Separator editMenu->AppendSeparator(); // Delete AddMenuItem( editMenu, ID_LIBEDIT_DELETE_ITEM_BUTT, _( "&Delete" ), HELP_DELETE_ITEMS, KiBitmap( delete_xpm ) ); // Menu View: wxMenu* viewMenu = new wxMenu; /** * Important Note for ZOOM IN and ZOOM OUT commands from menubar: * we cannot add hotkey info here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT * events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command: * zoom in and out from hotkeys are equivalent to the pop up menu zoom * From here, zooming is made around the screen center * From hotkeys, zooming is made around the mouse cursor position * (obviously not possible from the toolbar or menubar command) * * in others words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators * for Zoom in and Zoom out sub menus */ // Zoom in text = _( "Zoom &In" ); AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) ); // Zoom out text = _( "Zoom &Out" ); AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) ); // Fit on screen text = AddHotkeyName( _( "&Fit on Screen" ), g_Libedit_Hokeys_Descr, HK_ZOOM_AUTO ); AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT, KiBitmap( zoom_fit_in_page_xpm ) ); // Separator viewMenu->AppendSeparator(); // Redraw text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW ); AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) ); // Menu Place: wxMenu* placeMenu = new wxMenu; // Pin AddMenuItem( placeMenu, ID_LIBEDIT_PIN_BUTT, _( "&Pin" ), HELP_ADD_PIN, KiBitmap( pin_xpm ) ); // Graphic text AddMenuItem( placeMenu, ID_LIBEDIT_BODY_TEXT_BUTT, _( "Graphic &Text" ), HELP_ADD_BODYTEXT, KiBitmap( add_text_xpm ) ); // Graphic rectangle AddMenuItem( placeMenu, ID_LIBEDIT_BODY_RECT_BUTT, _( "&Rectangle" ), HELP_ADD_BODYRECT, KiBitmap( add_rectangle_xpm ) ); // Graphic Circle AddMenuItem( placeMenu, ID_LIBEDIT_BODY_CIRCLE_BUTT, _( "&Circle" ), HELP_ADD_BODYCIRCLE, KiBitmap( add_circle_xpm ) ); // Graphic Arc AddMenuItem( placeMenu, ID_LIBEDIT_BODY_ARC_BUTT, _( "&Arc" ), HELP_ADD_BODYARC, KiBitmap( add_arc_xpm ) ); // Graphic Line or Polygon AddMenuItem( placeMenu, ID_LIBEDIT_BODY_LINE_BUTT, _( "&Line or Polygon" ), HELP_ADD_BODYPOLYGON, KiBitmap( add_polygon_xpm ) ); // Menu Preferences: wxMenu* preferencesMenu = new wxMenu; // Library list AddMenuItem( preferencesMenu, ID_CONFIG_REQ, _( "Component &Libraries" ), _( "Configure component libraries and paths" ), KiBitmap( library_xpm ) ); // Default values and options AddMenuItem( preferencesMenu, wxID_PREFERENCES, _( "Component Editor &Options" ), _( "Set Component Editor default values and options" ), KiBitmap( preference_xpm ) ); // Colors AddMenuItem( preferencesMenu, ID_COLORS_SETUP, _( "Set &Colors Scheme" ), _( "Set color preferences" ), KiBitmap( palette_xpm ) ); // Language submenu Pgm().AddMenuLanguageList( preferencesMenu ); // Hotkey submenu AddHotkeyConfigMenu( preferencesMenu ); // Menu Help: wxMenu* helpMenu = new wxMenu; // Version info AddHelpVersionInfoMenuEntry( helpMenu ); // Contents AddMenuItem( helpMenu, wxID_HELP, _( "&Contents" ), _( "Open the Eeschema manual" ), KiBitmap( online_help_xpm ) ); AddMenuItem( helpMenu, wxID_INDEX, _( "&Getting Started in KiCad" ), _( "Open the \"Getting Started in KiCad\" guide for beginners" ), KiBitmap( help_xpm ) ); // About Eeschema helpMenu->AppendSeparator(); AddMenuItem( helpMenu, wxID_ABOUT, _( "&About Eeschema" ), _( "About Eeschema schematic designer" ), KiBitmap( info_xpm ) ); // Create the menubar and append all submenus menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( preferencesMenu, _( "P&references" ) ); 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(); }
void MainEmuFrame::ApplyCoreStatus() { wxMenuBar& menubar( *GetMenuBar() ); wxMenuItem* susres = menubar.FindItem( MenuId_Sys_SuspendResume ); wxMenuItem* cdvd = menubar.FindItem( MenuId_Boot_CDVD ); wxMenuItem* cdvd2 = menubar.FindItem( MenuId_Boot_CDVD2 ); wxMenuItem* restart = menubar.FindItem( MenuId_Sys_Restart ); // [TODO] : Ideally each of these items would bind a listener instance to the AppCoreThread // dispatcher, and modify their states accordingly. This is just a hack (for now) -- air bool vm = SysHasValidState(); if( susres ) { if( !CoreThread.IsClosing() ) { susres->Enable(); susres->SetText(_("Pause")); susres->SetHelp(_("Safely pauses emulation and preserves the PS2 state.")); } else { susres->Enable(vm); if( vm ) { susres->SetText(_("Resume")); susres->SetHelp(_("Resumes the suspended emulation state.")); } else { susres->SetText(_("Pause/Resume")); susres->SetHelp(_("No emulation state is active; cannot suspend or resume.")); } } } if( restart ) { if( vm ) { restart->SetText(_("Restart")); restart->SetHelp(_("Simulates hardware reset of the PS2 virtual machine.")); } else { restart->Enable( false ); restart->SetHelp(_("No emulation state is active; boot something first.")); } } if( cdvd ) { if( vm ) { cdvd->SetText(_("Reboot CDVD (full)")); cdvd->SetHelp(_("Hard reset of the active VM.")); } else { cdvd->SetText(_("Boot CDVD (full)")); cdvd->SetHelp(_("Boot the VM using the current DVD or Iso source media")); } } if( cdvd2 ) { if( vm ) { cdvd2->SetText(_("Reboot CDVD (fast)")); cdvd2->SetHelp(_("Reboot using fast BOOT (skips splash screens)")); } else { cdvd2->SetText(_("Boot CDVD (fast)")); cdvd2->SetHelp(_("Use fast boot to skip PS2 startup and splash screens")); } } menubar.Enable( MenuId_Sys_Shutdown, SysHasValidState() || CorePlugins.AreAnyInitialized() ); }
// Virtual function void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar( void ) { // Create and try to get the current menubar 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(); while( menuBar->GetMenuCount() ) delete menuBar->Remove( 0 ); // Recreate all menus: wxString text; // Menu File: wxMenu* fileMenu = new wxMenu; // Active library selection AddMenuItem( fileMenu, ID_MODVIEW_SELECT_LIB, _("Set Current Library"), _( "Select library to be displayed" ), KiBitmap( open_library_xpm ) ); fileMenu->AppendSeparator(); // Close viewer AddMenuItem( fileMenu, wxID_EXIT, _( "Cl&ose" ), _( "Close footprint viewer" ), KiBitmap( exit_xpm ) ); // View menu wxMenu* viewMenu = new wxMenu; text = AddHotkeyName( _( "Zoom &In" ), g_Module_Viewer_Hokeys_Descr, HK_ZOOM_IN, IS_ACCELERATOR ); AddMenuItem( viewMenu, ID_VIEWER_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) ); text = AddHotkeyName( _( "Zoom &Out" ), g_Module_Viewer_Hokeys_Descr, HK_ZOOM_OUT, IS_ACCELERATOR ); AddMenuItem( viewMenu, ID_VIEWER_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) ); text = AddHotkeyName( _( "&Fit on Screen" ), g_Module_Viewer_Hokeys_Descr, HK_ZOOM_AUTO ); AddMenuItem( viewMenu, ID_VIEWER_ZOOM_PAGE, text, HELP_ZOOM_FIT, KiBitmap( zoom_fit_in_page_xpm ) ); text = AddHotkeyName( _( "&Redraw" ), g_Module_Viewer_Hokeys_Descr, HK_ZOOM_REDRAW ); AddMenuItem( viewMenu, ID_VIEWER_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) ); viewMenu->AppendSeparator(); // 3D view text = AddHotkeyName( _( "3&D Viewer" ), g_Module_Viewer_Hokeys_Descr, HK_3D_VIEWER ); AddMenuItem( viewMenu, ID_MODVIEW_SHOW_3D_VIEW, text, _( "Show footprint in 3D viewer" ), KiBitmap( three_d_xpm ) ); // Menu Help: wxMenu* helpMenu = new wxMenu; // Version info AddHelpVersionInfoMenuEntry( helpMenu ); // Contents AddMenuItem( helpMenu, wxID_HELP, _( "P&cbnew Manual" ), _( "Open the Pcbnew manual" ), KiBitmap( online_help_xpm ) ); AddMenuItem( helpMenu, wxID_INDEX, _( "&Getting Started in KiCad" ), _( "Open the \"Getting Started in KiCad\" guide for beginners" ), KiBitmap( help_xpm ) ); // About Pcbnew helpMenu->AppendSeparator(); AddMenuItem( helpMenu, wxID_ABOUT, _( "&About Pcbnew" ), _( "About Pcbnew PCB designer" ), KiBitmap( info_xpm ) ); // Append menus to the menubar menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( viewMenu, _( "&View" ) ); 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(); }
//write pending preset settings from the gui to g_Conf, // without triggering an overall "settingsApplied" event. void MainEmuFrame::CommitPreset_noTrigger() { wxMenuBar& menubar( *GetMenuBar() ); g_Conf->EmuOptions.EnablePatches = menubar.IsChecked( MenuId_EnablePatches ); }
void GridFrame::ToggleColMoving( wxCommandEvent& WXUNUSED(ev) ) { grid->EnableDragColMove( GetMenuBar()->IsChecked( ID_TOGGLECOLMOVING ) ); }
void EDA_BASE_FRAME::ShowChangedLanguage() { ReCreateMenuBar(); GetMenuBar()->Refresh(); }
void GridFrame::ToggleGridDragCell( wxCommandEvent& WXUNUSED(ev) ) { grid->EnableDragCell( GetMenuBar()->IsChecked( ID_TOGGLEGRIDDRAGCELL ) ); }
wxToolMenuBar::~wxToolMenuBar() { if (GetMenuBar()) GetMenuBar()->SetToolBar(NULL); }
void ConsoleLogFrame::OnAutoDock(wxCommandEvent& evt) { if (auto menuBar = GetMenuBar()) m_conf.AutoDock = menuBar->IsChecked(MenuId_AutoDock); evt.Skip(); }
bool wxToolMenuBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) { // Skip over the menus if (GetMenuBar()) pos += GetMenuBar()->GetMenuCount(); // the main difficulty we have here is with the controls in the toolbars: // as we (sometimes) use several separators to cover up the space used by // them, the indices are not the same for us and the toolbar // first determine the position of the first button to delete: it may be // different from pos if we use several separators to cover the space used // by a control wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { wxToolBarToolBase *tool2 = node->GetData(); if ( tool2 == tool ) { // let node point to the next node in the list node = node->GetNext(); break; } if ( tool2->IsControl() ) { pos += ((wxToolMenuBarTool *)tool2)->GetSeparatorsCount() - 1; } } // now determine the number of buttons to delete and the area taken by them size_t nButtonsToDelete = 1; // get the size of the button we're going to delete RECT r; if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT, pos, (LPARAM)&r) ) { wxLogLastError(wxT("TB_GETITEMRECT")); } int width = r.right - r.left; if ( tool->IsControl() ) { nButtonsToDelete = ((wxToolMenuBarTool *)tool)->GetSeparatorsCount(); width *= nButtonsToDelete; } // do delete all buttons m_nButtons -= nButtonsToDelete; while ( nButtonsToDelete-- > 0 ) { if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON, pos, 0) ) { wxLogLastError(wxT("TB_DELETEBUTTON")); return false; } } tool->Detach(); // and finally reposition all the controls after this button (the toolbar // takes care of all normal items) for ( /* node -> first after deleted */ ; node; node = node->GetNext() ) { wxToolBarToolBase *tool2 = node->GetData(); if ( tool2->IsControl() ) { int x; wxControl *control = tool2->GetControl(); control->GetPosition(&x, NULL); control->Move(x - width, wxDefaultCoord); } } return true; }
void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxFileName fn; switch( id ) { case ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER: m_show_layer_manager_tools = ! m_show_layer_manager_tools; m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER, m_show_layer_manager_tools ? _("Hide &Layers Manager" ) : _("Show &Layers Manager" )); break; case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR: m_show_microwave_tools = ! m_show_microwave_tools; m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR, m_show_microwave_tools ? _( "Hide Microwa&ve Toolbar" ): _( "Show Microwa&ve Toolbar" )); break; case ID_PCB_LAYERS_SETUP: if( InvokeLayerSetup( this, GetBoard() ) ) { LAYER_ID cur_layer = GetActiveLayer(); // If after showing the dialog the user has removed the active layer, // then select a new active layer (front copper layer). if( !GetBoard()->GetEnabledLayers()[ cur_layer ] ) cur_layer = F_Cu; SetActiveLayer( cur_layer ); OnModify(); ReCreateLayerBox(); ReFillLayerWidget(); if( IsGalCanvasActive() ) static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() ); } break; case ID_PCB_LIB_WIZARD: case ID_PCB_LIB_TABLE_EDIT: { bool tableChanged = false; int r = 0; if( id == ID_PCB_LIB_TABLE_EDIT ) r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); else r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() ); if( r & 1 ) { try { FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); GFootprintTable.Format( &sf, 0 ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving the global footprint library " "table:\n\n%s" ), GetChars( ioe.What().GetData() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } // If no board file is defined, do not save the project specific library table. It // is kept in memory and created in the path when the new board is saved. if( (r & 2) && !GetBoard()->GetFileName().IsEmpty() ) { wxString tblName = Prj().FootprintLibTblName(); try { Prj().PcbFootprintLibs()->Save( tblName ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving project specific footprint library " "table:\n\n%s" ), GetChars( ioe.What() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } FOOTPRINT_VIEWER_FRAME* viewer; if( tableChanged && (viewer = (FOOTPRINT_VIEWER_FRAME*)Kiway().Player( FRAME_PCB_MODULE_VIEWER, false )) != NULL ) { viewer->ReCreateLibraryList(); } } break; case ID_PCB_3DSHAPELIB_WIZARD: #ifdef BUILD_GITHUB_PLUGIN Invoke3DShapeLibsDownloaderWizard( this ); #endif break; case ID_PCB_MASK_CLEARANCE: { DIALOG_PADS_MASK_CLEARANCE dlg( this ); if( dlg.ShowModal() == 1 && IsGalCanvasActive() ) { for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) GetGalCanvas()->GetView()->Update( module ); GetGalCanvas()->Refresh(); } } break; case wxID_PREFERENCES: { DIALOG_GENERALOPTIONS dlg( this ); dlg.ShowModal(); } break; case ID_PCB_PAD_SETUP: InstallPadOptionsFrame( NULL ); break; case ID_CONFIG_SAVE: SaveProjectSettings( true ); break; case ID_CONFIG_READ: { fn = GetBoard()->GetFileName(); fn.SetExt( ProjectFileExtension ); wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) break; if( !wxFileExists( dlg.GetPath() ) ) { wxString msg = wxString::Format( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); DisplayError( this, msg ); break; } wxString pro_file = dlg.GetPath(); Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_file ); } break; // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( g_Board_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for Pcbnew. DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; default: DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); } }
void MyFrame::OnUpdateUI(wxUpdateUIEvent& WXUNUSED(event) ) { GetMenuBar()->FindItem(wxID_STOP)->Enable(m_animationCtrl->IsPlaying()); GetMenuBar()->FindItem(ID_PLAY)->Enable(!m_animationCtrl->IsPlaying()); GetMenuBar()->FindItem(ID_SET_NO_AUTO_RESIZE)->Enable(!m_animationCtrl->IsPlaying()); }
void GERBVIEW_FRAME::ReCreateMenuBar() { // Create and try to get the current menubar 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(); while( menuBar->GetMenuCount() ) delete menuBar->Remove( 0 ); // Recreate all menus: // Menu File: wxMenu* fileMenu = new wxMenu; // Load AddMenuItem( fileMenu, wxID_FILE, _( "Load &Gerber File" ), _( "Load a new Gerber file on the current layer. Previous data will be deleted" ), KiBitmap( gerber_file_xpm ) ); // Excellon AddMenuItem( fileMenu, ID_GERBVIEW_LOAD_DRILL_FILE, _( "Load &EXCELLON Drill File" ), _( "Load excellon drill file" ), KiBitmap( gerbview_drill_file_xpm ) ); // Recent gerber files 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 ) Kiface().GetFileHistory().RemoveMenu( openRecentGbrMenu ); openRecentGbrMenu = new wxMenu(); Kiface().GetFileHistory().UseMenu( openRecentGbrMenu ); Kiface().GetFileHistory().AddFilesToMenu(); AddMenuItem( fileMenu, openRecentGbrMenu, wxID_ANY, _( "Open &Recent Gerber File" ), _( "Open a recent opened Gerber file" ), KiBitmap( gerber_recent_files_xpm ) ); // Recent drill files static wxMenu* openRecentDrlMenu; if( openRecentDrlMenu ) m_drillFileHistory.RemoveMenu( openRecentDrlMenu ); openRecentDrlMenu = new wxMenu(); m_drillFileHistory.UseMenu( openRecentDrlMenu ); m_drillFileHistory.AddFilesToMenu( ); AddMenuItem( fileMenu, openRecentDrlMenu, wxID_ANY, _( "Open Recent Dri&ll File" ), _( "Open a recent opened drill file" ), KiBitmap( gerbview_open_recent_drill_files_xpm ) ); // Separator fileMenu->AppendSeparator(); // Clear all AddMenuItem( fileMenu, ID_GERBVIEW_ERASE_ALL, _( "Clear &All" ), _( "Clear all layers. All data will be deleted" ), KiBitmap( gerbview_clear_layers_xpm ) ); // Separator fileMenu->AppendSeparator(); // Export to Pcbnew AddMenuItem( fileMenu, ID_GERBVIEW_EXPORT_TO_PCBNEW, _( "E&xport to Pcbnew" ), _( "Export data in Pcbnew format" ), KiBitmap( export_xpm ) ); // Separator fileMenu->AppendSeparator(); // Print AddMenuItem( fileMenu, wxID_PRINT, _( "&Print" ), _( "Print gerber" ), KiBitmap( print_button_xpm ) ); // Separator fileMenu->AppendSeparator(); // Exit AddMenuItem( fileMenu, wxID_EXIT, _( "&Close" ), _( "Close GerbView" ), KiBitmap( exit_xpm ) ); // Menu for configuration and preferences wxMenu* configMenu = new wxMenu; // Hide layer manager AddMenuItem( configMenu, ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, _( "Hide &Layers Manager" ), m_show_layer_manager_tools ? _( "Hide &Layers Manager" ) : _("Show &Layers Manager" ), KiBitmap( layers_manager_xpm ) ); // Options (Preferences on WXMAC) #ifdef __WXMAC__ configMenu->Append(wxID_PREFERENCES); #else AddMenuItem( configMenu, wxID_PREFERENCES, _( "&Options" ), _( "Set options to draw items" ), KiBitmap( preference_xpm ) ); #endif // __WXMAC__ // Language submenu Pgm().AddMenuLanguageList( configMenu ); // Hotkey submenu AddHotkeyConfigMenu( configMenu ); // Menu miscellaneous wxMenu* miscellaneousMenu = new wxMenu; // List dcodes AddMenuItem( miscellaneousMenu, ID_GERBVIEW_SHOW_LIST_DCODES, _( "&List DCodes" ), _( "List and edit D-codes" ), KiBitmap( show_dcodenumber_xpm ) ); // Show source AddMenuItem( miscellaneousMenu, ID_GERBVIEW_SHOW_SOURCE, _( "&Show Source" ), _( "Show source file for the current layer" ), KiBitmap( tools_xpm ) ); // Separator miscellaneousMenu->AppendSeparator(); // Clear layer AddMenuItem( miscellaneousMenu, ID_GERBVIEW_GLOBAL_DELETE, _( "&Clear Layer" ), _( "Clear current layer" ), KiBitmap( general_deletions_xpm ) ); // Separator miscellaneousMenu->AppendSeparator(); // Text editor AddMenuItem( miscellaneousMenu, ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR, _( "&Text Editor" ), _( "Select your preferred text editor" ), KiBitmap( editor_xpm ) ); // Menu Help wxMenu* helpMenu = new wxMenu; // Contents AddMenuItem( helpMenu, wxID_HELP, _( "Gerbview &Manual" ), _( "Open the GerbView Manual" ), KiBitmap( online_help_xpm ) ); AddMenuItem( helpMenu, wxID_INDEX, _( "&Getting Started in KiCad" ), _( "Open \"Getting Started in KiCad\" guide for beginners" ), KiBitmap( help_xpm ) ); // Separator helpMenu->AppendSeparator(); // About Kicad AddMenuItem( helpMenu, wxID_ABOUT, _( "&About Kicad" ), _( "About KiCad" ), KiBitmap( info_xpm ) ); // Append menus to the menubar menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( configMenu, _( "&Preferences" ) ); menuBar->Append( miscellaneousMenu, _( "&Miscellaneous" ) ); 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(); }
/** * @brief (Re)Create the menubar */ void KICAD_MANAGER_FRAME::ReCreateMenuBar() { wxString msg; static wxMenu* openRecentMenu; // Open Recent submenu, // static to remember this menu m_manager_Hokeys_Descr = kicad_Manager_Hokeys_Descr; // Create and try to get the current menubar 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 ) Pgm().GetFileHistory().RemoveMenu( openRecentMenu ); // Delete all existing menus while( menuBar->GetMenuCount() ) delete menuBar->Remove( 0 ); // Recreate all menus: // Menu File: wxMenu* fileMenu = new wxMenu; // Open msg = AddHotkeyName( _( "&Open Project" ), kicad_Manager_Hokeys_Descr, HK_LOAD_PROJECT ); AddMenuItem( fileMenu, ID_LOAD_PROJECT, msg, _( "Open existing project" ), KiBitmap( open_project_xpm ) ); // File history openRecentMenu = new wxMenu(); Pgm().GetFileHistory().UseMenu( openRecentMenu ); Pgm().GetFileHistory().AddFilesToMenu( ); AddMenuItem( fileMenu, openRecentMenu, wxID_ANY, _( "Open &Recent" ), _( "Open recent schematic project" ), KiBitmap( open_project_xpm ) ); // New project creation wxMenu* newprjSubMenu = new wxMenu(); msg = AddHotkeyName( _( "&New Project" ), kicad_Manager_Hokeys_Descr, HK_NEW_PRJ ); AddMenuItem( newprjSubMenu, ID_NEW_PROJECT, msg, _( "Create new blank project" ), KiBitmap( new_project_xpm ) ); msg = AddHotkeyName( _( "New Project from &Template" ), kicad_Manager_Hokeys_Descr, HK_NEW_PRJ_TEMPLATE ); AddMenuItem( newprjSubMenu, ID_NEW_PROJECT_FROM_TEMPLATE, msg, _( "Create a new project from a template" ), KiBitmap( new_project_with_template_xpm ) ); AddMenuItem( fileMenu, newprjSubMenu, wxID_ANY, _( "New Project" ), _( "Create new project" ), KiBitmap( new_project_xpm ) ); // Currently there is nothing to save // (Kicad manager does not save any info in .pro file) #if 0 // Save msg = AddHotkeyName( _( "&Save" ), kicad_Manager_Hokeys_Descr, HK_SAVE_PROJECT ); AddMenuItem( fileMenu, ID_SAVE_PROJECT, msg, _( "Save current project" ), KiBitmap( save_project_xpm ) ); #endif // 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, _( "&Close" ), _( "Close KiCad" ), KiBitmap( exit_xpm ) ); // Menu Browse: wxMenu* browseMenu = new wxMenu(); // Text editor AddMenuItem( browseMenu, ID_TO_TEXT_EDITOR, _( "Open Text E&ditor" ), _( "Launch preferred text editor" ), KiBitmap( editor_xpm ) ); // View file AddMenuItem( browseMenu, ID_BROWSE_AN_SELECT_FILE, _( "&Open Local File" ), _( "Edit local file" ), KiBitmap( browse_files_xpm ) ); // Menu Preferences: wxMenu* preferencesMenu = new wxMenu; // Path configuration edit dialog. AddMenuItem( preferencesMenu, ID_PREFERENCES_CONFIGURE_PATHS, _( "Configure Pa&ths" ), _( "Edit path configuration environment variables" ), KiBitmap( editor_xpm ) ); // Text editor AddMenuItem( preferencesMenu, ID_SELECT_PREFERED_EDITOR, _( "&Set Text Editor" ), _( "Set your preferred text editor" ), KiBitmap( editor_xpm ) ); // PDF Viewer submenu:System browser or user defined checkbox wxMenu* SubMenuPdfBrowserChoice = new wxMenu; // Default AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_DEFAULT_PDF_BROWSER, _( "System &Default PDF Viewer" ), _( "Use system default PDF viewer" ), KiBitmap( datasheet_xpm ), wxITEM_CHECK ); SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER, Pgm().UseSystemPdfBrowser() ); // Favourite AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_PREFERED_PDF_BROWSER, _( "&Favourite PDF Viewer" ), _( "Use favourite PDF viewer" ), KiBitmap( datasheet_xpm ), wxITEM_CHECK ); SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER, !Pgm().UseSystemPdfBrowser() ); SubMenuPdfBrowserChoice->AppendSeparator(); // Append PDF Viewer submenu to preferences AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_PREFERED_PDF_BROWSER_NAME, _( "Set &PDF Viewer" ), _( "Set favourite PDF viewer" ), KiBitmap( datasheet_xpm ) ); // PDF viewer submenu AddMenuItem( preferencesMenu, SubMenuPdfBrowserChoice, -1, _( "&PDF Viewer" ), _( "PDF viewer preferences" ), KiBitmap( datasheet_xpm ) ); // Hotkey submenu preferencesMenu->AppendSeparator(); AddHotkeyConfigMenu( preferencesMenu ); // Language submenu preferencesMenu->AppendSeparator(); Pgm().AddMenuLanguageList( preferencesMenu ); // Menu Tools: wxMenu* toolsMenu = new wxMenu; msg = AddHotkeyName( _( "Run Eeschema" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA ); AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) ); msg = AddHotkeyName( _( "Run Library Editor" ), kicad_Manager_Hokeys_Descr, HK_RUN_LIBEDIT ); AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) ); msg = AddHotkeyName( _( "Run Pcbnew" ), kicad_Manager_Hokeys_Descr, HK_RUN_PCBNEW ); AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) ); msg = AddHotkeyName( _( "Run Footprint Editor" ), kicad_Manager_Hokeys_Descr, HK_RUN_FPEDITOR ); AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) ); msg = AddHotkeyName( _( "Run Gerbview" ), kicad_Manager_Hokeys_Descr, HK_RUN_GERBVIEW ); AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) ); msg = AddHotkeyName( _( "Run Bitmap2Component" ), kicad_Manager_Hokeys_Descr, HK_RUN_BM2COMPONENT ); AddMenuItem( toolsMenu, ID_TO_BITMAP_CONVERTER, msg, _( "Bitmap2Component - Convert bitmap images to Eeschema\n" "or Pcbnew elements" ), KiBitmap( image_xpm ) ); msg = AddHotkeyName( _( "Run Pcb Calculator" ), kicad_Manager_Hokeys_Descr, HK_RUN_PCBCALCULATOR ); AddMenuItem( toolsMenu, ID_TO_PCB_CALCULATOR, msg, _( "Pcb calculator - Calculator for components, track width, etc." ), KiBitmap( options_module_xpm ) ); msg = AddHotkeyName( _( "Run Page Layout Editor" ), kicad_Manager_Hokeys_Descr, HK_RUN_PLEDITOR ); AddMenuItem( toolsMenu, ID_TO_PL_EDITOR, msg, _( "Pl editor - Worksheet layout editor" ), KiBitmap( pagelayout_load_xpm ) ); // Menu Help: wxMenu* helpMenu = new wxMenu; // Version info AddHelpVersionInfoMenuEntry( helpMenu ); // Contents AddMenuItem( helpMenu, wxID_HELP, _( "KiCad &Manual" ), _( "Open KiCad user manual" ), KiBitmap( online_help_xpm ) ); AddMenuItem( helpMenu, wxID_INDEX, _( "&Getting Started in KiCad" ), _( "Open \"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( toolsMenu, _( "&Tools" ) ); 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(); // Add the hotkey to the "show hotkey list" menu, because we do not have // a management of the keyboard keys in Kicad. // So all hotheys should be added to the menubar // Note Use wxMenuBar::SetLabel only after the menubar // has been associated with a frame. (see wxWidgets doc) msg = AddHotkeyName( menuBar->GetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST ), kicad_Manager_Hokeys_Descr, HK_HELP ); menuBar->SetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg ); }
void MainFrame::UpdateUI(wxCommandEvent& event) { event.Skip(); bool is_running, is_stopped, is_ready; if(event.GetEventType() == wxEVT_DBG_COMMAND) { switch(event.GetId()) { case DID_START_EMU: case DID_STARTED_EMU: is_running = true; is_stopped = false; is_ready = false; break; case DID_STOP_EMU: case DID_STOPPED_EMU: is_running = false; is_stopped = true; is_ready = false; m_sys_menu_opened = false; break; case DID_PAUSE_EMU: case DID_PAUSED_EMU: is_running = false; is_stopped = false; is_ready = false; break; case DID_RESUME_EMU: case DID_RESUMED_EMU: is_running = true; is_stopped = false; is_ready = false; break; case DID_READY_EMU: is_running = false; is_stopped = false; is_ready = true; break; case DID_REGISTRED_CALLBACK: is_running = Emu.IsRunning(); is_stopped = Emu.IsStopped(); is_ready = Emu.IsReady(); break; default: return; } if (event.GetId() == DID_STOPPED_EMU) { if (rpcs3::config.misc.exit_on_stop.value()) { wxGetApp().Exit(); } } } else { is_running = Emu.IsRunning(); is_stopped = Emu.IsStopped(); is_ready = Emu.IsReady(); } // Update menu items based on the state of the emulator wxMenuBar& menubar( *GetMenuBar() ); // Emulation wxMenuItem& pause = *menubar.FindItem(id_sys_pause); wxMenuItem& stop = *menubar.FindItem(id_sys_stop); pause.SetItemLabel(is_running ? "&Pause\tCtrl + P" : is_ready ? "&Start\tCtrl + E" : "&Resume\tCtrl + E"); pause.Enable(!is_stopped); stop.Enable(!is_stopped); // PS3 Commands wxMenuItem& send_exit = *menubar.FindItem(id_sys_send_exit); wxMenuItem& send_open_menu = *menubar.FindItem(id_sys_send_open_menu); bool enable_commands = !is_stopped; send_open_menu.SetItemLabel(wxString::Format("Send &%s system menu cmd", (m_sys_menu_opened ? "close" : "open"))); send_open_menu.Enable(enable_commands); send_exit.Enable(enable_commands); // Tools wxMenuItem& kernel_explorer = *menubar.FindItem(id_tools_kernel_explorer); wxMenuItem& memory_viewer = *menubar.FindItem(id_tools_memory_viewer); wxMenuItem& rsx_debugger = *menubar.FindItem(id_tools_rsx_debugger); wxMenuItem& string_search = *menubar.FindItem(id_tools_string_search); kernel_explorer.Enable(!is_stopped); memory_viewer.Enable(!is_stopped); rsx_debugger.Enable(!is_stopped); string_search.Enable(!is_stopped); }
void CCodeWindow::UpdateButtonStates() { bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED); bool Pause = (Core::GetState() == Core::CORE_PAUSE); bool Stepping = CCPU::IsStepping(); wxAuiToolBar* ToolBar = GetToolBar(); // Toolbar if (!ToolBar) return; if (!Initialized) { ToolBar->EnableTool(IDM_STEPOVER, false); ToolBar->EnableTool(IDM_SKIP, false); } else { if (!Stepping) { ToolBar->EnableTool(IDM_STEPOVER, false); ToolBar->EnableTool(IDM_SKIP, false); } else { ToolBar->EnableTool(IDM_STEPOVER, true); ToolBar->EnableTool(IDM_SKIP, true); } } ToolBar->EnableTool(IDM_STEP, Initialized && Stepping); if (ToolBar) ToolBar->Realize(); // Menu bar // ------------------ GetMenuBar()->Enable(IDM_INTERPRETER, Pause); // CPU Mode GetMenuBar()->Enable(IDM_JITNOBLOCKCACHE, !Initialized); GetMenuBar()->Enable(IDM_JITOFF, Pause); GetMenuBar()->Enable(IDM_JITLSOFF, Pause); GetMenuBar()->Enable(IDM_JITLSLXZOFF, Pause); GetMenuBar()->Enable(IDM_JITLSLWZOFF, Pause); GetMenuBar()->Enable(IDM_JITLSLBZXOFF, Pause); GetMenuBar()->Enable(IDM_JITLSFOFF, Pause); GetMenuBar()->Enable(IDM_JITLSPOFF, Pause); GetMenuBar()->Enable(IDM_JITFPOFF, Pause); GetMenuBar()->Enable(IDM_JITIOFF, Pause); GetMenuBar()->Enable(IDM_JITPOFF, Pause); GetMenuBar()->Enable(IDM_JITSROFF, Pause); GetMenuBar()->Enable(IDM_CLEARCODECACHE, Pause); // JIT Menu GetMenuBar()->Enable(IDM_SEARCHINSTRUCTION, Initialized); GetMenuBar()->Enable(IDM_CLEARSYMBOLS, Initialized); // Symbols menu GetMenuBar()->Enable(IDM_SCANFUNCTIONS, Initialized); GetMenuBar()->Enable(IDM_LOADMAPFILE, Initialized); GetMenuBar()->Enable(IDM_SAVEMAPFILE, Initialized); GetMenuBar()->Enable(IDM_SAVEMAPFILEWITHCODES, Initialized); GetMenuBar()->Enable(IDM_CREATESIGNATUREFILE, Initialized); GetMenuBar()->Enable(IDM_RENAME_SYMBOLS, Initialized); GetMenuBar()->Enable(IDM_USESIGNATUREFILE, Initialized); GetMenuBar()->Enable(IDM_PATCHHLEFUNCTIONS, Initialized); // Update Fonts callstack->SetFont(DebuggerFont); symbols->SetFont(DebuggerFont); callers->SetFont(DebuggerFont); calls->SetFont(DebuggerFont); }