2007-08-30 08:15:05 +00:00
|
|
|
/***************/
|
|
|
|
/* hotkeys.cpp */
|
|
|
|
/***************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
#include "hotkeys.h"
|
2007-08-20 10:55:09 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
/* How to add a new hotkey:
|
|
|
|
* 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);
|
|
|
|
* "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 overrided by the user hotkey list file
|
2007-09-06 11:52:26 +00:00
|
|
|
* 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)
|
2007-08-30 08:15:05 +00:00
|
|
|
* Add the new code in the switch in OnHotKey() function.
|
2007-09-22 14:31:20 +00:00
|
|
|
* when the variable ItemInEdit is true, an item is currently edited.
|
2007-08-30 08:15:05 +00:00
|
|
|
* 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-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
|
|
|
|
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, ' ' );
|
2007-09-22 14:31:20 +00:00
|
|
|
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
|
2007-08-30 08:15:05 +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' );
|
2007-12-11 16:41:43 +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' );
|
2007-09-22 14:31:20 +00:00
|
|
|
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 );
|
2007-08-30 08:15:05 +00:00
|
|
|
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:
|
2007-09-10 04:51:01 +00:00
|
|
|
static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
|
2007-12-11 16:41:43 +00:00
|
|
|
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,
|
|
|
|
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
|
|
|
|
&HkResetLocalCoord,
|
2007-09-22 14:31:20 +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
|
2007-08-30 08:15:05 +00:00
|
|
|
Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = {
|
2007-09-06 11:52:26 +00:00
|
|
|
&HkNextSearch,
|
2007-08-30 08:15:05 +00:00
|
|
|
&HkDelete, &HkInsert, &HkMove2Drag,
|
2007-09-22 14:31:20 +00:00
|
|
|
&HkMoveComponent, &HkDragComponent, &HkAddComponent,
|
2007-08-30 08:15:05 +00:00
|
|
|
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, &HkOrientNormalComponent,
|
2007-12-11 16:41:43 +00:00
|
|
|
&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,
|
2007-12-11 16:41:43 +00:00
|
|
|
&HkEditPin,
|
|
|
|
&HkMovePin,
|
|
|
|
&HkDeletePin,
|
2007-08-30 08:15:05 +00:00
|
|
|
NULL
|
2007-08-10 18:05:42 +00:00
|
|
|
};
|
|
|
|
|
2007-09-06 11:52:26 +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[] =
|
|
|
|
{
|
|
|
|
{ &g_CommonSectionTag, s_Common_Hotkey_List, "Common keys" },
|
|
|
|
{ &g_SchematicSectionTag, s_Schematic_Hotkey_List, "Schematic editor keys" },
|
|
|
|
{ &g_LibEditSectionTag, s_LibEdit_Hotkey_List, "library editor keys" },
|
|
|
|
{ NULL, NULL }
|
2007-09-06 11:52:26 +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 },
|
|
|
|
{ NULL, NULL, NULL }
|
2007-09-06 11:52:26 +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 },
|
|
|
|
{ NULL, NULL, NULL }
|
2007-09-06 11:52:26 +00:00
|
|
|
};
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
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
|
|
|
/***********************************************************/
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
/* Hot keys. Some commands are relative to the item under the mouse cursor
|
2007-08-30 08:15:05 +00:00
|
|
|
* Commands are case insensitive
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
bool ItemInEdit = GetScreen()->GetCurItem()
|
|
|
|
&& GetScreen()->GetCurItem()->m_Flags;
|
2007-08-30 08:15:05 +00:00
|
|
|
bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified
|
|
|
|
|
|
|
|
if( hotkey == 0 )
|
|
|
|
return;
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
wxPoint MousePos = GetScreen()->m_MousePosition;
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to handle...)
|
|
|
|
if( (hotkey & GR_KB_CTRL) != 0 )
|
|
|
|
hotkey += 'A' - 1;
|
|
|
|
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
|
|
|
|
if( (hotkey >= 'a') && (hotkey <= 'z') )
|
|
|
|
hotkey += 'A' - 'a';
|
|
|
|
|
|
|
|
// Search command from key :
|
2007-09-22 14:31:20 +00:00
|
|
|
Ki_HotkeyInfo * HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List );
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
HK_Descr = GetDescriptorFromHotkey( hotkey, s_Schematic_Hotkey_List );
|
|
|
|
if( HK_Descr == NULL ) return;
|
2007-08-30 08:15:05 +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_Schematic_Hokeys_Descr );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_RESET_LOCAL_COORD: /* Reset the relative coord */
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
2008-02-17 21:19:13 +00:00
|
|
|
OnZoom( ID_ZOOM_IN_KEY );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
2008-02-17 21:19:13 +00:00
|
|
|
OnZoom( ID_ZOOM_OUT_KEY );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
|
|
|
OnZoom( ID_ZOOM_REDRAW_KEY );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_CENTER:
|
|
|
|
OnZoom( ID_ZOOM_CENTER_KEY );
|
|
|
|
break;
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
case HK_UNDO:
|
|
|
|
case HK_REDO:
|
2007-09-22 14:31:20 +00:00
|
|
|
if( ItemInEdit )
|
|
|
|
break;
|
|
|
|
{
|
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
|
|
|
|
|
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
|
|
|
break;
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
|
|
|
|
HandleBlockEndByPopUp( BLOCK_DRAG, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_DELETE:
|
2007-09-22 14:31:20 +00:00
|
|
|
if( ItemInEdit )
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
RefreshToolBar = LocateAndDeleteItem( this, DC );
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_REPEAT_LAST:
|
2007-09-22 14:31:20 +00:00
|
|
|
if( ItemInEdit )
|
|
|
|
break;
|
2007-08-30 08:15:05 +00:00
|
|
|
if( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) )
|
|
|
|
{
|
|
|
|
RepeatDrawItem( DC );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_NEXT_SEARCH:
|
2007-09-22 14:31:20 +00:00
|
|
|
if( ItemInEdit )
|
|
|
|
break;
|
2007-10-03 19:45:32 +00:00
|
|
|
if( g_LastSearchIsMarker )
|
2007-08-30 08:15:05 +00:00
|
|
|
WinEDA_SchematicFrame::FindMarker( 1 );
|
|
|
|
else
|
|
|
|
FindSchematicItem( wxEmptyString, 2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ADD_NEW_COMPONENT: // Add component
|
2007-09-22 14:31:20 +00:00
|
|
|
if( ItemInEdit )
|
2007-08-09 11:20:05 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
// 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 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_BEGIN_WIRE: // Add wire
|
|
|
|
if( DrawStruct ) // An item is selected. If edited and not a wire, a new command is not possible
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_Flags ) // Item selected and edition in progress
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
EDA_DrawLineStruct* segment = (EDA_DrawLineStruct*) DrawStruct;
|
|
|
|
if( segment->m_Layer != LAYER_WIRE )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ROTATE_COMPONENT: // Component Rotation
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
{
|
|
|
|
DrawStruct = PickStruct( GetScreen()->m_Curseur,
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen(), LIBITEM | TEXTITEM | LABELITEM );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)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
|
|
|
{
|
|
|
|
case DRAW_LIB_ITEM_STRUCT_TYPE:
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
|
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CmpRotationMiroir(
|
|
|
|
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_TEXT_STRUCT_TYPE:
|
|
|
|
case DRAW_LABEL_STRUCT_TYPE:
|
|
|
|
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
|
2008-02-12 21:12:46 +00:00
|
|
|
case DRAW_HIER_LABEL_STRUCT_TYPE:
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
|
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
|
|
|
ChangeTextOrient( (DrawTextStruct*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
|
|
|
|
if( DrawStruct == NULL )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
|
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
|
|
|
CmpRotationMiroir(
|
|
|
|
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_Y );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
|
|
|
|
if( DrawStruct == NULL )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
|
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
|
|
|
CmpRotationMiroir(
|
|
|
|
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_X );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
|
|
|
|
if( DrawStruct == NULL )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
|
|
|
|
RefreshToolBar = TRUE;
|
|
|
|
}
|
|
|
|
CmpRotationMiroir(
|
|
|
|
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_NORMAL );
|
2008-02-12 21:12:46 +00:00
|
|
|
TestDanglingEnds( (SCH_SCREEN*)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;
|
|
|
|
if( DrawStruct == NULL )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
|
2007-08-30 08:15:05 +00:00
|
|
|
if( DrawStruct && (DrawStruct->m_Flags ==0) )
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
((SCH_SCREEN*)GetScreen())->SetCurItem( DrawStruct );
|
2007-09-22 14:31:20 +00:00
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
|
|
|
|
|
|
|
|
wxPostEvent( this, event );
|
2007-08-30 08:15:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-12-11 16:41:43 +00:00
|
|
|
case HK_EDIT_COMPONENT_VALUE:
|
|
|
|
if( ItemInEdit )
|
|
|
|
break;
|
|
|
|
if( DrawStruct == NULL )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
|
2007-12-11 16:41:43 +00:00
|
|
|
if(DrawStruct)
|
|
|
|
{
|
|
|
|
EditComponentValue(
|
|
|
|
(EDA_SchComponentStruct*) DrawStruct, DC );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_EDIT_COMPONENT_FOOTPRINT:
|
|
|
|
if( ItemInEdit )
|
|
|
|
break;
|
|
|
|
if( DrawStruct == NULL )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
|
2007-12-11 16:41:43 +00:00
|
|
|
if(DrawStruct)
|
|
|
|
{
|
|
|
|
EditComponentFootprint(
|
|
|
|
(EDA_SchComponentStruct*) DrawStruct, DC );
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
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
|
|
|
/***********************************************************/
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2007-09-06 11:52:26 +00:00
|
|
|
/* Hot keys for the component editor. Some commands are relatives to the item under the mouse cursor
|
2007-08-30 08:15:05 +00:00
|
|
|
* Commands are case insensitive
|
|
|
|
*/
|
2007-08-10 18:05:42 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
bool ItemInEdit = GetScreen()->GetCurItem()
|
|
|
|
&& GetScreen()->GetCurItem()->m_Flags;
|
2007-08-30 08:15:05 +00:00
|
|
|
bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified
|
|
|
|
|
|
|
|
if( hotkey == 0 )
|
|
|
|
return;
|
2007-08-20 10:55:09 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
wxPoint MousePos = GetScreen()->m_MousePosition;
|
2007-12-11 16:41:43 +00:00
|
|
|
|
|
|
|
LibEDA_BaseStruct* DrawEntry = LocateItemUsingCursor();
|
2007-08-30 08:15:05 +00:00
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to handle...)
|
|
|
|
if( (hotkey & GR_KB_CTRL) != 0 )
|
|
|
|
hotkey += 'A' - 1;
|
2007-08-30 08:15:05 +00:00
|
|
|
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
|
|
|
|
if( (hotkey >= 'a') && (hotkey <= 'z') )
|
|
|
|
hotkey += 'A' - 'a';
|
2007-09-22 14:31:20 +00:00
|
|
|
Ki_HotkeyInfo * HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List );
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
HK_Descr = GetDescriptorFromHotkey( hotkey, s_LibEdit_Hotkey_List );
|
|
|
|
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-02-12 21:12:46 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
2008-02-17 21:19:13 +00:00
|
|
|
OnZoom( ID_ZOOM_IN_KEY );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_OUT:
|
2008-02-17 21:19:13 +00:00
|
|
|
OnZoom( ID_ZOOM_OUT_KEY );
|
2007-08-30 08:15:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
|
|
|
OnZoom( ID_ZOOM_REDRAW_KEY );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_CENTER:
|
|
|
|
OnZoom( ID_ZOOM_CENTER_KEY );
|
|
|
|
break;
|
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
case HK_UNDO:
|
|
|
|
case HK_REDO:
|
|
|
|
if( ItemInEdit )
|
|
|
|
break;
|
|
|
|
{
|
|
|
|
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
|
|
|
|
|
|
|
|
wxPostEvent( this, event );
|
|
|
|
}
|
|
|
|
break;
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
case HK_REPEAT_LAST:
|
|
|
|
if( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0)
|
2007-09-01 12:00:30 +00:00
|
|
|
&& (LibItemToRepeat->Type() == COMPONENT_PIN_DRAW_TYPE) )
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
|
|
|
RepeatPinItem( DC, (LibDrawPin*) LibItemToRepeat );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wxBell();
|
|
|
|
break;
|
2007-12-11 16:41:43 +00:00
|
|
|
case HK_EDIT_PIN:
|
|
|
|
if(DrawEntry)
|
|
|
|
CurrentDrawItem = DrawEntry;
|
|
|
|
if(CurrentDrawItem)
|
|
|
|
{
|
|
|
|
if(CurrentDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE)
|
|
|
|
InstallPineditFrame( this, DC, MousePos );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HK_DELETE_PIN:
|
|
|
|
if(DrawEntry)
|
|
|
|
CurrentDrawItem = DrawEntry;
|
|
|
|
if(CurrentDrawItem)
|
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
|
|
|
evt.SetId(ID_POPUP_LIBEDIT_DELETE_ITEM);
|
|
|
|
Process_Special_Functions(evt);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HK_MOVE_PIN:
|
|
|
|
if(DrawEntry)
|
|
|
|
CurrentDrawItem = DrawEntry;
|
|
|
|
if(CurrentDrawItem)
|
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
|
|
|
evt.SetId(ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST);
|
|
|
|
Process_Special_Functions(evt);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
if( RefreshToolBar )
|
|
|
|
SetToolbars();
|
2007-08-10 18:05:42 +00:00
|
|
|
}
|