void GRID_MENU::update() { BASE_SCREEN* screen = m_parent->GetScreen(); int currentId = screen->GetGridCmdId(); wxArrayString gridsList; screen->BuildGridsChoiceList( gridsList, m_parent->GetUserUnits() != INCHES ); for( unsigned int i = 0; i < GetMenuItemCount(); ++i ) { int menuId = ID_POPUP_GRID_SELECT + 1 + i; SetLabel( menuId, gridsList[i] ); // Refresh label in case units have changed Check( menuId, menuId == currentId ); // Refresh checkmark } }
GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) : m_parent( aParent ) { BASE_SCREEN* screen = aParent->GetScreen(); SetTitle( _( "Grid" ) ); SetIcon( grid_select_xpm ); wxArrayString gridsList; screen->BuildGridsChoiceList( gridsList, g_UserUnit != INCHES ); for( unsigned int i = 0; i < gridsList.GetCount(); ++i ) { GRID_TYPE& grid = screen->GetGrid( i ); Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK ); } }
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) { int maxZoomIds; double zoom; wxString msg; BASE_SCREEN* screen = m_canvas->GetScreen(); msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) ); msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) ); msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) ); msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) ); msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) ); wxMenu* zoom_choice = new wxMenu; AddMenuItem( MasterMenu, zoom_choice, ID_POPUP_ZOOM_SELECT, _( "Zoom" ), KiBitmap( zoom_selection_xpm ) ); zoom = screen->GetZoom(); maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START; maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ? maxZoomIds : screen->m_ZoomList.size(); // Populate zoom submenu. for( int i = 0; i < maxZoomIds; i++ ) { msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] ); zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg, wxEmptyString, wxITEM_CHECK ); if( zoom == screen->m_ZoomList[i] ) zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true ); } // Create grid submenu as required. if( screen->GetGridCount() ) { wxMenu* gridMenu = new wxMenu; AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT, _( "Grid" ), KiBitmap( grid_select_xpm ) ); wxArrayString gridsList; int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES ); for( unsigned i = 0; i < gridsList.GetCount(); i++ ) { GRID_TYPE& grid = screen->GetGrid( i ); gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK ); if( (int)i == icurr ) gridMenu->Check( grid.m_CmdId, true ); } } MasterMenu->AppendSeparator(); AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) ); }