Eeschema: fix many wxASSERT when trying to open menus from the main menubar.

This is due to the fact the same ID was used for menuitems in menubar,
and tools in toobars.
Especially, some items were not compatible due to different attributes.

Windows does not accept the same ID for 2 items inside the same frame.
It creates issues (items not shown, Asserts, ...)
This commit is contained in:
jean-pierre charras 2018-04-01 20:58:27 +02:00
parent 54f14b08ca
commit e750417fa0
8 changed files with 93 additions and 42 deletions

View File

@ -284,7 +284,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
wxMenu* zoom_choice = new wxMenu;
AddMenuItem( MasterMenu, zoom_choice,
ID_POPUP_ZOOM_SELECT, _( "Zoom to Selection" ),
ID_POPUP_ZOOM_SELECT, _( "Zoom Select" ),
KiBitmap( zoom_selection_xpm ) );
zoom = screen->GetZoom();

View File

@ -77,7 +77,7 @@ enum id_eeschema_frm
ID_UPDATE_FIELDS,
ID_GEN_PLOT_SCHEMATIC,
/* Schematic editor veritcal toolbar IDs */
/* Schematic editor vertical toolbar IDs */
ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
ID_HIGHLIGHT,
ID_SCH_PLACE_COMPONENT,
@ -100,6 +100,31 @@ enum id_eeschema_frm
ID_SCHEMATIC_DELETE_ITEM_BUTT,
ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
// Schematic editor menu place IDs (equivalent to vertical toolbar IDs
// for submenus.
// On Windows we cannot use the same ID for 2 items in the same frame.
// Usually it creates issues (wxASSERTS, item not displayed, ...)
ID_SCHEMATIC_PLACE_MENU_START,
ID_MENU_PLACE_COMPONENT,
ID_MENU_PLACE_POWER_BUTT,
ID_MENU_BUS_BUTT,
ID_MENU_WIRE_BUTT,
ID_MENU_BUSTOBUS_ENTRY_BUTT,
ID_MENU_WIRETOBUS_ENTRY_BUTT,
ID_MENU_LABEL_BUTT,
ID_MENU_GLABEL_BUTT,
ID_MENU_HIERLABEL_BUTT,
ID_MENU_IMPORT_HLABEL_BUTT,
ID_MENU_SHEET_PIN_BUTT,
ID_MENU_NOCONN_BUTT,
ID_MENU_JUNCTION_BUTT,
ID_MENU_SHEET_SYMBOL_BUTT,
ID_MENU_TEXT_COMMENT_BUTT,
ID_MENU_LINE_COMMENT_BUTT,
ID_MENU_ADD_IMAGE_BUTT,
ID_MENU_DELETE_ITEM_BUTT,
ID_SCHEMATIC_PLACE_MENU_END,
// Toolbar options id:
ID_TB_OPTIONS_HIDDEN_PINS,
ID_TB_OPTIONS_BUS_WIRES_ORIENT,

View File

@ -132,6 +132,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
// Right vertical toolbar.
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
EVT_MENU( ID_MENU_ZOOM_SELECTION, LIB_EDIT_FRAME::OnSelectTool )
EVT_TOOL( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnSelectTool )
@ -1153,6 +1154,7 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
break;
case ID_MENU_ZOOM_SELECTION:
case ID_ZOOM_SELECTION:
// This tool is located on the main toolbar: switch it on or off on click on it
if( lastToolID != ID_ZOOM_SELECTION )

View File

