Commit 1bfe8306 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Minor schematic move item code improvements.

parent 7c87086f
......@@ -63,9 +63,7 @@ enum id_eeschema_frm
ID_POPUP_SCH_DELETE,
ID_POPUP_SCH_BREAK_WIRE,
ID_POPUP_SCH_DELETE_CONNECTION,
ID_POPUP_SCH_MOVE_ITEM_REQUEST,
ID_POPUP_SCH_DELETE_NODE,
ID_POPUP_SCH_MOVE_CMP_REQUEST,
ID_POPUP_SCH_DELETE_CMP,
ID_POPUP_SCH_DRAG_CMP_REQUEST,
ID_POPUP_SCH_DRAG_WIRE_REQUEST,
......@@ -150,6 +148,8 @@ enum id_eeschema_frm
ID_SCH_SELECT_ITEM_START,
ID_SCH_SELECT_ITEM_END = ID_SCH_SELECT_ITEM_START + MAX_SELECT_ITEM_IDS,
ID_POPUP_SCH_MOVE_ITEM,
// Schematic editor commmands. These are command IDs that are generated by multiple
// events (menus, toolbar, context menu, etc.) that result in the same event handler.
ID_CANCEL_CURRENT_COMMAND,
......
......@@ -131,7 +131,7 @@ static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" )
ID_POPUP_SCH_EDIT_FOOTPRINT_CMP );
static Ki_HotkeyInfo HkMove( wxT( "Move Schematic Item" ),
HK_MOVE_COMPONENT_OR_ITEM, 'M',
ID_POPUP_SCH_MOVE_CMP_REQUEST );
ID_POPUP_SCH_MOVE_ITEM );
static Ki_HotkeyInfo HkCopyComponentOrText( wxT( "Copy Component or Label" ),
HK_COPY_COMPONENT_OR_LABEL, 'C',
......@@ -754,7 +754,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
*/
if( ((SCH_ITEM*) aItem )->GetLayer() != LAYER_BUS )
{
cmd.SetId( ID_POPUP_SCH_MOVE_ITEM_REQUEST );
cmd.SetId( ID_POPUP_SCH_MOVE_ITEM );
wxPostEvent( this, cmd );
}
......
......@@ -126,7 +126,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{
wxString msg = AddHotkeyName( _( "Move Bus Entry" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_xpm );
}
if( GetBusEntryShape( (SCH_BUS_ENTRY*) item ) == '\\' )
......@@ -210,7 +210,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
{
msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_text_xpm );
}
msg = AddHotkeyName( _( "Rotate Field" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
......@@ -242,7 +242,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
msg = _( "Move Component" );
msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text;
msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, msg, move_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_xpm );
msg = AddHotkeyName( _( "Drag Component" ), s_Schematic_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_xpm );
}
......@@ -326,7 +326,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
{
msg = AddHotkeyName( _( "Move Global Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_text_xpm );
msg = AddHotkeyName( _( "Drag Global Label" ), s_Schematic_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_text_xpm );
......@@ -363,7 +363,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
{
msg = AddHotkeyName( _( "Move Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_text_xpm );
msg = AddHotkeyName( _( "Drag Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_text_xpm );
......@@ -399,7 +399,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
{
msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_text_xpm );
msg = AddHotkeyName( _( "Drag Label" ), s_Schematic_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_text_xpm );
......@@ -435,7 +435,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
{
msg = AddHotkeyName( _( "Move Text" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_text_xpm );
msg = AddHotkeyName( _( "Copy Text" ), s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
......@@ -568,7 +568,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
PopMenu->AppendSeparator();
msg = AddHotkeyName( _( "Move Sheet" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_sheet_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, move_sheet_xpm );
msg = AddHotkeyName( _( "Drag Sheet" ), s_Schematic_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_sheet_xpm );
......
......@@ -55,8 +55,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_IMPORT_GLABEL:
case ID_POPUP_SCH_EDIT_SHEET_PIN:
case ID_POPUP_SCH_MOVE_SHEET_PIN:
case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST:
case ID_POPUP_SCH_DRAG_CMP_REQUEST:
case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
case ID_POPUP_SCH_EDIT_CMP:
......@@ -263,13 +261,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_DRAG_CMP_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST:
case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
DrawPanel->MoveCursorToCrossHair();
if( (id == ID_POPUP_SCH_DRAG_CMP_REQUEST) || (id == ID_POPUP_SCH_DRAG_WIRE_REQUEST) )
{
// The easiest way to handle a drag component or sheet command
// is to simulate a block drag command
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
......@@ -281,9 +275,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
screen->m_BlockLocate.Inflate( 1 );
HandleBlockEnd( &dc );
}
}
else
Process_Move_Item( item, &dc );
break;
......@@ -456,56 +447,62 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC )
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
{
if( DrawStruct == NULL )
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
if( item == NULL )
return;
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
DrawPanel->MoveCursorToCrossHair();
switch( DrawStruct->Type() )
switch( item->Type() )
{
case SCH_JUNCTION_T:
break;
case SCH_BUS_ENTRY_T:
StartMoveBusEntry( (SCH_BUS_ENTRY*) DrawStruct, DC );
StartMoveBusEntry( (SCH_BUS_ENTRY*) item, &dc );
break;
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
MoveText( (SCH_TEXT*) DrawStruct, DC );
MoveText( (SCH_TEXT*) item, &dc );
break;
case SCH_COMPONENT_T:
StartMovePart( (SCH_COMPONENT*) DrawStruct, DC );
StartMovePart( (SCH_COMPONENT*) item, &dc );
break;
case SCH_LINE_T:
break;
case SCH_SHEET_T:
StartMoveSheet( (SCH_SHEET*) DrawStruct, DC );
StartMoveSheet( (SCH_SHEET*) item, &dc );
break;
case SCH_NO_CONNECT_T:
break;
case SCH_FIELD_T:
MoveField( (SCH_FIELD*) DrawStruct, DC );
MoveField( (SCH_FIELD*) item, &dc );
break;
case SCH_MARKER_T:
case SCH_SHEET_PIN_T:
default:
wxString msg;
msg.Printf( wxT( "SCH_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ),
DrawStruct->Type() );
DisplayError( this, msg );
wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ),
GetChars( item->GetClass() ) ) );
break;
}
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_itemToRepeat = NULL;
}
......
......@@ -98,6 +98,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_GET_TOOLS, SCH_EDIT_FRAME::OnCreateBillOfMaterials )
EVT_TOOL( ID_FIND_ITEMS, SCH_EDIT_FRAME::OnFindItems )
EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadStuffFile )
EVT_TOOL( ID_POPUP_SCH_MOVE_ITEM, SCH_EDIT_FRAME::OnMoveItem )
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
......
......@@ -430,7 +430,7 @@ public:
// General search:
private:
void Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC );
void OnMoveItem( wxCommandEvent& aEvent );
void OnExit( wxCommandEvent& event );
void OnAnnotate( wxCommandEvent& event );
void OnErc( wxCommandEvent& event );
......
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