Commit e21ebb72 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Factor Eeschema place item hot keys into select tool event handler.

parent 8e584fc2
......@@ -130,20 +130,30 @@ static EDA_HOTKEY HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_SHIFT + GR_KB_CTRL + 'Z'
#endif
// Schematic editor
static EDA_HOTKEY HkAddLabel( wxT( "add Label" ), HK_ADD_LABEL, 'L' );
static EDA_HOTKEY HkAddHierarchicalLabel( wxT( "Add Hierarchical Label" ), HK_ADD_HLABEL, 'H' );
static EDA_HOTKEY HkAddGlobalLabel( wxT( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'L' );
static EDA_HOTKEY HkAddJunction( wxT( "Add Junction" ), HK_ADD_JUNCTION, 'J' );
static EDA_HOTKEY HkBeginWire( wxT( "Draw Wire" ), HK_BEGIN_WIRE, 'W' );
static EDA_HOTKEY HkBeginBus( wxT( "Draw Bus" ), HK_BEGIN_BUS, 'B' );
static EDA_HOTKEY HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' );
static EDA_HOTKEY HkAddPower( wxT( "Add Power" ), HK_ADD_NEW_POWER, 'P' );
static EDA_HOTKEY HkAddNoConn( wxT( "Add NoConnected Flag" ), HK_ADD_NOCONN_FLAG, 'Q' );
static EDA_HOTKEY HkAddHierSheet( wxT( "Add Sheet" ), HK_ADD_HIER_SHEET, 'S' );
static EDA_HOTKEY HkAddBusEntry( wxT( "Add Bus Entry" ), HK_ADD_BUS_ENTRY, '/' );
static EDA_HOTKEY HkAddWireEntry( wxT( "Add Wire Entry" ), HK_ADD_WIRE_ENTRY, 'Z' );
static EDA_HOTKEY HkAddGraphicPolyLine( wxT( "Add Graphic PolyLine" ), HK_ADD_GRAPHIC_POLYLINE, 'I' );
static EDA_HOTKEY HkAddGraphicText( wxT( "Add Graphic Text" ), HK_ADD_GRAPHIC_TEXT, 'T' );
static EDA_HOTKEY HkAddLabel( wxT( "Add Label" ), HK_ADD_LABEL, 'L', ID_LABEL_BUTT );
static EDA_HOTKEY HkAddHierarchicalLabel( wxT( "Add Hierarchical Label" ), HK_ADD_HLABEL, 'H',
ID_HIERLABEL_BUTT );
static EDA_HOTKEY HkAddGlobalLabel( wxT( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'L',
ID_GLABEL_BUTT );
static EDA_HOTKEY HkAddJunction( wxT( "Add Junction" ), HK_ADD_JUNCTION, 'J', ID_JUNCTION_BUTT );
static EDA_HOTKEY HkBeginWire( wxT( "Draw Wire" ), HK_BEGIN_WIRE, 'W', ID_WIRE_BUTT );
static EDA_HOTKEY HkBeginBus( wxT( "Draw Bus" ), HK_BEGIN_BUS, 'B', ID_BUS_BUTT );
static EDA_HOTKEY HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A',
ID_SCH_PLACE_COMPONENT );
static EDA_HOTKEY HkAddPower( wxT( "Add Power" ), HK_ADD_NEW_POWER, 'P',
ID_PLACE_POWER_BUTT );
static EDA_HOTKEY HkAddNoConn( wxT( "Add NoConnected Flag" ), HK_ADD_NOCONN_FLAG, 'Q',
ID_NOCONN_BUTT );
static EDA_HOTKEY HkAddHierSheet( wxT( "Add Sheet" ), HK_ADD_HIER_SHEET, 'S',
ID_SHEET_SYMBOL_BUTT );
static EDA_HOTKEY HkAddBusEntry( wxT( "Add Bus Entry" ), HK_ADD_BUS_ENTRY, '/',
ID_BUSTOBUS_ENTRY_BUTT );
static EDA_HOTKEY HkAddWireEntry( wxT( "Add Wire Entry" ), HK_ADD_WIRE_ENTRY, 'Z',
ID_WIRETOBUS_ENTRY_BUTT );
static EDA_HOTKEY HkAddGraphicPolyLine( wxT( "Add Graphic PolyLine" ), HK_ADD_GRAPHIC_POLYLINE,
'I', ID_LINE_COMMENT_BUTT );
static EDA_HOTKEY HkAddGraphicText( wxT( "Add Graphic Text" ), HK_ADD_GRAPHIC_TEXT, 'T',
ID_TEXT_COMMENT_BUTT );
static EDA_HOTKEY HkMirrorYComponent( wxT( "Mirror Y Component" ), HK_MIRROR_Y_COMPONENT, 'Y' );
static EDA_HOTKEY HkMirrorXComponent( wxT( "Mirror X Component" ), HK_MIRROR_X_COMPONENT, 'X' );
static EDA_HOTKEY HkOrientNormalComponent( wxT( "Orient Normal Component" ),
......@@ -397,129 +407,30 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break;
case HK_ADD_NEW_COMPONENT: // Add component
if( !itemInEdit )
{
if( GetToolId() != ID_SCH_PLACE_COMPONENT )
SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add Component" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_NEW_POWER: // Add power component
if( !itemInEdit )
{
if( GetToolId() != ID_PLACE_POWER_BUTT )
SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add Power" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_LABEL:
if( notBusy )
{
if( GetToolId() != ID_LABEL_BUTT )
SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add Label" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_HLABEL:
if( notBusy )
{
if( GetToolId() != ID_HIERLABEL_BUTT )
SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Hierarchical Label" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_GLABEL:
if( notBusy )
{
if( GetToolId() != ID_GLABEL_BUTT )
SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Global Label" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_JUNCTION:
if( notBusy )
{
if( GetToolId() != ID_JUNCTION_BUTT )
SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add Junction" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_WIRE_ENTRY:
if( notBusy )
{
if( GetToolId() != ID_WIRETOBUS_ENTRY_BUTT )
SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Wire to Bus Entry" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_BUS_ENTRY:
if( notBusy )
{
if( GetToolId() != ID_BUSTOBUS_ENTRY_BUTT )
SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Bus to Bus Entry" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_HIER_SHEET:
if( notBusy )
{
if( GetToolId() != ID_SHEET_SYMBOL_BUTT )
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add Sheet" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_GRAPHIC_TEXT:
if( notBusy )
{
if( GetToolId() != ID_TEXT_COMMENT_BUTT )
SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Text" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_GRAPHIC_POLYLINE:
if( notBusy )
{
if( GetToolId() != ID_LINE_COMMENT_BUTT )
SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Lines" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ADD_NOCONN_FLAG: // Add a no connected flag
case HK_BEGIN_BUS:
// An item can be selected. If not a Bus, a begin command is not possible
case HK_BEGIN_WIRE:
if( notBusy )
{
if( GetToolId() != ID_BUS_BUTT )
SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add Bus" ) );
OnLeftClick( aDC, aPosition );
break;
cmd.SetInt( aHotKey );
cmd.SetClientData( new EDA_HOTKEY_CLIENT_DATA( aPosition ) );
cmd.SetId( hotKey->m_IdMenuEvent );
wxPostEvent( this, cmd );
}
if( aItem && aItem->IsNew() && ( GetToolId() == ID_BUS_BUTT ) )
else if( aItem && aItem->IsNew() )
{
if( aItem->Type() == SCH_LINE_T )
// If the item is a bus or a wire, a begin command is not possible.
if( (GetToolId() == ID_BUS_BUTT) && (aItem->Type() == SCH_LINE_T) )
{
SCH_LINE* segment = (SCH_LINE*) aItem;
......@@ -529,24 +440,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
// Bus in progress:
OnLeftClick( aDC, aPosition );
}
}
break;
case HK_BEGIN_WIRE:
// An item can be selected. If not a wire, a begin command is not possible
if( notBusy )
{
if( GetToolId() != ID_WIRE_BUTT )
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) );
OnLeftClick( aDC, aPosition );
break;
}
if( aItem && aItem->IsNew() && ( GetToolId() == ID_WIRE_BUTT ) )
{
if( aItem->Type() == SCH_LINE_T )
else if( (GetToolId() == ID_WIRE_BUTT ) && (aItem->Type() == SCH_LINE_T) )
{
SCH_LINE* segment = (SCH_LINE*) aItem;
......@@ -557,16 +451,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
OnLeftClick( aDC, aPosition );
}
}
break;
case HK_ADD_NOCONN_FLAG: // Add a no connected flag
if( notBusy )
{
if( GetToolId() != ID_NOCONN_BUTT )
SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add \"No Connect\" Flag" ) );
OnLeftClick( aDC, aPosition );
}
break;
case HK_ROTATE: // Component or other schematic item rotation
......
......@@ -666,6 +666,20 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
default:
m_itemToRepeat = NULL;
}
// Simulate left click event if we got here from a hot key.
if( aEvent.GetClientData() != NULL )
{
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientData();
wxPoint pos = data->GetPosition();
aEvent.SetClientData( NULL );
delete data;
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
OnLeftClick( &dc, pos );
}
}
......
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