Make better use of TOOL_EVENT parameters.

This commit is contained in:
Jeff Young 2019-06-17 23:02:30 +01:00
parent 2f2c358aef
commit 7dd247f1dc
14 changed files with 63 additions and 136 deletions

View File

@ -409,11 +409,10 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
// in fact 0 to n-1 for n items in clarification list) // in fact 0 to n-1 for n items in clarification list)
// id < 0 are automatically created for menuitems created with wxID_ANY // id < 0 are automatically created for menuitems created with wxID_ANY
#define ID_CONTEXT_MENU_ID_MAX wxID_LOWEST /* = 100 should be enough and better */ #define ID_CONTEXT_MENU_ID_MAX wxID_LOWEST /* = 100 should be enough and better */
if( !evt && ( ( m_selected >=0 && m_selected < ID_CONTEXT_MENU_ID_MAX ) ||
( m_selected >= ID_POPUP_MENU_START && if( !evt &&
m_selected <= ID_POPUP_MENU_END ) ( ( m_selected >= 0 && m_selected < ID_CONTEXT_MENU_ID_MAX ) ||
) ( m_selected >= ID_POPUP_MENU_START && m_selected <= ID_POPUP_MENU_END ) ) )
)
{ {
menuText = GetLabelText( aEvent.GetId() ); menuText = GetLabelText( aEvent.GetId() );
evt = TOOL_EVENT( TC_COMMAND, TA_CHOICE_MENU_CHOICE, m_selected, AS_GLOBAL, evt = TOOL_EVENT( TC_COMMAND, TA_CHOICE_MENU_CHOICE, m_selected, AS_GLOBAL,

View File

@ -24,6 +24,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <tool/actions.h> #include <tool/actions.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <frame_type.h>
// Actions, being statically-defined, require specialized I18N handling. We continue to // Actions, being statically-defined, require specialized I18N handling. We continue to
@ -478,22 +479,22 @@ TOOL_ACTION ACTIONS::show3DViewer( "common.Control.show3DViewer",
TOOL_ACTION ACTIONS::showSymbolBrowser( "common.Control.showSymbolBrowser", TOOL_ACTION ACTIONS::showSymbolBrowser( "common.Control.showSymbolBrowser",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Symbol Library Browser" ), _( "Browse symbol libraries" ), _( "Symbol Library Browser" ), _( "Browse symbol libraries" ),
library_browse_xpm ); library_browse_xpm, AF_NONE, (void*) FRAME_SCH_VIEWER );
TOOL_ACTION ACTIONS::showSymbolEditor( "common.Control.showSymbolEditor", TOOL_ACTION ACTIONS::showSymbolEditor( "common.Control.showSymbolEditor",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Symbol Editor" ), _( "Create, delete and edit symbols" ), _( "Symbol Editor" ), _( "Create, delete and edit symbols" ),
libedit_xpm ); libedit_xpm, AF_NONE, (void*) FRAME_SCH_LIB_EDITOR );
TOOL_ACTION ACTIONS::showFootprintBrowser( "common.Control.showFootprintBrowser", TOOL_ACTION ACTIONS::showFootprintBrowser( "common.Control.showFootprintBrowser",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Footprint Library Browser" ), _( "Browse footprint libraries" ), _( "Footprint Library Browser" ), _( "Browse footprint libraries" ),
modview_icon_xpm ); modview_icon_xpm, AF_NONE, (void*) FRAME_PCB_MODULE_VIEWER );
TOOL_ACTION ACTIONS::showFootprintEditor( "common.Control.showFootprintEditor", TOOL_ACTION ACTIONS::showFootprintEditor( "common.Control.showFootprintEditor",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Footprint Editor" ), _( "Create, delete and edit footprints" ), _( "Footprint Editor" ), _( "Create, delete and edit footprints" ),
module_editor_xpm ); module_editor_xpm, AF_NONE, (void*) FRAME_PCB_MODULE_EDITOR );
TOOL_ACTION ACTIONS::updatePcbFromSchematic( "common.Control.updatePcbFromSchematic", TOOL_ACTION ACTIONS::updatePcbFromSchematic( "common.Control.updatePcbFromSchematic",
AS_GLOBAL, AS_GLOBAL,

View File

@ -74,19 +74,7 @@ int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
int COMMON_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent ) int COMMON_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
{ {
FRAME_T playerType = FRAME_SCH_VIEWER; FRAME_T playerType = aEvent.Parameter<FRAME_T>();
if( aEvent.IsAction( &ACTIONS::showSymbolBrowser ) )
playerType = FRAME_SCH_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showSymbolEditor ) )
playerType = FRAME_SCH_LIB_EDITOR;
else if( aEvent.IsAction( &ACTIONS::showFootprintBrowser ) )
playerType = FRAME_PCB_MODULE_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showFootprintEditor ) )
playerType = FRAME_PCB_MODULE_EDITOR;
else
wxFAIL_MSG( "ShowPlayer(): unexpected request" );
KIWAY_PLAYER* editor = m_frame->Kiway().Player( playerType, true ); KIWAY_PLAYER* editor = m_frame->Kiway().Player( playerType, true );
// Needed on Windows, other platforms do not use it, but it creates no issue // Needed on Windows, other platforms do not use it, but it creates no issue

View File

@ -24,6 +24,7 @@
#include <tool/tool_action.h> #include <tool/tool_action.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <tools/ee_actions.h> #include <tools/ee_actions.h>
#include <core/typeinfo.h>
// Actions, being statically-defined, require specialized I18N handling. We continue to // Actions, being statically-defined, require specialized I18N handling. We continue to
@ -199,32 +200,32 @@ TOOL_ACTION EE_ACTIONS::placeSymbolPin( "eeschema.SymbolDrawing.placeSymbolPin",
AS_GLOBAL, AS_GLOBAL,
'P', LEGACY_HK_NAME( "Create Pin" ), 'P', LEGACY_HK_NAME( "Create Pin" ),
_( "Add Pin" ), _( "Add a pin" ), _( "Add Pin" ), _( "Add a pin" ),
pin_xpm, AF_ACTIVATE ); pin_xpm, AF_ACTIVATE, (void*) LIB_PIN_T );
TOOL_ACTION EE_ACTIONS::placeSymbolText( "eeschema.SymbolDrawing.placeSymbolText", TOOL_ACTION EE_ACTIONS::placeSymbolText( "eeschema.SymbolDrawing.placeSymbolText",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Add Text" ), _( "Add a text item" ), _( "Add Text" ), _( "Add a text item" ),
text_xpm, AF_ACTIVATE ); text_xpm, AF_ACTIVATE, (void*) LIB_TEXT_T );
TOOL_ACTION EE_ACTIONS::drawSymbolRectangle( "eeschema.SymbolDrawing.drawSymbolRectangle", TOOL_ACTION EE_ACTIONS::drawSymbolRectangle( "eeschema.SymbolDrawing.drawSymbolRectangle",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Add Rectangle" ), _( "Add a rectangle" ), _( "Add Rectangle" ), _( "Add a rectangle" ),
add_rectangle_xpm, AF_ACTIVATE ); add_rectangle_xpm, AF_ACTIVATE, (void*) LIB_RECTANGLE_T );
TOOL_ACTION EE_ACTIONS::drawSymbolCircle( "eeschema.SymbolDrawing.drawSymbolCircle", TOOL_ACTION EE_ACTIONS::drawSymbolCircle( "eeschema.SymbolDrawing.drawSymbolCircle",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Add Circle" ), _( "Add a circle" ), _( "Add Circle" ), _( "Add a circle" ),
add_circle_xpm, AF_ACTIVATE ); add_circle_xpm, AF_ACTIVATE, (void*) LIB_CIRCLE_T );
TOOL_ACTION EE_ACTIONS::drawSymbolArc( "eeschema.SymbolDrawing.drawSymbolArc", TOOL_ACTION EE_ACTIONS::drawSymbolArc( "eeschema.SymbolDrawing.drawSymbolArc",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Add Arc" ), _( "Add an arc" ), _( "Add Arc" ), _( "Add an arc" ),
add_arc_xpm, AF_ACTIVATE ); add_arc_xpm, AF_ACTIVATE, (void*) LIB_ARC_T );
TOOL_ACTION EE_ACTIONS::drawSymbolLines( "eeschema.SymbolDrawing.drawSymbolLines", TOOL_ACTION EE_ACTIONS::drawSymbolLines( "eeschema.SymbolDrawing.drawSymbolLines",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Add Lines" ), _( "Add connected graphic lines" ), _( "Add Lines" ), _( "Add connected graphic lines" ),
add_graphical_segments_xpm, AF_ACTIVATE ); add_graphical_segments_xpm, AF_ACTIVATE, (void*) LIB_POLYLINE_T );
TOOL_ACTION EE_ACTIONS::placeSymbolAnchor( "eeschema.SymbolDrawing.placeSymbolAnchor", TOOL_ACTION EE_ACTIONS::placeSymbolAnchor( "eeschema.SymbolDrawing.placeSymbolAnchor",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
@ -273,65 +274,65 @@ TOOL_ACTION EE_ACTIONS::placeNoConnect( "eeschema.InteractiveDrawing.placeNoConn
AS_GLOBAL, AS_GLOBAL,
'Q', LEGACY_HK_NAME( "Add No Connect Flag" ), 'Q', LEGACY_HK_NAME( "Add No Connect Flag" ),
_( "Add No Connect Flag" ), _( "Add a no-connection flag" ), _( "Add No Connect Flag" ), _( "Add a no-connection flag" ),
noconn_xpm, AF_ACTIVATE ); noconn_xpm, AF_ACTIVATE, (void*) SCH_NO_CONNECT_T );
TOOL_ACTION EE_ACTIONS::placeJunction( "eeschema.InteractiveDrawing.placeJunction", TOOL_ACTION EE_ACTIONS::placeJunction( "eeschema.InteractiveDrawing.placeJunction",
AS_GLOBAL, AS_GLOBAL,
'J', LEGACY_HK_NAME( "Add Junction" ), 'J', LEGACY_HK_NAME( "Add Junction" ),
_( "Add Junction" ), _( "Add a junction" ), _( "Add Junction" ), _( "Add a junction" ),
add_junction_xpm, AF_ACTIVATE ); add_junction_xpm, AF_ACTIVATE, (void*) SCH_JUNCTION_T );
TOOL_ACTION EE_ACTIONS::placeBusWireEntry( "eeschema.InteractiveDrawing.placeBusWireEntry", TOOL_ACTION EE_ACTIONS::placeBusWireEntry( "eeschema.InteractiveDrawing.placeBusWireEntry",
AS_GLOBAL, AS_GLOBAL,
'Z', LEGACY_HK_NAME( "Add Wire Entry" ), 'Z', LEGACY_HK_NAME( "Add Wire Entry" ),
_( "Add Wire to Bus Entry" ), _( "Add a wire entry to a bus" ), _( "Add Wire to Bus Entry" ), _( "Add a wire entry to a bus" ),
add_line2bus_xpm, AF_ACTIVATE ); add_line2bus_xpm, AF_ACTIVATE, (void*) SCH_BUS_WIRE_ENTRY_T );
TOOL_ACTION EE_ACTIONS::placeBusBusEntry( "eeschema.InteractiveDrawing.placeBusBusEntry", TOOL_ACTION EE_ACTIONS::placeBusBusEntry( "eeschema.InteractiveDrawing.placeBusBusEntry",
AS_GLOBAL, AS_GLOBAL,
'/', LEGACY_HK_NAME( "Add Bus Entry" ), '/', LEGACY_HK_NAME( "Add Bus Entry" ),
_( "Add Bus to Bus Entry" ), _( "Add a bus entry to a bus" ), _( "Add Bus to Bus Entry" ), _( "Add a bus entry to a bus" ),
add_bus2bus_xpm, AF_ACTIVATE ); add_bus2bus_xpm, AF_ACTIVATE, (void*) SCH_BUS_BUS_ENTRY_T );
TOOL_ACTION EE_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placeLabel", TOOL_ACTION EE_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placeLabel",
AS_GLOBAL, AS_GLOBAL,
'L', LEGACY_HK_NAME( "Add Label" ), 'L', LEGACY_HK_NAME( "Add Label" ),
_( "Add Label" ), _( "Add a net label" ), _( "Add Label" ), _( "Add a net label" ),
add_line_label_xpm, AF_ACTIVATE ); add_line_label_xpm, AF_ACTIVATE, (void*) SCH_LABEL_T );
TOOL_ACTION EE_ACTIONS::placeHierLabel( "eeschema.InteractiveDrawing.placeHierarchicalLabel", TOOL_ACTION EE_ACTIONS::placeHierLabel( "eeschema.InteractiveDrawing.placeHierarchicalLabel",
AS_GLOBAL, AS_GLOBAL,
'H', LEGACY_HK_NAME( "Add Hierarchical Label" ), 'H', LEGACY_HK_NAME( "Add Hierarchical Label" ),
_( "Add Hierarchical Label" ), _( "Add a hierarchical sheet label" ), _( "Add Hierarchical Label" ), _( "Add a hierarchical sheet label" ),
add_hierarchical_label_xpm, AF_ACTIVATE ); add_hierarchical_label_xpm, AF_ACTIVATE, (void*) SCH_HIER_LABEL_T );
TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet", TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet",
AS_GLOBAL, AS_GLOBAL,
'S', LEGACY_HK_NAME( "Add Sheet" ), 'S', LEGACY_HK_NAME( "Add Sheet" ),
_( "Add Sheet" ), _( "Add a hierarchical sheet" ), _( "Add Sheet" ), _( "Add a hierarchical sheet" ),
add_hierarchical_subsheet_xpm, AF_ACTIVATE ); add_hierarchical_subsheet_xpm, AF_ACTIVATE, (void*) SCH_SHEET_T );
TOOL_ACTION EE_ACTIONS::placeSheetPin( "eeschema.InteractiveDrawing.placeSheetPin", TOOL_ACTION EE_ACTIONS::placeSheetPin( "eeschema.InteractiveDrawing.placeSheetPin",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Add Sheet Pin" ), _( "Add a sheet pin" ), _( "Add Sheet Pin" ), _( "Add a sheet pin" ),
add_hierar_pin_xpm, AF_ACTIVATE ); add_hierar_pin_xpm, AF_ACTIVATE, (void*) SCH_SHEET_PIN_T );
TOOL_ACTION EE_ACTIONS::importSheetPin( "eeschema.InteractiveDrawing.importSheetPin", TOOL_ACTION EE_ACTIONS::importSheetPin( "eeschema.InteractiveDrawing.importSheetPin",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ), _( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ),
import_hierarchical_label_xpm, AF_ACTIVATE ); import_hierarchical_label_xpm, AF_ACTIVATE, (void*) SCH_SHEET_PIN_T );
TOOL_ACTION EE_ACTIONS::placeGlobalLabel( "eeschema.InteractiveDrawing.placeGlobalLabel", TOOL_ACTION EE_ACTIONS::placeGlobalLabel( "eeschema.InteractiveDrawing.placeGlobalLabel",
AS_GLOBAL, AS_GLOBAL,
MD_CTRL + 'H', LEGACY_HK_NAME( "Add Global Label" ), MD_CTRL + 'H', LEGACY_HK_NAME( "Add Global Label" ),
_( "Add Global Label" ), _( "Add a global label" ), _( "Add Global Label" ), _( "Add a global label" ),
add_glabel_xpm, AF_ACTIVATE ); add_glabel_xpm, AF_ACTIVATE, (void*) SCH_GLOBAL_LABEL_T );
TOOL_ACTION EE_ACTIONS::placeSchematicText( "eeschema.InteractiveDrawing.placeSchematicText", TOOL_ACTION EE_ACTIONS::placeSchematicText( "eeschema.InteractiveDrawing.placeSchematicText",
AS_GLOBAL, AS_GLOBAL,
'T', LEGACY_HK_NAME( "Add Graphic Text" ), 'T', LEGACY_HK_NAME( "Add Graphic Text" ),
_( "Add Text" ), _( "Add text" ), _( "Add Text" ), _( "Add text" ),
text_xpm, AF_ACTIVATE ); text_xpm, AF_ACTIVATE, (void*) SCH_TEXT_T );
TOOL_ACTION EE_ACTIONS::placeImage( "eeschema.InteractiveDrawing.placeImage", TOOL_ACTION EE_ACTIONS::placeImage( "eeschema.InteractiveDrawing.placeImage",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
@ -428,32 +429,32 @@ TOOL_ACTION EE_ACTIONS::showDeMorganAlternate( "eeschema.InteractiveEdit.showDeM
TOOL_ACTION EE_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash", TOOL_ACTION EE_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Set Bus Entry Shape /" ), _( "Change the bus entry shape to /" ), _( "Set Bus Entry Shape /" ), _( "Change the bus entry shape to /" ),
change_entry_orient_xpm ); change_entry_orient_xpm, AF_NONE, (void*) '/' );
TOOL_ACTION EE_ACTIONS::toShapeBackslash( "eeschema.InteractiveEdit.toShapeBackslash", TOOL_ACTION EE_ACTIONS::toShapeBackslash( "eeschema.InteractiveEdit.toShapeBackslash",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Set Bus Entry Shape \\" ), _( "Change the bus entry shape to \\" ), _( "Set Bus Entry Shape \\" ), _( "Change the bus entry shape to \\" ),
change_entry_orient_xpm ); change_entry_orient_xpm, AF_NONE, (void*) '\\' );
TOOL_ACTION EE_ACTIONS::toLabel( "eeschema.InteractiveEdit.toLabel", TOOL_ACTION EE_ACTIONS::toLabel( "eeschema.InteractiveEdit.toLabel",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Change to Label" ), _( "Change existing item to a label" ), _( "Change to Label" ), _( "Change existing item to a label" ),
add_line_label_xpm ); add_line_label_xpm, AF_NONE, (void*) SCH_LABEL_T );
TOOL_ACTION EE_ACTIONS::toHLabel( "eeschema.InteractiveEdit.toHLabel", TOOL_ACTION EE_ACTIONS::toHLabel( "eeschema.InteractiveEdit.toHLabel",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Change to Hierarchical Label" ), _( "Change existing item to a hierarchical label" ), _( "Change to Hierarchical Label" ), _( "Change existing item to a hierarchical label" ),
add_hierarchical_label_xpm ); add_hierarchical_label_xpm, AF_NONE, (void*) SCH_HIER_LABEL_T );
TOOL_ACTION EE_ACTIONS::toGLabel( "eeschema.InteractiveEdit.toGLabel", TOOL_ACTION EE_ACTIONS::toGLabel( "eeschema.InteractiveEdit.toGLabel",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Change to Global Label" ), _( "Change existing item to a global label" ), _( "Change to Global Label" ), _( "Change existing item to a global label" ),
add_glabel_xpm ); add_glabel_xpm, AF_NONE, (void*) SCH_GLOBAL_LABEL_T );
TOOL_ACTION EE_ACTIONS::toText( "eeschema.InteractiveEdit.toText", TOOL_ACTION EE_ACTIONS::toText( "eeschema.InteractiveEdit.toText",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Change to Text" ), _( "Change existing item to a text comment" ), _( "Change to Text" ), _( "Change existing item to a text comment" ),
text_xpm ); text_xpm, AF_NONE, (void*) SCH_TEXT_T );
TOOL_ACTION EE_ACTIONS::cleanupSheetPins( "eeschema.InteractiveEdit.cleanupSheetPins", TOOL_ACTION EE_ACTIONS::cleanupSheetPins( "eeschema.InteractiveEdit.cleanupSheetPins",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",

View File

@ -250,23 +250,12 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
{ {
KICAD_T type = TYPE_NOT_INIT; KICAD_T type = aEvent.Parameter<KICAD_T>();
// We might be running as the same shape in another co-routine. Make sure that one // We might be running as the same shape in another co-routine. Make sure that one
// gets whacked. // gets whacked.
m_toolMgr->DeactivateTool(); m_toolMgr->DeactivateTool();
if( aEvent.IsAction( &EE_ACTIONS::drawSymbolArc ) )
type = LIB_ARC_T;
else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolCircle ) )
type = LIB_CIRCLE_T;
else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolLines ) )
type = LIB_POLYLINE_T;
else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolRectangle ) )
type = LIB_RECTANGLE_T;
else
wxCHECK_MSG( false, 0, "Unknown action in LIB_DRAWING_TOOLS::DrawShape()" );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->ShowCursor( true ); getViewControls()->ShowCursor( true );

View File

@ -359,11 +359,9 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
{ {
bool immediateMode = aEvent.HasPosition(); bool immediateMode = aEvent.HasPosition();
wxPoint cursorPos; wxPoint cursorPos;
KICAD_T type = TYPE_NOT_INIT; KICAD_T type = aEvent.Parameter<KICAD_T>();
if( aEvent.IsAction( &EE_ACTIONS::placeNoConnect ) ) if( type == SCH_JUNCTION_T )
type = SCH_NO_CONNECT_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeJunction ) )
{ {
if( immediateMode ) if( immediateMode )
{ {
@ -378,19 +376,9 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true ); getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
} }
} }
type = SCH_JUNCTION_T;
} }
else if( aEvent.IsAction( &EE_ACTIONS::placeHierLabel ) )
type = SCH_HIER_LABEL_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeSheetPin ) ) else if( aEvent.IsAction( &EE_ACTIONS::placeSheetPin ) )
type = SCH_SHEET_PIN_T; type = SCH_SHEET_PIN_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeBusWireEntry ) )
type = SCH_BUS_WIRE_ENTRY_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeBusBusEntry ) )
type = SCH_BUS_BUS_ENTRY_T;
else
wxFAIL_MSG( "SingleClickPlace(): unexpected request" );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->ShowCursor( true ); getViewControls()->ShowCursor( true );
@ -476,22 +464,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
{ {
EDA_ITEM* item = nullptr; EDA_ITEM* item = nullptr;
bool immediateMode = aEvent.HasPosition(); bool immediateMode = aEvent.HasPosition();
KICAD_T type = TYPE_NOT_INIT; KICAD_T type = aEvent.Parameter<KICAD_T>();
if( aEvent.IsAction( &EE_ACTIONS::placeLabel ) )
type = SCH_LABEL_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel ) )
type = SCH_GLOBAL_LABEL_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeHierLabel ) )
type = SCH_HIER_LABEL_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeSheetPin ) )
type = SCH_SHEET_PIN_T;
else if( aEvent.IsAction( &EE_ACTIONS::importSheetPin ) )
type = SCH_SHEET_PIN_T;
else if( aEvent.IsAction( &EE_ACTIONS::placeSchematicText ) )
type = SCH_TEXT_T;
else
wxFAIL_MSG( "TwoClickPlace(): unexpected request" );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->ShowCursor( true ); getViewControls()->ShowCursor( true );

