2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file gerbview/hotkeys.cpp
|
|
|
|
*/
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <kicad_device_context.h>
|
|
|
|
#include <id.h>
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <hotkeys.h>
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-09-11 07:34:46 +00:00
|
|
|
/* How to add a new hotkey:
|
|
|
|
* add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION.
|
2011-09-29 16:49:40 +00:00
|
|
|
* add a new EDA_HOTKEY entry like:
|
|
|
|
* static EDA_HOTKEY HkMyNewEntry(wxT("Command Label"), MY_NEW_ID_FUNCTION, default key value);
|
2011-09-23 13:57:12 +00:00
|
|
|
* "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 add the HkMyNewEntry pointer in the
|
|
|
|
* s_board_edit_Hotkey_List list ( or/and the s_module_edit_Hotkey_List list) Add the
|
|
|
|
* new code in the switch in OnHotKey() function. when the variable PopupOn 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
|
2007-09-11 07:34:46 +00:00
|
|
|
* ( 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 ...)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
/* Hotkey list: */
|
2011-09-29 16:49:40 +00:00
|
|
|
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
|
|
|
|
HK_RESET_LOCAL_COORD, ' ' );
|
|
|
|
static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
|
|
|
|
static EDA_HOTKEY HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
|
|
|
|
static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
|
|
|
|
static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
|
|
|
|
static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
|
|
|
|
static EDA_HOTKEY HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' );
|
|
|
|
static EDA_HOTKEY HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
|
|
|
|
static EDA_HOTKEY HkTrackDisplayMode( wxT( "Track Display Mode" ),
|
|
|
|
HK_SWITCH_GBR_ITEMS_DISPLAY_MODE, 'F' );
|
|
|
|
|
|
|
|
static EDA_HOTKEY HkSwitch2NextCopperLayer( wxT( "Switch to Next Layer" ),
|
|
|
|
HK_SWITCH_LAYER_TO_NEXT, '+' );
|
|
|
|
static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" ),
|
|
|
|
HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
|
2007-09-11 07:34:46 +00:00
|
|
|
|
|
|
|
// List of common hotkey descriptors
|
2011-09-29 16:49:40 +00:00
|
|
|
EDA_HOTKEY* s_Gerbview_Hotkey_List[] = {
|
2007-09-11 07:34:46 +00:00
|
|
|
&HkHelp,
|
|
|
|
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
|
2009-09-27 14:09:26 +00:00
|
|
|
&HkZoomAuto, &HkSwitchUnits, &HkResetLocalCoord,
|
2007-09-11 07:34:46 +00:00
|
|
|
&HkTrackDisplayMode,
|
|
|
|
&HkSwitch2NextCopperLayer,
|
|
|
|
&HkSwitch2PreviousCopperLayer,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// list of sections and corresponding hotkey list for GerbView (used to create an hotkey
|
|
|
|
// config file)
|
2011-09-29 16:49:40 +00:00
|
|
|
struct EDA_HOTKEY_CONFIG s_Gerbview_Hokeys_Descr[] =
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
|
|
|
{ &g_CommonSectionTag, s_Gerbview_Hotkey_List, NULL },
|
|
|
|
{ NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-05-19 19:04:03 +00:00
|
|
|
/*
|
|
|
|
* Function OnHotKey.
|
|
|
|
* ** Commands are case insensitive **
|
|
|
|
* Some commands are relatives to the item under the mouse cursor
|
|
|
|
* aDC = current device context
|
|
|
|
* aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
|
|
|
|
* aPosition The cursor position in logical (drawing) units.
|
|
|
|
* aItem = NULL or pointer on a EDA_ITEM under the mouse cursor
|
2007-09-11 07:34:46 +00:00
|
|
|
*/
|
2012-05-19 19:04:03 +00:00
|
|
|
void GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem )
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
2009-01-07 15:59:49 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/* Convert lower to upper case (the usual toupper function has problem with non ascii
|
|
|
|
* codes like function keys */
|
2012-05-19 19:04:03 +00:00
|
|
|
if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') )
|
|
|
|
aHotkeyCode += 'A' - 'a';
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2012-05-19 19:04:03 +00:00
|
|
|
EDA_HOTKEY * HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_Gerbview_Hotkey_List );
|
2011-09-29 16:49:40 +00:00
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
|
|
|
return;
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
switch( HK_Descr->m_Idcommand )
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case HK_NOT_FOUND:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
|
|
|
DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_IN:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_POPUP_ZOOM_IN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-09-11 07:34:46 +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-09-11 07:34:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_ZOOM_REDRAW:
|
2009-01-07 15:59:49 +00:00
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-09-11 07:34:46 +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-09-11 07:34:46 +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-11 07:34:46 +00:00
|
|
|
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
|
2007-09-11 07:34:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_UNITS:
|
2010-07-12 14:07:09 +00:00
|
|
|
g_UserUnit = (g_UserUnit == INCHES ) ? MILLIMETRES : INCHES;
|
2007-09-11 07:34:46 +00:00
|
|
|
break;
|
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
case HK_SWITCH_GBR_ITEMS_DISPLAY_MODE:
|
2012-05-04 17:44:42 +00:00
|
|
|
m_DisplayOptions.m_DisplayLinesFill = not m_DisplayOptions.m_DisplayLinesFill;
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-09-11 07:34:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_PREVIOUS:
|
2011-03-14 21:19:13 +00:00
|
|
|
if( getActiveLayer() > 0 )
|
|
|
|
{
|
|
|
|
setActiveLayer( getActiveLayer() - 1 );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-03-14 21:19:13 +00:00
|
|
|
}
|
2007-09-11 07:34:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_SWITCH_LAYER_TO_NEXT:
|
2011-03-14 21:19:13 +00:00
|
|
|
if( getActiveLayer() < 31 )
|
|
|
|
{
|
|
|
|
setActiveLayer( getActiveLayer() + 1 );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-03-14 21:19:13 +00:00
|
|
|
}
|
2007-09-11 07:34:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|