Commit 8f62c6aa authored by jean-pierre charras's avatar jean-pierre charras

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)
parent f2f0f66a
...@@ -189,13 +189,9 @@ Info_3D_Visu::Info_3D_Visu() ...@@ -189,13 +189,9 @@ Info_3D_Visu::Info_3D_Visu()
m_Layers = 1; m_Layers = 1;
m_BoardSettings = NULL; m_BoardSettings = NULL;
m_Draw3DAxis = true; // default all special item layers Visible
m_Draw3DModule = true; for (ii=0; ii< FL_LAST; ii++)
m_Draw3DZone = true; m_DrawFlags[ii]=true;
m_Draw3DComments = true;
m_Draw3DDrawings = true;
m_Draw3DEco1 = true;
m_Draw3DEco2 = true;
} }
......
...@@ -206,7 +206,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -206,7 +206,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
// draw axis // 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 ); glEnable( GL_COLOR_MATERIAL );
SetGLColor( WHITE ); SetGLColor( WHITE );
...@@ -223,37 +223,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -223,37 +223,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
} }
// Draw epoxy limits (do not use, works and test in progress) // Draw epoxy limits (do not use, works and test in progress)
#if 0 // TODO
glEnable( GL_FOG );
GLfloat param;
// param = GL_LINEAR;
// glFogfv(GL_FOG_MODE, & param);
param = 0.2;
glFogfv( GL_FOG_DENSITY, &param );
param = g_Parm_3D_Visu.m_LayerZcoord[15];
glFogfv( GL_FOG_END, &param );
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
// move the board in order to draw it with its center at 0,0 3D coordinates // 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, glTranslatef( -g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale,
...@@ -271,7 +241,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() ...@@ -271,7 +241,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
Draw3D_Track( track ); 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! // Draw segments used to fill copper areas. outdated!
for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() ) for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() )
...@@ -707,7 +677,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) ...@@ -707,7 +677,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
S3D_MASTER* Struct3D = m_3D_Drawings; S3D_MASTER* Struct3D = m_3D_Drawings;
bool As3dShape = false; bool As3dShape = false;
if( g_Parm_3D_Visu.m_Draw3DModule ) if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE])
{ {
glPushMatrix(); glPushMatrix();
...@@ -1430,23 +1400,33 @@ void EDA_3D_CANVAS::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double a ...@@ -1430,23 +1400,33 @@ void EDA_3D_CANVAS::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double a
static int Get3DLayerEnable( int act_layer ) static int Get3DLayerEnable( int act_layer )
{ {
bool enablelayer; int i = -1;
// see if layer needs to be shown
enablelayer = true; // check the flags
switch (act_layer)
if( act_layer == DRAW_N && !g_Parm_3D_Visu.m_Draw3DDrawings ) {
enablelayer = false; case DRAW_N:
i=g_Parm_3D_Visu.FL_DRAWINGS;
break;
if( act_layer == COMMENT_N && !g_Parm_3D_Visu.m_Draw3DComments ) case COMMENT_N:
enablelayer = false; i=g_Parm_3D_Visu.FL_COMMENTS;
break;
if( act_layer == ECO1_N && !g_Parm_3D_Visu.m_Draw3DEco1 ) case ECO1_N:
enablelayer = false; i=g_Parm_3D_Visu.FL_ECO1;
break;
if( act_layer == ECO2_N && !g_Parm_3D_Visu.m_Draw3DEco2 ) case ECO2_N:
enablelayer = false; 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;
return enablelayer; // if the layer has a flag, return the flag
return g_Parm_3D_Visu.m_DrawFlags[i];
} }
......
...@@ -222,8 +222,10 @@ void EDA_3D_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -222,8 +222,10 @@ void EDA_3D_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
#define ROT_ANGLE 10.0 #define ROT_ANGLE 10.0
int id = event.GetId();
bool isChecked = event.IsChecked();
switch( event.GetId() ) switch( id )
{ {
case ID_RELOAD3D_BOARD: case ID_RELOAD3D_BOARD:
NewDisplay(); NewDisplay();
...@@ -285,31 +287,38 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -285,31 +287,38 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
return; return;
case ID_MENU3D_AXIS_ONOFF: case ID_MENU3D_AXIS_ONOFF:
Set3DAxisOnOff(); g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] = isChecked;
NewDisplay();
return; return;
case ID_MENU3D_MODULE_ONOFF: case ID_MENU3D_MODULE_ONOFF:
Set3DModuleOnOff(); g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] = isChecked;
NewDisplay();
return; return;
case ID_MENU3D_ZONE_ONOFF: case ID_MENU3D_ZONE_ONOFF:
Set3DZoneOnOff(); g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] = isChecked;
NewDisplay();
return; return;
case ID_MENU3D_COMMENTS_ONOFF: case ID_MENU3D_COMMENTS_ONOFF:
Set3DCommentsOnOff(); g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] = isChecked;
NewDisplay();
return; return;
case ID_MENU3D_DRAWINGS_ONOFF: case ID_MENU3D_DRAWINGS_ONOFF:
Set3DDrawingsOnOff(); g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_DRAWINGS] = isChecked;
NewDisplay();
return; return;
case ID_MENU3D_ECO1_ONOFF: case ID_MENU3D_ECO1_ONOFF:
Set3DEco1OnOff(); g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO1] = isChecked;
NewDisplay();
return; return;
case ID_MENU3D_ECO2_ONOFF: case ID_MENU3D_ECO2_ONOFF:
Set3DEco2OnOff(); g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO2] = isChecked;
NewDisplay();
return; return;
default: default:
...@@ -367,79 +376,3 @@ void EDA_3D_FRAME::Set3DBgColor() ...@@ -367,79 +376,3 @@ void EDA_3D_FRAME::Set3DBgColor()
NewDisplay(); 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();
}
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <3d_viewer.h> #include <3d_viewer.h>
#include <menus_helpers.h>
void EDA_3D_FRAME::ReCreateHToolbar() void EDA_3D_FRAME::ReCreateHToolbar()
...@@ -132,13 +133,13 @@ void EDA_3D_FRAME::ReCreateMenuBar() ...@@ -132,13 +133,13 @@ void EDA_3D_FRAME::ReCreateMenuBar()
bool full_options = true; bool full_options = true;
// If called from the display frame of CvPcb, only some options are relevant // If called from the display frame of CvPcb, only some options are relevant
if( Parent()->GetName() == wxT( "CmpFrame" ) ) if( Parent()->GetName() == wxT( "CmpFrame" ) ) {
// Called from CvPcb: do not display all options
full_options = false; full_options = false;
}
wxMenuBar* menuBar = new wxMenuBar; wxMenuBar* menuBar = new wxMenuBar;
wxMenu* fileMenu = new wxMenu;
wxMenu* fileMenu = new wxMenu; wxMenu* prefsMenu = new wxMenu;
menuBar->Append( fileMenu, _( "&File" ) ); menuBar->Append( fileMenu, _( "&File" ) );
...@@ -153,34 +154,43 @@ void EDA_3D_FRAME::ReCreateMenuBar() ...@@ -153,34 +154,43 @@ void EDA_3D_FRAME::ReCreateMenuBar()
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Append( wxID_EXIT, _( "&Exit" ) ); fileMenu->Append( wxID_EXIT, _( "&Exit" ) );
wxMenu* referencesMenu = new wxMenu; menuBar->Append( prefsMenu, _( "&Preferences" ) );
menuBar->Append( referencesMenu, _( "&Preferences" ) );
AddMenuItem( referencesMenu, ID_MENU3D_BGCOLOR_SELECTION, AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION,
_( "Choose background color" ), KiBitmap( palette_xpm ) ); _( "Choose background color" ), KiBitmap( palette_xpm ) );
AddMenuItem( referencesMenu, ID_MENU3D_AXIS_ONOFF, wxMenuItem* item;
_( "3D Axis On/Off" ), KiBitmap( axis3d_front_xpm ) ); 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 ) if( full_options )
{ {
AddMenuItem( referencesMenu, ID_MENU3D_MODULE_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
_( "3D Footprints Shapes On/Off" ), KiBitmap( shape_3d_xpm ) ); _( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]);
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_ZONE_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
_( "Zone Filling On/Off" ), KiBitmap( add_zone_xpm ) ); _( "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_COMMENTS_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_DRAWINGS_ONOFF,
_( "Comments Layer On/Off" ), KiBitmap( edit_sheet_xpm ) ); _( "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_DRAWINGS_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_ECO1_ONOFF,
_( "Drawings Layer On/Off" ), KiBitmap( add_polygon_xpm ) ); _( "Show Eco&1 Layer" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO1]);
AddMenuItem( referencesMenu, ID_MENU3D_ECO1_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_ECO2_ONOFF,
_( "Eco1 Layer On/Off" ), KiBitmap( tools_xpm ) ); _( "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 ); SetMenuBar( menuBar );
......
...@@ -134,19 +134,20 @@ class SEGVIA; ...@@ -134,19 +134,20 @@ class SEGVIA;
/* information needed to display 3D board */ /* information needed to display 3D board */
class Info_3D_Visu class Info_3D_Visu
{ {
public: 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_Beginx, m_Beginy; /* position of mouse */
double m_Quat[4]; /* orientation of object */ double m_Quat[4]; /* orientation of object */
double m_Rot[4]; /* man rotation of object */ double m_Rot[4]; /* man rotation of object */
double m_Zoom; /* field of view in degrees */ double m_Zoom; /* field of view in degrees */
S3D_Color m_BgColor; S3D_Color m_BgColor;
bool m_Draw3DAxis; bool m_DrawFlags[FL_LAST]; /* show these special items */
bool m_Draw3DModule;
bool m_Draw3DZone;
bool m_Draw3DComments;
bool m_Draw3DDrawings;
bool m_Draw3DEco1;
bool m_Draw3DEco2;
wxPoint m_BoardPos; wxPoint m_BoardPos;
wxSize m_BoardSize; wxSize m_BoardSize;
int m_Layers; int m_Layers;
...@@ -320,14 +321,6 @@ public: ...@@ -320,14 +321,6 @@ public:
void NewDisplay(); void NewDisplay();
void Set3DBgColor(); void Set3DBgColor();
void Set3DAxisOnOff();
void Set3DModuleOnOff();
void Set3DPlaceOnOff();
void Set3DZoneOnOff();
void Set3DCommentsOnOff();
void Set3DDrawingsOnOff();
void Set3DEco1OnOff();
void Set3DEco2OnOff();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <colors_selection.h> #include <colors_selection.h>
#include <build_version.h> #include <build_version.h>
#include <menus_helpers.h>
#define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" ) #define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" ) #define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" )
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <eda_doc.h> #include <eda_doc.h>
#include <wxstruct.h> #include <wxstruct.h>
#include <macros.h> #include <macros.h>
#include <menus_helpers.h>
/// The default auto save interval is 10 minutes. /// The default auto save interval is 10 minutes.
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <hotkeys_basic.h> #include <hotkeys_basic.h>
#include <online_help.h> #include <online_help.h>
#include <gestfich.h> #include <gestfich.h>
#include <menus_helpers.h>
static const wxChar* CommonConfigPath = wxT( "kicad_common" ); static const wxChar* CommonConfigPath = wxT( "kicad_common" );
...@@ -839,12 +840,9 @@ void EDA_APP::AddMenuLanguageList( wxMenu* MasterMenu ) ...@@ -839,12 +840,9 @@ void EDA_APP::AddMenuLanguageList( wxMenu* MasterMenu )
else else
label = wxGetTranslation( s_Language_List[ii].m_Lang_Label ); label = wxGetTranslation( s_Language_List[ii].m_Lang_Label );
item = new wxMenuItem( menu, AddMenuItem( menu, s_Language_List[ii].m_KI_Lang_Identifier,
s_Language_List[ii].m_KI_Lang_Identifier, label, KiBitmap(s_Language_List[ii].m_Lang_Icon ),
label, wxEmptyString, wxITEM_CHECK ); wxITEM_CHECK );
SETBITMAPS( s_Language_List[ii].m_Lang_Icon );
menu->Append( item );
} }
AddMenuItem( MasterMenu, menu, AddMenuItem( MasterMenu, menu,
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <wxstruct.h> #include <wxstruct.h>
#include <macros.h> #include <macros.h>
#include <dialog_hotkeys_editor.h> #include <dialog_hotkeys_editor.h>
#include <menus_helpers.h>
#include <wx/apptrait.h> #include <wx/apptrait.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <wxstruct.h> #include <wxstruct.h>
#include <kicad_device_context.h> #include <kicad_device_context.h>
#include <hotkeys_basic.h> #include <hotkeys_basic.h>
#include <menus_helpers.h>
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <menus_helpers.h>
#include <cvpcb.h> #include <cvpcb.h>
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <eda_dde.h> #include <eda_dde.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <menus_helpers.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <general.h> #include <general.h>
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
#include <class_sch_screen.h> #include <class_sch_screen.h>
#include <general.h> #include <general.h>
#include <protos.h>
#include <libeditframe.h> #include <libeditframe.h>
#include <class_libentry.h> #include <class_libentry.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_polyline.h> #include <lib_polyline.h>
#include <menus_helpers.h>
/* functions to add commands and submenus depending on the item */ /* functions to add commands and submenus depending on the item */
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <dialogs/dialog_libedit_dimensions.h> #include <dialogs/dialog_libedit_dimensions.h>
#include <dialog_helpers.h> #include <dialog_helpers.h>
#include <menus_helpers.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
......
...@@ -36,9 +36,10 @@ ...@@ -36,9 +36,10 @@
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <general.h> #include <general.h>
#include <protos.h> //#include <protos.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <menus_helpers.h>
#include <help_common_strings.h> #include <help_common_strings.h>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <hotkeys.h> #include <hotkeys.h>
#include <help_common_strings.h> #include <help_common_strings.h>
#include <menus_helpers.h>
/** /**
* @brief (Re)Create the menubar for the component editor frame * @brief (Re)Create the menubar for the component editor frame
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h> #include <confirm.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <menus_helpers.h>
#include <general.h> #include <general.h>
#include <protos.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
#include <sch_text.h> #include <sch_text.h>
#include <sch_marker.h> #include <sch_marker.h>
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h> #include <confirm.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <menus_helpers.h>
#include <general.h> #include <general.h>
#include <hotkeys.h> #include <hotkeys.h>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <gerbview.h> #include <gerbview.h>
#include <gerbview_id.h> #include <gerbview_id.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <menus_helpers.h>
void GERBVIEW_FRAME::ReCreateMenuBar( void ) void GERBVIEW_FRAME::ReCreateMenuBar( void )
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <id.h> #include <id.h>
#include <gerbview.h> #include <gerbview.h>
#include <menus_helpers.h>
/* Prepare the right-click pullup menu. /* Prepare the right-click pullup menu.
......
/**
* @file menus_helpers.h
* @brief Usefull macros and inline functions to create menus items
* in menubars or popup menus
*/
#include <bitmaps.h>
/**
* 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;
};
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include <wx/aui/aui.h> #include <wx/aui/aui.h>
#include <wx/docview.h> #include <wx/docview.h>
#include <bitmaps.h>
#include <colors.h> #include <colors.h>
#include <common.h> #include <common.h>
...@@ -961,148 +960,6 @@ public: ...@@ -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. * Specialization of the wxAuiPaneInfo class for KiCad panels.
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <wx/regex.h> #include <wx/regex.h>
#include <wx/imaglist.h> #include <wx/imaglist.h>
#include <menus_helpers.h>
IMPLEMENT_ABSTRACT_CLASS( TREEPROJECTFILES, wxTreeCtrl ) IMPLEMENT_ABSTRACT_CLASS( TREEPROJECTFILES, wxTreeCtrl )
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <macros.h> #include <macros.h>
#include <kicad.h> #include <kicad.h>
#include <menus_helpers.h>
RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) : RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) :
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <kicad.h> #include <kicad.h>
#include <tree_project_frame.h> #include <tree_project_frame.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <menus_helpers.h>
static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) );
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#include <kicad.h> #include <kicad.h>
#include <menus_helpers.h>
/* Menubar and toolbar event table */ /* Menubar and toolbar event table */
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <wx/regex.h> #include <wx/regex.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/imaglist.h> #include <wx/imaglist.h>
#include <menus_helpers.h>
/* Note about the tree project build process: /* Note about the tree project build process:
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <protos.h> #include <protos.h>
#include <collectors.h> #include <collectors.h>
#include <menus_helpers.h>
//external functions used here: //external functions used here:
extern bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, extern bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame,
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
#include <module_editor_frame.h> #include <module_editor_frame.h>
#include <menus_helpers.h>
#include <protos.h> #include <protos.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <help_common_strings.h> #include <help_common_strings.h>
#include <menus_helpers.h>
/** /**
* Pcbnew mainframe menubar * Pcbnew mainframe menubar
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <dialog_edit_module_for_Modedit.h> #include <dialog_edit_module_for_Modedit.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <menus_helpers.h>
// Functions defined in block_module_editor, but used here // Functions defined in block_module_editor, but used here
// These 2 functions are used in modedit to rotate or mirror the whole footprint // These 2 functions are used in modedit to rotate or mirror the whole footprint
......
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
#include <class_edge_mod.h> #include <class_edge_mod.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <protos.h> //#include <protos.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <module_editor_frame.h> #include <module_editor_frame.h>
#include <dialog_edit_module_for_Modedit.h> #include <dialog_edit_module_for_Modedit.h>
#include <menus_helpers.h>
void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <menus_helpers.h>
/* Handle the left button mouse click, when a tool is active /* Handle the left button mouse click, when a tool is active
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 <stambaughw@verizon.net> * Copyright (C) 2007-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <collectors.h> #include <collectors.h>
#include <menus_helpers.h>
static wxMenu* Append_Track_Width_List( BOARD* aBoard ); static wxMenu* Append_Track_Width_List( BOARD* aBoard );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment