diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 8d28133836..1652c73424 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -93,11 +93,9 @@ void WinEDA_BasicFrame::SetLanguage( wxCommandEvent& event ) int id = event.GetId(); wxGetApp().SetLanguageIdentifier( id ); - if ( wxGetApp().SetLanguage() ) - { - ReCreateMenuBar(); - Refresh(); - } + wxGetApp().SetLanguage(); + ReCreateMenuBar(); + GetMenuBar()->Refresh(); } diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index 37a3b14751..471f1ba702 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -22,7 +22,7 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) { #define WSTEXTSIZE 50 // Text size in mils Ki_PageDescr* Sheet = screen->m_CurrentSheetDesc; - int xg, yg, ipas, gxpas, gypas; + int xg, yg; wxSize PageSize; wxPoint pos, ref; EDA_Colors color; @@ -36,10 +36,11 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) wxSize text_size2; wxSize text_size3; wxSize text_size1_5; -#endif +#else int UpperLimit = VARIABLE_BLOCK_START_POSITION; - bool italic = false; bool bold = false; +#endif + bool italic = false; bool thickness = 0; //@todo : use current pen color = BLACK; @@ -150,8 +151,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) #else /* Plot legend along the X axis. */ - ipas = ( xg - ref.x ) / PAS_REF; - gxpas = ( xg - ref.x ) / ipas; + int ipas = ( xg - ref.x ) / PAS_REF; + int gxpas = ( xg - ref.x ) / ipas; for( int ii = ref.x + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- ) { msg.Empty(); @@ -193,7 +194,7 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) /* Plot legend along the Y axis. */ ipas = ( yg - ref.y ) / PAS_REF; - gypas = ( yg - ref.y ) / ipas; + int gypas = ( yg - ref.y ) / ipas; for( int ii = ref.y + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- ) { if( jj < 26 ) diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 62a1a340bb..8a0ae3963d 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -79,6 +79,7 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, m_AbortEnable = m_AbortRequest = false; m_AutoPAN_Enable = TRUE; m_IgnoreMouseEvents = 0; + m_DisableEraseBG = false; ManageCurseur = NULL; ForceCloseManageCurseur = NULL; @@ -673,7 +674,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) // call ~wxDCClipper() before ~wxPaintDC() { wxDCClipper dcclip( paintDC, PaintClipBox ); - ReDraw( &paintDC, true ); + ReDraw( &paintDC, m_DisableEraseBG ? false : true ); } m_ClipBox = tmp; @@ -914,6 +915,13 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) tmpDC.DrawPoint( 0, ypos ); } + // Use the layer bitmap itself as a mask when blitting. + // The bitmap cannot be referenced by a device context + // when setting the mask. + tmpDC.SelectObject( wxNullBitmap ); + tmpBM.SetMask( new wxMask( tmpBM, MakeColour( g_DrawBgColor ) ) ); + tmpDC.SelectObject( tmpBM ); + ypos = GRMapY( org.y ); for( ii = 0; ; ii += increment ) { @@ -925,7 +933,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) continue; if( xpos > m_ClipBox.GetEnd().x) // end of active area reached. break; - DC->Blit( xpos, ypos, 1, screenSize.y, &tmpDC, 0, 0 ); + DC->Blit( xpos, ypos, 1, screenSize.y, &tmpDC, 0, 0, wxCOPY, true ); } #endif diff --git a/common/zoom.cpp b/common/zoom.cpp index cca46116f9..2df04d7084 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -37,7 +37,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse ) * use Refresh() and update() do not change problems */ INSTALL_DC( dc, DrawPanel ); - DrawPanel->ReDraw( &dc ); + DrawPanel->ReDraw( &dc, DrawPanel->m_DisableEraseBG ? false : true ); /* Move the mouse cursor to the on grid graphic cursor position */ if( ToMouse == TRUE ) diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index e10ac4e4c4..50d6912ca4 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -36,7 +36,7 @@ set(CVPCB_SRCS listboxes.cpp listlib.cpp loadcmp.cpp - menucfg.cpp + menubar.cpp readschematicnetlist.cpp savecmp.cpp setvisu.cpp diff --git a/cvpcb/menucfg.cpp b/cvpcb/menubar.cpp similarity index 83% rename from cvpcb/menucfg.cpp rename to cvpcb/menubar.cpp index 0a7d287c99..e1a8ad919e 100644 --- a/cvpcb/menucfg.cpp +++ b/cvpcb/menubar.cpp @@ -1,5 +1,5 @@ /** - * @file ./menucfg.cpp + * @file menucfg.cpp * (Re)Create the CvPCB main MenuBar */ #include "fctsys.h" @@ -18,9 +18,18 @@ void WinEDA_CvpcbFrame::ReCreateMenuBar() { wxMenuItem* item; - wxMenuBar* menuBar; + wxMenuBar* menuBar = GetMenuBar(); - menuBar = new wxMenuBar(); + 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: wxMenu* filesMenu = new wxMenu; item = new wxMenuItem( filesMenu, ID_LOAD_PROJECT, @@ -29,7 +38,7 @@ void WinEDA_CvpcbFrame::ReCreateMenuBar() item->SetBitmap( open_xpm ); filesMenu->Append( item ); - /* Open Recent submenu */ + /* Open Recent submenu */ wxMenu* openRecentMenu = new wxMenu(); wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1, _( "Open &Recent" ), @@ -96,14 +105,16 @@ void WinEDA_CvpcbFrame::ReCreateMenuBar() #endif /* !defined(__WXMAC__) */ - /** - * Create the menubar and append all submenus - */ + // Create the menubar and append all submenus menuBar->Append( filesMenu, _( "&File" ) ); menuBar->Append( configmenu, _( "&Preferences" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - /* Calling SetMenuBar() will Destroy the existing menu bar so it can be - * rebuilt. This allows language changes of the menu text on the fly. */ - SetMenuBar( menuBar ); + menuBar->Thaw(); + + // Associate the menu bar with the frame, if no previous menubar + if( GetMenuBar() == NULL ) + SetMenuBar( menuBar ); + else + menuBar->Refresh(); } diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 5e42eb9da0..707a5ed871 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -958,6 +958,9 @@ void LIB_EDIT_FRAME::SetLanguage( wxCommandEvent& event ) { WinEDA_BasicFrame::SetLanguage( event ); SCH_EDIT_FRAME *parent = (SCH_EDIT_FRAME *)GetParent(); + // Call parent->WinEDA_BasicFrame::SetLanguage and NOT + // parent->SetLanguage because parent->SetLanguage call + // LIB_EDIT_FRAME::SetLanguage parent->WinEDA_BasicFrame::SetLanguage( event ); } diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index ab6917ab3b..1efe5d0bbd 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -28,34 +28,34 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() wxMenuItem* item; wxMenuBar* menuBar = GetMenuBar(); - /** - * Destroy the existing menu bar so it can be rebuilt. This allows - * language changes of the menu text on the fly. - */ - if( menuBar ) - SetMenuBar( NULL ); + if( ! menuBar ) + menuBar = new wxMenuBar(); - 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); - /** - * File menu - */ + // Recreate all menus: + + // File menu wxMenu* filesMenu = new wxMenu; - /* New */ + // New item = new wxMenuItem( filesMenu, ID_NEW_PROJECT, _( "&New\tCtrl+N" ), _( "New schematic project" ) ); item->SetBitmap( new_xpm ); filesMenu->Append( item ); - /* Open */ + // Open item = new wxMenuItem( filesMenu, ID_LOAD_PROJECT, _( "&Open\tCtrl+O" ), _( "Open an existing schematic project" ) ); item->SetBitmap( open_xpm ); filesMenu->Append( item ); - /* Open Recent submenu */ + // Open Recent submenu wxMenu* openRecentMenu = new wxMenu(); wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, @@ -63,11 +63,9 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() _( "Open a recent opened schematic project" ), open_project_xpm ); - /* Separator */ - filesMenu->AppendSeparator(); - /* Save */ - /* Save Project */ + // Save schematic + filesMenu->AppendSeparator(); item = new wxMenuItem( filesMenu, ID_SAVE_PROJECT, _( "&Save Whole Schematic Project\tCtrl+S" ), _( "Save all sheets in the schematic project" ) ); @@ -79,22 +77,21 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( save_xpm ); filesMenu->Append( item ); - /* Save as... */ + // Save as... item = new wxMenuItem( filesMenu, ID_SAVE_ONE_SHEET_AS, _( "Save Current Sheet &as" ), _( "Save current schematic sheet as..." ) ); item->SetBitmap( save_as_xpm ); filesMenu->Append( item ); - /* Separator */ - filesMenu->AppendSeparator(); - /* Print */ + // Print + filesMenu->AppendSeparator(); item = new wxMenuItem( filesMenu, wxID_PRINT, _( "P&rint" ), _( "Print schematic" ) ); item->SetBitmap( print_button ); filesMenu->Append( item ); - /* Plot submenu */ + // Plot submenu wxMenu* choice_plot_fmt = new wxMenu; item = new wxMenuItem( choice_plot_fmt, ID_GEN_PLOT_PS, _( "Plot PostScript" ), @@ -108,19 +105,19 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( plot_HPG_xpm ); choice_plot_fmt->Append( item ); - /* Plot SVG */ + // Plot SVG item = new wxMenuItem( choice_plot_fmt, ID_GEN_PLOT_SVG, _( "Plot SVG" ), _( "Plot schematic sheet in SVG format" ) ); item->SetBitmap( plot_xpm ); choice_plot_fmt->Append( item ); - /* Plot DXF */ + // Plot DXF item = new wxMenuItem( choice_plot_fmt, ID_GEN_PLOT_DXF, _( "Plot DXF" ), _( "Plot schematic sheet in DXF format" ) ); item->SetBitmap( plot_xpm ); choice_plot_fmt->Append( item ); - /* Under windows, one can draw to the clipboard */ + // Under windows, one can draw to the clipboard #ifdef __WINDOWS__ item = new wxMenuItem( choice_plot_fmt, ID_GEN_COPY_SHEET_TO_CLIPBOARD, @@ -128,7 +125,6 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() _( "Export drawings to clipboard" ) ); item->SetBitmap( copy_button ); choice_plot_fmt->Append( item ); - #endif ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, choice_plot_fmt, @@ -136,7 +132,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() _( "Plot schematic sheet in HPGL, PostScript or SVG format" ), plot_xpm ); - /* Quit on all platforms except WXMAC */ + // Quit on all platforms except WXMAC #if !defined(__WXMAC__) filesMenu->AppendSeparator(); @@ -144,15 +140,12 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( exit_xpm ); filesMenu->Append( item ); -#endif /* !defined( __WXMAC__) */ - +#endif // !defined( __WXMAC__) - /** - * Edit menu - */ + // Edit menu wxMenu* editMenu = new wxMenu; - /* Undo */ + // Undo text = AddHotkeyName( _( "Undo" ), s_Schematic_Hokeys_Descr, HK_UNDO ); item = new wxMenuItem( editMenu, wxID_UNDO, text, HELP_UNDO, wxITEM_NORMAL ); @@ -166,10 +159,8 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( redo_xpm ); editMenu->Append( item ); - /* Separator */ - editMenu->AppendSeparator(); - /* Delete */ + editMenu->AppendSeparator(); item = new wxMenuItem( editMenu, ID_SCHEMATIC_DELETE_ITEM_BUTT, _( "Delete" ), HELP_DELETE_ITEMS, wxITEM_NORMAL ); item->SetBitmap( delete_body_xpm ); @@ -195,9 +186,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() editMenu->Append( item ); - /** - * View menu - */ + // View menu wxMenu* viewMenu = new wxMenu; /* Important Note for ZOOM IN and ZOOM OUT commands from menubar: @@ -378,9 +367,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() placeMenu->Append( item ); - /** - * Preferences Menu - */ + // Preferences Menu wxMenu* configmenu = new wxMenu; /* Library */ @@ -423,9 +410,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() configmenu->Append( item ); - /** - * Help Menu - */ + // Help Menu wxMenu* helpMenu = new wxMenu; AddHelpVersionInfoMenuEntry( helpMenu ); @@ -446,9 +431,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() #endif /* !defined(__WXMAC__) */ - /** - * Create the menubar and append all submenus - */ + // Create the menubar and append all submenus menuBar->Append( filesMenu, _( "&File" ) ); menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( viewMenu, _( "&View" ) ); @@ -456,6 +439,11 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() menuBar->Append( configmenu, _( "&Preferences" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - /* Associate the menu bar with the frame */ - SetMenuBar( menuBar ); + menuBar->Thaw(); + + // Associate the menu bar with the frame, if no previous menubar + if( GetMenuBar() == NULL ) + SetMenuBar( menuBar ); + else + menuBar->Refresh(); } diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index 3cbbe1faef..a6b0a6202a 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -23,44 +23,44 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() wxMenuItem *item; wxMenuBar *menuBar = GetMenuBar(); - /** - * Destroy the existing menu bar so it can be rebuilt. This allows - * language changes of the menu text on the fly. - */ - if( menuBar ) - SetMenuBar( NULL ); + if( ! menuBar ) + menuBar = new wxMenuBar(); - 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); - /** - * File menu - */ + // Recreate all menus: + + // File menu wxMenu* filesMenu = new wxMenu; - /* Save current lib */ + // Save current lib item = new wxMenuItem( filesMenu, ID_LIBEDIT_SAVE_CURRENT_LIB, _( "&Save Current Library\tCtrl+S" ), _( "Save the current active library" ) ); item->SetBitmap( save_xpm ); filesMenu->Append( item ); - /* Save as... */ + // Save as... item = new wxMenuItem( filesMenu, ID_LIBEDIT_SAVE_CURRENT_LIB_AS, _( "Save Current Library &as" ), _( "Save current active library as..." ) ); item->SetBitmap( save_as_xpm ); filesMenu->Append( item ); - /* Separator */ + // Separator filesMenu->AppendSeparator(); - /* Export as png file */ + // Export as png file item = new wxMenuItem( filesMenu, ID_LIBEDIT_GEN_PNG_FILE, _( "&Create PNG File from Screen" ), _( "Create a PNG file from the component displayed on screen" ) ); item->SetBitmap( plot_xpm ); filesMenu->Append( item ); - /* Export as SVG file */ + // Export as SVG file item = new wxMenuItem( filesMenu, ID_LIBEDIT_GEN_SVG_FILE, _( "&Create SVG File" ), _( "Create a SVG file from the current loaded component" ) ); item->SetBitmap( plot_xpm ); @@ -77,19 +77,17 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() filesMenu->Append( item ); #endif - /** - * Edit menu - */ + // Edit menu wxMenu* editMenu = new wxMenu; - /* Undo */ + // Undo text = AddHotkeyName( _( "Undo" ), s_Libedit_Hokeys_Descr, HK_UNDO); item = new wxMenuItem( editMenu, wxID_UNDO, text, _( "Undo last edition" ), wxITEM_NORMAL ); item->SetBitmap( undo_xpm ); editMenu->Append( item ); - /* Redo */ + // Redo text = AddHotkeyName( _( "Redo" ), s_Libedit_Hokeys_Descr, HK_REDO); item = new wxMenuItem( editMenu, wxID_REDO, text, @@ -97,18 +95,14 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( redo_xpm ); editMenu->Append( item ); - /* Separator */ + // Delete editMenu->AppendSeparator(); - - /* Delete */ item = new wxMenuItem( editMenu, ID_LIBEDIT_DELETE_ITEM_BUTT, _( "Delete" ), HELP_DELETE_ITEMS, wxITEM_NORMAL ); item->SetBitmap( delete_body_xpm ); editMenu->Append( item ); - /** - * View menu - */ + // View menu wxMenu* viewMenu = new wxMenu; /* Important Note for ZOOM IN and ZOOM OUT commands from menubar: @@ -128,13 +122,13 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( zoom_in_xpm ); viewMenu->Append( item ); - /* Zoom out */ + // Zoom out text = _( "Zoom Out" ); item = new wxMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, wxITEM_NORMAL ); item->SetBitmap( zoom_out_xpm ); viewMenu->Append( item ); - /* Fit on screen */ + // Fit on screen text = AddHotkeyName( _( "Fit on Screen" ), s_Schematic_Hokeys_Descr, HK_ZOOM_AUTO ); item = new wxMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT, wxITEM_NORMAL ); @@ -143,40 +137,37 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() viewMenu->AppendSeparator(); - /* Redraw view */ + // Redraw view text = AddHotkeyName( _( "Redraw" ), s_Schematic_Hokeys_Descr, HK_ZOOM_REDRAW ); item = new wxMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, wxITEM_NORMAL ); item->SetBitmap( zoom_redraw_xpm ); viewMenu->Append( item ); - /** - * Place menu - * TODO: Unify the ID names! - */ + // Place menu wxMenu* placeMenu = new wxMenu; - /* Pin */ + // place Pin item = new wxMenuItem( placeMenu, ID_LIBEDIT_PIN_BUTT, _( "&Pin" ), HELP_ADD_PIN, wxITEM_NORMAL ); item->SetBitmap( pin_xpm ); placeMenu->Append( item ); - /* Graphic text */ + // Graphic text item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_TEXT_BUTT, _( "Graphic text" ), HELP_ADD_BODYTEXT, wxITEM_NORMAL ); item->SetBitmap( add_text_xpm ); placeMenu->Append( item ); - /* Graphic rectangle */ + // Graphic rectangle item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_RECT_BUTT, _( "Rectangle" ), HELP_ADD_BODYRECT, wxITEM_NORMAL ); item->SetBitmap( add_rectangle_xpm ); placeMenu->Append( item ); - /* Graphic Circle */ + // Graphic Circle item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_CIRCLE_BUTT, _( "Circle" ), HELP_ADD_BODYCIRCLE, @@ -184,68 +175,55 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( add_circle_xpm ); placeMenu->Append( item ); - /* Graphic Arc */ + // Graphic Arc item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_ARC_BUTT, _( "Arc" ), HELP_ADD_BODYARC, wxITEM_NORMAL ); item->SetBitmap( add_arc_xpm ); placeMenu->Append( item ); - /* Graphic line or polygon */ + // Graphic line or polygon item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_LINE_BUTT, _( "Line or Polygon" ), HELP_ADD_BODYPOLYGON, wxITEM_NORMAL ); item->SetBitmap( add_polygon_xpm ); placeMenu->Append( item ); - /** - * Preferences Menu - */ + // Preferences Menu wxMenu* configmenu = new wxMenu; - /* Library */ + // Library item = new wxMenuItem( configmenu, ID_CONFIG_REQ, _( "&Library" ), _( "Library preferences" ) ); item->SetBitmap( library_xpm ); configmenu->Append( item ); - /* Colors */ + // Colors item = new wxMenuItem( configmenu, ID_COLORS_SETUP, _( "&Colors" ), _( "Color preferences" ) ); item->SetBitmap( palette_xpm ); configmenu->Append( item ); -#if 0 // work in progress. activated when finished -/* Dimension */ - item = new wxMenuItem( configmenu, ID_LIBEDIT_DIMENSIONS, _( "&Dimensions" ), - _( "Thickness of graphic lines, texts sizes and others" ) ); - item->SetBitmap( add_dimension_xpm ); - configmenu->Append( item ); -#endif - /* Language submenu */ + // Language submenu wxGetApp().AddMenuLanguageList( configmenu ); - /* Hotkey submenu */ + // Hotkey submenu AddHotkeyConfigMenu( configmenu ); - /* Separator */ + // Save preferences configmenu->AppendSeparator(); - - /* Save preferences */ item = new wxMenuItem( configmenu, ID_CONFIG_SAVE, _( "&Save preferences" ), _( "Save application preferences" ) ); item->SetBitmap( save_setup_xpm ); configmenu->Append( item ); - /* Read preferences */ + // Read preferences item = new wxMenuItem( configmenu, ID_CONFIG_READ, _( "&Read preferences" ), _( "Read application preferences" ) ); item->SetBitmap( read_setup_xpm ); configmenu->Append( item ); - /** - * Help Menu - */ + // Help Menu wxMenu* helpMenu = new wxMenu; AddHelpVersionInfoMenuEntry( helpMenu ); @@ -255,9 +233,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() item->SetBitmap( online_help_xpm ); helpMenu->Append( item ); - /** - * Create the menubar and append all submenus - */ + // Create the menubar and append all submenus menuBar->Append( filesMenu, _( "&File" ) ); menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( viewMenu, _( "&View" ) ); @@ -265,6 +241,11 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() menuBar->Append( configmenu, _( "&Preferences" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - /* Associate the menu bar with the frame */ - SetMenuBar( menuBar ); + menuBar->Thaw(); + + // Associate the menu bar with the frame, if no previous menubar + if( GetMenuBar() == NULL ) + SetMenuBar( menuBar ); + else + menuBar->Refresh(); } diff --git a/eeschema/sch_items.cpp b/eeschema/sch_items.cpp index 95935ca721..c27ffd90bb 100644 --- a/eeschema/sch_items.cpp +++ b/eeschema/sch_items.cpp @@ -1031,9 +1031,9 @@ bool SCH_LINE::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFi || ( ( aFilter & WIRE_T ) && ( m_Layer == LAYER_WIRE ) ) || ( ( aFilter & BUS_T ) && ( m_Layer == LAYER_BUS ) ) ) { - if( aFilter & EXCLUDE_WIRE_BUS_ENDPOINTS && IsEndPoint( aPoint ) - || aFilter & WIRE_BUS_ENDPOINTS_ONLY && !IsEndPoint( aPoint ) - || TestSegmentHit( aPoint, m_Start, m_End, aAccuracy ) ) + if( ( aFilter & EXCLUDE_WIRE_BUS_ENDPOINTS && IsEndPoint( aPoint ) ) + || ( aFilter & WIRE_BUS_ENDPOINTS_ONLY && !IsEndPoint( aPoint ) ) + || ( TestSegmentHit( aPoint, m_Start, m_End, aAccuracy ) ) ) return true; } diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index e119a98b23..027781eacd 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -25,6 +25,7 @@ set(GERBVIEW_SRCS block.cpp class_am_param.cpp class_aperture_macro.cpp + class_DCodeSelectionbox.cpp class_GERBER.cpp class_gerber_draw_item.cpp class_gerbview_layer_widget.cpp diff --git a/gerbview/class_DCodeSelectionbox.cpp b/gerbview/class_DCodeSelectionbox.cpp new file mode 100644 index 0000000000..ad247cba31 --- /dev/null +++ b/gerbview/class_DCodeSelectionbox.cpp @@ -0,0 +1,61 @@ +/*****************************************************************/ +/* class_DCodeSelectionbox.cpp: class for displaying DCodes list */ +/*****************************************************************/ + +#include "fctsys.h" +#include "appl_wxstruct.h" +#include "wxstruct.h" +#include "common.h" +#include "class_drawpanel.h" +#include "gerbview.h" + +#include "class_DCodeSelectionbox.h" + +/*******************************************/ +/* Helper class for displaying DCodes list */ +/*******************************************/ + +DCODE_SELECTION_BOX::DCODE_SELECTION_BOX( WinEDA_Toolbar* aParent, wxWindowID aId, + const wxPoint& aLocation, const wxSize& aSize, + const wxArrayString& aChoices ) : + wxComboBox( aParent, aId, wxEmptyString, aLocation, aSize, aChoices, wxCB_READONLY ) +{ + m_dcodeList = &aChoices; +} + + +DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX() +{ +} + + +int DCODE_SELECTION_BOX::GetSelectedDCodeId() +{ + int ii = GetSelection(); + + if( ii > 0 ) + { + wxString msg = (*m_dcodeList)[ii].AfterFirst( wxChar( ' ' ) ); + long id; + msg.ToLong(&id); + return id; + } + + return -1; +} + + +/* SetDCodeSelection + * aDCodeId = the DCode Id to select or -1 to select "no dcode" + */ +void DCODE_SELECTION_BOX::SetDCodeSelection( int aDCodeId ) +{ + if( aDCodeId > LAST_DCODE ) + aDCodeId = LAST_DCODE; + + int index = 0; + if( aDCodeId >= FIRST_DCODE ) + index = aDCodeId - FIRST_DCODE + 1; + + SetSelection(index); +} diff --git a/gerbview/class_DCodeSelectionbox.h b/gerbview/class_DCodeSelectionbox.h new file mode 100644 index 0000000000..b5cd05a4fa --- /dev/null +++ b/gerbview/class_DCodeSelectionbox.h @@ -0,0 +1,34 @@ +// file class_DCodeSelectionbox.h + +#ifndef CLASS_DCODESELECTIONBOX_H +#define CLASS_DCODESELECTIONBOX_H + +/* helper class to display a DCode list and select a DCode id. + */ + +// Define event type for DCODE_SELECTION_BOX +#define EVT_SELECT_DCODE EVT_COMBOBOX + +class DCODE_SELECTION_BOX : public wxComboBox +{ +private: + const wxArrayString* m_dcodeList; + +public: DCODE_SELECTION_BOX( WinEDA_Toolbar* aParent, wxWindowID aId, + const wxPoint& aLocation, const wxSize& aSize, + const wxArrayString& aChoices); + ~DCODE_SELECTION_BOX(); + + /** + * Function GetSelectedDCodeId + * @return the current selected DCode Id or -1 if no dcode + */ + int GetSelectedDCodeId(); + /** + * Function SetDCodeSelection + * @param aDCodeId = the DCode Id to select or -1 to select "no dcode" + */ + void SetDCodeSelection( int aDCodeId ); +}; + +#endif //CLASS_DCODESELECTIONBOX_H diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index d6e2d524a1..1eab1c4299 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -80,6 +80,8 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) if( !GetBoard() ) return; + wxBusyCursor dummy; + ActiveScreen = screen; GRSetDrawMode( DC, GR_COPY ); diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 86ec9b9088..f3ccbf4c7b 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -15,7 +15,7 @@ #include "gerbview_id.h" #include "class_GERBER.h" #include "dialog_helpers.h" - +#include "class_DCodeSelectionbox.h" /* Process the command triggered by the left button of the mouse when a tool * is already selected. @@ -145,19 +145,18 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_TOOLBARH_GERBVIEW_SELECT_LAYER: setActiveLayer(m_SelLayerBox->GetChoice()); - DrawPanel->Refresh( TRUE ); + DrawPanel->Refresh(); break; case ID_TOOLBARH_GERBER_SELECT_TOOL: if( gerber_layer ) { - int tool = m_SelLayerTool->GetChoice(); - if( tool > 0 ) - tool = tool - 1 + FIRST_DCODE; - else - tool = 0; - gerber_layer->m_Selected_Tool = tool; - DrawPanel->Refresh( TRUE ); + int tool = m_DCodeSelector->GetSelectedDCodeId(); + if( tool != gerber_layer->m_Selected_Tool ) + { + gerber_layer->m_Selected_Tool = tool; + DrawPanel->Refresh(); + } } break; diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 32bbae3434..693efec552 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -9,8 +9,6 @@ #include "gestfich.h" #include "gerbview.h" -#include "pcbplot.h" - static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileName ); @@ -159,7 +157,7 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) } // Read gerber files: each file is loaded on a new gerbview layer - int layer = getActiveLayer() - 1; + int layer = getActiveLayer(); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { wxFileName filename = filenamesList[ii]; @@ -167,21 +165,13 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) GetScreen()->m_FileName = filename.GetFullPath(); filename.SetExt( g_PenFilenameExt ); - layer++; - if( layer >= NB_LAYERS ) - layer = 0; - setActiveLayer(layer); + setActiveLayer( layer, false ); if( Read_GERBER_File( GetScreen()->m_FileName, filename.GetFullPath() ) ) { SetLastProject( GetScreen()->m_FileName ); - } - else - { - layer--; - if( layer >= 0 ) - setActiveLayer(layer); - else - setActiveLayer(0); + layer++; + if( layer >= NB_LAYERS ) + layer = 0; } } @@ -189,6 +179,10 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) GetScreen()->SetRefreshReq(); g_SaveTime = time( NULL ); + // Synchronize layers tools with actual active layer: + setActiveLayer(getActiveLayer()); + syncLayerBox(); + return true; } diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index f2f5e65386..7f7a30d443 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -2,10 +2,6 @@ /* gerberframe.cpp */ /*******************/ -#ifdef __GNUG__ -#pragma implementation -#endif - #include "fctsys.h" #include "appl_wxstruct.h" #include "wxstruct.h" @@ -20,6 +16,7 @@ #include "hotkeys.h" #include "class_GERBER.h" #include "dialog_helpers.h" +#include "class_DCodeSelectionbox.h" #include "build_version.h" @@ -29,110 +26,109 @@ /****************************************/ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame ) - EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow ) - EVT_SIZE( WinEDA_GerberFrame::OnSize ) +EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow ) +EVT_SIZE( WinEDA_GerberFrame::OnSize ) - EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_GerberFrame::OnZoom ) +EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_GerberFrame::OnZoom ) - EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io ) - EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io ) +EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io ) +EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io ) +EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io ) +EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io ) +EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io ) // Menu Files: - EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io ) - EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io ) - EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io ) - EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter ) - EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, - WinEDA_GerberFrame::ExportDataInPcbnewFormat ) +EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io ) +EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io ) +EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io ) +EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter ) +EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, + WinEDA_GerberFrame::ExportDataInPcbnewFormat ) - EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_GerberFrame::OnFileHistory ) +EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_GerberFrame::OnFileHistory ) - EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions ) +EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions ) // menu Preferences - EVT_MENU( ID_CONFIG_REQ, - WinEDA_GerberFrame::Process_Config ) - EVT_MENU( ID_CONFIG_SAVE, - WinEDA_GerberFrame::Process_Config ) - EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, - ID_PREFERENCES_HOTKEY_END, - WinEDA_GerberFrame::Process_Config ) +EVT_MENU( ID_CONFIG_REQ, + WinEDA_GerberFrame::Process_Config ) +EVT_MENU( ID_CONFIG_SAVE, + WinEDA_GerberFrame::Process_Config ) +EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, + ID_PREFERENCES_HOTKEY_END, + WinEDA_GerberFrame::Process_Config ) - EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberOptionsDialog ) +EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, + WinEDA_GerberFrame::OnSelectOptionToolbar ) +EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberOptionsDialog ) - EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, - WinEDA_DrawFrame::SetLanguage ) +EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, + WinEDA_DrawFrame::SetLanguage ) // menu Postprocess - EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, - WinEDA_GerberFrame::Process_Special_Functions ) - EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, - WinEDA_GerberFrame::Process_Special_Functions ) - EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, - WinEDA_GerberFrame::Process_Special_Functions ) +EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, + WinEDA_GerberFrame::Process_Special_Functions ) +EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, + WinEDA_GerberFrame::Process_Special_Functions ) +EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, + WinEDA_GerberFrame::Process_Special_Functions ) // menu Miscellaneous - EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, - WinEDA_GerberFrame::Process_Special_Functions ) +EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, + WinEDA_GerberFrame::Process_Special_Functions ) // Menu Help - EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp ) - EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout ) +EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp ) +EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout ) - EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( wxID_PRINT, WinEDA_GerberFrame::ToPrinter ) - EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER, - WinEDA_GerberFrame::Process_Special_Functions ) +EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions ) +EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions ) +EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions ) +EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions ) +EVT_TOOL( wxID_PRINT, WinEDA_GerberFrame::ToPrinter ) +EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions ) +EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER, + WinEDA_GerberFrame::Process_Special_Functions ) - EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBER_SELECT_TOOL, - WinEDA_GerberFrame::Process_Special_Functions ) +EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL, + WinEDA_GerberFrame::Process_Special_Functions ) // Vertical toolbar: - EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_TOOL( ID_GERBVIEW_DELETE_ITEM_BUTT, +EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions ) +EVT_TOOL( ID_GERBVIEW_DELETE_ITEM_BUTT, WinEDA_GerberFrame::Process_Special_Functions ) - EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, - WinEDA_GerberFrame::Process_Special_Functions ) +EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, + WinEDA_GerberFrame::Process_Special_Functions ) // Pop up menu - EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, - WinEDA_GerberFrame::Process_Special_Functions ) +EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, + WinEDA_GerberFrame::Process_Special_Functions ) // Option toolbar - EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, - WinEDA_GerberFrame::OnSelectOptionToolbar ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_0, - WinEDA_GerberFrame::OnSelectDisplayMode ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_1, - WinEDA_GerberFrame::OnSelectDisplayMode ) - EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_2, - WinEDA_GerberFrame::OnSelectDisplayMode ) - -END_EVENT_TABLE() - -WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style ) : +EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END, + WinEDA_GerberFrame::OnSelectOptionToolbar ) +EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, + WinEDA_GerberFrame::OnSelectOptionToolbar ) +EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, + WinEDA_GerberFrame::OnSelectOptionToolbar ) +EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, + WinEDA_GerberFrame::OnSelectOptionToolbar ) +EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, + WinEDA_GerberFrame::OnSelectOptionToolbar ) +EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_0, + WinEDA_GerberFrame::OnSelectDisplayMode ) +EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_1, + WinEDA_GerberFrame::OnSelectDisplayMode ) +EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_2, + WinEDA_GerberFrame::OnSelectDisplayMode ) + +END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style ) : WinEDA_BasePcbFrame( father, GERBER_FRAME, title, pos, size, style ) { m_FrameName = wxT( "GerberFrame" ); @@ -141,9 +137,9 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, m_Draw_Axis = true; // true to show X and Y axis on screen m_Draw_Sheet_Ref = false; // true for reference drawings. m_HotkeysZoomAndGridList = s_Gerbview_Hokeys_Descr; - m_SelLayerBox = NULL; - m_SelLayerTool = NULL; - m_displayMode = 0; + m_SelLayerBox = NULL; + m_DCodeSelector = NULL; + m_displayMode = 0; if( DrawPanel ) DrawPanel->m_Block_Enable = true; @@ -163,8 +159,8 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, // Create the PCB_LAYER_WIDGET *after* SetBoard(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - int pointSize = font.GetPointSize(); - int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); + int pointSize = font.GetPointSize(); + int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); if( screenHeight <= 900 ) pointSize = (pointSize * 8) / 10; @@ -176,9 +172,12 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); + if( GetDisplayMode() == 1 || GetDisplayMode() == 2 ) + DrawPanel->m_DisableEraseBG = true; ReCreateMenuBar(); ReCreateHToolbar(); + // ReCreateVToolbar(); // Currently: no right vertical toolbar ReCreateOptToolbar(); @@ -198,39 +197,38 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, horiz.LeftDockable( false ).RightDockable( false ); // LAYER_WIDGET is floatable, but initially docked at far right - wxAuiPaneInfo lyrs; + wxAuiPaneInfo lyrs; lyrs.CloseButton( false ); lyrs.Caption( _( "Visibles" ) ); lyrs.IsFloatable(); if( m_HToolBar ) m_auimgr.AddPane( m_HToolBar, - wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) ); + wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) ); if( m_VToolBar ) m_auimgr.AddPane( m_VToolBar, - wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) ); + wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) ); m_auimgr.AddPane( m_LayersManager, - lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Row( 0 ) ); + lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Row( 0 ) ); if( m_OptionsToolBar ) m_auimgr.AddPane( m_OptionsToolBar, - wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() ); + wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() ); if( DrawPanel ) m_auimgr.AddPane( DrawPanel, - wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); + wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); if( MsgPanel ) m_auimgr.AddPane( MsgPanel, - wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); + wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); ReFillLayerWidget(); // this is near end because contents establish size SetToolbars(); m_auimgr.Update(); - } @@ -253,10 +251,10 @@ int WinEDA_GerberFrame::BestZoom() { // gives a minimal value to zoom, if no item in list if( GetBoard()->m_Drawings == NULL ) - return(16 * GetScreen()->m_ZoomScalar) ; + return 16 * GetScreen()->m_ZoomScalar; - double x, y; - EDA_Rect bbox; + double x, y; + EDA_Rect bbox; BOARD_ITEM* item = GetBoard()->m_Drawings; @@ -267,14 +265,14 @@ int WinEDA_GerberFrame::BestZoom() } bbox.Inflate( wxRound( GetScreen()->GetGridSize().x * 2 ), - wxRound( GetScreen()->GetGridSize().y * 2 ) ); + wxRound( GetScreen()->GetGridSize().y * 2 ) ); wxSize size = DrawPanel->GetClientSize(); x = bbox.GetWidth() / (double) size.x; y = bbox.GetHeight() / (double) size.y; GetScreen()->m_Curseur = bbox.Centre(); - int best_zoom = wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ) ; - return best_zoom; + int best_zoom = wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ); + return best_zoom; } @@ -289,16 +287,17 @@ void WinEDA_GerberFrame::LoadSettings() config->Read( GerbviewDrawModeOption, &m_displayMode, 0l ); long pageSize_opt; config->Read( GerbviewShowPageSizeOption, &pageSize_opt, 0l ); - int imax = 0; + int imax = 0; - for( ; g_GerberPageSizeList[imax] != NULL; imax++ ); + for( ; g_GerberPageSizeList[imax] != NULL; imax++ ) + ; if( pageSize_opt < 0 || pageSize_opt >= imax ) pageSize_opt = 0; GetScreen()->m_CurrentSheetDesc = g_GerberPageSizeList[pageSize_opt]; - if ( pageSize_opt > 0 ) + if( pageSize_opt > 0 ) { m_Draw_Sheet_Ref = true; } @@ -320,7 +319,7 @@ void WinEDA_GerberFrame::SaveSettings() wxRealPoint GridSize = GetScreen()->GetGridSize(); - long pageSize_opt = 0; + long pageSize_opt = 0; if( m_Draw_Sheet_Ref ) { @@ -346,7 +345,7 @@ void WinEDA_GerberFrame::ReFillLayerWidget() wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager ); - wxSize bestz = m_LayersManager->GetBestSize(); + wxSize bestz = m_LayersManager->GetBestSize(); lyrs.MinSize( bestz ); lyrs.BestSize( bestz ); @@ -397,7 +396,7 @@ int WinEDA_GerberFrame::GetGridColor() * Function SetGridColor() , virtual * @param aColor = the new color of the grid */ -void WinEDA_GerberFrame::SetGridColor(int aColor) +void WinEDA_GerberFrame::SetGridColor( int aColor ) { GetBoard()->SetVisibleElementColor( GERBER_GRID_VISIBLE, aColor ); } @@ -417,12 +416,13 @@ void WinEDA_GerberFrame::SetElementVisibility( int aGERBER_VISIBLE, bool aNewSta } -void WinEDA_GerberFrame::syncLayerWidget( ) +void WinEDA_GerberFrame::syncLayerWidget() { m_LayersManager->SelectLayer( getActiveLayer() ); UpdateTitleAndInfo(); } + /** * Function syncLayerBox * updates the currently "selected" layer within m_SelLayerBox @@ -432,6 +432,15 @@ void WinEDA_GerberFrame::syncLayerWidget( ) void WinEDA_GerberFrame::syncLayerBox() { m_SelLayerBox->SetSelection( getActiveLayer() ); + int dcodeSelected = -1; + GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer()]; + if( gerber ) + dcodeSelected = gerber->m_Selected_Tool; + if( m_DCodeSelector ) + { + m_DCodeSelector->SetDCodeSelection( dcodeSelected ); + m_DCodeSelector->Enable( gerber != NULL ); + } UpdateTitleAndInfo(); } @@ -453,9 +462,9 @@ void WinEDA_GerberFrame::SetLanguage( wxCommandEvent& event ) } -void WinEDA_GerberFrame::Liste_D_Codes( ) +void WinEDA_GerberFrame::Liste_D_Codes() { - int ii, jj; + int ii, jj; D_CODE* pt_D_code; wxString Line; WinEDA_TextFrame* List; @@ -530,7 +539,7 @@ void WinEDA_GerberFrame::Liste_D_Codes( ) void WinEDA_GerberFrame::UpdateTitleAndInfo() { GERBER_IMAGE* gerber = g_GERBER_List[ GetScreen()->m_Active_Layer ]; - wxString text; + wxString text; // Display the gerber filename if( gerber == NULL ) @@ -538,7 +547,7 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo() text = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); SetTitle( text ); SetStatusText( wxEmptyString, 0 ); - text.Printf( _("Layer %d not used"), GetScreen()->m_Active_Layer+1 ); + text.Printf( _( "Layer %d not in use" ), GetScreen()->m_Active_Layer + 1 ); m_TextInfo->SetValue( text ); ClearMsgPanel(); return; @@ -552,12 +561,12 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo() // Display Image Name and Layer Name (from the current gerber data): text.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ), - GetChars( gerber->m_ImageName ), - GetChars( gerber->GetLayerParams().m_LayerName ) ); + GetChars( gerber->m_ImageName ), + GetChars( gerber->GetLayerParams().m_LayerName ) ); SetStatusText( text, 0 ); // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar - text.Printf( wxT("fmt: %s X%d.%d Y%d.%d no %cZ"), + text.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ), gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ), gerber->m_FmtLen.x - gerber->m_FmtScale.x, gerber->m_FmtScale.x, gerber->m_FmtLen.y - gerber->m_FmtScale.y, gerber->m_FmtScale.y, @@ -573,24 +582,26 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo() void WinEDA_GerberFrame::OnSelectDisplayMode( wxCommandEvent& event ) { int oldMode = GetDisplayMode(); + switch( event.GetId() ) { - case ID_TB_OPTIONS_SHOW_GBR_MODE_0: - SetDisplayMode( 0 ); - break; - - case ID_TB_OPTIONS_SHOW_GBR_MODE_1: - SetDisplayMode( 1 ); - break; - - case ID_TB_OPTIONS_SHOW_GBR_MODE_2: - SetDisplayMode( 2 ); - break; + case ID_TB_OPTIONS_SHOW_GBR_MODE_0: + SetDisplayMode( 0 ); + DrawPanel->m_DisableEraseBG = false; + break; + + case ID_TB_OPTIONS_SHOW_GBR_MODE_1: + SetDisplayMode( 1 ); + DrawPanel->m_DisableEraseBG = true; + break; + + case ID_TB_OPTIONS_SHOW_GBR_MODE_2: + SetDisplayMode( 2 ); + DrawPanel->m_DisableEraseBG = true; + break; } SetToolbars(); if( GetDisplayMode() != oldMode ) - DrawPanel->Refresh(); + DrawPanel->Refresh(); } - - diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index 5abc26d00c..1837b4e823 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -87,7 +87,6 @@ bool WinEDA_App::OnInit() } ScreenPcb = new PCB_SCREEN(); ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER; - ActiveScreen = ScreenPcb; // read current setup and reopen last directory if no filename to open in diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 4c465bbdd6..14230c74b8 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -3,7 +3,6 @@ /*************************************/ #include "fctsys.h" -#include "wx/wupdlock.h" #include "appl_wxstruct.h" #include "common.h" @@ -16,17 +15,18 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) { - wxWindowUpdateLocker dummy(this); - wxMenuBar *menuBar = GetMenuBar(); - /* Destroy the existing menu bar so it can be rebuilt. This allows - * language changes of the menu text on the fly. */ - if( menuBar ) - SetMenuBar( NULL ); + if( ! menuBar ) + menuBar = new wxMenuBar(); - 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: wxMenu* filesMenu = new wxMenu; filesMenu->Append( wxID_FILE, _( "Load Gerber File" ), _( "Load a new Gerber file on the current layer. Previous data will be deleted" ), @@ -111,9 +111,13 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) menuBar->Append( configmenu, _( "&Preferences" ) ); menuBar->Append( miscellaneous_menu, _( "&Miscellaneous" ) ); -//TODO: one day... menuBar->Append(drill_menu, _("&Drill")); menuBar->Append( helpMenu, _( "&Help" ) ); - // Associate the menu bar with the frame - SetMenuBar( menuBar ); + menuBar->Thaw(); + + // Associate the menu bar with the frame, if no previous menubar + if( GetMenuBar() == NULL ) + SetMenuBar( menuBar ); + else + menuBar->Refresh(); } diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 102ad6cbad..51b1a49437 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -3,7 +3,6 @@ /*************************************/ #include "fctsys.h" -#include "wx/wupdlock.h" //#include "appl_wxstruct.h" #include "common.h" @@ -14,6 +13,7 @@ #include "hotkeys.h" #include "class_GERBER.h" #include "class_layerchoicebox.h" +#include "class_DCodeSelectionbox.h" #include "dialog_helpers.h" void WinEDA_GerberFrame::ReCreateHToolbar( void ) @@ -27,10 +27,6 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) if( m_HToolBar != NULL ) return; - // we create m_SelLayerTool that have a lot of items, - // so create a wxWindowUpdateLocker is a good idea - wxWindowUpdateLocker dummy(this); - if( GetScreen() ) { layer = GetScreen()->m_Active_Layer; @@ -89,7 +85,6 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) msg = _( "Layer " ); msg << ii + 1; choices.Add( msg ); } - m_SelLayerBox = new WinEDALayerChoiceBox( m_HToolBar, ID_TOOLBARH_GERBVIEW_SELECT_LAYER, wxDefaultPosition, wxSize( 150, -1 ), @@ -97,22 +92,23 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) m_HToolBar->AddControl( m_SelLayerBox ); m_HToolBar->AddSeparator(); - choices.Clear(); - choices.Alloc(TOOLS_MAX_COUNT+1); - choices.Add( _( "No tool" ) ); + m_DCodesList.Alloc(TOOLS_MAX_COUNT+1); + m_DCodesList.Add( _( "No tool" ) ); - for( ii = 0; ii < TOOLS_MAX_COUNT; ii++ ) + msg = _( "Tool " ); + wxString text; + for( ii = FIRST_DCODE; ii < TOOLS_MAX_COUNT; ii++ ) { - wxString msg; - msg = _( "Tool " ); msg << ii + FIRST_DCODE; - choices.Add( msg ); + text = msg; + text << ii; + m_DCodesList.Add( text ); } - m_SelLayerTool = new WinEDAChoiceBox( m_HToolBar, + m_DCodeSelector = new DCODE_SELECTION_BOX( m_HToolBar, ID_TOOLBARH_GERBER_SELECT_TOOL, wxDefaultPosition, wxSize( 150, -1 ), - choices ); - m_HToolBar->AddControl( m_SelLayerTool ); + m_DCodesList ); + m_HToolBar->AddControl( m_DCodeSelector ); m_TextInfo = new wxTextCtrl(m_HToolBar, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150,-1), @@ -133,8 +129,6 @@ void WinEDA_GerberFrame::ReCreateVToolbar( void ) if( m_VToolBar ) return; - wxWindowUpdateLocker dummy(this); - m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE ); // Set up toolbar @@ -157,8 +151,6 @@ void WinEDA_GerberFrame::ReCreateOptToolbar( void ) if( m_OptionsToolBar ) return; - wxWindowUpdateLocker dummy(this); - // creation of tool bar options m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE ); @@ -249,26 +241,21 @@ void WinEDA_GerberFrame::SetToolbars() m_SelLayerBox->SetSelection( screen->m_Active_Layer ); } - if( m_SelLayerTool ) + if( m_DCodeSelector ) { if( gerber ) { - int sel_index; - m_SelLayerTool->Enable( true ); - if( gerber->m_Selected_Tool < FIRST_DCODE ) // No tool selected - sel_index = 0; - else - sel_index = gerber->m_Selected_Tool - FIRST_DCODE + 1; - - if( sel_index != m_SelLayerTool->GetSelection() ) - { - m_SelLayerTool->SetSelection( sel_index ); - } + int dcodeSelected; + m_DCodeSelector->Enable( true ); + dcodeSelected = gerber->m_Selected_Tool; + + if( dcodeSelected != m_DCodeSelector->GetSelectedDCodeId() ) + m_DCodeSelector->SetDCodeSelection( dcodeSelected ); } else { - m_SelLayerTool->SetSelection( 0 ); - m_SelLayerTool->Enable( false ); + m_DCodeSelector->SetDCodeSelection( 0 ); + m_DCodeSelector->Enable( false ); } } diff --git a/gerbview/wxGerberFrame.h b/gerbview/wxGerberFrame.h index d3f82f41e9..23d7320bff 100644 --- a/gerbview/wxGerberFrame.h +++ b/gerbview/wxGerberFrame.h @@ -17,8 +17,7 @@ * global id.h file. This will prevent the entire project from being rebuilt * when adding new command to the gerber file viewer. */ -enum id_gerbview_frm -{ +enum id_gerbview_frm { // A MenuItem ID of Zero does not work under Mac,first id = 1 ID_GERBVIEW_SHOW_LIST_DCODES = 1, ID_GERBVIEW_LOAD_DRILL_FILE, @@ -32,8 +31,10 @@ enum id_gerbview_frm }; +class DCODE_SELECTION_BOX; + /****************************************************************** -class WinEDA_GerberFrame: this is the main window used in gerbview +* class WinEDA_GerberFrame: this is the main window used in gerbview ******************************************************************/ class WinEDA_GerberFrame : public WinEDA_BasePcbFrame @@ -41,36 +42,36 @@ class WinEDA_GerberFrame : public WinEDA_BasePcbFrame friend class PCB_LAYER_WIDGET; protected: - GERBER_LAYER_WIDGET* m_LayersManager; + GERBER_LAYER_WIDGET* m_LayersManager; public: WinEDALayerChoiceBox* m_SelLayerBox; - WinEDAChoiceBox* m_SelLayerTool; - wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about - // gerber data (format..) + DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to hightlight. + wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about + // gerber data (format..) + wxArrayString m_DCodesList; // an array string containint all decodes Id (10 to 999) private: - int m_displayMode; // Gerber images ("layers" in Gerbview) can be drawn: - // - in fast mode (write mode) but if there are negative items - // only the last image is correctly drawn - // (no problem to see only one image or when no negative items) - // - in "exact" mode (but slower) in write mode: - // last image covers previous images - // - in "exact" mode (also slower) in OR mode - // (transparency mode) - // m_displayMode = 0, 1 or 2 - bool m_show_layer_manager_tools; + int m_displayMode; // Gerber images ("layers" in Gerbview) can be drawn: + // - in fast mode (write mode) but if there are negative items + // only the last image is correctly drawn + // (no problem to see only one image or when no negative items) + // - in "exact" mode (but slower) in write mode: + // last image covers previous images + // - in "exact" mode (also slower) in OR mode + // (transparency mode) + // m_displayMode = 0, 1 or 2 + bool m_show_layer_manager_tools; wxArrayString m_Messages; // An array sting to store warning messages when reaging a gerber file -public: - WinEDA_GerberFrame( wxWindow* father, const wxString& title, - const wxPoint& pos, const wxSize& size, - long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); +public: WinEDA_GerberFrame( wxWindow* father, const wxString& title, + const wxPoint& pos, const wxSize& size, + long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); ~WinEDA_GerberFrame(); - void Update_config(); - void OnCloseWindow( wxCloseEvent& Event ); + void Update_config(); + void OnCloseWindow( wxCloseEvent& Event ); /** * Function ReportMessage @@ -78,27 +79,30 @@ public: * for instance when reading a Gerber file * @param aMessage = the straing to add in list */ - void ReportMessage(const wxString aMessage ) + void ReportMessage( const wxString aMessage ) { m_Messages.Add( aMessage ); } + + /** * Function ClearMessageList * Clear the message list * Call it before reading a Gerber file */ - void ClearMessageList( ) + void ClearMessageList() { - m_Messages.Clear( ); + m_Messages.Clear(); } + /** * Function GetDisplayMode * @return 0 for fast mode (not fully compatible with negative objects) * 1 for exact mode, write mode * 2 for exact mode, OR mode (transparency mode) */ - int GetDisplayMode() { return m_displayMode;} + int GetDisplayMode() { return m_displayMode; } /** * Function SetDisplayMode @@ -106,13 +110,13 @@ public: * 1 for exact mode, write mode * 2 for exact mode, OR mode (transparency mode) */ - void SetDisplayMode( int aMode ) { m_displayMode = aMode;} + void SetDisplayMode( int aMode ) { m_displayMode = aMode; } /** * Function IsGridVisible() , virtual * @return true if the grid must be shown */ - virtual bool IsGridVisible(); + virtual bool IsGridVisible(); /** * Function SetGridVisibility() , virtual @@ -120,19 +124,19 @@ public: * if you want to store/retrieve the grid visiblity in configuration. * @param aVisible = true if the grid must be shown */ - virtual void SetGridVisibility(bool aVisible); + virtual void SetGridVisibility( bool aVisible ); /** * Function GetGridColor() , virtual * @return the color of the grid */ - virtual int GetGridColor(); + virtual int GetGridColor(); /** * Function SetGridColor() , virtual * @param aColor = the new color of the grid */ - virtual void SetGridColor(int aColor); + virtual void SetGridColor( int aColor ); /** * Function IsElementVisible @@ -147,6 +151,7 @@ public: return GetBoard()->IsElementVisible( aGERBER_VISIBLE ); } + /** * Function SetElementVisibility * changes the visibility of an element category @@ -160,14 +165,14 @@ public: * Function SetVisibleAlls * Set the status of all visible element categories and layers to VISIBLE */ - void SetVisibleAlls( ); + void SetVisibleAlls(); /** * Function ReFillLayerWidget * changes out all the layers in m_Layers and may be called upon * loading a new BOARD. */ - void ReFillLayerWidget(); + void ReFillLayerWidget(); /** * Function setActiveLayer @@ -182,6 +187,7 @@ public: syncLayerWidget(); } + /** * Function getActiveLayer * returns the active layer @@ -191,6 +197,7 @@ public: return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer; } + /** * Function syncLayerWidget * updates the currently "selected" layer within the PCB_LAYER_WIDGET. @@ -199,7 +206,7 @@ public: * This function cannot be inline without including layer_widget.h in * here and we do not want to do that. */ - void syncLayerWidget( ); + void syncLayerWidget(); /** * Function syncLayerBox @@ -207,7 +214,7 @@ public: * The currently active layer, as defined by the return value of * getActiveLayer(). And updates the colored icon in the toolbar. */ - void syncLayerBox(); + void syncLayerBox(); /** * Function UpdateTitleAndInfo @@ -218,7 +225,7 @@ public: * Name of the Image (found in the gerber file: IN <name> command) in the status bar * and other data in toolbar */ - void UpdateTitleAndInfo(); + void UpdateTitleAndInfo(); /** * Load applications settings specific to the PCBNew. @@ -229,7 +236,7 @@ public: * drawing frames. Please put your application settings for PCBNew here * to avoid having application settings loaded all over the place. */ - virtual void LoadSettings(); + virtual void LoadSettings(); /** * Save applications settings common to PCB draw frame objects. @@ -240,51 +247,53 @@ public: * drawing frames. Please put your application settings for PCBNew here * to avoid having application settings saved all over the place. */ - virtual void SaveSettings(); + virtual void SaveSettings(); /** * Function SetLanguage * called on a language menu selection */ - virtual void SetLanguage( wxCommandEvent& event ); - - void Process_Special_Functions( wxCommandEvent& event ); - void RedrawActiveWindow( wxDC* DC, bool EraseBg ); - void ReCreateHToolbar(); - void ReCreateVToolbar(); - void ReCreateOptToolbar(); - void ReCreateMenuBar(); - void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); - void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); - bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); - int BestZoom(); - void OnSelectOptionToolbar( wxCommandEvent& event ); + virtual void SetLanguage( wxCommandEvent& event ); + + void Process_Special_Functions( wxCommandEvent& event ); + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); + void ReCreateHToolbar(); + void ReCreateVToolbar(); + void ReCreateOptToolbar(); + void ReCreateMenuBar(); + void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); + void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); + bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); + int BestZoom(); + void OnSelectOptionToolbar( wxCommandEvent& event ); + /** * Function OnSelectDisplayMode * called on a display mode selection * Mode selection can be fast display, * or exact mode with stacked images or with transparency */ - void OnSelectDisplayMode( wxCommandEvent& event ); - void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ); + void OnSelectDisplayMode( wxCommandEvent& event ); + void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ); - GERBER_DRAW_ITEM* GerberGeneralLocateAndDisplay(); - GERBER_DRAW_ITEM* Locate( int typeloc ); + GERBER_DRAW_ITEM* GerberGeneralLocateAndDisplay(); + GERBER_DRAW_ITEM* Locate( int typeloc ); - void SetToolbars(); - void Process_Settings( wxCommandEvent& event ); - void Process_Config( wxCommandEvent& event ); - void InstallConfigFrame( const wxPoint& pos ); - void InstallGerberOptionsDialog( wxCommandEvent& event ); - void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); + void SetToolbars(); + void Process_Settings( wxCommandEvent& event ); + void Process_Config( wxCommandEvent& event ); + void InstallConfigFrame( const wxPoint& pos ); + void InstallGerberOptionsDialog( wxCommandEvent& event ); + void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); /* handlers for block commands */ - virtual int ReturnBlockCommand( int key ); - virtual void HandleBlockPlace( wxDC* DC ); - virtual bool HandleBlockEnd( wxDC* DC ); + virtual int ReturnBlockCommand( int key ); + virtual void HandleBlockPlace( wxDC* DC ); + virtual bool HandleBlockEnd( wxDC* DC ); /* Block operations: */ + /** * Function Block_Delete * deletes all tracks and segments within the selected block. @@ -292,7 +301,7 @@ public: * * @param DC A device context to draw on. */ - void Block_Delete( wxDC* DC ); + void Block_Delete( wxDC* DC ); /** * Function Block_Move @@ -303,7 +312,7 @@ public: * * @param DC A device context to draw on. */ - void Block_Move( wxDC* DC ); + void Block_Move( wxDC* DC ); /** * Function Block_Duplicate @@ -314,39 +323,39 @@ public: * * @param DC A device context to draw on. */ - void Block_Duplicate( wxDC* DC ); + void Block_Duplicate( wxDC* DC ); - void ToPostProcess( wxCommandEvent& event ); + void ToPostProcess( wxCommandEvent& event ); /** * Function ToPlotter * Open a dialog frame to create plot and drill files * relative to the current board */ - void ToPlotter( wxCommandEvent& event ); + void ToPlotter( wxCommandEvent& event ); /** * Function ToPrinter * Open a dialog frame to print layers */ - void ToPrinter( wxCommandEvent& event ); - - void Genere_HPGL( const wxString& FullFileName, int Layers ); - void Genere_GERBER( const wxString& FullFileName, int Layers ); - void Genere_PS( const wxString& FullFileName, int Layers ); - void Plot_Layer_HPGL( FILE* File, int masque_layer, - int garde, bool trace_via, - GRTraceMode trace_mode ); - void Plot_Layer_GERBER( FILE* File, int masque_layer, - int garde, bool trace_via, - GRTraceMode trace_mode ); - int Gen_D_CODE_File( const wxString& Name_File ); - void Plot_Layer_PS( FILE* File, int masque_layer, - int garde, bool trace_via, - GRTraceMode trace_mode ); - - void Files_io( wxCommandEvent& event ); - void OnFileHistory( wxCommandEvent& event ); + void ToPrinter( wxCommandEvent& event ); + + void Genere_HPGL( const wxString& FullFileName, int Layers ); + void Genere_GERBER( const wxString& FullFileName, int Layers ); + void Genere_PS( const wxString& FullFileName, int Layers ); + void Plot_Layer_HPGL( FILE* File, int masque_layer, + int garde, bool trace_via, + GRTraceMode trace_mode ); + void Plot_Layer_GERBER( FILE* File, int masque_layer, + int garde, bool trace_via, + GRTraceMode trace_mode ); + int Gen_D_CODE_File( const wxString& Name_File ); + void Plot_Layer_PS( FILE* File, int masque_layer, + int garde, bool trace_via, + GRTraceMode trace_mode ); + + void Files_io( wxCommandEvent& event ); + void OnFileHistory( wxCommandEvent& event ); /** * function LoadGerberFiles @@ -356,12 +365,12 @@ public: * if void string: user will be prompted for filename(s) * @return true if file was opened successfully. */ - bool LoadGerberFiles( const wxString& aFileName ); - int ReadGerberFile( FILE* File, bool Append ); - bool Read_GERBER_File( const wxString& GERBER_FullFileName, - const wxString& D_Code_FullFileName ); + bool LoadGerberFiles( const wxString& aFileName ); + int ReadGerberFile( FILE* File, bool Append ); + bool Read_GERBER_File( const wxString& GERBER_FullFileName, + const wxString& D_Code_FullFileName ); - void GeneralControle( wxDC* DC, wxPoint Mouse ); + void GeneralControle( wxDC* DC, wxPoint Mouse ); /** @@ -387,17 +396,17 @@ public: * g_GERBER_List[]
* 1 = read OK
*/ - int Read_D_Code_File( const wxString& D_Code_FullFileName ); - void CopyDCodesSizeToItems(); - void Liste_D_Codes( ); + int Read_D_Code_File( const wxString& D_Code_FullFileName ); + void CopyDCodesSizeToItems(); + void Liste_D_Codes(); // PCB handling - bool Clear_Pcb( bool query ); - void Erase_Current_Layer( bool query ); - void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number ); + bool Clear_Pcb( bool query ); + void Erase_Current_Layer( bool query ); + void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number ); // Conversion function - void ExportDataInPcbnewFormat( wxCommandEvent& event ); + void ExportDataInPcbnewFormat( wxCommandEvent& event ); /* SaveCopyInUndoList() virtual * currently: do nothing in gerbview. @@ -406,7 +415,7 @@ public: virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, UndoRedoOpType aTypeCommand = UR_UNSPECIFIED, - const wxPoint& aTransformPoint = wxPoint(0,0) ) { } + const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) { } /** * Function SaveCopyInUndoList (overloaded). @@ -420,11 +429,12 @@ public: virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, UndoRedoOpType aTypeCommand, - const wxPoint& aTransformPoint = wxPoint(0,0) ) + const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) { // currently: do nothing in gerbview. } + /** Virtual function PrintPage * used to print a page * @param aDC = wxDC given by the calling print function @@ -434,8 +444,8 @@ public: * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, - int aPrintMasklayer, bool aPrintMirrorMode, - void * aData = NULL); + int aPrintMasklayer, bool aPrintMirrorMode, + void* aData = NULL ); /** * Function InstallDialogLayerPairChoice @@ -443,7 +453,7 @@ public: * between gerber layers and pcbnew layers * @return the "lookup table" if ok, or NULL */ - int* InstallDialogLayerPairChoice( ); + int* InstallDialogLayerPairChoice(); /** * Function DrawItemsDCodeID @@ -452,7 +462,7 @@ public: * @param aDC = the current device contect * @param aDrawMode = GR_COPY, GR_OR ... */ - void DrawItemsDCodeID( wxDC* aDC, int aDrawMode ); + void DrawItemsDCodeID( wxDC* aDC, int aDrawMode ); DECLARE_EVENT_TABLE() }; diff --git a/include/boost/config/platform/vms.hpp b/include/boost/config/platform/vms.hpp new file mode 100644 index 0000000000..3d510296f7 --- /dev/null +++ b/include/boost/config/platform/vms.hpp @@ -0,0 +1,25 @@ +// (C) Copyright Artyom Beilis 2010. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_CONFIG_PLATFORM_VMS_HPP +#define BOOST_CONFIG_PLATFORM_VMS_HPP + +#define BOOST_PLATFORM "OpenVMS" + +#undef BOOST_HAS_STDINT_H +#define BOOST_HAS_UNISTD_H +#define BOOST_HAS_NL_TYPES_H +#define BOOST_HAS_GETTIMEOFDAY +#define BOOST_HAS_DIRENT_H +#define BOOST_HAS_PTHREADS +#define BOOST_HAS_NANOSLEEP +#define BOOST_HAS_CLOCK_GETTIME +#define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +#define BOOST_HAS_LOG1P +#define BOOST_HAS_EXPM1 +#define BOOST_HAS_THREADS +#undef BOOST_HAS_SCHED_YIELD + +#endif diff --git a/include/boost/type_traits/add_lvalue_reference.hpp b/include/boost/type_traits/add_lvalue_reference.hpp new file mode 100644 index 0000000000..47cecb7a5c --- /dev/null +++ b/include/boost/type_traits/add_lvalue_reference.hpp @@ -0,0 +1,26 @@ +// Copyright 2010 John Maddock + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP +#define BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP + +#include + +// should be the last #include +#include + +namespace boost{ + +BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_lvalue_reference,T,typename boost::add_reference::type) + +#ifndef BOOST_NO_RVALUE_REFERENCES +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,add_lvalue_reference,T&&,T&) +#endif + +} + +#include + +#endif // BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP diff --git a/include/boost/type_traits/add_rvalue_reference.hpp b/include/boost/type_traits/add_rvalue_reference.hpp new file mode 100644 index 0000000000..9c16fe35b6 --- /dev/null +++ b/include/boost/type_traits/add_rvalue_reference.hpp @@ -0,0 +1,67 @@ +// add_rvalue_reference.hpp ---------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP +#define BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP + +#include + +//----------------------------------------------------------------------------// + +#include +#include + +// should be the last #include +#include + +//----------------------------------------------------------------------------// +// // +// C++03 implementation of // +// 20.7.6.2 Reference modifications [meta.trans.ref] // +// Written by Vicente J. Botet Escriba // +// // +// If T names an object or function type then the member typedef type +// shall name T&&; otherwise, type shall name T. [ Note: This rule reflects +// the semantics of reference collapsing. For example, when a type T names +// a type T1&, the type add_rvalue_reference::type is not an rvalue +// reference. —end note ] +//----------------------------------------------------------------------------// + +namespace boost { + +namespace type_traits_detail { + + template + struct add_rvalue_reference_helper + { typedef T type; }; + + template + struct add_rvalue_reference_helper + { +#if !defined(BOOST_NO_RVALUE_REFERENCES) + typedef T&& type; +#else + typedef T type; +#endif + }; + + template + struct add_rvalue_reference_imp + { + typedef typename boost::type_traits_detail::add_rvalue_reference_helper + ::value && !is_reference::value) >::type type; + }; + +} + +BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_rvalue_reference,T,typename boost::type_traits_detail::add_rvalue_reference_imp::type) + +} // namespace boost + +#include + +#endif // BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP diff --git a/include/boost/type_traits/common_type.hpp b/include/boost/type_traits/common_type.hpp new file mode 100644 index 0000000000..d6e84573de --- /dev/null +++ b/include/boost/type_traits/common_type.hpp @@ -0,0 +1,153 @@ +// common_type.hpp ---------------------------------------------------------// + +// Copyright 2008 Howard Hinnant +// Copyright 2008 Beman Dawes + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_TYPE_TRAITS_COMMON_TYPE_HPP +#define BOOST_TYPE_TRAITS_COMMON_TYPE_HPP + +#include + +#ifdef __SUNPRO_CC +# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF +#endif +#ifdef __IBMCPP__ +# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF +#endif + +//----------------------------------------------------------------------------// +#if defined(BOOST_NO_VARIADIC_TEMPLATES) +#define BOOST_COMMON_TYPE_ARITY 3 +#endif + +//----------------------------------------------------------------------------// +#if defined(BOOST_NO_DECLTYPE) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF) +#define BOOST_TYPEOF_SILENT +#include // boost wonders never cease! +#endif + +//----------------------------------------------------------------------------// +#ifndef BOOST_NO_STATIC_ASSERT +#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG) +#elif defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT) +#include +#include +#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) \ + BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES) +#else +#include +#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND) +#endif + +#if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT) +#define BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE "must be complete type" +#endif + +#if defined(BOOST_NO_DECLTYPE) && defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF) +#include +#include +#endif +#include +#include +#include + +//----------------------------------------------------------------------------// +// // +// C++03 implementation of // +// 20.6.7 Other transformations [meta.trans.other] // +// Written by Howard Hinnant // +// Adapted for Boost by Beman Dawes, Vicente Botet and Jeffrey Hellrung // +// // +//----------------------------------------------------------------------------// + +namespace boost { + +// prototype +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + template + struct common_type; +#else // or no specialization + template + struct common_type + { + public: + typedef typename common_type::type, V>::type type; + }; +#endif + + +// 1 arg + template +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + struct common_type +#else + struct common_type + +#endif + { + BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T)); + public: + typedef T type; + }; + +// 2 args +namespace type_traits_detail { + + template + struct common_type_2 + { + private: + BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T)); + BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(U) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (U)); + static bool declval_bool(); // workaround gcc bug; not required by std + static typename add_rvalue_reference::type declval_T(); // workaround gcc bug; not required by std + static typename add_rvalue_reference::type declval_U(); // workaround gcc bug; not required by std + static typename add_rvalue_reference::type declval_b(); + +#if !defined(BOOST_NO_DECLTYPE) + public: + typedef decltype(declval() ? declval() : declval()) type; +#elif defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF) + public: + typedef typename detail_type_traits_common_type::common_type_impl< + typename remove_cv::type, + typename remove_cv::type + >::type type; +#else + public: + typedef BOOST_TYPEOF_TPL(declval_b() ? declval_T() : declval_U()) type; +#endif + }; + + template + struct common_type_2 + { + typedef T type; + }; + } + +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + template + struct common_type +#else + template + struct common_type +#endif + : type_traits_detail::common_type_2 + { }; + + +// 3 or more args +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) + template + struct common_type { + public: + typedef typename common_type::type, V...>::type type; + }; +#endif +} // namespace boost + +#endif // BOOST_TYPE_TRAITS_COMMON_TYPE_HPP diff --git a/include/boost/type_traits/conditional.hpp b/include/boost/type_traits/conditional.hpp new file mode 100644 index 0000000000..fa62b1828f --- /dev/null +++ b/include/boost/type_traits/conditional.hpp @@ -0,0 +1,25 @@ + +// (C) Copyright John Maddock 2010. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + + +#ifndef BOOST_TT_CONDITIONAL_HPP_INCLUDED +#define BOOST_TT_CONDITIONAL_HPP_INCLUDED + +#include + +namespace boost { + +template +struct conditional : public mpl::if_c +{ +}; + +} // namespace boost + + +#endif // BOOST_TT_CONDITIONAL_HPP_INCLUDED diff --git a/include/boost/type_traits/detail/common_type_imp.hpp b/include/boost/type_traits/detail/common_type_imp.hpp new file mode 100644 index 0000000000..721c0cd161 --- /dev/null +++ b/include/boost/type_traits/detail/common_type_imp.hpp @@ -0,0 +1,302 @@ +/******************************************************************************* + * boost/type_traits/detail/common_type_imp.hpp + * + * Copyright 2010, Jeffrey Hellrung. + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + * struct boost::common_type + * + * common_type::type is the type of the expression + * b() ? x() : y() + * where b() returns a bool, x() has return type T, and y() has return type U. + * See + * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm#common_type + * + * Note that this evaluates to void if one or both of T and U is void. + ******************************************************************************/ + +#ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP +#define BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + +namespace detail_type_traits_common_type +{ + +/******************************************************************************* + * struct propagate_cv< From, To > + * + * This metafunction propagates cv-qualifiers on type From to type To. + ******************************************************************************/ + +template< class From, class To > +struct propagate_cv +{ typedef To type; }; +template< class From, class To > +struct propagate_cv< const From, To > +{ typedef To const type; }; +template< class From, class To > +struct propagate_cv< volatile From, To > +{ typedef To volatile type; }; +template< class From, class To > +struct propagate_cv< const volatile From, To > +{ typedef To const volatile type; }; + +/******************************************************************************* + * struct is_signable_integral + * + * This metafunction determines if T is an integral type which can be made + * signed or unsigned. + ******************************************************************************/ + +template< class T > +struct is_signable_integral + : mpl::or_< is_integral, is_enum > +{ }; +template<> +struct is_signable_integral< bool > + : false_type +{ }; + +/******************************************************************************* + * struct sizeof_t + * typedef ... yes_type + * typedef ... no_type + * + * These types are integral players in the use of the "sizeof trick", i.e., we + * can distinguish overload selection by inspecting the size of the return type + * of the overload. + ******************************************************************************/ + +template< std::size_t N > struct sizeof_t { char _dummy[N]; }; +typedef sizeof_t<1> yes_type; +typedef sizeof_t<2> no_type; +BOOST_MPL_ASSERT_RELATION( sizeof( yes_type ), ==, 1 ); +BOOST_MPL_ASSERT_RELATION( sizeof( no_type ), ==, 2 ); + +/******************************************************************************* + * rvalue_test(T&) -> no_type + * rvalue_test(...) -> yes_type + * + * These overloads are used to determine the rvalue-ness of an expression. + ******************************************************************************/ + +template< class T > no_type rvalue_test(T&); +yes_type rvalue_test(...); + +/******************************************************************************* + * struct conversion_test_overloads< Sequence > + * + * This struct has multiple overloads of the static member function apply, each + * one taking a single parameter of a type within the Boost.MPL sequence + * Sequence. Each such apply overload has a return type with sizeof equal to + * one plus the index of the parameter type within Sequence. Thus, we can + * deduce the type T of an expression as long as we can generate a finite set of + * candidate types containing T via these apply overloads and the "sizeof + * trick". + ******************************************************************************/ + +template< class First, class Last, std::size_t Index > +struct conversion_test_overloads_iterate + : conversion_test_overloads_iterate< + typename mpl::next< First >::type, Last, Index + 1 + > +{ + using conversion_test_overloads_iterate< + typename mpl::next< First >::type, Last, Index + 1 + >::apply; + static sizeof_t< Index + 1 > + apply(typename mpl::deref< First >::type); +}; + +template< class Last, std::size_t Index > +struct conversion_test_overloads_iterate< Last, Last, Index > +{ static sizeof_t< Index + 1 > apply(...); }; + +template< class Sequence > +struct conversion_test_overloads + : conversion_test_overloads_iterate< + typename mpl::begin< Sequence >::type, + typename mpl::end< Sequence >::type, + 0 + > +{ }; + +/******************************************************************************* + * struct select< Sequence, Index > + * + * select is synonymous with mpl::at_c unless Index equals the size of the + * Boost.MPL Sequence, in which case this evaluates to void. + ******************************************************************************/ + +template< + class Sequence, int Index, + int N = mpl::size< Sequence >::value +> +struct select + : mpl::at_c< Sequence, Index > +{ }; +template< class Sequence, int N > +struct select< Sequence, N, N > +{ typedef void type; }; + +/******************************************************************************* + * class deduce_common_type< T, U, NominalCandidates > + * struct nominal_candidates + * struct common_type_dispatch_on_rvalueness + * struct common_type_impl + * + * These classes and structs implement the logic behind common_type, which goes + * roughly as follows. Let C be the type of the conditional expression + * declval< bool >() ? declval() : declval() + * if C is an rvalue, then: + * let T' and U' be T and U stripped of reference- and cv-qualifiers + * if T' and U' are pointer types, say, T' = V* and U' = W*, then: + * define the set of NominalCandidates to be + * { V*, W*, V'*, W'* } + * where V' is V with whatever cv-qualifiers are on W, and W' is W + * with whatever cv-qualifiers are on V + * else T' and U' are both "signable integral types" (integral and enum + * types excepting bool), then: + * define the set of NominalCandidates to be + * { unsigned(T'), unsigned(U'), signed(T'), signed(U') } + * where unsigned(X) is make_unsigned::type and signed(X) is + * make_signed::type + * else + * define the set of NominalCandidates to be + * { T', U' } + * else + * let V and W be T and U stripped of reference-qualifiers + * define the set of NominalCandidates to be + * { V&, W&, V'&, W'& } + * where V' is V with whatever cv-qualifiers are on W, and W' is W with + * whatever cv-qualifiers are on V + * define the set of Candidates to be equal to the set of NominalCandidates with + * duplicates removed, and use this set of Candidates to determine C using the + * conversion_test_overloads struct + ******************************************************************************/ + +template< class T, class U, class NominalCandidates > +class deduce_common_type +{ + typedef typename mpl::copy< + NominalCandidates, + mpl::inserter< + mpl::vector0<>, + mpl::if_< + mpl::contains< mpl::_1, mpl::_2 >, + mpl::_1, + mpl::push_back< mpl::_1, mpl::_2 > + > + > + >::type candidate_types; + static const int best_candidate_index = + sizeof( conversion_test_overloads< candidate_types >::apply( + declval< bool >() ? declval() : declval() + ) ) - 1; +public: + typedef typename select< candidate_types, best_candidate_index >::type type; +}; + +template< + class T, class U, + class V = typename remove_cv< typename remove_reference::type >::type, + class W = typename remove_cv< typename remove_reference::type >::type, + bool = is_signable_integral::value && is_signable_integral::value +> +struct nominal_candidates; + +template< class T, class U, class V, class W > +struct nominal_candidates< T, U, V, W, false > +{ typedef mpl::vector2 type; }; + +template< class T, class U, class V, class W > +struct nominal_candidates< T, U, V, W, true > +{ + typedef mpl::vector4< + typename make_unsigned::type, + typename make_unsigned::type, + typename make_signed::type, + typename make_signed::type + > type; +}; + +template< class T, class U, class V, class W > +struct nominal_candidates< T, U, V*, W*, false > +{ + typedef mpl::vector4< + V*, W*, + typename propagate_cv::type *, + typename propagate_cv::type * + > type; +}; + +template +struct common_type_dispatch_on_rvalueness + : deduce_common_type< T, U, typename nominal_candidates::type > +{ }; + +template< class T, class U > +struct common_type_dispatch_on_rvalueness< T, U, false > +{ +private: + typedef typename remove_reference::type unrefed_T_type; + typedef typename remove_reference::type unrefed_U_type; +public: + typedef typename deduce_common_type< + T, U, + mpl::vector4< + unrefed_T_type &, + unrefed_U_type &, + typename propagate_cv< unrefed_U_type, unrefed_T_type >::type &, + typename propagate_cv< unrefed_T_type, unrefed_U_type >::type & + > + >::type type; +}; + +template< class T, class U > +struct common_type_impl + : common_type_dispatch_on_rvalueness() ? declval() : declval() ) ) == sizeof( yes_type ) > +{ }; + +template< class T > struct common_type_impl< T, void > { typedef void type; }; +template< class T > struct common_type_impl< void, T > { typedef void type; }; +template<> struct common_type_impl< void, void > { typedef void type; }; + +} // namespace detail_type_traits_common_type + + +} // namespace boost + +#endif // BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_HPP + diff --git a/include/boost/typeof/unsupported.hpp b/include/boost/typeof/unsupported.hpp new file mode 100644 index 0000000000..bccb40840c --- /dev/null +++ b/include/boost/typeof/unsupported.hpp @@ -0,0 +1,29 @@ +// Copyright (C) 2010 Peder Holt +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TYPEOF_UNSUPPORTED_HPP_INCLUDED +#define BOOST_TYPEOF_UNSUPPORTED_HPP_INCLUDED + +namespace boost { namespace type_of { + struct typeof_emulation_is_unsupported_on_this_compiler {}; +}} + +#define BOOST_TYPEOF(expr) boost::type_of::typeof_emulation_is_unsupported_on_this_compiler +#define BOOST_TYPEOF_TPL BOOST_TYPEOF + +#define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ +struct name {\ + typedef BOOST_TYPEOF_TPL(expr) type;\ +}; + +#define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ +struct name {\ + typedef BOOST_TYPEOF(expr) type;\ +}; + + +#define BOOST_TYPEOF_REGISTER_TYPE(x) +#define BOOST_TYPEOF_REGISTER_TEMPLATE(x, params) + +#endif \ No newline at end of file diff --git a/include/boost/utility/declval.hpp b/include/boost/utility/declval.hpp new file mode 100644 index 0000000000..9f4ae10015 --- /dev/null +++ b/include/boost/utility/declval.hpp @@ -0,0 +1,44 @@ +// common_type.hpp ---------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP +#define BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP + +#include + +//----------------------------------------------------------------------------// + +#include + +//----------------------------------------------------------------------------// +// // +// C++03 implementation of // +// Written by Vicente J. Botet Escriba // +//~ 20.3.4 Function template declval [declval] +//~ 1 The library provides the function template declval to simplify the definition of expressions which occur as +//~ unevaluated operands. +//~ 2 Remarks: If this function is used, the program is ill-formed. +//~ 3 Remarks: The template parameter T of declval may be an incomplete type. +//~ [ Example: + +//~ template +//~ decltype(static_cast(declval())) convert(From&&); + +//~ declares a function template convert which only participats in overloading if the type From can be +//~ explicitly converted to type To. For another example see class template common_type (20.7.6.6). —end +//~ example ] +// // +//----------------------------------------------------------------------------// + +namespace boost { + + template + typename add_rvalue_reference::type declval(); //noexcept; // as unevaluated operand + +} // namespace boost + +#endif // BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index 84f7cfeb99..517c72d2c2 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -35,6 +35,9 @@ public: bool m_AbortEnable; // TRUE if abort button or menu to // be displayed + bool m_DisableEraseBG; // if true: do not allow background erasure + // (used to reduce flicker in Gerbview ) + bool m_AutoPAN_Enable; // TRUE to allow auto pan bool m_AutoPAN_Request; // TRUE to request an auto pan diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index e0b68d34b6..e79cea71d7 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -62,8 +62,6 @@ void WinEDA_App::MacOpenFile(const wxString &fileName) { frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() + wxT( " " ) + frame->m_ProjectFileName.GetFullPath() ); - frame->ReCreateMenuBar(); - frame->RecreateBaseHToolbar(); frame->m_LeftWin->ReCreateTreePrj(); diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index 6e83efa599..c925885d0e 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -73,20 +73,21 @@ void WinEDA_MainFrame::ReCreateMenuBar() wxMenuItem *item; wxMenuBar *menuBar = GetMenuBar(); - /** - * Destroy the existing menu bar so it can be rebuilt. This allows - * language changes of the menu text on the fly. - */ - if( menuBar ) - SetMenuBar( NULL ); - menuBar = new wxMenuBar(); - - /** - * Files menu - */ + 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: + + // Files menu wxMenu* filesMenu = new wxMenu; - /* Open */ + // Open item = new wxMenuItem( filesMenu, ID_LOAD_PROJECT, _( "&Open\tCtrl+O" ), _( "Open an existing project" ) ); @@ -96,7 +97,7 @@ void WinEDA_MainFrame::ReCreateMenuBar() filesMenu->Append( item ); - /* Open Recent submenu */ + // Open Recent submenu wxMenu* openRecentMenu = new wxMenu(); wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, @@ -104,7 +105,7 @@ void WinEDA_MainFrame::ReCreateMenuBar() _("Open a recent opened schematic project" ), open_project_xpm ); - /* New */ + // New item = new wxMenuItem( filesMenu, ID_NEW_PROJECT, _( "&New\tCtrl+N" ), _( "Start a new project" ) ); @@ -124,10 +125,8 @@ void WinEDA_MainFrame::ReCreateMenuBar() filesMenu->Append( item ); - /* Separator */ + // Archive filesMenu->AppendSeparator(); - - /* Archive */ item = new wxMenuItem( filesMenu, ID_SAVE_AND_ZIP_FILES, _( "&Archive" ), _( "Archive project files in zip archive" ) ); @@ -137,7 +136,7 @@ void WinEDA_MainFrame::ReCreateMenuBar() filesMenu->Append( item ); - /* Unarchive */ + // Unarchive item = new wxMenuItem( filesMenu, ID_READ_ZIP_ARCHIVE, _( "&Unarchive" ), _( "Unarchive project files from zip file" ) ); @@ -160,12 +159,10 @@ void WinEDA_MainFrame::ReCreateMenuBar() - /** - * Browse menu - */ + // Browse menu wxMenu* browseMenu = new wxMenu(); - /* Text editor */ + // Text editor item = new wxMenuItem( browseMenu, ID_TO_EDITOR, _( "Text E&ditor" ), _( "Open preferred text editor" ) ); #if !defined( __WXMAC__ ) @@ -186,12 +183,10 @@ void WinEDA_MainFrame::ReCreateMenuBar() - /** - * Preferences menu - */ + // Preferences menu wxMenu* PreferencesMenu = new wxMenu; - /* Text editor */ + // Text editor item = new wxMenuItem( PreferencesMenu, ID_SELECT_PREFERED_EDITOR, _( "&Text Editor" ), _( "Select your preferred text editor" ) ); @@ -201,13 +196,10 @@ void WinEDA_MainFrame::ReCreateMenuBar() PreferencesMenu->Append( item ); - /** - * PDF Viewer submenu - * System browser or user defined checkbox - */ + // PDF Viewer submenu:System browser or user defined checkbox wxMenu* SubMenuPdfBrowserChoice = new wxMenu; - /* Default */ + // Default item = new wxMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_DEFAULT_PDF_BROWSER, _( "Default" ), @@ -222,7 +214,7 @@ void WinEDA_MainFrame::ReCreateMenuBar() SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER, wxGetApp().m_PdfBrowserIsDefault ); - /* Favourite */ + // Favourite viewer item = new wxMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_PREFERED_PDF_BROWSER, _( "Favourite" ), @@ -237,7 +229,7 @@ void WinEDA_MainFrame::ReCreateMenuBar() SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER, !wxGetApp().m_PdfBrowserIsDefault ); - /* Append PDF Viewer submenu to preferences */ + // Append PDF Viewer submenu to preferences item = new wxMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_PREFERED_PDF_BROWSER_NAME, _( "PDF Viewer" ), @@ -254,14 +246,11 @@ void WinEDA_MainFrame::ReCreateMenuBar() _( "PDF viewer preferences" ), datasheet_xpm ); + // Add languages list: PreferencesMenu->AppendSeparator(); wxGetApp().AddMenuLanguageList( PreferencesMenu ); - - - /** - * Help menu - */ + // Help menu wxMenu* helpMenu = new wxMenu; AddHelpVersionInfoMenuEntry( helpMenu ); @@ -276,27 +265,26 @@ void WinEDA_MainFrame::ReCreateMenuBar() helpMenu->Append( item ); - /* About on all platforms except WXMAC */ -#if !defined( __WXMAC__ ) - + // About helpMenu->AppendSeparator(); item = new wxMenuItem( helpMenu, ID_KICAD_ABOUT, _( "&About" ), _( "About kicad project manager" ) ); item->SetBitmap( info_xpm ); helpMenu->Append( item ); -#endif /* !defined( __WXMAC__ ) */ - - /** - * Create the menubar and append all submenus - */ + // Create the menubar and append all submenus menuBar->Append( filesMenu, _( "&File" ) ); menuBar->Append( browseMenu, _( "&Browse" ) ); menuBar->Append( PreferencesMenu, _( "&Preferences" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - /* Associate the menu bar with the frame */ - SetMenuBar( menuBar ); + menuBar->Thaw(); + + // Associate the menu bar with the frame, if no previous menubar + if( GetMenuBar() == NULL ) + SetMenuBar( menuBar ); + else + menuBar->Refresh(); } diff --git a/kicad/preferences.cpp b/kicad/preferences.cpp index 43acbdf011..f724657f50 100644 --- a/kicad/preferences.cpp +++ b/kicad/preferences.cpp @@ -98,11 +98,5 @@ void WinEDA_MainFrame::OnSelectPreferredEditor( wxCommandEvent& event ) void WinEDA_MainFrame::SetLanguage( wxCommandEvent& event ) { - wxGetApp().SetLanguageIdentifier( event.GetId() ); - if ( wxGetApp().SetLanguage() ) - { - wxLogDebug( wxT( "Recreating menu bar due to language change." ) ); - ReCreateMenuBar(); - Refresh(); - } + WinEDA_BasicFrame::SetLanguage( event ); } diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp index 99297ef613..402cb2a160 100644 --- a/pcbnew/menubar_modedit.cpp +++ b/pcbnew/menubar_modedit.cpp @@ -19,10 +19,16 @@ void WinEDA_ModuleEditFrame::ReCreateMenuBar() wxMenuBar* menuBar = GetMenuBar(); wxMenuItem* item; - if( menuBar ) - return; + if( ! menuBar ) + menuBar = new wxMenuBar(); - 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: /* File menu */ wxMenu* fileMenu = new wxMenu; @@ -310,6 +316,11 @@ void WinEDA_ModuleEditFrame::ReCreateMenuBar() menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - /* Associate the menu bar with the frame */ - SetMenuBar( menuBar ); + menuBar->Thaw(); + + // Associate the menu bar with the frame, if no previous menubar + if( GetMenuBar() == NULL ) + SetMenuBar( menuBar ); + else + menuBar->Refresh(); } diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 023cbb3a07..3fd5d476d5 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -23,16 +23,18 @@ void WinEDA_PcbFrame::ReCreateMenuBar() wxMenuItem* item; wxMenuBar* menuBar = GetMenuBar(); - /** - * Destroy the existing menu bar so it can be rebuilt. This allows - * language changes of the menu text on the fly. - */ - if( menuBar ) - SetMenuBar( NULL ); - menuBar = new wxMenuBar(); + 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); - /** Create File Menu */ + // Recreate all menus: + + // Create File Menu wxMenu* filesMenu = new wxMenu; // New @@ -606,6 +608,11 @@ void WinEDA_PcbFrame::ReCreateMenuBar() menuBar->Append( designRulesMenu, _( "&Design Rules" ) ); menuBar->Append( helpMenu, _( "&Help" ) ); - /* Associate the menu bar with the frame */ - SetMenuBar( menuBar ); + menuBar->Thaw(); + + // Associate the menu bar with the frame, if no previous menubar + if( GetMenuBar() == NULL ) + SetMenuBar( menuBar ); + else + menuBar->Refresh(); } diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 9602ac282e..a6236e8e72 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -163,9 +163,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() if( (m_PrintParams.m_PrintScale > 1.0) // scale > 1 -> Recadrage || (m_PrintParams.m_PrintScale == 0) ) // fit in page { - DrawOffset.x += pcbframe->GetBoard()->m_BoundaryBox.Centre().x; - DrawOffset.y += pcbframe->GetBoard()->m_BoundaryBox.Centre().y; - } + DrawOffset += pcbframe->GetBoard()->m_BoundaryBox.Centre(); + } if( m_PrintParams.m_PageSetupData ) { @@ -258,6 +257,11 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() * the old draw area in the new draw area, because the draw origin has not moved * (this is the upper left corner) but the Y axis is reversed, therefore the plotting area * is the y coordinate values from - PlotAreaSize.y to 0 */ +#ifdef USE_WX_ZOOM + int y_dc_offset = PlotAreaSizeInPixels.y; + y_dc_offset = (int) y_dc_offset * userscale; + dc->SetDeviceOrigin( 0, y_dc_offset ); +#endif int ysize = (int) ( PlotAreaSizeInPixels.y / sy ); DrawOffset.y += ysize; @@ -271,7 +275,11 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() wxPoint pcb_centre = pcbframe->GetBoard()->m_BoundaryBox.Centre(); if( userscale <= 1.0 ) DrawOffset.y += pcb_centre.y - (ysize / 2); +#ifdef USE_WX_ZOOM + dc->SetLogicalOrigin( ActiveScreen->m_DrawOrg.x, ActiveScreen->m_DrawOrg.y ); +#else ActiveScreen->m_DrawOrg = DrawOffset; +#endif panel->m_ClipBox.SetOrigin( wxPoint( -0x7FFFFF, -0x7FFFFF ) ); }