@ -191,7 +191,7 @@ void prepareViewMenu( wxMenu* aParentMenu )
text = AddHotkeyName( _( "Zoom to Selection" ), g_Eeschema_Hokeys_Descr, HK_ZOOM_SELECTION );
AddMenuItem( aParentMenu, ID_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
AddMenuItem( aParentMenu, ID_MENU_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
text = AddHotkeyName( _( "&Redraw" ), g_Schematic_Hokeys_Descr, HK_ZOOM_REDRAW );
@ -251,59 +251,59 @@ void preparePlaceMenu( wxMenu* aParentMenu )
text = AddHotkeyName( _( "&Symbol" ), g_Schematic_Hokeys_Descr,
HK_ADD_NEW_COMPONENT, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_SCH_PLACE_COMPONENT, text,
AddMenuItem( aParentMenu, ID_MENU_PLACE_COMPONENT, text,
HELP_PLACE_COMPONENTS,
KiBitmap( add_component_xpm ) );
text = AddHotkeyName( _( "&Power Port" ), g_Schematic_Hokeys_Descr,
HK_ADD_NEW_POWER, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_PLACE_POWER_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_PLACE_POWER_BUTT, text,
HELP_PLACE_POWERPORT,
KiBitmap( add_power_xpm ) );
text = AddHotkeyName( _( "&Wire" ), g_Schematic_Hokeys_Descr,
HK_BEGIN_WIRE, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_WIRE_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_WIRE_BUTT, text,
HELP_PLACE_WIRE,
KiBitmap( add_line_xpm ) );
text = AddHotkeyName( _( "&Bus" ), g_Schematic_Hokeys_Descr,
HK_BEGIN_BUS, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_BUS_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_BUS_BUTT, text,
HELP_PLACE_BUS,
KiBitmap( add_bus_xpm ) );
text = AddHotkeyName( _( "Wire to Bus &Entry" ), g_Schematic_Hokeys_Descr,
HK_ADD_WIRE_ENTRY, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_WIRETOBUS_ENTRY_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_WIRETOBUS_ENTRY_BUTT, text,
HELP_PLACE_WIRE2BUS_ENTRY,
KiBitmap( add_line2bus_xpm ) );
text = AddHotkeyName( _( "Bus &to Bus Entry" ), g_Schematic_Hokeys_Descr,
HK_ADD_BUS_ENTRY, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_BUSTOBUS_ENTRY_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_BUSTOBUS_ENTRY_BUTT, text,
HELP_PLACE_BUS2BUS_ENTRY,
KiBitmap( add_bus2bus_xpm ) );
text = AddHotkeyName( _( "&No Connect Flag" ), g_Schematic_Hokeys_Descr,
HK_ADD_NOCONN_FLAG, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_NOCONN_BUTT, text, HELP_PLACE_NC_FLAG, KiBitmap( noconn_xpm ) );
AddMenuItem( aParentMenu, ID_MENU_NOCONN_BUTT, text, HELP_PLACE_NC_FLAG, KiBitmap( noconn_xpm ) );
text = AddHotkeyName( _( "&Junction" ), g_Schematic_Hokeys_Descr,
HK_ADD_JUNCTION, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_JUNCTION_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_JUNCTION_BUTT, text,
HELP_PLACE_JUNCTION,
KiBitmap( add_junction_xpm ) );
text = AddHotkeyName( _( "&Label" ), g_Schematic_Hokeys_Descr,
HK_ADD_LABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_LABEL_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_LABEL_BUTT, text,
HELP_PLACE_NETLABEL,
KiBitmap( add_line_label_xpm ) );
text = AddHotkeyName( _( "Gl&obal Label" ), g_Schematic_Hokeys_Descr,
HK_ADD_GLABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_GLABEL_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_GLABEL_BUTT, text,
HELP_PLACE_GLOBALLABEL,
KiBitmap( add_glabel_xpm ) );
@ -311,25 +311,25 @@ void preparePlaceMenu( wxMenu* aParentMenu )
text = AddHotkeyName( _( "&Hierarchical Label" ), g_Schematic_Hokeys_Descr,
HK_ADD_HLABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_HIERLABEL_BUTT,
AddMenuItem( aParentMenu, ID_MENU_HIERLABEL_BUTT,
text, HELP_PLACE_HIER_LABEL,
KiBitmap( add_hierarchical_label_xpm ) );
text = AddHotkeyName( _( "Hierar&chical Sheet" ), g_Schematic_Hokeys_Descr,
HK_ADD_HIER_SHEET, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_SHEET_SYMBOL_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_SHEET_SYMBOL_BUTT, text,
HELP_PLACE_SHEET,
KiBitmap( add_hierarchical_subsheet_xpm ) );
AddMenuItem( aParentMenu,
ID_IMPORT_HLABEL_BUTT,
ID_MENU_IMPORT_HLABEL_BUTT,
_( "I&mport Hierarchical Label" ),
HELP_IMPORT_SHEETPIN,
KiBitmap( import_hierarchical_label_xpm ) );
AddMenuItem( aParentMenu,
ID_SHEET_PIN_BUTT,
ID_MENU_SHEET_PIN_BUTT,
_( "Hierarchical Pi&n to Sheet" ),
HELP_PLACE_SHEETPIN,
KiBitmap( add_hierar_pin_xpm ) );
@ -338,18 +338,18 @@ void preparePlaceMenu( wxMenu* aParentMenu )
text = AddHotkeyName( _( "Graphic Pol&yline" ), g_Schematic_Hokeys_Descr,
HK_ADD_GRAPHIC_POLYLINE, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_LINE_COMMENT_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_LINE_COMMENT_BUTT, text,
HELP_PLACE_GRAPHICLINES,
KiBitmap( add_dashed_line_xpm ) );
text = AddHotkeyName( _( "&Graphic Text" ), g_Schematic_Hokeys_Descr,
HK_ADD_GRAPHIC_TEXT, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_TEXT_COMMENT_BUTT, text,
AddMenuItem( aParentMenu, ID_MENU_TEXT_COMMENT_BUTT, text,
HELP_PLACE_GRAPHICTEXTS,
KiBitmap( text_xpm ) );
// Add graphic image
AddMenuItem( aParentMenu, ID_ADD_IMAGE_BUTT, _( "&Image" ),
AddMenuItem( aParentMenu, ID_MENU_ADD_IMAGE_BUTT, _( "&Image" ),
HELP_PLACE_GRAPHICIMAGES,
KiBitmap( image_xpm ) );
}
@ -515,7 +515,7 @@ void prepareEditMenu( wxMenu* aParentMenu )
KiBitmap( paste_xpm ) );
// Delete
AddMenuItem( aParentMenu, ID_SCHEMATIC_DELETE_ITEM_BUTT,
AddMenuItem( aParentMenu, ID_MENU_DELETE_ITEM_BUTT,
_( "&Delete" ), HELP_DELETE_ITEMS,
KiBitmap( delete_xpm ) );

View File

@ -171,8 +171,9 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit symbol" ),
KiBitmap( zoom_fit_in_page_xpm ) );
text = AddHotkeyName( _( "Zoom to Selection" ), g_Schematic_Hokeys_Descr, HK_ZOOM_SELECTION );
AddMenuItem( viewMenu, ID_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
text = AddHotkeyName( _( "Zoom to Selection" ),
g_Schematic_Hokeys_Descr, HK_ZOOM_SELECTION );
AddMenuItem( viewMenu, ID_MENU_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
// Redraw
text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW );

View File

@ -289,9 +289,12 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
// Tools and buttons for vertical toolbar.
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnSelectTool )
EVT_MENU( ID_MENU_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_SCHEMATIC_PLACE_MENU_START, ID_SCHEMATIC_PLACE_MENU_END,
SCH_EDIT_FRAME::OnSelectTool )
#ifdef KICAD_SPICE
EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate )

View File

@ -507,9 +507,10 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
break;
case ID_HIGHLIGHT:
SetToolID( id, wxCURSOR_HAND, _("Highlight specific net") );
SetToolID( ID_HIGHLIGHT, wxCURSOR_HAND, _("Highlight specific net") );
break;
case ID_MENU_ZOOM_SELECTION:
case ID_ZOOM_SELECTION:
// This tool is located on the main toolbar: switch it on or off on click
if( lastToolID != ID_ZOOM_SELECTION )
@ -518,76 +519,94 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
SetNoToolSelected();
break;
case ID_MENU_NOCONN_BUTT:
case ID_NOCONN_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add no connect" ) );
SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
break;
case ID_MENU_WIRE_BUTT:
case ID_WIRE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add wire" ) );
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
break;
case ID_MENU_BUS_BUTT:
case ID_BUS_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add bus" ) );
SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
break;
case ID_MENU_LINE_COMMENT_BUTT:
case ID_LINE_COMMENT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add lines" ) );
SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
break;
case ID_MENU_JUNCTION_BUTT:
case ID_JUNCTION_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add junction" ) );
SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
break;
case ID_MENU_LABEL_BUTT:
case ID_LABEL_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add label" ) );
SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add label" ) );
break;
case ID_MENU_GLABEL_BUTT:
case ID_GLABEL_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add global label" ) );
SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
break;
case ID_MENU_HIERLABEL_BUTT:
case ID_HIERLABEL_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
break;
case ID_MENU_TEXT_COMMENT_BUTT:
case ID_TEXT_COMMENT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
break;
case ID_MENU_ADD_IMAGE_BUTT:
case ID_ADD_IMAGE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add image" ) );
SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
break;
case ID_MENU_WIRETOBUS_ENTRY_BUTT:
case ID_WIRETOBUS_ENTRY_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
break;
case ID_MENU_BUSTOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
break;
case ID_MENU_SHEET_SYMBOL_BUTT:
case ID_SHEET_SYMBOL_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) );
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
break;
case ID_MENU_SHEET_PIN_BUTT:
case ID_SHEET_PIN_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
SetToolID( ID_SHEET_PIN_BUTT, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
break;
case ID_MENU_IMPORT_HLABEL_BUTT:
case ID_IMPORT_HLABEL_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
break;
case ID_MENU_PLACE_COMPONENT:
case ID_SCH_PLACE_COMPONENT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add component" ) );
SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add component" ) );
break;
case ID_MENU_PLACE_POWER_BUTT:
case ID_PLACE_POWER_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add power" ) );
SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add power" ) );
break;
case ID_MENU_DELETE_ITEM_BUTT:
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
SetToolID( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
break;
#ifdef KICAD_SPICE

View File

@ -122,6 +122,7 @@ enum main_id
ID_EDIT,
ID_NO_TOOL_SELECTED,
ID_ZOOM_SELECTION,
ID_MENU_ZOOM_SELECTION, // similar to ID_ZOOM_SELECTION, used in main memubar
ID_SEL_BG_COLOR,
ID_REPEAT_BUTT,