From c3d320aa8ca55831fd1b1aa4d3b0a40b2e3a7b8c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 9 Apr 2012 11:16:47 +0200 Subject: [PATCH] Move AddMenuItem inline functions outside wxstruct.h in a new file (menu_helpers.h) Enhancements in AddMenuItem (that accepts now a menu type) Partial use of the Edwin van den Oetelaar's patch (patch not fully working or correct) --- 3d-viewer/3d_aux.cpp | 10 +- 3d-viewer/3d_draw.cpp | 74 +++++------- 3d-viewer/3d_frame.cpp | 101 +++------------- 3d-viewer/3d_toolbar.cpp | 54 +++++---- 3d-viewer/3d_viewer.h | 23 ++-- bitmap2component/bitmap2cmp_gui.cpp | 1 + common/basicframe.cpp | 1 + common/edaappl.cpp | 10 +- common/hotkeys_basic.cpp | 1 + common/zoom.cpp | 1 + cvpcb/menubar.cpp | 1 + eeschema/controle.cpp | 1 + eeschema/libedit_onrightclick.cpp | 2 +- eeschema/libeditframe.cpp | 1 + eeschema/menubar.cpp | 3 +- eeschema/menubar_libedit.cpp | 1 + eeschema/onleftclick.cpp | 2 +- eeschema/onrightclick.cpp | 1 + gerbview/menubar.cpp | 1 + gerbview/onrightclick.cpp | 1 + include/menus_helpers.h | 174 ++++++++++++++++++++++++++++ include/wxstruct.h | 143 ----------------------- kicad/class_treeprojectfiles.cpp | 1 + kicad/commandframe.cpp | 1 + kicad/mainframe.cpp | 1 + kicad/menubar.cpp | 1 + kicad/tree_project_frame.cpp | 1 + pcbnew/controle.cpp | 1 + pcbnew/menubar_modedit.cpp | 1 + pcbnew/menubar_pcbframe.cpp | 1 + pcbnew/modedit.cpp | 1 + pcbnew/modedit_onclick.cpp | 3 +- pcbnew/onleftclick.cpp | 3 +- pcbnew/onrightclick.cpp | 3 +- 34 files changed, 295 insertions(+), 330 deletions(-) create mode 100644 include/menus_helpers.h diff --git a/3d-viewer/3d_aux.cpp b/3d-viewer/3d_aux.cpp index 6947c2d126..ceb7ba9711 100644 --- a/3d-viewer/3d_aux.cpp +++ b/3d-viewer/3d_aux.cpp @@ -189,13 +189,9 @@ Info_3D_Visu::Info_3D_Visu() m_Layers = 1; m_BoardSettings = NULL; - m_Draw3DAxis = true; - m_Draw3DModule = true; - m_Draw3DZone = true; - m_Draw3DComments = true; - m_Draw3DDrawings = true; - m_Draw3DEco1 = true; - m_Draw3DEco2 = true; + // default all special item layers Visible + for (ii=0; ii< FL_LAST; ii++) + m_DrawFlags[ii]=true; } diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 02f77d724d..0cda29ba35 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -206,7 +206,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); // draw axis - if( g_Parm_3D_Visu.m_Draw3DAxis ) + if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS]) { glEnable( GL_COLOR_MATERIAL ); SetGLColor( WHITE ); @@ -223,37 +223,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() } // Draw epoxy limits (do not use, works and test in progress) -#if 0 - glEnable( GL_FOG ); - GLfloat param; - -// param = GL_LINEAR; -// glFogfv(GL_FOG_MODE, & param); - param = 0.2; - glFogfv( GL_FOG_DENSITY, ¶m ); - param = g_Parm_3D_Visu.m_LayerZcoord[15]; - glFogfv( GL_FOG_END, ¶m ); - glBegin( GL_QUADS ); - SetGLColor( g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[LAYER_N_FRONT] ); - double sx = DataScale3D * g_Parm_3D_Visu.m_BoardSize.x / 2; - double sy = DataScale3D * g_Parm_3D_Visu.m_BoardSize.y / 2; - double zpos = g_Parm_3D_Visu.m_LayerZcoord[15]; - glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis - sx = sy = 0.5; - glVertex3f( -sx, -sy, zpos ); - glVertex3f( -sx, sy, zpos ); - glVertex3f( sx, sy, zpos ); - glVertex3f( sx, -sy, zpos ); - glEnd(); - glBegin( GL_QUADS ); - SetGLColor( g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[LAYER_N_BACK] ); - glNormal3f( 0.0, 0.0, -1.0 ); // Normal is -Z axis - glVertex3f( -sx, -sy, 0 ); - glVertex3f( -sx, sy, 0 ); - glVertex3f( sx, sy, 0 ); - glVertex3f( sx, -sy, 0 ); - glEnd(); -#endif + // TODO // move the board in order to draw it with its center at 0,0 3D coordinates glTranslatef( -g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale, @@ -271,7 +241,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() Draw3D_Track( track ); } - if( g_Parm_3D_Visu.m_Draw3DZone ) + if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]) { // Draw segments used to fill copper areas. outdated! for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() ) @@ -707,7 +677,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) S3D_MASTER* Struct3D = m_3D_Drawings; bool As3dShape = false; - if( g_Parm_3D_Visu.m_Draw3DModule ) + if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]) { glPushMatrix(); @@ -1430,23 +1400,33 @@ void EDA_3D_CANVAS::Draw3D_Polygon( std::vector& aCornersList, double a static int Get3DLayerEnable( int act_layer ) { - bool enablelayer; + int i = -1; + // see if layer needs to be shown + // check the flags + switch (act_layer) + { + case DRAW_N: + i=g_Parm_3D_Visu.FL_DRAWINGS; + break; - enablelayer = true; + case COMMENT_N: + i=g_Parm_3D_Visu.FL_COMMENTS; + break; - if( act_layer == DRAW_N && !g_Parm_3D_Visu.m_Draw3DDrawings ) - enablelayer = false; + case ECO1_N: + i=g_Parm_3D_Visu.FL_ECO1; + break; - if( act_layer == COMMENT_N && !g_Parm_3D_Visu.m_Draw3DComments ) - enablelayer = false; + case ECO2_N: + i=g_Parm_3D_Visu.FL_ECO2; + break; + } + // the layer was not a layer with a flag, so show it + if (i < 0) + return true; - if( act_layer == ECO1_N && !g_Parm_3D_Visu.m_Draw3DEco1 ) - enablelayer = false; - - if( act_layer == ECO2_N && !g_Parm_3D_Visu.m_Draw3DEco2 ) - enablelayer = false; - - return enablelayer; + // if the layer has a flag, return the flag + return g_Parm_3D_Visu.m_DrawFlags[i]; } diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index 44fc345b8d..205ddb0d9b 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -222,8 +222,10 @@ void EDA_3D_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) { #define ROT_ANGLE 10.0 + int id = event.GetId(); + bool isChecked = event.IsChecked(); - switch( event.GetId() ) + switch( id ) { case ID_RELOAD3D_BOARD: NewDisplay(); @@ -285,31 +287,38 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) return; case ID_MENU3D_AXIS_ONOFF: - Set3DAxisOnOff(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] = isChecked; + NewDisplay(); return; case ID_MENU3D_MODULE_ONOFF: - Set3DModuleOnOff(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] = isChecked; + NewDisplay(); return; case ID_MENU3D_ZONE_ONOFF: - Set3DZoneOnOff(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] = isChecked; + NewDisplay(); return; case ID_MENU3D_COMMENTS_ONOFF: - Set3DCommentsOnOff(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] = isChecked; + NewDisplay(); return; case ID_MENU3D_DRAWINGS_ONOFF: - Set3DDrawingsOnOff(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_DRAWINGS] = isChecked; + NewDisplay(); return; case ID_MENU3D_ECO1_ONOFF: - Set3DEco1OnOff(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO1] = isChecked; + NewDisplay(); return; case ID_MENU3D_ECO2_ONOFF: - Set3DEco2OnOff(); + g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO2] = isChecked; + NewDisplay(); return; default: @@ -367,79 +376,3 @@ void EDA_3D_FRAME::Set3DBgColor() NewDisplay(); } } - - -void EDA_3D_FRAME::Set3DAxisOnOff() -{ - if( g_Parm_3D_Visu.m_Draw3DAxis ) - g_Parm_3D_Visu.m_Draw3DAxis = false; - else - g_Parm_3D_Visu.m_Draw3DAxis = true; - - NewDisplay(); -} - - -void EDA_3D_FRAME::Set3DModuleOnOff() -{ - if( g_Parm_3D_Visu.m_Draw3DModule ) - g_Parm_3D_Visu.m_Draw3DModule = false; - else - g_Parm_3D_Visu.m_Draw3DModule = true; - - NewDisplay(); -} - - -void EDA_3D_FRAME::Set3DZoneOnOff() -{ - if( g_Parm_3D_Visu.m_Draw3DZone ) - g_Parm_3D_Visu.m_Draw3DZone = false; - else - g_Parm_3D_Visu.m_Draw3DZone = true; - NewDisplay(); -} - - -void EDA_3D_FRAME::Set3DCommentsOnOff() -{ - if( g_Parm_3D_Visu.m_Draw3DComments ) - g_Parm_3D_Visu.m_Draw3DComments = false; - else - g_Parm_3D_Visu.m_Draw3DComments = true; - - NewDisplay(); -} - - -void EDA_3D_FRAME::Set3DDrawingsOnOff() -{ - if( g_Parm_3D_Visu.m_Draw3DDrawings ) - g_Parm_3D_Visu.m_Draw3DDrawings = false; - else - g_Parm_3D_Visu.m_Draw3DDrawings = true; - - NewDisplay(); -} - - -void EDA_3D_FRAME::Set3DEco1OnOff() -{ - if( g_Parm_3D_Visu.m_Draw3DEco1 ) - g_Parm_3D_Visu.m_Draw3DEco1 = false; - else - g_Parm_3D_Visu.m_Draw3DEco1 = true; - - NewDisplay(); -} - - -void EDA_3D_FRAME::Set3DEco2OnOff() -{ - if( g_Parm_3D_Visu.m_Draw3DEco2 ) - g_Parm_3D_Visu.m_Draw3DEco2 = false; - else - g_Parm_3D_Visu.m_Draw3DEco2 = true; - - NewDisplay(); -} diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp index c5806e3e6f..cd1a3c2a91 100644 --- a/3d-viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_toolbar.cpp @@ -30,6 +30,7 @@ #include #include <3d_viewer.h> +#include void EDA_3D_FRAME::ReCreateHToolbar() @@ -132,13 +133,13 @@ void EDA_3D_FRAME::ReCreateMenuBar() bool full_options = true; // If called from the display frame of CvPcb, only some options are relevant - if( Parent()->GetName() == wxT( "CmpFrame" ) ) - // Called from CvPcb: do not display all options + if( Parent()->GetName() == wxT( "CmpFrame" ) ) { full_options = false; + } - wxMenuBar* menuBar = new wxMenuBar; - - wxMenu* fileMenu = new wxMenu; + wxMenuBar* menuBar = new wxMenuBar; + wxMenu* fileMenu = new wxMenu; + wxMenu* prefsMenu = new wxMenu; menuBar->Append( fileMenu, _( "&File" ) ); @@ -153,34 +154,43 @@ void EDA_3D_FRAME::ReCreateMenuBar() fileMenu->AppendSeparator(); fileMenu->Append( wxID_EXIT, _( "&Exit" ) ); - wxMenu* referencesMenu = new wxMenu; - menuBar->Append( referencesMenu, _( "&Preferences" ) ); + menuBar->Append( prefsMenu, _( "&Preferences" ) ); - AddMenuItem( referencesMenu, ID_MENU3D_BGCOLOR_SELECTION, + AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION, _( "Choose background color" ), KiBitmap( palette_xpm ) ); - AddMenuItem( referencesMenu, ID_MENU3D_AXIS_ONOFF, - _( "3D Axis On/Off" ), KiBitmap( axis3d_front_xpm ) ); + wxMenuItem* item; + item = AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF, + _( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS]); + if( full_options ) { - AddMenuItem( referencesMenu, ID_MENU3D_MODULE_ONOFF, - _( "3D Footprints Shapes On/Off" ), KiBitmap( shape_3d_xpm ) ); + item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF, + _( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]); - AddMenuItem( referencesMenu, ID_MENU3D_ZONE_ONOFF, - _( "Zone Filling On/Off" ), KiBitmap( add_zone_xpm ) ); + item = AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF, + _( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]); - AddMenuItem( referencesMenu, ID_MENU3D_COMMENTS_ONOFF, - _( "Comments Layer On/Off" ), KiBitmap( edit_sheet_xpm ) ); + item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF, + _( "Show &Comments Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]); - AddMenuItem( referencesMenu, ID_MENU3D_DRAWINGS_ONOFF, - _( "Drawings Layer On/Off" ), KiBitmap( add_polygon_xpm ) ); + item = AddMenuItem( prefsMenu, ID_MENU3D_DRAWINGS_ONOFF, + _( "Show &Drawings Layer" ), KiBitmap( add_polygon_xpm ), wxITEM_CHECK ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_DRAWINGS]); - AddMenuItem( referencesMenu, ID_MENU3D_ECO1_ONOFF, - _( "Eco1 Layer On/Off" ), KiBitmap( tools_xpm ) ); + item = AddMenuItem( prefsMenu, ID_MENU3D_ECO1_ONOFF, + _( "Show Eco&1 Layer" ), KiBitmap( tools_xpm ), wxITEM_CHECK ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO1]); + + item = AddMenuItem( prefsMenu, ID_MENU3D_ECO2_ONOFF, + _( "Show Eco&2 Layer" ), KiBitmap( tools_xpm ), wxITEM_CHECK ); + item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO2]); - AddMenuItem( referencesMenu, ID_MENU3D_ECO2_ONOFF, - _( "Eco2 Layer On/Off" ), KiBitmap( tools_xpm ) ); } SetMenuBar( menuBar ); diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 703fc70382..f98151aac7 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -134,19 +134,20 @@ class SEGVIA; /* information needed to display 3D board */ class Info_3D_Visu { + public: + enum { + FL_AXIS=0, FL_MODULE, FL_ZONE, + FL_COMMENTS, FL_DRAWINGS, FL_ECO1, FL_ECO2, + FL_LAST + }; + double m_Beginx, m_Beginy; /* position of mouse */ double m_Quat[4]; /* orientation of object */ double m_Rot[4]; /* man rotation of object */ double m_Zoom; /* field of view in degrees */ S3D_Color m_BgColor; - bool m_Draw3DAxis; - bool m_Draw3DModule; - bool m_Draw3DZone; - bool m_Draw3DComments; - bool m_Draw3DDrawings; - bool m_Draw3DEco1; - bool m_Draw3DEco2; + bool m_DrawFlags[FL_LAST]; /* show these special items */ wxPoint m_BoardPos; wxSize m_BoardSize; int m_Layers; @@ -320,14 +321,6 @@ public: void NewDisplay(); void Set3DBgColor(); - void Set3DAxisOnOff(); - void Set3DModuleOnOff(); - void Set3DPlaceOnOff(); - void Set3DZoneOnOff(); - void Set3DCommentsOnOff(); - void Set3DDrawingsOnOff(); - void Set3DEco1OnOff(); - void Set3DEco2OnOff(); DECLARE_EVENT_TABLE() }; diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 4ec5ee3a3d..e9efb955d7 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -38,6 +38,7 @@ #include #include +#include #define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" ) #define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" ) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index d5d96c10e0..e9330c1959 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -42,6 +42,7 @@ #include #include #include +#include /// The default auto save interval is 10 minutes. diff --git a/common/edaappl.cpp b/common/edaappl.cpp index 005aff1e83..d870a08ac7 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -51,6 +51,7 @@ #include #include #include +#include static const wxChar* CommonConfigPath = wxT( "kicad_common" ); @@ -839,12 +840,9 @@ void EDA_APP::AddMenuLanguageList( wxMenu* MasterMenu ) else label = wxGetTranslation( s_Language_List[ii].m_Lang_Label ); - item = new wxMenuItem( menu, - s_Language_List[ii].m_KI_Lang_Identifier, - label, wxEmptyString, wxITEM_CHECK ); - - SETBITMAPS( s_Language_List[ii].m_Lang_Icon ); - menu->Append( item ); + AddMenuItem( menu, s_Language_List[ii].m_KI_Lang_Identifier, + label, KiBitmap(s_Language_List[ii].m_Lang_Icon ), + wxITEM_CHECK ); } AddMenuItem( MasterMenu, menu, diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 91a3de87b9..46cea5969e 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/common/zoom.cpp b/common/zoom.cpp index 390507fc96..cae1173461 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -14,6 +14,7 @@ #include #include #include +#include void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index caf9c90150..19fab61ade 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 5b6f133310..fb077f70a4 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index 93f011c85e..1b8ffb9ab9 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -13,11 +13,11 @@ #include #include -#include #include #include #include #include +#include /* functions to add commands and submenus depending on the item */ diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 2c0a32ff29..fe4d61ef63 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -51,6 +51,7 @@ #include #include +#include #include diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index a214ba26df..d60032fb5c 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -36,9 +36,10 @@ #include #include -#include +//#include #include #include +#include #include diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index e8b9045762..64367b1a0f 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -36,6 +36,7 @@ #include #include +#include /** * @brief (Re)Create the menubar for the component editor frame diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 9413ea8bcb..bd4c30e38f 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -32,9 +32,9 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 5b65ee4c40..49bf5b374a 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index b1d8c78a57..9aeca9ba95 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -34,6 +34,7 @@ #include #include #include +#include void GERBVIEW_FRAME::ReCreateMenuBar( void ) diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp index b4f7f7ae21..bf9e24ca66 100644 --- a/gerbview/onrightclick.cpp +++ b/gerbview/onrightclick.cpp @@ -8,6 +8,7 @@ #include #include +#include /* Prepare the right-click pullup menu. diff --git a/include/menus_helpers.h b/include/menus_helpers.h new file mode 100644 index 0000000000..482d39bbda --- /dev/null +++ b/include/menus_helpers.h @@ -0,0 +1,174 @@ +/** + * @file menus_helpers.h + * @brief Usefull macros and inline functions to create menus items + * in menubars or popup menus + */ + +#include + +/** + * Definition SETBITMAPS + * is a macro use to add a bitmaps to check menu item. + * @note Do not use with normal menu items or any platform other than Windows. + * @param aImage is the image to add the menu item. + */ +#if defined( USE_IMAGES_IN_MENUS ) && defined( __WINDOWS__ ) +# define SETBITMAPS( aImage ) item->SetBitmaps( KiBitmap( apply_xpm ), KiBitmap( aImage ) ) +#else +# define SETBITMAPS( aImage ) +#endif + +/** + * Definition SETBITMAP + * is a macro use to add a bitmap to a menu items. + * @note Do not use with checked menu items. + * @param aImage is the image to add the menu item. + */ +#if !defined( USE_IMAGES_IN_MENUS ) +# define SET_BITMAP( aImage ) +#else +# define SET_BITMAP( aImage ) item->SetBitmap( aImage ) +#endif + +/** + * Function AddMenuItem + * is an inline helper function to create and insert a menu item with an icon + * into \a aMenu + * + * @param aMenu is the menu to add the new item. + * @param aId is the command ID for the new menu item. + * @param aText is the string for the new menu item. + * @param aImage is the icon to add to the new menu item. + * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... + * @return a pointer to the new created wxMenuItem + */ +static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, + int aId, + const wxString& aText, + const wxBitmap& aImage, + wxItemKind aType = wxITEM_NORMAL ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType ); + + if( aType == wxITEM_CHECK ) + { +#if defined( USE_IMAGES_IN_MENUS ) && defined( __WINDOWS__ ) + item->SetBitmaps( KiBitmap( apply_xpm ), aImage ); +#endif + } + else + { + SET_BITMAP( aImage ); + } + + aMenu->Append( item ); + + return item; +} + + +/** + * Function AddMenuItem + * is an inline helper function to create and insert a menu item with an icon + * and a help message string into \a aMenu + * + * @param aMenu is the menu to add the new item. + * @param aId is the command ID for the new menu item. + * @param aText is the string for the new menu item. + * @param aHelpText is the help message string for the new menu item. + * @param aImage is the icon to add to the new menu item. + * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... + * @return a pointer to the new created wxMenuItem + */ +static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, + int aId, + const wxString& aText, + const wxString& aHelpText, + const wxBitmap& aImage, + wxItemKind aType = wxITEM_NORMAL ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText, aHelpText, aType ); + + if( aType == wxITEM_CHECK ) + { +#if defined( USE_IMAGES_IN_MENUS ) && defined( __WINDOWS__ ) + item->SetBitmaps( KiBitmap( apply_xpm ), aImage ); +#endif + } + else + { + SET_BITMAP( aImage ); + } + + aMenu->Append( item ); + + return item; +} + + +/** + * Function AddMenuItem + * is an inline helper function to create and insert a menu item with an icon + * into \a aSubMenu in \a aMenu + * + * @param aMenu is the menu to add the new submenu item. + * @param aSubMenu is the submenu to add the new menu. + * @param aId is the command ID for the new menu item. + * @param aText is the string for the new menu item. + * @param aImage is the icon to add to the new menu item. + * @return a pointer to the new created wxMenuItem + */ +static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, + wxMenu* aSubMenu, + int aId, + const wxString& aText, + const wxBitmap& aImage ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText ); + item->SetSubMenu( aSubMenu ); + + SET_BITMAP( aImage ); + + aMenu->Append( item ); + + return item; +}; + + +/** + * Function AddMenuItem + * is an inline helper function to create and insert a menu item with an icon + * and a help message string into \a aSubMenu in \a aMenu + * + * @param aMenu is the menu to add the new submenu item. + * @param aSubMenu is the submenu to add the new menu. + * @param aId is the command ID for the new menu item. + * @param aText is the string for the new menu item. + * @param aHelpText is the help message string for the new menu item. + * @param aImage is the icon to add to the new menu item. + * @return a pointer to the new created wxMenuItem + */ +static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, + wxMenu* aSubMenu, + int aId, + const wxString& aText, + const wxString& aHelpText, + const wxBitmap& aImage ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText, aHelpText ); + item->SetSubMenu( aSubMenu ); + + SET_BITMAP( aImage ); + + aMenu->Append( item ); + + return item; +}; diff --git a/include/wxstruct.h b/include/wxstruct.h index f74e5baa7d..a59fdd9876 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -42,7 +42,6 @@ #include #include -#include #include #include @@ -961,148 +960,6 @@ public: }; -/** - * Function AddMenuItem - * is an inline helper function to create and insert a menu item with an image - * into \a aMenu - * - * @param aMenu is the menu to add the new item. - * @param aId is the command ID for the new menu item. - * @param aText is the string for the new menu item. - * @param aImage is the image to add to the new menu item. - */ -static inline void AddMenuItem( wxMenu* aMenu, - int aId, - const wxString& aText, - const wxBitmap& aImage ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText ); - -#if defined( USE_IMAGES_IN_MENUS ) - item->SetBitmap( aImage ); -#endif - - aMenu->Append( item ); -} - - -/** - * Function AddMenuItem - * is an inline helper function to create and insert a menu item with an image - * and a help message string into \a aMenu - * - * @param aMenu is the menu to add the new item. - * @param aId is the command ID for the new menu item. - * @param aText is the string for the new menu item. - * @param aHelpText is the help message string for the new menu item. - * @param aImage is the image to add to the new menu item. - */ -static inline void AddMenuItem( wxMenu* aMenu, - int aId, - const wxString& aText, - const wxString& aHelpText, - const wxBitmap& aImage ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText, aHelpText ); - -#if defined( USE_IMAGES_IN_MENUS ) - item->SetBitmap( aImage ); -#endif - - aMenu->Append( item ); -} - - -/** - * Function AddMenuItem - * is an inline helper function to create and insert a menu item with an image - * into \a aSubMenu in \a aMenu - * - * @param aMenu is the menu to add the new submenu item. - * @param aSubMenu is the submenu to add the new menu. - * @param aId is the command ID for the new menu item. - * @param aText is the string for the new menu item. - * @param aImage is the image to add to the new menu item. - */ -static inline void AddMenuItem( wxMenu* aMenu, - wxMenu* aSubMenu, - int aId, - const wxString& aText, - const wxBitmap& aImage ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText ); - item->SetSubMenu( aSubMenu ); - -#if defined( USE_IMAGES_IN_MENUS ) - item->SetBitmap( aImage ); -#endif - - aMenu->Append( item ); -}; - - -/** - * Function AddMenuItem - * is an inline helper function to create and insert a menu item with an image - * and a help message string into \a aSubMenu in \a aMenu - * - * @param aMenu is the menu to add the new submenu item. - * @param aSubMenu is the submenu to add the new menu. - * @param aId is the command ID for the new menu item. - * @param aText is the string for the new menu item. - * @param aHelpText is the help message string for the new menu item. - * @param aImage is the image to add to the new menu item. - */ -static inline void AddMenuItem( wxMenu* aMenu, - wxMenu* aSubMenu, - int aId, - const wxString& aText, - const wxString& aHelpText, - const wxBitmap& aImage ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText, aHelpText ); - item->SetSubMenu( aSubMenu ); - -#if defined( USE_IMAGES_IN_MENUS ) - item->SetBitmap( aImage ); -#endif - - aMenu->Append( item ); -}; - - -/** - * Definition SETBITMAPS - * is a macro use to add a bitmaps to check menu item. - * @note Do not use with normal menu items or any platform other than Windows. - * @param aImage is the image to add the menu item. - */ -#if defined( USE_IMAGES_IN_MENUS ) && defined( __WINDOWS__ ) -# define SETBITMAPS( aImage ) item->SetBitmaps( KiBitmap( apply_xpm ), KiBitmap( aImage ) ) -#else -# define SETBITMAPS( aImage ) -#endif - -/** - * Definition SETBITMAP - * is a macro use to add a bitmap to a menu items. - * @note Do not use with checked menu items. - * @param aImage is the image to add the menu item. - */ -#if !defined( USE_IMAGES_IN_MENUS ) -# define SET_BITMAP( aImage ) -#else -# define SET_BITMAP( aImage ) item->SetBitmap( aImage ) -#endif - /** * Specialization of the wxAuiPaneInfo class for KiCad panels. diff --git a/kicad/class_treeprojectfiles.cpp b/kicad/class_treeprojectfiles.cpp index 8f58775a49..9cf484db70 100644 --- a/kicad/class_treeprojectfiles.cpp +++ b/kicad/class_treeprojectfiles.cpp @@ -12,6 +12,7 @@ #include #include +#include IMPLEMENT_ABSTRACT_CLASS( TREEPROJECTFILES, wxTreeCtrl ) diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp index 28fda0568f..51ed272674 100644 --- a/kicad/commandframe.cpp +++ b/kicad/commandframe.cpp @@ -7,6 +7,7 @@ #include #include +#include RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) : diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index d203bd4665..772c66e054 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -36,6 +36,7 @@ #include #include #include +#include static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index c284cd85d0..6c4957d47c 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -30,6 +30,7 @@ #include #include #include +#include /* Menubar and toolbar event table */ diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp index 2271b1ae2f..a50d2ecc74 100644 --- a/kicad/tree_project_frame.cpp +++ b/kicad/tree_project_frame.cpp @@ -18,6 +18,7 @@ #include #include #include +#include /* Note about the tree project build process: diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index f2b3ce617c..a59abef318 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -41,6 +41,7 @@ #include #include #include +#include //external functions used here: extern bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp index 054e27d00d..ff4c0afb37 100644 --- a/pcbnew/menubar_modedit.cpp +++ b/pcbnew/menubar_modedit.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 9f71b28a6d..5df5fee5e4 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -36,6 +36,7 @@ #include #include +#include /** * Pcbnew mainframe menubar diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index b9acd991d9..0c1ccc4363 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -28,6 +28,7 @@ #include #include +#include // Functions defined in block_module_editor, but used here // These 2 functions are used in modedit to rotate or mirror the whole footprint diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 2d4cbfd7c0..eb9e3b8d70 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -14,11 +14,12 @@ #include #include -#include +//#include #include #include #include #include +#include void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index a6bb4035bc..644b11ca64 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2007 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr * Copyright (C) 2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * @@ -39,6 +39,7 @@ #include #include +#include /* Handle the left button mouse click, when a tool is active diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index e48080de6f..b61dbf25bb 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr * Copyright (C) 2007-2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * @@ -43,6 +43,7 @@ #include #include #include +#include static wxMenu* Append_Track_Width_List( BOARD* aBoard );