View File

@ -1204,14 +1204,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::ChangeShape( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::ChangeShape( const TOOL_EVENT& aEvent )
{ {
EE_SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
char shape; char shape = aEvent.Parameter<char>();
if( aEvent.IsAction( &EE_ACTIONS::toShapeSlash ) )
shape = '/';
else if( aEvent.IsAction( &EE_ACTIONS::toShapeBackslash ) )
shape = '\\';
else
return 0;
for( unsigned int i = 0; i < selection.GetSize(); ++i ) for( unsigned int i = 0; i < selection.GetSize(); ++i )
{ {
@ -1238,20 +1231,9 @@ int SCH_EDIT_TOOL::ChangeShape( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{ {
KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes ); EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
KICAD_T convertTo;
if( aEvent.IsAction( &EE_ACTIONS::toLabel ) )
convertTo = SCH_LABEL_T;
else if( aEvent.IsAction( &EE_ACTIONS::toHLabel ) )
convertTo = SCH_HIER_LABEL_T;
else if( aEvent.IsAction( &EE_ACTIONS::toGLabel ) )
convertTo = SCH_GLOBAL_LABEL_T;
else if( aEvent.IsAction( &EE_ACTIONS::toText ) )
convertTo = SCH_TEXT_T;
else
return 0;
for( unsigned int i = 0; i < selection.GetSize(); ++i ) for( unsigned int i = 0; i < selection.GetSize(); ++i )
{ {

View File

@ -33,7 +33,7 @@
*/ */
enum FRAME_T enum FRAME_T
{ {
FRAME_SCH, FRAME_SCH = 0,
FRAME_SCH_LIB_EDITOR, FRAME_SCH_LIB_EDITOR,
FRAME_SCH_VIEWER, FRAME_SCH_VIEWER,
FRAME_SCH_VIEWER_MODAL, FRAME_SCH_VIEWER_MODAL,

View File

@ -54,6 +54,10 @@ public:
~TOOL_ACTION(); ~TOOL_ACTION();
// TOOL_ACTIONS are singletons; don't be copying them around....
TOOL_ACTION( const TOOL_ACTION& ) = delete;
TOOL_ACTION& operator= ( const TOOL_ACTION& ) = delete;
bool operator==( const TOOL_ACTION& aRhs ) const bool operator==( const TOOL_ACTION& aRhs ) const
{ {
return m_id == aRhs.m_id; return m_id == aRhs.m_id;
@ -168,11 +172,6 @@ protected:
TOOL_ACTION_FLAGS m_flags; TOOL_ACTION_FLAGS m_flags;
void* m_param; // Generic parameter void* m_param; // Generic parameter
private:
// TOOL_ACTIONS are singletons; don't be copying them around....
TOOL_ACTION( const TOOL_ACTION& ) = delete;
TOOL_ACTION& operator= ( const TOOL_ACTION& ) = delete;
}; };
#endif #endif

View File

@ -176,7 +176,7 @@ public:
const std::string Format() const; const std::string Format() const;
TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory = TC_NONE, TOOL_ACTIONS aAction = TA_NONE, TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory = TC_NONE, TOOL_ACTIONS aAction = TA_NONE,
TOOL_ACTION_SCOPE aScope = AS_GLOBAL, void* aParameter = NULL ) : TOOL_ACTION_SCOPE aScope = AS_GLOBAL, void* aParameter = nullptr ) :
m_category( aCategory ), m_category( aCategory ),
m_actions( aAction ), m_actions( aAction ),
m_scope( aScope ), m_scope( aScope ),
@ -192,7 +192,7 @@ public:
} }
TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam, TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam,
TOOL_ACTION_SCOPE aScope = AS_GLOBAL, void* aParameter = nullptr ) : TOOL_ACTION_SCOPE aScope = AS_GLOBAL, void* aParameter = nullptr ) :
m_category( aCategory ), m_category( aCategory ),
m_actions( aAction ), m_actions( aAction ),
m_scope( aScope ), m_scope( aScope ),
@ -392,7 +392,13 @@ public:
template<typename T> template<typename T>
inline T Parameter() const inline T Parameter() const
{ {
return reinterpret_cast<T>( m_param ); // Exhibit #798 on why I love to hate C++
// - reinterpret_cast needs to be used for pointers
// - static_cast must be used for enums
// - templates can't usefully distinguish between pointer and non-pointer types
// Fortunately good old C's cast can be a reinterpret_cast or a static_cast, and
// C99 gave us intptr_t which is guaranteed to be round-trippable with a pointer.
return (T) reinterpret_cast<intptr_t>( m_param );
} }
/** /**

View File

@ -24,6 +24,7 @@
#include <tool/tool_action.h> #include <tool/tool_action.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <tools/kicad_manager_actions.h> #include <tools/kicad_manager_actions.h>
#include <frame_type.h>
// Actions, being statically-defined, require specialized I18N handling. We continue to // Actions, being statically-defined, require specialized I18N handling. We continue to
@ -55,25 +56,25 @@ TOOL_ACTION KICAD_MANAGER_ACTIONS::editSchematic( "kicad.Control.editSchematic",
AS_GLOBAL, AS_GLOBAL,
MD_CTRL + 'E', LEGACY_HK_NAME( "Run Eeschema" ), MD_CTRL + 'E', LEGACY_HK_NAME( "Run Eeschema" ),
_( "Edit Schematic" ), "", _( "Edit Schematic" ), "",
icon_eeschema_xpm ); icon_eeschema_xpm, AF_NONE, (void*) FRAME_SCH );
TOOL_ACTION KICAD_MANAGER_ACTIONS::editSymbols( "kicad.Control.editSymbols", TOOL_ACTION KICAD_MANAGER_ACTIONS::editSymbols( "kicad.Control.editSymbols",
AS_GLOBAL, AS_GLOBAL,
MD_CTRL + 'L', LEGACY_HK_NAME( "Run LibEdit" ), MD_CTRL + 'L', LEGACY_HK_NAME( "Run LibEdit" ),
_( "Edit Schematic Symbols" ), "", _( "Edit Schematic Symbols" ), "",
icon_libedit_xpm ); icon_libedit_xpm, AF_NONE, (void*) FRAME_SCH_LIB_EDITOR );
TOOL_ACTION KICAD_MANAGER_ACTIONS::editPCB( "kicad.Control.editPCB", TOOL_ACTION KICAD_MANAGER_ACTIONS::editPCB( "kicad.Control.editPCB",
AS_GLOBAL, AS_GLOBAL,
MD_CTRL + 'P', LEGACY_HK_NAME( "Run Pcbnew" ), MD_CTRL + 'P', LEGACY_HK_NAME( "Run Pcbnew" ),
_( "Edit PCB" ), "", _( "Edit PCB" ), "",
icon_pcbnew_xpm ); icon_pcbnew_xpm, AF_NONE, (void*) FRAME_PCB );
TOOL_ACTION KICAD_MANAGER_ACTIONS::editFootprints( "kicad.Control.editFootprints", TOOL_ACTION KICAD_MANAGER_ACTIONS::editFootprints( "kicad.Control.editFootprints",
AS_GLOBAL, AS_GLOBAL,
MD_CTRL + 'F', LEGACY_HK_NAME( "Run FpEditor" ), MD_CTRL + 'F', LEGACY_HK_NAME( "Run FpEditor" ),
_( "Edit PCB Footprints" ), "", _( "Edit PCB Footprints" ), "",
icon_modedit_xpm ); icon_modedit_xpm, AF_NONE, (void*) FRAME_PCB_MODULE_EDITOR );
TOOL_ACTION KICAD_MANAGER_ACTIONS::viewGerbers( "kicad.Control.viewGerbers", TOOL_ACTION KICAD_MANAGER_ACTIONS::viewGerbers( "kicad.Control.viewGerbers",
AS_GLOBAL, AS_GLOBAL,

View File

@ -337,19 +337,7 @@ int KICAD_MANAGER_CONTROL::UpdateMenu( const TOOL_EVENT& aEvent )
int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent ) int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
{ {
FRAME_T playerType = FRAME_SCH_VIEWER; FRAME_T playerType = aEvent.Parameter<FRAME_T>();
if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editSchematic ) )
playerType = FRAME_SCH;
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editSymbols ) )
playerType = FRAME_SCH_LIB_EDITOR;
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editPCB ) )
playerType = FRAME_PCB;
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editFootprints ) )
playerType = FRAME_PCB_MODULE_EDITOR;
else
wxFAIL_MSG( "ShowPlayer(): unexpected request" );
KIWAY_PLAYER* player; KIWAY_PLAYER* player;
try try

View File

@ -796,8 +796,8 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
// get a copy instead of reference (as we're going to clear the selection before removing items) // get a copy instead of reference (as we're going to clear the selection before removing items)
PCBNEW_SELECTION selectionCopy; PCBNEW_SELECTION selectionCopy;
bool isCut = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::CUT ); bool isCut = aEvent.Parameter<PCB_ACTIONS::REMOVE_FLAGS>() == PCB_ACTIONS::REMOVE_FLAGS::CUT;
bool isAlt = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::ALT ); bool isAlt = aEvent.Parameter<PCB_ACTIONS::REMOVE_FLAGS>() == PCB_ACTIONS::REMOVE_FLAGS::ALT;
// If we are in a "Cut" operation, then the copied selection exists already // If we are in a "Cut" operation, then the copied selection exists already
if( isCut ) if( isCut )

View File

@ -285,7 +285,7 @@ int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
// Layer control // Layer control
int PCBNEW_CONTROL::LayerSwitch( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::LayerSwitch( const TOOL_EVENT& aEvent )
{ {
m_frame->SwitchLayer( NULL, (PCB_LAYER_ID) aEvent.Parameter<intptr_t>() ); m_frame->SwitchLayer( NULL, aEvent.Parameter<PCB_LAYER_ID>() );
return 0; return 0;
} }