Commit 71956443 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Unify Eeschema edit item commands into a single event handler.

* Create command event handler for editing all schematic and child items.
* Remove unique edit schematic item command IDs.
* Unify find item, undo, and redo hot key commands.
parent 443b4a6f
......@@ -99,23 +99,16 @@ enum id_eeschema_frm
ID_POPUP_SCH_ENTRY_SELECT_SLASH,
ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH,
ID_POPUP_SCH_EDIT_CMP,
ID_POPUP_SCH_INIT_CMP,
ID_POPUP_SCH_EDIT_TEXT,
ID_POPUP_SCH_SET_SHAPE_TEXT,
ID_POPUP_END_LINE,
ID_POPUP_SCH_END_SHEET,
ID_POPUP_SCH_EDIT_SHEET,
ID_POPUP_SCH_RESIZE_SHEET,
ID_POPUP_SCH_CLEANUP_SHEET,
ID_POPUP_SCH_EDIT_SHEET_PIN,
ID_POPUP_IMPORT_GLABEL,
ID_POPUP_SCH_GENERIC_ORIENT_CMP,
ID_POPUP_SCH_GENERIC_EDIT_CMP,
ID_POPUP_SCH_EDIT_VALUE_CMP,
ID_POPUP_SCH_EDIT_REF_CMP,
ID_POPUP_SCH_EDIT_FOOTPRINT_CMP,
ID_POPUP_SCH_EDIT_CONVERT_CMP,
ID_POPUP_SCH_EDIT_FIELD,
ID_POPUP_SCH_DISPLAYDOC_CMP,
......@@ -126,7 +119,6 @@ enum id_eeschema_frm
ID_POPUP_SCH_ADD_GLABEL,
ID_POPUP_SCH_GETINFO_MARKER,
// Edit or change image orientation or context menu command IDs.
ID_POPUP_SCH_EDIT_IMAGE,
ID_POPUP_SCH_MIRROR_X_IMAGE,
ID_POPUP_SCH_MIRROR_Y_IMAGE,
ID_POPUP_END_RANGE,
......@@ -180,7 +172,10 @@ enum id_eeschema_frm
ID_SELECT_ITEM_END = ID_SELECT_ITEM_START + MAX_SELECT_ITEM_IDS,
ID_SCH_ROTATE_ITEM,
ID_SCH_EDIT_ITEM,
ID_SCH_EDIT_COMPONENT_VALUE,
ID_SCH_EDIT_COMPONENT_REFERENCE,
ID_SCH_EDIT_COMPONENT_FOOTPRINT,
ID_POPUP_SCH_MOVE_ITEM,
// Schematic editor commmands. These are command IDs that are generated by multiple
......
......@@ -159,13 +159,13 @@ static EDA_HOTKEY HkMirrorXComponent( wxT( "Mirror X Component" ), HK_MIRROR_X_C
static EDA_HOTKEY HkOrientNormalComponent( wxT( "Orient Normal Component" ),
HK_ORIENT_NORMAL_COMPONENT, 'N' );
static EDA_HOTKEY HkRotate( wxT( "Rotate Item" ), HK_ROTATE, 'R', ID_SCH_ROTATE_ITEM );
static EDA_HOTKEY HkEdit( wxT( "Edit Schematic Item" ), HK_EDIT, 'E' );
static EDA_HOTKEY HkEdit( wxT( "Edit Schematic Item" ), HK_EDIT, 'E', ID_SCH_EDIT_ITEM );
static EDA_HOTKEY HkEditComponentValue( wxT( "Edit Component Value" ),
HK_EDIT_COMPONENT_VALUE, 'V',
ID_POPUP_SCH_EDIT_VALUE_CMP );
ID_SCH_EDIT_COMPONENT_VALUE );
static EDA_HOTKEY HkEditComponentFootprint( wxT( "Edit Component Footprint" ),
HK_EDIT_COMPONENT_FOOTPRINT, 'F',
ID_POPUP_SCH_EDIT_FOOTPRINT_CMP );
ID_SCH_EDIT_COMPONENT_FOOTPRINT );
static EDA_HOTKEY HkMove( wxT( "Move Schematic Item" ),
HK_MOVE_COMPONENT_OR_ITEM, 'M',
ID_POPUP_SCH_MOVE_ITEM );
......@@ -181,7 +181,7 @@ static EDA_HOTKEY HkMove2Drag( wxT( "Move Block -> Drag Block" ),
static EDA_HOTKEY HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
static EDA_HOTKEY HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL );
static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL, ID_FIND_ITEMS );
static EDA_HOTKEY HkFindNextItem( wxT( "Find Next Item" ), HK_FIND_NEXT_ITEM, WXK_F5,
wxEVT_COMMAND_FIND );
static EDA_HOTKEY HkFindNextDrcMarker( wxT( "Find Next DRC Marker" ), HK_FIND_NEXT_DRC_MARKER,
......@@ -352,15 +352,6 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_UNDO:
case HK_REDO:
if( notBusy )
{
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, hotKey->m_IdMenuEvent );
wxPostEvent( this, event );
}
break;
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
HandleBlockEndByPopUp( BLOCK_DRAG, aDC );
break;
......@@ -374,15 +365,18 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_REPEAT_LAST:
if( notBusy && m_itemToRepeat && ( m_itemToRepeat->GetFlags() == 0 ) )
RepeatDrawItem( aDC );
break;
case HK_UNDO:
case HK_REDO:
case HK_FIND_ITEM:
if( notBusy )
{
wxCommandEvent evt;
evt.SetId( ID_FIND_ITEMS );
Process_Special_Functions( evt );
cmd.SetId( hotKey->m_IdMenuEvent );
GetEventHandler()->ProcessEvent( cmd );
}
break;
case HK_FIND_NEXT_ITEM:
......@@ -557,8 +551,11 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break;
case HK_ROTATE: // Component or other schematic item rotation.
case HK_ROTATE: // Rotate schematic item or block.
case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item.
case HK_EDIT: // Edit schematic item.
case HK_EDIT_COMPONENT_VALUE: // Edit component value field.
case HK_EDIT_COMPONENT_FOOTPRINT: // Edit component footprint field.
{
EDA_HOTKEY_CLIENT_DATA data( aPosition );
cmd.SetInt( aHotKey );
......@@ -567,72 +564,6 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
GetEventHandler()->ProcessEvent( cmd );
break;
}
case HK_EDIT:
if( itemInEdit )
break;
if( aItem == NULL )
{
aItem = LocateAndShowItem( aPosition, SCH_COLLECTOR::EditableItems );
if( aItem == NULL )
break;
}
switch( aItem->Type() )
{
case SCH_COMPONENT_T:
EditComponent( (SCH_COMPONENT*) aItem );
break;
case SCH_SHEET_T:
cmd.SetId( ID_POPUP_SCH_EDIT_SHEET );
wxPostEvent( this, cmd );
break;
case SCH_SHEET_PIN_T:
cmd.SetId( ID_POPUP_SCH_EDIT_SHEET_PIN );
wxPostEvent( this, cmd );
break;
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
EditSchematicText( (SCH_TEXT*) aItem );
break;
case SCH_FIELD_T:
EditComponentFieldText( (SCH_FIELD*) aItem, aDC );
break;
case SCH_BITMAP_T:
EditImage( (SCH_BITMAP*) aItem );
break;
default:
;
}
break;
case HK_EDIT_COMPONENT_VALUE:
case HK_EDIT_COMPONENT_FOOTPRINT:
if( itemInEdit )
break;
if( aItem == NULL )
aItem = LocateAndShowItem( aPosition, SCH_COLLECTOR::ComponentsOnly );
if( aItem )
{
cmd.SetId( hotKey->m_IdMenuEvent );
wxPostEvent( this, cmd );
}
break;
}
}
......
......@@ -252,7 +252,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
msg = AddHotkeyName( _( "Rotate Field" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_field_xpm ) );
msg = AddHotkeyName( _( "Edit Field" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_FIELD, msg, KiBitmap( edit_text_xpm ) );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
}
......@@ -300,19 +300,19 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
wxMenu* editmenu = new wxMenu;
msg = AddHotkeyName( _( "Edit" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_CMP, msg, KiBitmap( edit_component_xpm ) );
AddMenuItem( editmenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_component_xpm ) );
if( libComponent && libComponent->IsNormal() )
{
msg = AddHotkeyName( _( "Value " ), s_Schematic_Hokeys_Descr, HK_EDIT_COMPONENT_VALUE );
AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, msg, KiBitmap( edit_comp_value_xpm ) );
AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_VALUE, msg, KiBitmap( edit_comp_value_xpm ) );
AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _( "Reference" ),
AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_REFERENCE, _( "Reference" ),
KiBitmap( edit_comp_ref_xpm ) );
msg = AddHotkeyName( _( "Footprint " ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_FOOTPRINT );
AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, msg,
AddMenuItem( editmenu, ID_SCH_EDIT_COMPONENT_FOOTPRINT, msg,
KiBitmap( edit_comp_footprint_xpm ) );
}
......@@ -348,7 +348,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
KiBitmap( libedit_xpm ) );
}
AddMenuItem( PopMenu, editmenu, ID_POPUP_SCH_GENERIC_EDIT_CMP,
AddMenuItem( PopMenu, editmenu, ID_SCH_EDIT_ITEM,
_( "Edit Component" ), KiBitmap( edit_component_xpm ) );
if( !Component->GetFlags() )
......@@ -386,7 +386,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
msg = AddHotkeyName( _( "Rotate Global Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_glabel_xpm ) );
msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Global Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_text_xpm ) );
......@@ -422,7 +422,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_glabel_xpm ) );
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_text_xpm ) );
......@@ -458,7 +458,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
msg = AddHotkeyName( _( "Rotate Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_ccw_xpm ) );
msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_text_xpm ) );
......@@ -492,7 +492,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
msg = AddHotkeyName( _( "Rotate Text" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
AddMenuItem( PopMenu, ID_SCH_ROTATE_ITEM, msg, KiBitmap( rotate_ccw_xpm ) );
msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, KiBitmap( edit_text_xpm ) );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
msg = AddHotkeyName( _( "Delete Text" ), s_Schematic_Hokeys_Descr, HK_DELETE );
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_text_xpm ) );
......@@ -639,7 +639,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
else
{
msg = AddHotkeyName( _( "Edit Sheet" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_SHEET, msg, KiBitmap( edit_sheet_xpm ) );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_sheet_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ),
KiBitmap( resize_sheet_xpm ) );
......@@ -669,8 +669,7 @@ void AddMenusForSheetPin( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
AddMenuItem( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) );
}
AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_SHEET_PIN, _( "Edit Sheet Pin" ),
KiBitmap( edit_xpm ) );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, _( "Edit Sheet Pin" ), KiBitmap( edit_xpm ) );
if( !PinSheet->GetFlags() )
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet Pin" ),
......@@ -746,7 +745,7 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
if( aBitmap->GetFlags() == 0 )
{
msg = AddHotkeyName( _( "Edit Image" ), s_Schematic_Hokeys_Descr, HK_EDIT );
AddMenuItem( aPopMenu, ID_POPUP_SCH_EDIT_IMAGE, msg, KiBitmap( image_xpm ) );
AddMenuItem( aPopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( image_xpm ) );
aPopMenu->AppendSeparator();
msg = AddHotkeyName( _( "Delete Image" ), s_Schematic_Hokeys_Descr, HK_DELETE );
AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) );
......
......@@ -69,29 +69,20 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
case ID_POPUP_END_LINE:
case ID_POPUP_SCH_EDIT_TEXT:
case ID_POPUP_SCH_SET_SHAPE_TEXT:
case ID_POPUP_SCH_EDIT_SHEET:
case ID_POPUP_SCH_CLEANUP_SHEET:
case ID_POPUP_SCH_END_SHEET:
case ID_POPUP_SCH_RESIZE_SHEET:
case ID_POPUP_IMPORT_GLABEL:
case ID_POPUP_SCH_EDIT_SHEET_PIN:
case ID_POPUP_SCH_DRAG_ITEM_REQUEST:
case ID_POPUP_SCH_EDIT_CMP:
case ID_POPUP_SCH_INIT_CMP:
case ID_POPUP_SCH_DISPLAYDOC_CMP:
case ID_POPUP_SCH_EDIT_VALUE_CMP:
case ID_POPUP_SCH_EDIT_REF_CMP:
case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP:
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
case ID_POPUP_SCH_EDIT_FIELD:
case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_PLACE_BLOCK:
case ID_POPUP_ZOOM_BLOCK:
case ID_POPUP_DRAG_BLOCK:
case ID_POPUP_COPY_BLOCK:
case ID_POPUP_ROTATE_BLOCK:
case ID_POPUP_MIRROR_X_BLOCK:
case ID_POPUP_MIRROR_Y_BLOCK:
case ID_POPUP_SCH_DELETE_NODE:
......@@ -137,6 +128,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case wxID_CUT:
if( screen->m_BlockLocate.m_Command != BLOCK_MOVE )
break;
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
m_itemToRepeat = NULL;
SetSheetNumberAndCount();
......@@ -171,19 +163,11 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
EndSegment( &dc );
break;
case ID_POPUP_SCH_EDIT_TEXT:
EditSchematicText( (SCH_TEXT*) item );
break;
case ID_POPUP_SCH_SET_SHAPE_TEXT:
// Not used
break;
case ID_POPUP_SCH_EDIT_FIELD:
EditComponentFieldText( (SCH_FIELD*) item, &dc );
break;
case ID_POPUP_SCH_DELETE_NODE:
case ID_POPUP_SCH_DELETE_CONNECTION:
DrawPanel->MoveCursorToCrossHair();
......@@ -230,11 +214,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
screen->TestDanglingEnds( DrawPanel, &dc );
break;
case ID_POPUP_SCH_EDIT_SHEET:
if( EditSheet( (SCH_SHEET*) item, &dc ) )
OnModify();
break;
case ID_POPUP_IMPORT_GLABEL:
if( item != NULL && item->Type() == SCH_SHEET_T )
screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
......@@ -263,10 +242,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
break;
case ID_POPUP_SCH_EDIT_SHEET_PIN:
EditSheetPin( (SCH_SHEET_PIN*) item, &dc );
break;
case ID_POPUP_SCH_DRAG_ITEM_REQUEST:
DrawPanel->MoveCursorToCrossHair();
......@@ -284,44 +259,10 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_EDIT_CMP:
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( item && item->Type() == SCH_COMPONENT_T )
EditComponent( (SCH_COMPONENT*) item );
break;
case ID_POPUP_SCH_INIT_CMP:
DrawPanel->MoveCursorToCrossHair();
break;
case ID_POPUP_SCH_EDIT_VALUE_CMP:
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( item != NULL && item->Type() == SCH_COMPONENT_T )
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ), &dc );
break;
case ID_POPUP_SCH_EDIT_REF_CMP:
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
if( item != NULL && item->Type() == SCH_COMPONENT_T )
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ), &dc );
break;
case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP:
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
if( item && item->Type() == SCH_COMPONENT_T )
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ), &dc );
break;
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
......@@ -388,11 +329,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetSheetNumberAndCount();
break;
case ID_POPUP_ROTATE_BLOCK:
DrawPanel->MoveCursorToCrossHair();
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
break;
case ID_POPUP_MIRROR_X_BLOCK:
DrawPanel->MoveCursorToCrossHair();
HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
......@@ -441,11 +377,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_EDIT_IMAGE:
if( item && item->GetFlags() == 0 )
EditImage( (SCH_BITMAP*) item );
break;
case ID_POPUP_SCH_MIRROR_X_IMAGE:
if( item )
MirrorImage( (SCH_BITMAP*) item, true );
......@@ -860,7 +791,96 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
case SCH_SHEET_T: /// @todo allow sheet rotate on hotkey
default:
wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
GetChars( item->GetClass() ) ) );
}
if( item->GetFlags() == 0 )
screen->SetCurItem( NULL );
}
void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
{
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
if( item == NULL )
{
// If we didn't get here by a hot key, then something has gone wrong.
if( aEvent.GetInt() == 0 )
return;
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::EditableItems,
aEvent.GetInt() );
// Exit if no item found at the current location or the item is already being edited.
if( (item == NULL) || (item->GetFlags() != 0) )
return;
}
switch( item->Type() )
{
case SCH_COMPONENT_T:
{
switch( aEvent.GetId() )
{
case ID_SCH_EDIT_COMPONENT_REFERENCE:
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ), &dc );
break;
case ID_SCH_EDIT_COMPONENT_VALUE:
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ), &dc );
break;
case ID_SCH_EDIT_COMPONENT_FOOTPRINT:
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ), &dc );
break;
case ID_SCH_EDIT_ITEM:
EditComponent( (SCH_COMPONENT*) item );
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
aEvent.GetId() ) );
}
break;
}
case SCH_SHEET_T:
EditSheet( (SCH_SHEET*) item, &dc );
break;
case SCH_SHEET_PIN_T:
EditSheetPin( (SCH_SHEET_PIN*) item, &dc );
break;
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
EditSchematicText( (SCH_TEXT*) item );
break;
case SCH_FIELD_T:
EditComponentFieldText( (SCH_FIELD*) item, &dc );
break;
case SCH_BITMAP_T:
EditImage( (SCH_BITMAP*) item );
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
GetChars( item->GetClass() ) ) );
}
if( item->GetFlags() == 0 )
......
......@@ -137,6 +137,8 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_SCH_ROTATE_ITEM, SCH_EDIT_FRAME::OnRotate )
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
SCH_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_SCH_EDIT_ITEM, ID_SCH_EDIT_COMPONENT_FOOTPRINT,
SCH_EDIT_FRAME::OnEditItem )
// Tools and buttons options toolbar
EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
......
/////////////////////////////////////////////////////////////////////////////
// Name: sheet.cpp
// Purpose:
// Author: jean-pierre Charras
// Modified by: Wayne Stambaugh
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright: License GNU
// License:
/////////////////////////////////////////////////////////////////////////////
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sheet.cpp
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -188,6 +206,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
DrawPanel->MoveCursorToCrossHair();
DrawPanel->m_IgnoreMouseEvents = false;
aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
OnModify();
return true;
}
......
......@@ -617,14 +617,24 @@ public:
// General search:
private:
/**
* Function OnMoveItem
* handles the #ID_SCH_MOVE_ITEM event used to move schematic itams.
*/
void OnMoveItem( wxCommandEvent& aEvent );
/**
* Function OnRotate
* handles the #ID_SCH_ROTATE_ITEM event used to rotates schematic itams and blocks.
* handles the #ID_SCH_ROTATE_ITEM event used to rotate schematic itams and blocks.
*/
void OnRotate( wxCommandEvent& aEvent );
/**
* Function OnEditItem
* handles the #ID_SCH_EDIT_ITEM event used to edit schematic itams.
*/
void OnEditItem( 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