2007-09-15 04:25:54 +00:00
|
|
|
/*****************************************/
|
2009-09-04 18:57:37 +00:00
|
|
|
/* EESchema - libedit_onleftclick.cpp */
|
2007-09-15 04:25:54 +00:00
|
|
|
/*****************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Library editor commands created by a mouse left button simple or double click
|
2007-09-15 04:25:54 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* item = m_drawItem;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL ) // No component loaded !
|
2007-09-15 04:25:54 +00:00
|
|
|
return;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
if( item == NULL || item->m_Flags == 0 )
|
2011-02-23 13:48:19 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
item = LocateItemUsingCursor( aPosition );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
if( item )
|
|
|
|
item->DisplayInfo( this );
|
2011-02-23 13:48:19 +00:00
|
|
|
else
|
2011-04-27 19:44:32 +00:00
|
|
|
{
|
2011-02-23 13:48:19 +00:00
|
|
|
DisplayCmpDoc();
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
if( DrawPanel->m_AbortRequest )
|
|
|
|
DrawPanel->m_AbortRequest = false;
|
|
|
|
}
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2011-04-27 19:44:32 +00:00
|
|
|
if( item && item->m_Flags ) // moved object
|
2011-02-25 15:17:07 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
switch( item->Type() )
|
2011-02-25 15:17:07 +00:00
|
|
|
{
|
|
|
|
case LIB_PIN_T:
|
|
|
|
PlacePin( DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2011-02-24 12:35:14 +00:00
|
|
|
case ID_LIBEDIT_PIN_BUTT:
|
|
|
|
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
CreatePin( DC );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlacePin( DC );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
|
|
|
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
m_drawItem = CreateGraphicItem( m_component, DC );
|
|
|
|
}
|
|
|
|
else if( m_drawItem )
|
|
|
|
{
|
|
|
|
if( m_drawItem->IsNew() )
|
|
|
|
GraphicItemBeginDraw( DC );
|
2007-09-15 04:25:54 +00:00
|
|
|
else
|
2011-02-24 12:35:14 +00:00
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
}
|
|
|
|
break;
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2011-02-24 12:35:14 +00:00
|
|
|
case ID_LIBEDIT_DELETE_ITEM_BUTT:
|
2011-02-28 13:53:49 +00:00
|
|
|
m_drawItem = LocateItemUsingCursor( aPosition );
|
|
|
|
|
|
|
|
if( m_drawItem )
|
2011-02-24 22:29:43 +00:00
|
|
|
deleteItem( DC );
|
2011-02-24 12:35:14 +00:00
|
|
|
else
|
2011-02-24 22:29:43 +00:00
|
|
|
DisplayCmpDoc();
|
2011-02-24 12:35:14 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
|
|
|
|
SaveCopyInUndoList( m_component );
|
|
|
|
PlaceAncre();
|
2011-02-24 20:22:12 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-02-24 22:29:43 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Unhandled command ID %d" ), GetToolId() ) );
|
2011-02-24 20:22:12 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/*
|
|
|
|
* Called on a double click:
|
2008-08-11 18:21:21 +00:00
|
|
|
* If an editable item (field, pin, graphic):
|
|
|
|
* Call the suitable dialog editor.
|
2007-09-15 04:25:54 +00:00
|
|
|
*/
|
2011-02-21 13:54:29 +00:00
|
|
|
void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
if( ( m_drawItem == NULL ) || ( m_drawItem->m_Flags == 0 ) )
|
2008-08-11 18:21:21 +00:00
|
|
|
{ // We can locate an item
|
2011-02-24 20:22:12 +00:00
|
|
|
m_drawItem = LocateItemUsingCursor( aPosition );
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetId( ID_LIBEDIT_GET_FRAME_EDIT_PART );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem )
|
|
|
|
m_drawItem->DisplayInfo( this );
|
2007-09-15 04:25:54 +00:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2011-02-24 22:29:43 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
switch( m_drawItem->Type() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_PIN_T:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-10-30 19:26:25 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_ARC_T:
|
|
|
|
case LIB_CIRCLE_T:
|
|
|
|
case LIB_RECTANGLE_T:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditGraphicSymbol( DC, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_POLYLINE_T:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditGraphicSymbol( DC, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
else if( m_drawItem->IsNew() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_TEXT_T:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditSymbolText( DC, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_FIELD_T:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditField( DC, (LIB_FIELD*) m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-02-24 22:29:43 +00:00
|
|
|
wxFAIL_MSG( wxT( "Unhandled item <" ) + m_drawItem->GetClass() + wxT( ">" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-02-24 22:29:43 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|