2014-08-29 20:23:40 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-06-28 16:32:04 +00:00
|
|
|
* Copyright (C) 1992-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-08-29 20:23:40 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
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>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <gerbview_id.h>
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gerbview_layer_widget.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#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:
|
2019-04-29 10:40:44 +00:00
|
|
|
* add a new id in the enum hotkey_id_command 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 ...)
|
|
|
|
*/
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// local variables
|
|
|
|
// Hotkey list:
|
2015-04-19 18:41:57 +00:00
|
|
|
static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
|
|
|
|
static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
|
|
|
|
static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
|
|
|
|
static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
|
|
|
|
static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
|
2017-06-28 16:32:04 +00:00
|
|
|
static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ),
|
2018-04-03 11:54:10 +00:00
|
|
|
HK_ZOOM_SELECTION, GR_KB_CTRL + WXK_F5 );
|
2019-04-01 17:18:29 +00:00
|
|
|
static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ),
|
|
|
|
HK_PREFERENCES, GR_KB_CTRL + ',', (int) wxID_PREFERENCES );
|
2019-01-02 05:12:52 +00:00
|
|
|
static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
|
2015-04-19 18:41:57 +00:00
|
|
|
static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
|
2017-06-28 16:32:04 +00:00
|
|
|
static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ),
|
|
|
|
HK_RESET_LOCAL_COORD, ' ' );
|
2019-03-03 23:45:52 +00:00
|
|
|
static EDA_HOTKEY HkSwitchHighContrastMode( _HKI( "Toggle High Contrast Mode" ),
|
|
|
|
HK_SWITCH_HIGHCONTRAST_MODE, 'H' + GR_KB_CTRL );
|
2017-06-28 16:32:04 +00:00
|
|
|
|
|
|
|
static EDA_HOTKEY HkLinesDisplayMode( _HKI( "Gbr Lines Display Mode" ),
|
|
|
|
HK_GBR_LINES_DISPLAY_MODE, 'L' );
|
|
|
|
static EDA_HOTKEY HkFlashedDisplayMode( _HKI( "Gbr Flashed Display Mode" ),
|
|
|
|
HK_GBR_FLASHED_DISPLAY_MODE, 'F' );
|
|
|
|
static EDA_HOTKEY HkPolygonDisplayMode( _HKI( "Gbr Polygons Display Mode" ),
|
|
|
|
HK_GBR_POLYGON_DISPLAY_MODE, 'P' );
|
|
|
|
static EDA_HOTKEY HkNegativeObjDisplayMode( _HKI( "Gbr Negative Obj Display Mode" ),
|
|
|
|
HK_GBR_NEGATIVE_DISPLAY_ONOFF, 'N' );
|
|
|
|
static EDA_HOTKEY HkDCodesDisplayMode( _HKI( "DCodes Display Mode" ),
|
|
|
|
HK_GBR_DCODE_DISPLAY_ONOFF, 'D' );
|
|
|
|
|
|
|
|
static EDA_HOTKEY HkSwitch2NextCopperLayer( _HKI( "Switch to Next Layer" ),
|
|
|
|
HK_SWITCH_LAYER_TO_NEXT, '+' );
|
|
|
|
static EDA_HOTKEY HkSwitch2PreviousCopperLayer( _HKI( "Switch to Previous Layer" ),
|
|
|
|
HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2018-02-19 19:26:02 +00:00
|
|
|
static EDA_HOTKEY HkCanvasDefault( _HKI( "Switch to Legacy Toolset" ),
|
2017-09-17 22:43:20 +00:00
|
|
|
HK_CANVAS_LEGACY,
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
GR_KB_ALT +
|
|
|
|
#endif
|
|
|
|
WXK_F9 );
|
2018-02-19 19:26:02 +00:00
|
|
|
static EDA_HOTKEY HkCanvasOpenGL( _HKI( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ),
|
2017-09-17 22:43:20 +00:00
|
|
|
HK_CANVAS_OPENGL,
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
GR_KB_ALT +
|
|
|
|
#endif
|
|
|
|
WXK_F11 );
|
2018-02-19 19:26:02 +00:00
|
|
|
static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Modern Toolset with software graphics (fall-back)" ),
|
2017-09-17 22:43:20 +00:00
|
|
|
HK_CANVAS_CAIRO,
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
GR_KB_ALT +
|
|
|
|
#endif
|
|
|
|
WXK_F12 );
|
|
|
|
|
2018-02-25 18:30:59 +00:00
|
|
|
static EDA_HOTKEY HkMeasureTool( _HKI( "Measure Distance (Modern Toolset only)" ),
|
|
|
|
HK_MEASURE_TOOL, 'M' + GR_KB_SHIFTCTRL );
|
|
|
|
|
2007-09-11 07:34:46 +00:00
|
|
|
// List of common hotkey descriptors
|
2015-04-19 18:41:57 +00:00
|
|
|
EDA_HOTKEY* gerbviewHotkeyList[] = {
|
2019-04-01 17:18:29 +00:00
|
|
|
&HkHelp, &HkPreferences,
|
2018-04-14 14:58:50 +00:00
|
|
|
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
|
|
|
|
&HkZoomAuto, &HkZoomSelection, &HkSwitchUnits, &HkResetLocalCoord,
|
2015-04-19 18:41:57 +00:00
|
|
|
&HkLinesDisplayMode, &HkFlashedDisplayMode, &HkPolygonDisplayMode,
|
|
|
|
&HkDCodesDisplayMode, &HkNegativeObjDisplayMode,
|
2019-03-03 23:45:52 +00:00
|
|
|
&HkSwitchHighContrastMode,
|
2007-09-11 07:34:46 +00:00
|
|
|
&HkSwitch2NextCopperLayer,
|
|
|
|
&HkSwitch2PreviousCopperLayer,
|
2017-09-17 22:43:20 +00:00
|
|
|
&HkCanvasDefault,
|
|
|
|
&HkCanvasOpenGL,
|
|
|
|
&HkCanvasCairo,
|
2018-02-25 18:30:59 +00:00
|
|
|
&HkMeasureTool,
|
2007-09-11 07:34:46 +00:00
|
|
|
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)
|
2015-04-19 18:41:57 +00:00
|
|
|
static wxString gerbviewSectionTag( wxT( "[gerbview]" ) );
|
|
|
|
static wxString gerbviewSectionTitle( _HKI( "Gerbview Hotkeys" ) );
|
|
|
|
|
2019-04-01 17:14:16 +00:00
|
|
|
struct EDA_HOTKEY_CONFIG GerbviewHotkeysDescr[] =
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
2015-04-19 18:41:57 +00:00
|
|
|
{ &gerbviewSectionTag, gerbviewHotkeyList, &gerbviewSectionTitle },
|
|
|
|
{ NULL, NULL, NULL }
|
2007-09-11 07:34:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-05-05 18:39:42 +00:00
|
|
|
EDA_HOTKEY* GERBVIEW_FRAME::GetHotKeyDescription( int aCommand ) const
|
|
|
|
{
|
|
|
|
EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, gerbviewHotkeyList );
|
|
|
|
|
|
|
|
return HK_Descr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-29 20:23:40 +00:00
|
|
|
bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem )
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
2015-04-19 18:41:57 +00:00
|
|
|
#define CHANGE( x ) ( x ) = not (x )
|
|
|
|
|
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
|
|
|
|
2015-04-19 18:41:57 +00:00
|
|
|
EDA_HOTKEY * HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, gerbviewHotkeyList );
|
2011-09-29 16:49:40 +00:00
|
|
|
|
|
|
|
if( HK_Descr == NULL )
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
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:
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2007-09-11 07:34:46 +00:00
|
|
|
|
|
|
|
case HK_HELP: // Display Current hotkey list
|
2019-04-01 17:14:16 +00:00
|
|
|
DisplayHotkeyList( this, GerbviewHotkeysDescr );
|
2007-09-11 07:34:46 +00:00
|
|
|
break;
|
|
|
|
|
2019-04-01 17:18:29 +00:00
|
|
|
case HK_PREFERENCES:
|
|
|
|
cmd.SetId( wxID_PREFERENCES );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case HK_RESET_LOCAL_COORD: // Reset the relative coord
|
|
|
|
GetScreen()->m_O_Curseur = GetCrossHairPosition();
|
|
|
|
break;
|
|
|
|
|
2007-09-11 07:34:46 +00:00
|
|
|
case HK_SWITCH_LAYER_TO_PREVIOUS:
|
2017-09-17 22:43:20 +00:00
|
|
|
if( GetActiveLayer() > 0 )
|
2011-03-14 21:19:13 +00:00
|
|
|
{
|
2018-03-04 04:43:16 +00:00
|
|
|
SetActiveLayer( GetActiveLayer() - 1, true );
|
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:
|
2017-09-17 22:43:20 +00:00
|
|
|
if( GetActiveLayer() < GERBER_DRAWLAYERS_COUNT - 1 )
|
2011-03-14 21:19:13 +00:00
|
|
|
{
|
2018-03-04 04:43:16 +00:00
|
|
|
SetActiveLayer( GetActiveLayer() + 1, true );
|
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;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
case HK_CANVAS_CAIRO:
|
|
|
|
cmd.SetId( ID_MENU_CANVAS_CAIRO );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CANVAS_OPENGL:
|
|
|
|
cmd.SetId( ID_MENU_CANVAS_OPENGL );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HK_CANVAS_LEGACY:
|
|
|
|
cmd.SetId( ID_MENU_CANVAS_LEGACY );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
2007-09-11 07:34:46 +00:00
|
|
|
}
|
2014-08-29 20:23:40 +00:00
|
|
|
|
|
|
|
return true;
|
2007-09-11 07:34:46 +00:00
|
|
|
}
|