2007-08-30 08:15:05 +00:00
|
|
|
/***************/
|
|
|
|
/* hotkeys.cpp */
|
|
|
|
/***************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
|
|
|
#include "hotkeys.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "libeditfrm.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* How to add a new hotkey:
|
2009-02-25 20:54:49 +00:00
|
|
|
* add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION (see
|
|
|
|
* hotkeys.h).
|
|
|
|
* add a new Ki_HotkeyInfo entry like:
|
|
|
|
* static Ki_HotkeyInfo HkMyNewEntry(wxT("Command Label"), MY_NEW_ID_FUNCTION,
|
|
|
|
* default key value);
|
|
|
|
* wxT("Command Label") is the name used in hotkey list display, and the
|
|
|
|
* identifier in the hotkey list file
|
|
|
|
* MY_NEW_ID_FUNCTION is an equivalent id function used in the switch in
|
|
|
|
* OnHotKey() function.
|
|
|
|
* default key value is the default hotkey for this command. Can be overridden
|
|
|
|
* by the user hotkey list file
|
|
|
|
* add the HkMyNewEntry pointer in the s_Schematic_Hotkey_List list or the
|
|
|
|
* s_LibEdit_Hotkey_List list or s_Common_Hotkey_List if the same command is
|
|
|
|
* added both in eeschema and libedit)
|
|
|
|
* Add the new code in the switch in OnHotKey() function.
|
|
|
|
* when the variable ItemInEdit is true, an item is currently edited.
|
|
|
|
* This can be usefull if the new function cannot be executed while an item is
|
|
|
|
* currently being edited
|
|
|
|
* ( For example, one cannot start a new wire when a component is moving.)
|
|
|
|
*
|
|
|
|
* Note: If an hotkey is a special key be sure the corresponding wxWidget
|
|
|
|
* keycode (WXK_XXXX) is handled in the hotkey_name_descr
|
|
|
|
* s_Hotkey_Name_List list (see hotkeys_basic.cpp) and see this list
|
|
|
|
* for some ascii keys (space ...)
|
2007-08-30 08:15:05 +00:00
|
|
|
*
|
2007-09-19 15:29:50 +00:00
|
|
|
* Key modifier are: GR_KB_CTRL GR_KB_ALT
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2007-08-10 18:05:42 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-08-10 18:05:42 +00:00
|
|
|
/* local variables */
|
|
|
|
/* Hotkey list: */
|
2007-09-10 04:51:01 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
// Common commands
|
2009-09-27 14:09:26 +00:00
|
|
|
static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO,
|
|
|
|
WXK_HOME );
|
2009-02-25 20:54:49 +00:00
|
|
|
static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER,
|
|
|
|
WXK_F4 );
|
|
|
|
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW,
|
|
|
|
WXK_F3 );
|
|
|
|
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
|
|
|
|
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
|
|
|
|
static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
|
|
|
|
static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ),
|
|
|
|
HK_RESET_LOCAL_COORD, ' ' );
|
|
|
|
static Ki_HotkeyInfo HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z',
|
|
|
|
(int) ID_SCHEMATIC_UNDO );
|
|
|
|
static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y',
|
|
|
|
(int) ID_SCHEMATIC_REDO );
|
2007-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
// Schematic editor
|
2009-02-25 20:54:49 +00:00
|
|
|
static Ki_HotkeyInfo HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' );
|
|
|
|
static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ),
|
|
|
|
HK_ADD_NEW_COMPONENT, 'A' );
|
|
|
|
static Ki_HotkeyInfo HkMirrorYComponent( wxT( "Mirror Y Component" ),
|
|
|
|
HK_MIRROR_Y_COMPONENT, 'Y' );
|
|
|
|
static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ),
|
|
|
|
HK_MIRROR_X_COMPONENT, 'X' );
|
|
|
|
static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ),
|
|
|
|
HK_ORIENT_NORMAL_COMPONENT, 'N' );
|
|
|
|
static Ki_HotkeyInfo HkRotateComponent( wxT( "Rotate Component" ),
|
|
|
|
HK_ROTATE_COMPONENT, 'R' );
|
2009-10-16 10:44:44 +00:00
|
|
|
static Ki_HotkeyInfo HkEditComponent( wxT( "Edit Component" ),
|
|
|
|
HK_EDIT_COMPONENT, 'E' );
|
2009-02-25 20:54:49 +00:00
|
|
|
static Ki_HotkeyInfo HkEditComponentValue( wxT( "Edit Component Value" ),
|
|
|
|
HK_EDIT_COMPONENT_VALUE, 'V' );
|
|
|
|
static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" ),
|
|
|
|
HK_EDIT_COMPONENT_FOOTPRINT,
|
|
|
|
'F' );
|
|
|
|
static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component" ),
|
|
|
|
HK_MOVE_COMPONENT, 'M',
|
|
|
|
ID_POPUP_SCH_MOVE_CMP_REQUEST );
|
|
|
|
static Ki_HotkeyInfo HkDragComponent( wxT( "Drag Component" ),
|
|
|
|
HK_DRAG_COMPONENT, 'G',
|
|
|
|
ID_POPUP_SCH_DRAG_CMP_REQUEST );
|
|
|
|
static Ki_HotkeyInfo HkMove2Drag( wxT( "Switch move block to drag block" ),
|
|
|
|
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' );
|
|
|
|
static Ki_HotkeyInfo HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST,
|
|
|
|
WXK_INSERT );
|
|
|
|
static Ki_HotkeyInfo HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
|
|
|
|
static Ki_HotkeyInfo HkNextSearch( wxT( "Next Search" ), HK_NEXT_SEARCH,
|
|
|
|
WXK_F5 );
|
2007-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
// Library editor:
|
2009-02-25 20:54:49 +00:00
|
|
|
static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST,
|
|
|
|
WXK_INSERT );
|
|
|
|
static Ki_HotkeyInfo HkEditPin( wxT( "Edit Pin" ), HK_EDIT_PIN, 'E' );
|
|
|
|
static Ki_HotkeyInfo HkMovePin( wxT( "Move Pin" ), HK_MOVE_PIN, 'M' );
|
|
|
|
static Ki_HotkeyInfo HkDeletePin( wxT( "Delete Pin" ), HK_DELETE_PIN,
|
|
|
|
WXK_DELETE );
|
2007-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
// List of common hotkey descriptors
|
|
|
|
Ki_HotkeyInfo* s_Common_Hotkey_List[] =
|
|
|
|
{
|
|
|
|
&HkHelp,
|
2009-02-25 20:54:49 +00:00
|
|
|
&HkZoomIn, &HkZoomOut, &HkZoomRedraw,
|
2009-09-27 14:09:26 +00:00
|
|
|
&HkZoomCenter, &HkZoomAuto,
|
2007-09-06 11:52:26 +00:00
|
|
|
&HkResetLocalCoord,
|
2009-02-25 20:54:49 +00:00
|
|
|
&HkUndo, &HkRedo,
|
2007-09-06 11:52:26 +00:00
|
|
|
NULL
|
|
|
|
};
|
2007-08-10 18:05:42 +00:00
|
|
|
|
|
|
|
// List of hotkey descriptors for schematic
|
2009-02-25 20:54:49 +00:00
|
|
|
Ki_HotkeyInfo* s_Schematic_Hotkey_List[] =
|
|
|
|
{
|
2007-09-06 11:52:26 +00:00
|
|
|
&HkNextSearch,
|
2009-02-25 20:54:49 +00:00
|
|
|
&HkDelete, &HkInsert, &HkMove2Drag,
|
|
|
|
&HkMoveComponent, &HkDragComponent, &HkAddComponent,
|
|
|
|
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent,
|
|
|
|
&HkOrientNormalComponent,
|
2009-10-16 10:44:44 +00:00
|
|
|
&HkEditComponent,&HkEditComponentValue,&HkEditComponentFootprint,
|
2007-08-30 08:15:05 +00:00
|
|
|
&HkBeginWire,
|
|
|
|
NULL
|
2007-08-10 18:05:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// List of hotkey descriptors for libray editor
|
2007-08-30 08:15:05 +00:00
|
|
|
Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] =
|
2007-08-10 18:05:42 +00:00
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
&HkInsertPin,
|
2008-03-20 01:50:21 +00:00
|
|
|
&HkEditPin,
|
|
|
|
&HkMovePin,
|
|
|
|
&HkDeletePin,
|
2007-08-30 08:15:05 +00:00
|
|
|
NULL
|
2007-08-10 18:05:42 +00:00
|
|
|
};
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
// list of sections and corresponding hotkey list for eeschema (used to create
|
|
|
|
// an hotkey config file)
|
2007-09-10 04:51:01 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor s_Eeschema_Hokeys_Descr[] =
|
|
|
|
{
|
2009-02-25 20:54:49 +00:00
|
|
|
{ &g_CommonSectionTag, s_Common_Hotkey_List, "Common keys" },
|
2007-09-10 04:51:01 +00:00
|
|
|
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, "Schematic editor keys" },
|
2009-02-25 20:54:49 +00:00
|
|
|
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, "library editor keys" },
|
|
|
|
{ NULL, NULL, NULL }
|
2007-09-06 11:52:26 +00:00
|
|
|
};
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
// list of sections and corresponding hotkey list for the schematic editor
|
|
|
|
// (used to list current hotkeys)
|
2007-09-10 04:51:01 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor s_Schematic_Hokeys_Descr[] =
|
|
|
|
{
|
|
|
|
{ &g_CommonSectionTag, s_Common_Hotkey_List, NULL },
|
|
|
|
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, NULL },
|
2009-02-25 20:54:49 +00:00
|
|
|
{ NULL, NULL, NULL }
|
2007-09-06 11:52:26 +00:00
|
|
|
};
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
// list of sections and corresponding hotkey list for the component editor
|
|
|
|
// (used to list current hotkeys)
|
2007-09-10 04:51:01 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor s_Libedit_Hokeys_Descr[] =
|
|
|
|
{
|
|
|
|
{ &g_CommonSectionTag, s_Common_Hotkey_List, NULL },
|
|
|
|
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, NULL },
|
2009-02-25 20:54:49 +00:00
|
|
|
{ NULL, NULL, NULL }
|
2007-09-06 11:52:26 +00:00
|
|
|
};
|
|
|
|
|
2009-09-27 14:09:26 +00:00
|
|
|
// list of sections and corresponding hotkey list for the component browser
|
|
|
|
// (used to list current hotkeys)
|
|
|
|
struct Ki_HotkeyInfoSectionDescriptor s_Viewlib_Hokeys_Descr[] =
|
|
|
|
{
|
|
|
|
{ &g_CommonSectionTag, s_Common_Hotkey_List, NULL },
|
|
|
|
{ NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
/*
|
|
|
|
* Hot keys. Some commands are relative to the item under the mouse cursor
|
|
|
|
* Commands are case insensitive
|
|
|
|
*/
|
2007-08-30 08:15:05 +00:00
|
|
|
void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
|
|
|
|
EDA_BaseStruct* DrawStruct )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-01-07 15:59:49 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
2009-02-25 20:54:49 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
bool ItemInEdit = GetScreen()->GetCurItem()
|
2009-02-25 20:54:49 +00:00
|
|
|
&& GetScreen()->GetCurItem()->m_Flags;
|
|
|
|
bool RefreshToolBar = FALSE;
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
if( hotkey == 0 )
|
|
|
|
return;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
wxPoint MousePos = GetScreen()->m_MousePosition;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to
|
|
|
|
// handle...)
|
2007-08-30 08:15:05 +00:00
|
|
|
if( (hotkey & GR_KB_CTRL) != 0 )
|
|
|
|
hotkey += 'A' - 1;
|
2009-02-25 20:54:49 +00:00
|
|
|
/* Convert lower to upper case (the usual toupper function has problem
|
|
|
|
* with non ascii codes like function keys */
|
2007-08-30 08:15:05 +00:00
|
|
|
if( (hotkey >= 'a') && (hotkey <= 'z') )
|
|
|
|
hotkey += 'A' - 'a';
|
|
|
|
|
|
|
|
// Search command from key :
|
2009-02-25 20:54:49 +00:00
|
|
|
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey,
|
|
|
|
s_Common_Hotkey_List );
|
2007-09-22 14:31:20 +00:00
|
|
|
if( HK_Descr == NULL )
|
|
|
|
HK_Descr = GetDescriptorFromHotkey( hotkey, s_Schematic_Hotkey_List );
|
2009-02-25 20:54:49 +00:00
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
switch( HK_Descr->m_Idcommand )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
2007-09-06 11:52:26 +00:00
|
|
|
DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RESET_LOCAL_COORD: /* Reset the relative coord */
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_POPUP_ZOOM_IN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_POPUP_ZOOM_OUT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_CENTER:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_POPUP_ZOOM_CENTER );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-27 14:09:26 +00:00
|
|
|
case HK_ZOOM_AUTO:
|
|
|
|
cmd.SetId( ID_ZOOM_PAGE );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
case HK_UNDO:
|
|
|
|
case HK_REDO:
|
2009-02-25 20:54:49 +00:00
|
|
|
if( !ItemInEdit )
|
|
|
|
{
|
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
|
|
|
|
HK_Descr->m_IdMenuEvent );
|
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
2007-09-22 14:31:20 +00:00
|
|
|
break;
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
|
2007-08-30 08:15:05 +00:00
|
|
|
HandleBlockEndByPopUp( BLOCK_DRAG, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DELETE:
|
2009-07-25 04:53:39 +00:00
|
|
|
if( !ItemInEdit && screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
|
2009-02-25 20:54:49 +00:00
|
|
|
{
|
|
|
|
RefreshToolBar = LocateAndDeleteItem( this, DC );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_REPEAT_LAST:
|
2009-02-25 20:54:49 +00:00
|
|
|
if( !ItemInEdit && g_ItemToRepeat && ( g_ItemToRepeat->m_Flags == 0 ) )
|
2007-08-30 08:15:05 +00:00
|
|
|
RepeatDrawItem( DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_NEXT_SEARCH:
|
2009-02-25 20:54:49 +00:00
|
|
|
if( !ItemInEdit )
|
|
|
|
{
|
|
|
|
if( g_LastSearchIsMarker )
|
|
|
|
WinEDA_SchematicFrame::FindMarker( 1 );
|
|
|
|
else
|
|
|
|
FindSchematicItem( wxEmptyString, 2 );
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ADD_NEW_COMPONENT: // Add component
|
2009-02-25 20:54:49 +00:00
|
|
|
if( !ItemInEdit )
|
|
|
|
{
|
|
|
|
// switch to m_ID_current_state = ID_COMPONENT_BUTT;
|
|
|
|
if( m_ID_current_state != ID_COMPONENT_BUTT )
|
|
|
|
SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL,
|
|
|
|
_( "Add Component" ) );
|
|
|
|
OnLeftClick( DC, MousePos );
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
case HK_BEGIN_WIRE:
|
|
|
|
/* An item is selected. If edited and not a wire, a new command is not
|
|
|
|
* possible */
|
2009-07-25 04:53:39 +00:00
|
|
|
if( !ItemInEdit && screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2009-02-25 20:54:49 +00:00
|
|
|
if( DrawStruct && DrawStruct->m_Flags )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2009-02-25 20:54:49 +00:00
|
|
|
EDA_DrawLineStruct* segment =
|
|
|
|
(EDA_DrawLineStruct*) DrawStruct;
|
2008-04-14 19:22:48 +00:00
|
|
|
if( segment->GetLayer() != LAYER_WIRE )
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
// switch to m_ID_current_state = ID_WIRE_BUTT;
|
|
|
|
if( m_ID_current_state != ID_WIRE_BUTT )
|
|
|
|
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) );
|
|
|
|
OnLeftClick( DC, MousePos );
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ROTATE_COMPONENT: // Component Rotation
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
{
|
|
|
|
DrawStruct = PickStruct( GetScreen()->m_Curseur,
|
2009-02-25 20:54:49 +00:00
|
|
|
GetScreen(), LIBITEM | TEXTITEM |
|
|
|
|
LABELITEM );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawStruct->Type() )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
|
2007-08-30 08:15:05 +00:00
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC,
|
|
|
|
CMP_ROTATE_COUNTERCLOCKWISE );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
|
2007-08-30 08:15:05 +00:00
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
ChangeTextOrient( (SCH_TEXT*) DrawStruct, DC );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
|
|
|
|
if( DrawStruct == NULL )
|
2009-02-25 20:54:49 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*) GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
|
2007-08-30 08:15:05 +00:00
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
2008-04-14 19:22:48 +00:00
|
|
|
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_Y );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
|
|
|
|
if( DrawStruct == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
|
2007-08-30 08:15:05 +00:00
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
2009-02-25 20:54:49 +00:00
|
|
|
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_MIROIR_X );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
|
|
|
|
if( DrawStruct == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
|
2007-08-30 08:15:05 +00:00
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
2008-04-14 19:22:48 +00:00
|
|
|
CmpRotationMiroir( (SCH_COMPONENT*) DrawStruct, DC, CMP_NORMAL );
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
case HK_DRAG_COMPONENT: // Start drag Component
|
|
|
|
case HK_MOVE_COMPONENT: // Start move Component
|
|
|
|
if( ItemInEdit )
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
2009-10-16 10:44:44 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct == NULL )
|
|
|
|
{
|
2009-10-16 10:44:44 +00:00
|
|
|
DrawStruct = PickStruct( GetScreen()->m_Curseur,
|
|
|
|
GetScreen(), LIBITEM | TEXTITEM |
|
|
|
|
LABELITEM );
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
|
|
|
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
|
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch( DrawStruct->Type() )
|
|
|
|
{
|
|
|
|
case TYPE_SCH_COMPONENT:
|
|
|
|
if( DrawStruct && (DrawStruct->m_Flags ==0) )
|
|
|
|
{
|
|
|
|
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct );
|
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
|
2009-02-25 20:54:49 +00:00
|
|
|
HK_Descr->m_IdMenuEvent );
|
2009-10-16 10:44:44 +00:00
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
|
|
|
break;
|
2007-09-22 14:31:20 +00:00
|
|
|
|
2009-10-16 10:44:44 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) DrawStruct, UR_CHANGED );
|
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
|
|
|
StartMoveTexte( (SCH_TEXT*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_EDIT_COMPONENT:
|
|
|
|
|
|
|
|
if( ItemInEdit )
|
|
|
|
break;
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
{
|
|
|
|
DrawStruct = PickStruct( GetScreen()->m_Curseur,
|
|
|
|
GetScreen(), LIBITEM | TEXTITEM |
|
|
|
|
LABELITEM );
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
|
|
|
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
|
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( DrawStruct->Type() )
|
|
|
|
{
|
|
|
|
case TYPE_SCH_COMPONENT:
|
|
|
|
InstallCmpeditFrame( this, MousePos,(SCH_COMPONENT*) DrawStruct );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
EditSchematicText( (SCH_TEXT*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-02-25 20:54:49 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case HK_EDIT_COMPONENT_VALUE:
|
|
|
|
if( ItemInEdit )
|
2007-12-11 16:41:43 +00:00
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DrawStruct == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
2009-02-25 20:54:49 +00:00
|
|
|
if( DrawStruct )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2009-02-25 20:54:49 +00:00
|
|
|
EditComponentValue( (SCH_COMPONENT*) DrawStruct, DC );
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_EDIT_COMPONENT_FOOTPRINT:
|
|
|
|
if( ItemInEdit )
|
2007-12-11 16:41:43 +00:00
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DrawStruct == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
2009-02-25 20:54:49 +00:00
|
|
|
if( DrawStruct )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2009-02-25 20:54:49 +00:00
|
|
|
EditComponentFootprint( (SCH_COMPONENT*) DrawStruct, DC );
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
2007-12-11 16:41:43 +00:00
|
|
|
break;
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( RefreshToolBar )
|
|
|
|
SetToolbars();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-08-10 18:05:42 +00:00
|
|
|
|
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
/*
|
|
|
|
* Hot keys for the component editor. Some commands are relatives to the item
|
|
|
|
* under the mouse cursor
|
|
|
|
* Commands are case insensitive
|
|
|
|
*/
|
2007-08-30 08:15:05 +00:00
|
|
|
void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
|
|
|
|
EDA_BaseStruct* DrawStruct )
|
2007-08-10 18:05:42 +00:00
|
|
|
{
|
2009-01-07 15:59:49 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
2009-02-25 20:54:49 +00:00
|
|
|
wxCommandEvent toolCmd( wxEVT_COMMAND_TOOL_CLICKED );
|
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
wxPoint MousePos = GetScreen()->m_MousePosition;
|
2008-03-20 01:50:21 +00:00
|
|
|
bool ItemInEdit = GetScreen()->GetCurItem()
|
2009-02-25 20:54:49 +00:00
|
|
|
&& GetScreen()->GetCurItem()->m_Flags;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
if( hotkey == 0 )
|
|
|
|
return;
|
2007-08-20 10:55:09 +00:00
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to
|
|
|
|
// handle...)
|
2007-09-19 15:29:50 +00:00
|
|
|
if( (hotkey & GR_KB_CTRL) != 0 )
|
|
|
|
hotkey += 'A' - 1;
|
2009-02-25 20:54:49 +00:00
|
|
|
|
|
|
|
/* Convert lower to upper case (the usual toupper function has problem
|
|
|
|
* with non ascii codes like function keys */
|
2007-08-30 08:15:05 +00:00
|
|
|
if( (hotkey >= 'a') && (hotkey <= 'z') )
|
|
|
|
hotkey += 'A' - 'a';
|
2009-02-25 20:54:49 +00:00
|
|
|
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey,
|
|
|
|
s_Common_Hotkey_List );
|
2007-09-22 14:31:20 +00:00
|
|
|
if( HK_Descr == NULL )
|
|
|
|
HK_Descr = GetDescriptorFromHotkey( hotkey, s_LibEdit_Hotkey_List );
|
2009-02-25 20:54:49 +00:00
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
2007-08-20 10:55:09 +00:00
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
switch( HK_Descr->m_Idcommand )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
2007-09-06 11:52:26 +00:00
|
|
|
DisplayHotkeyList( this, s_Libedit_Hokeys_Descr );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RESET_LOCAL_COORD: /* Reset the relative coord */
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_POPUP_ZOOM_IN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_POPUP_ZOOM_OUT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_CENTER:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_POPUP_ZOOM_CENTER );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-27 14:09:26 +00:00
|
|
|
case HK_ZOOM_AUTO:
|
|
|
|
cmd.SetId( ID_ZOOM_PAGE );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
case HK_UNDO:
|
2009-02-25 20:54:49 +00:00
|
|
|
if( !ItemInEdit )
|
|
|
|
{
|
|
|
|
toolCmd.SetId( ID_LIBEDIT_UNDO );
|
|
|
|
GetEventHandler()->ProcessEvent( toolCmd );
|
|
|
|
}
|
|
|
|
break;
|
2007-09-22 14:31:20 +00:00
|
|
|
|
2009-02-25 20:54:49 +00:00
|
|
|
case HK_REDO:
|
|
|
|
if( !ItemInEdit )
|
|
|
|
{
|
|
|
|
toolCmd.SetId( ID_LIBEDIT_REDO );
|
|
|
|
GetEventHandler()->ProcessEvent( toolCmd );
|
|
|
|
}
|
2007-09-22 14:31:20 +00:00
|
|
|
break;
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
case HK_REPEAT_LAST:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0)
|
|
|
|
&& (m_lastDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE) )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
RepeatPinItem( DC, (LIB_PIN*) m_lastDrawItem );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
wxBell();
|
|
|
|
break;
|
2009-02-25 20:54:49 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case HK_EDIT_PIN:
|
2009-09-29 18:38:21 +00:00
|
|
|
m_drawItem = LocateItemUsingCursor();
|
|
|
|
|
|
|
|
if( m_drawItem && m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
InstallPineditFrame( this, DC, MousePos );
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
break;
|
2009-02-25 20:54:49 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case HK_DELETE_PIN:
|
2009-09-29 18:38:21 +00:00
|
|
|
m_drawItem = LocateItemUsingCursor();
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
2009-02-25 20:54:49 +00:00
|
|
|
evt.SetId( ID_POPUP_LIBEDIT_DELETE_ITEM );
|
|
|
|
Process_Special_Functions( evt );
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-02-25 20:54:49 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case HK_MOVE_PIN:
|
2009-09-29 18:38:21 +00:00
|
|
|
m_drawItem = LocateItemUsingCursor();
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
2009-02-25 20:54:49 +00:00
|
|
|
evt.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST );
|
|
|
|
Process_Special_Functions( evt );
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-08-10 18:05:42 +00:00
|
|
|
}
|