You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

722 lines
28 KiB

12 years ago
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file pcbnew/hotkeys.cpp
  26. */
  27. #include <fctsys.h>
  28. #include <pcbnew.h>
  29. #include <pcb_edit_frame.h>
  30. #include <footprint_viewer_frame.h>
  31. #include <footprint_wizard_frame.h>
  32. #include <pcbnew_id.h>
  33. #include <hotkeys.h>
  34. // Remark: the hotkey message info is used as keyword in hotkey config files and
  35. // as comments in help windows, therefore translated only when displayed
  36. // they are marked _HKI to be extracted by translation tools
  37. // See hotkeys_basic.h for more info
  38. /* How to add a new hotkey:
  39. * add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION.
  40. * add a new EDA_HOTKEY entry like:
  41. * static EDA_HOTKEY HkMyNewEntry(_HKI("Command Label"), MY_NEW_ID_FUNCTION, default key value);
  42. * "Command Label" is the name used in hotkey list display, and the identifier in the
  43. * hotkey list file MY_NEW_ID_FUNCTION is an equivalent id function used in the switch
  44. * in OnHotKey() function.
  45. * default key value is the default hotkey for this command. Can be overridden by the user
  46. * hotkey list file
  47. * add the HkMyNewEntry pointer in the s_board_edit_Hotkey_List list ( or/and the
  48. * s_module_edit_Hotkey_List list)
  49. * Add the new code in the switch in OnHotKey() function.
  50. * Note: when the variable itemCurrentlyEdited is true, an item is currently edited.
  51. * This can be useful if the new function cannot be executed while an item is currently
  52. * being edited ( For example, one cannot start a new wire when a component is moving.)
  53. *
  54. * Note: If a hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX)
  55. * is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp)
  56. * and see this list for some ascii keys (space ...)
  57. */
  58. // Hotkey list:
  59. // mouse click command:
  60. static EDA_HOTKEY HkMouseLeftClick( _HKI( "Mouse Left Click" ),
  61. HK_LEFT_CLICK, WXK_RETURN, 0 );
  62. static EDA_HOTKEY HkMouseLeftDClick( _HKI( "Mouse Left Double Click" ),
  63. HK_LEFT_DCLICK, WXK_END, 0 );
  64. static EDA_HOTKEY HkSwitch2CopperLayer( _HKI( "Switch to Copper (B.Cu) layer" ),
  65. HK_SWITCH_LAYER_TO_COPPER, WXK_PAGEDOWN );
  66. static EDA_HOTKEY HkSwitch2ComponentLayer( _HKI( "Switch to Component (F.Cu) layer" ),
  67. HK_SWITCH_LAYER_TO_COMPONENT, WXK_PAGEUP );
  68. static EDA_HOTKEY HkSwitch2InnerLayer1( _HKI( "Switch to Inner layer 1" ),
  69. HK_SWITCH_LAYER_TO_INNER1, WXK_F5 );
  70. static EDA_HOTKEY HkSwitch2InnerLayer2( _HKI( "Switch to Inner layer 2" ),
  71. HK_SWITCH_LAYER_TO_INNER2, WXK_F6 );
  72. static EDA_HOTKEY HkSwitch2InnerLayer3( _HKI( "Switch to Inner layer 3" ),
  73. HK_SWITCH_LAYER_TO_INNER3, WXK_F7 );
  74. static EDA_HOTKEY HkSwitch2InnerLayer4( _HKI( "Switch to Inner layer 4" ),
  75. HK_SWITCH_LAYER_TO_INNER4, WXK_F8 );
  76. static EDA_HOTKEY HkSwitch2InnerLayer5( _HKI( "Switch to Inner layer 5" ),
  77. HK_SWITCH_LAYER_TO_INNER5, GR_KB_SHIFT+WXK_F5 );
  78. static EDA_HOTKEY HkSwitch2InnerLayer6( _HKI( "Switch to Inner layer 6" ),
  79. HK_SWITCH_LAYER_TO_INNER6, GR_KB_SHIFT+WXK_F6 );
  80. static EDA_HOTKEY HkSwitch2NextCopperLayer( _HKI( "Switch to Next Layer" ),
  81. HK_SWITCH_LAYER_TO_NEXT, '+' );
  82. static EDA_HOTKEY HkSwitch2PreviousCopperLayer( _HKI( "Switch to Previous Layer" ),
  83. HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
  84. static EDA_HOTKEY HkFindItem( _HKI( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL );
  85. static EDA_HOTKEY HkBackspace( _HKI( "Delete Track Segment" ), HK_BACK_SPACE, WXK_BACK );
  86. static EDA_HOTKEY HkAddNewTrack( _HKI( "Add New Track" ), HK_ADD_NEW_TRACK, 'X' );
  87. static EDA_HOTKEY HkRouteDiffPair( _HKI( "Route Differential Pair (Modern Toolset only)" ),
  88. HK_ROUTE_DIFF_PAIR, '6' );
  89. static EDA_HOTKEY HkRouteTuneSingle( _HKI( "Tune Single Track (Modern Toolset only)" ),
  90. HK_ROUTE_TUNE_SINGLE, '7' );
  91. static EDA_HOTKEY HkRouteTuneDiffPair( _HKI( "Tune Differential Pair Length (Modern Toolset only)" ),
  92. HK_ROUTE_TUNE_DIFF_PAIR, '8' );
  93. static EDA_HOTKEY HkRouteTuneSkew( _HKI( "Tune Differential Pair Skew (Modern Toolset only)" ),
  94. HK_ROUTE_TUNE_SKEW, '9' );
  95. static EDA_HOTKEY HkRouteTuneSettings( _HKI( "Length Tuning Settings (Modern Toolset only)" ),
  96. HK_ROUTE_TUNE_SETTINGS, 'L' + GR_KB_CTRL );
  97. static EDA_HOTKEY HkRouteTuneIncreaseSpacing( _HKI( "Increase meander spacing by one step." ),
  98. HK_ROUTE_TUNE_INCREASE_SPACING, '1' );
  99. static EDA_HOTKEY HkRouteTuneDecreaseSpacing( _HKI( "Decrease meander spacing by one step." ),
  100. HK_ROUTE_TUNE_DECREASE_SPACING, '2' );
  101. static EDA_HOTKEY HkRouteTuneIncreaseAmp( _HKI( "Increase meander amplitude by one step." ),
  102. HK_ROUTE_TUNE_INCREASE_AMP, '3' );
  103. static EDA_HOTKEY HkRouteTuneDecreaseAmp( _HKI( "Decrease meander amplitude by one step." ),
  104. HK_ROUTE_TUNE_DECREASE_AMP, '4' );
  105. static EDA_HOTKEY HkAddThroughVia( _HKI( "Add Through Via" ), HK_ADD_THROUGH_VIA, 'V' );
  106. static EDA_HOTKEY HkSelLayerAndAddThroughVia( _HKI( "Select Layer and Add Through Via" ),
  107. HK_SEL_LAYER_AND_ADD_THROUGH_VIA, '<' );
  108. static EDA_HOTKEY HkAddMicroVia( _HKI( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL );
  109. static EDA_HOTKEY HkAddBlindBuriedVia( _HKI( "Add Blind/Buried Via" ), HK_ADD_BLIND_BURIED_VIA, 'V' + GR_KB_ALT + GR_KB_SHIFT );
  110. static EDA_HOTKEY HkSelLayerAndAddBlindBuriedVia( _HKI( "Select Layer and Add Blind/Buried Via" ),
  111. HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA, '<' + GR_KB_ALT );
  112. static EDA_HOTKEY HkSwitchTrackPosture( _HKI( "Switch Track Posture" ), HK_SWITCH_TRACK_POSTURE, '/' );
  113. static EDA_HOTKEY HkDragTrackKeepSlope( _HKI( "Drag Track Keep Slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' );
  114. static EDA_HOTKEY HkPlaceItem( _HKI( "Place Item" ), HK_PLACE_ITEM, 'P' );
  115. static EDA_HOTKEY HkEditBoardItem( _HKI( "Edit Item" ), HK_EDIT_ITEM, 'E' );
  116. static EDA_HOTKEY HkEditWithModedit( _HKI( "Edit with Footprint Editor" ), HK_EDIT_MODULE_WITH_MODEDIT, 'E' + GR_KB_CTRL );
  117. static EDA_HOTKEY HkFlipItem( _HKI( "Flip Item" ), HK_FLIP_ITEM, 'F' );
  118. static EDA_HOTKEY HkRotateItem( _HKI( "Rotate Item" ), HK_ROTATE_ITEM, 'R' );
  119. static EDA_HOTKEY HkRotateItemClockwise( _HKI( "Rotate Item Clockwise (Modern Toolset only)" ),
  120. HK_ROTATE_ITEM_CLOCKWISE, GR_KB_SHIFT + 'R' );
  121. static EDA_HOTKEY HkMoveItem( _HKI( "Move Item" ), HK_MOVE_ITEM, 'M' );
  122. static EDA_HOTKEY HkMoveItemExact( _HKI( "Move Item Exactly" ), HK_MOVE_ITEM_EXACT, 'M' + GR_KB_CTRL );
  123. static EDA_HOTKEY HkPositionItemRelative( _HKI( "Position Item Relative" ), HK_POSITION_RELATIVE, 'R' + GR_KB_CTRL );
  124. static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate Item" ), HK_DUPLICATE_ITEM, 'D' + GR_KB_CTRL );
  125. static EDA_HOTKEY HkDuplicateItemAndIncrement( _HKI( "Duplicate Item and Increment" ),
  126. HK_DUPLICATE_ITEM_AND_INCREMENT, 'D' + GR_KB_SHIFTCTRL );
  127. static EDA_HOTKEY HkCreateArray( _HKI( "Create Array" ), HK_CREATE_ARRAY, 'T' + GR_KB_CTRL );
  128. static EDA_HOTKEY HkCopyItem( _HKI( "Copy Item" ), HK_COPY_ITEM, 'C' );
  129. static EDA_HOTKEY HkDragFootprint( _HKI( "Drag Item" ), HK_DRAG_ITEM, 'G' );
  130. static EDA_HOTKEY HkGetAndMoveFootprint( _HKI( "Get and Move Footprint" ), HK_GET_AND_MOVE_FOOTPRINT, 'T' );
  131. static EDA_HOTKEY HkLock_Unlock_Footprint( _HKI( "Lock/Unlock Footprint" ), HK_LOCK_UNLOCK_FOOTPRINT, 'L' );
  132. static EDA_HOTKEY HkDelete( _HKI( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE );
  133. static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
  134. static EDA_HOTKEY HkSwitchHighContrastMode( _HKI( "Toggle High Contrast Mode" ), HK_SWITCH_HIGHCONTRAST_MODE,'H');
  135. static EDA_HOTKEY HkAddLine( _HKI( "Draw Line" ), HK_ADD_LINE, 'L' + GR_KB_SHIFTCTRL );
  136. static EDA_HOTKEY HkAddPolygon( _HKI( "Draw Graphic Polygon" ), HK_ADD_POLYGON, 'P' + GR_KB_SHIFTCTRL );
  137. static EDA_HOTKEY HkAddCircle( _HKI( "Draw Circle" ), HK_ADD_CIRCLE, 'C' + GR_KB_SHIFTCTRL );
  138. static EDA_HOTKEY HkAddArc( _HKI( "Draw Arc" ), HK_ADD_ARC, 'A' + GR_KB_SHIFTCTRL );
  139. static EDA_HOTKEY HkAddText( _HKI( "Add Text" ), HK_ADD_TEXT, 'T' + GR_KB_SHIFTCTRL );
  140. static EDA_HOTKEY HkAddDimension( _HKI( "Add Dimension" ), HK_ADD_DIMENSION, 'H' + GR_KB_SHIFTCTRL );
  141. static EDA_HOTKEY HkAddFilledZone( _HKI( "Add Filled Zone" ), HK_ADD_ZONE, 'Z' + GR_KB_SHIFTCTRL );
  142. static EDA_HOTKEY HkAddFreeVia( _HKI( "Add Vias" ), HK_ADD_FREE_VIA, 'V' + GR_KB_SHIFTCTRL );
  143. static EDA_HOTKEY HkAddKeepout( _HKI( "Add Keepout Area" ), HK_ADD_KEEPOUT, 'K' + GR_KB_SHIFTCTRL );
  144. static EDA_HOTKEY HkAddZoneCutout( _HKI( "Add a Zone Cutout" ), HK_ADD_CUTOUT, 'C' + GR_KB_SHIFT );
  145. static EDA_HOTKEY HkAddSimilarZone( _HKI( "Add a Similar Zone" ), HK_ADD_SIMILAR_ZONE, '.' + GR_KB_SHIFTCTRL );
  146. static EDA_HOTKEY HkAddDXF( _HKI( "Place DXF" ), HK_ADD_DXF, 'F' + GR_KB_SHIFTCTRL );
  147. static EDA_HOTKEY HkAddAnchor( _HKI( "Place the Footprint Anchor" ), HK_ADD_ANCHOR, 'N' + GR_KB_SHIFTCTRL );
  148. static EDA_HOTKEY HkIncreaseLineWidth( _HKI( "Increase Line Width" ), HK_INC_LINE_WIDTH, '+' + GR_KB_CTRL );
  149. static EDA_HOTKEY HkDecreaseLineWidth( _HKI( "Decrease Line Width" ), HK_DEC_LINE_WIDTH, '-' + GR_KB_CTRL );
  150. static EDA_HOTKEY HkSetGridOrigin( _HKI( "Set Grid Origin" ), HK_SET_GRID_ORIGIN, 'S' );
  151. static EDA_HOTKEY HkResetGridOrigin( _HKI( "Reset Grid Origin" ), HK_RESET_GRID_ORIGIN, 'Z' );
  152. static EDA_HOTKEY HkCanvasDefault( _HKI( "Switch to Legacy Toolset (not all features will be available" ),
  153. HK_CANVAS_LEGACY,
  154. #ifdef __WXMAC__
  155. GR_KB_ALT +
  156. #endif
  157. WXK_F9 );
  158. static EDA_HOTKEY HkCanvasOpenGL( _HKI( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ),
  159. HK_CANVAS_OPENGL,
  160. #ifdef __WXMAC__
  161. GR_KB_ALT +
  162. #endif
  163. WXK_F11 );
  164. static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Modern Toolset with software graphics (fall-back)" ),
  165. HK_CANVAS_CAIRO,
  166. #ifdef __WXMAC__
  167. GR_KB_ALT +
  168. #endif
  169. WXK_F12 );
  170. static EDA_HOTKEY HkZoneFillOrRefill( _HKI( "Fill or Refill All Zones" ),
  171. HK_ZONE_FILL_OR_REFILL, 'B' );
  172. static EDA_HOTKEY HkZoneRemoveFilled( _HKI( "Remove Filled Areas in All Zones" ),
  173. HK_ZONE_REMOVE_FILLED, 'B' + GR_KB_CTRL );
  174. /* Fit on Screen */
  175. #if !defined( __WXMAC__ )
  176. static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
  177. #else
  178. static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0' );
  179. #endif
  180. static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
  181. /* Refresh Screen */
  182. #if !defined( __WXMAC__ )
  183. static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
  184. #else
  185. static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTRL + 'R' );
  186. #endif
  187. /* Zoom In */
  188. #if !defined( __WXMAC__ )
  189. static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
  190. #else
  191. static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+' );
  192. #endif
  193. /* Zoom Out */
  194. #if !defined( __WXMAC__ )
  195. static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
  196. #else
  197. static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-' );
  198. #endif
  199. static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION,
  200. GR_KB_CTRL + WXK_F5, ID_ZOOM_SELECTION );
  201. static EDA_HOTKEY Hk3DViewer( _HKI( "3D Viewer" ), HK_3D_VIEWER, GR_KB_ALT + '3' );
  202. static EDA_HOTKEY HkHelp( _HKI( "Help (this window)" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
  203. static EDA_HOTKEY HkSwitchTrackWidthToNext( _HKI( "Switch Track Width To Next" ),
  204. HK_SWITCH_TRACK_WIDTH_TO_NEXT, 'W' );
  205. static EDA_HOTKEY HkSwitchTrackWidthToPrevious( _HKI( "Switch Track Width To Previous" ),
  206. HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS, 'W'
  207. + GR_KB_CTRL );
  208. static EDA_HOTKEY HkSwitchGridToFastGrid1( _HKI( "Switch Grid To Fast Grid1" ),
  209. HK_SWITCH_GRID_TO_FASTGRID1, GR_KB_ALT + '1' );
  210. static EDA_HOTKEY HkSwitchGridToFastGrid2( _HKI( "Switch Grid To Fast Grid2" ),
  211. HK_SWITCH_GRID_TO_FASTGRID2, GR_KB_ALT + '2' );
  212. static EDA_HOTKEY HkSwitchGridToNext( _HKI( "Switch Grid To Next" ),
  213. HK_SWITCH_GRID_TO_NEXT, 'N' );
  214. static EDA_HOTKEY HkSwitchGridToPrevious( _HKI( "Switch Grid To Previous" ),
  215. HK_SWITCH_GRID_TO_PREVIOUS, 'N' + GR_KB_SHIFT );
  216. static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' + GR_KB_CTRL );
  217. static EDA_HOTKEY HkTrackDisplayMode( _HKI( "Track Display Mode" ),
  218. HK_SWITCH_TRACK_DISPLAY_MODE, 'K' );
  219. static EDA_HOTKEY HkAddModule( _HKI( "Add Footprint" ), HK_ADD_MODULE, 'O' );
  220. // These hotkeys work only in GAL canvas, because the legacy canvas using wxDC does not know
  221. // the transparency (alpha channel)
  222. static EDA_HOTKEY HkIncLayerAlpha( _HKI( "Increment Layer Transparency (Modern Toolset only)" ),
  223. HK_INC_LAYER_ALPHA, '}' );
  224. static EDA_HOTKEY HkDecLayerAlpha( _HKI( "Decrement Layer Transparency (Modern Toolset only)" ),
  225. HK_DEC_LAYER_ALPHA, '{' );
  226. // These two are currently unused, and are intentionally not added to a list below.
  227. static EDA_HOTKEY HkIncHighContrast( _HKI( "Increment High Contrast" ), HK_HIGHCONTRAST_INC, '>' );
  228. static EDA_HOTKEY HkDecHighContrast( _HKI( "Decrement High Contrast" ), HK_HIGHCONTRAST_DEC, '<' );
  229. static EDA_HOTKEY HkSelectConnection( _HKI( "Select Trivial Connection" ), HK_SEL_TRIVIAL_CONNECTION, 'U' );
  230. static EDA_HOTKEY HkSelectCopper( _HKI( "Select Copper Connection" ), HK_SEL_COPPER_CONNECTION, 'I' );
  231. static EDA_HOTKEY HkRoutingOptions( _HKI( "Routing Options" ), HK_ROUTING_OPTIONS, ',' + GR_KB_CTRL );
  232. static EDA_HOTKEY HkCustomTrackWidth( _HKI( "Custom Track/Via Size" ), HK_CUSTOM_TRACK_WIDTH, 'Q' );
  233. static EDA_HOTKEY HkDpDimension( _HKI( "Differential Pair Dimensions" ), HK_DP_DIMENSIONS, 'R' + GR_KB_SHIFTCTRL );
  234. static EDA_HOTKEY HkViaSizeInc( _HKI( "Increase Via Size" ), HK_VIA_SIZE_INC, '\'' );
  235. static EDA_HOTKEY HkViaSizeDec( _HKI( "Decrease Via Size" ), HK_VIA_SIZE_DEC, '\\' );
  236. static EDA_HOTKEY HkHighlightNetSelection( _HKI( "Toggle Highlight of Selected Net (Modern Toolset only)" ),
  237. HK_HIGHLIGHT_NET_SELECTION, '`' );
  238. // Common: hotkeys_basic.h
  239. static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', (int) wxID_NEW );
  240. static EDA_HOTKEY HkOpen( _HKI( "Open" ), HK_OPEN, GR_KB_CTRL + 'O', (int) wxID_OPEN );
  241. static EDA_HOTKEY HkSave( _HKI( "Save" ), HK_SAVE, GR_KB_CTRL + 'S', (int) wxID_SAVE );
  242. static EDA_HOTKEY HkSaveAs( _HKI( "Save As" ), HK_SAVEAS, GR_KB_SHIFT + GR_KB_CTRL + 'S', (int) wxID_SAVEAS );
  243. static EDA_HOTKEY HkPrint( _HKI( "Print" ), HK_PRINT, GR_KB_CTRL + 'P', (int) wxID_PRINT );
  244. static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z', (int) wxID_UNDO );
  245. #if !defined( __WXMAC__ )
  246. static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y', (int) wxID_REDO );
  247. #else
  248. static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO,
  249. GR_KB_SHIFT + GR_KB_CTRL + 'Z',
  250. (int) wxID_REDO );
  251. #endif
  252. static EDA_HOTKEY HkEditCut( _HKI( "Cut" ), HK_EDIT_CUT, GR_KB_CTRL + 'X', (int) wxID_CUT );
  253. static EDA_HOTKEY HkEditCopy( _HKI( "Copy" ), HK_EDIT_COPY, GR_KB_CTRL + 'C', (int) wxID_COPY );
  254. static EDA_HOTKEY HkEditPaste( _HKI( "Paste" ), HK_EDIT_PASTE, GR_KB_CTRL + 'V', (int) wxID_PASTE );
  255. static EDA_HOTKEY HkToggleCursor( _HKI( "Toggle Cursor Display (Modern Toolset only)" ),
  256. HK_TOGGLE_CURSOR, 'X' + GR_KB_SHIFTCTRL );
  257. static EDA_HOTKEY HkMeasureTool( _HKI( "Measure Distance (Modern Toolset only)" ),
  258. HK_MEASURE_TOOL, 'M' + GR_KB_SHIFTCTRL );
  259. static EDA_HOTKEY HkInsertCorner( _HKI( "Insert Corner (Modern Toolset only)" ),
  260. HK_INSERT_CORNER, WXK_INSERT );
  261. // List of common hotkey descriptors
  262. EDA_HOTKEY* common_Hotkey_List[] =
  263. {
  264. &HkNew, &HkOpen, &HkSave, &HkSaveAs, &HkPrint,
  265. &HkUndo, &HkRedo,
  266. &HkEditCut, &HkEditCopy, &HkEditPaste,
  267. &HkHelp, &HkZoomIn, &HkZoomOut,
  268. &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, &HkZoomSelection, &Hk3DViewer,
  269. &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, &HkResetGridOrigin,
  270. &HkMouseLeftClick,
  271. &HkMouseLeftDClick,
  272. &HkIncLayerAlpha, &HkDecLayerAlpha,
  273. &HkToggleCursor,
  274. &HkMeasureTool,
  275. NULL
  276. };
  277. // common hotkey descriptors only useful in footprint viewer
  278. EDA_HOTKEY* common_basic_Hotkey_List[] =
  279. {
  280. &HkHelp, &HkZoomIn, &HkZoomOut,
  281. &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, &Hk3DViewer,
  282. &HkSwitchUnits, &HkResetLocalCoord,
  283. &HkMouseLeftClick,
  284. &HkMouseLeftDClick,
  285. NULL
  286. };
  287. // List of hotkey descriptors for Pcbnew
  288. EDA_HOTKEY* board_edit_Hotkey_List[] =
  289. {
  290. // Adding Items
  291. &HkPlaceItem,
  292. &HkAddModule,
  293. &HkAddFreeVia,
  294. &HkAddFilledZone,
  295. &HkAddKeepout,
  296. &HkAddZoneCutout,
  297. &HkAddSimilarZone,
  298. &HkAddLine,
  299. &HkAddCircle,
  300. &HkAddArc,
  301. &HkAddPolygon,
  302. &HkAddText,
  303. &HkAddDimension,
  304. &HkAddDXF,
  305. // Routing and options during routing
  306. &HkAddNewTrack,
  307. &HkSwitchTrackPosture,
  308. &HkDragTrackKeepSlope,
  309. &HkAddThroughVia,
  310. &HkAddBlindBuriedVia,
  311. &HkAddMicroVia,
  312. // Routing
  313. &HkRouteDiffPair,
  314. &HkRouteTuneSingle,
  315. &HkRouteTuneDiffPair,
  316. &HkRouteTuneSkew,
  317. // Routing Options
  318. &HkRoutingOptions,
  319. &HkRouteTuneSettings,
  320. &HkRouteTuneIncreaseSpacing,
  321. &HkRouteTuneDecreaseSpacing,
  322. &HkRouteTuneIncreaseAmp,
  323. &HkRouteTuneDecreaseAmp,
  324. &HkDpDimension,
  325. // Zones
  326. &HkZoneFillOrRefill,
  327. &HkZoneRemoveFilled,
  328. // Point editor (zones and segments)
  329. &HkInsertCorner,
  330. // Highlight and display
  331. &HkSelectConnection,
  332. &HkSelectCopper,
  333. &HkHighlightNetSelection,
  334. &HkTrackDisplayMode,
  335. // Adjust track/via sizes
  336. &HkCustomTrackWidth,
  337. &HkSwitchTrackWidthToNext,
  338. &HkSwitchTrackWidthToPrevious,
  339. &HkViaSizeInc,
  340. &HkViaSizeDec,
  341. // Remove items
  342. &HkDelete,
  343. &HkBackspace,
  344. // Edit placement
  345. &HkDragFootprint,
  346. &HkCopyItem,
  347. &HkMoveItem,
  348. &HkGetAndMoveFootprint,
  349. &HkMoveItemExact,
  350. &HkPositionItemRelative,
  351. &HkFlipItem,
  352. &HkRotateItem,
  353. &HkRotateItemClockwise,
  354. &HkSelLayerAndAddThroughVia,
  355. &HkSelLayerAndAddBlindBuriedVia,
  356. &HkDuplicateItem,
  357. &HkDuplicateItemAndIncrement,
  358. &HkCreateArray,
  359. &HkLock_Unlock_Footprint,
  360. &HkFindItem,
  361. &HkEditBoardItem,
  362. &HkEditWithModedit,
  363. // Active Layer
  364. &HkSwitch2ComponentLayer,
  365. &HkSwitch2CopperLayer,
  366. &HkSwitch2InnerLayer1,
  367. &HkSwitch2InnerLayer2,
  368. &HkSwitch2InnerLayer3,
  369. &HkSwitch2InnerLayer4,
  370. &HkSwitch2InnerLayer5,
  371. &HkSwitch2InnerLayer6,
  372. &HkSwitch2NextCopperLayer,
  373. &HkSwitch2PreviousCopperLayer,
  374. // Grids
  375. &HkSwitchGridToFastGrid1,
  376. &HkSwitchGridToFastGrid2,
  377. &HkSwitchGridToNext,
  378. &HkSwitchGridToPrevious,
  379. // Display
  380. &HkSwitchHighContrastMode,
  381. &HkCanvasDefault,
  382. &HkCanvasCairo,
  383. &HkCanvasOpenGL,
  384. NULL
  385. };
  386. // List of hotkey descriptors for the module editor
  387. EDA_HOTKEY* module_edit_Hotkey_List[] = {
  388. // Add Items
  389. &HkAddLine,
  390. &HkAddCircle,
  391. &HkAddArc,
  392. &HkAddPolygon,
  393. &HkAddText,
  394. &HkAddAnchor,
  395. // Delete/Move
  396. &HkDelete,
  397. &HkMoveItem,
  398. &HkMoveItemExact,
  399. &HkRotateItem,
  400. &HkSwitchTrackPosture,
  401. // Edit/Duplicate
  402. &HkEditBoardItem,
  403. &HkDuplicateItem,
  404. &HkDuplicateItemAndIncrement,
  405. &HkCreateArray,
  406. // Grids
  407. &HkSwitchGridToFastGrid1,
  408. &HkSwitchGridToFastGrid2,
  409. &HkSwitchGridToNext,
  410. &HkSwitchGridToPrevious,
  411. // Display
  412. &HkSwitchHighContrastMode,
  413. &HkCanvasDefault,
  414. &HkCanvasCairo,
  415. &HkCanvasOpenGL,
  416. NULL
  417. };
  418. // List of hotkey descriptors for the module viewer
  419. // Currently empty
  420. EDA_HOTKEY* module_viewer_Hotkey_List[] = {
  421. NULL
  422. };
  423. // Keyword Identifiers (tags) in key code configuration file (section names)
  424. // (.m_SectionTag member of a EDA_HOTKEY_CONFIG)
  425. static wxString boardEditorSectionTag( wxT( "[pcbnew]" ) );
  426. static wxString moduleEditSectionTag( wxT( "[footprinteditor]" ) );
  427. // Titles for hotkey editor and hotkey display
  428. static wxString commonSectionTitle( _HKI( "Common" ) );
  429. static wxString boardEditorSectionTitle( _HKI( "Board Editor" ) );
  430. static wxString moduleEditSectionTitle( _HKI( "Footprint Editor" ) );
  431. // list of sections and corresponding hotkey list for Pcbnew
  432. // (used to create an hotkey config file, and edit hotkeys )
  433. struct EDA_HOTKEY_CONFIG g_Pcbnew_Editor_Hotkeys_Descr[] = {
  434. { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle },
  435. { &boardEditorSectionTag, board_edit_Hotkey_List, &boardEditorSectionTitle },
  436. { &moduleEditSectionTag, module_edit_Hotkey_List, &moduleEditSectionTitle },
  437. { NULL, NULL, NULL }
  438. };
  439. // list of sections and corresponding hotkey list for the board editor
  440. // (used to list current hotkeys in the board editor)
  441. struct EDA_HOTKEY_CONFIG g_Board_Editor_Hotkeys_Descr[] = {
  442. { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle },
  443. { &boardEditorSectionTag, board_edit_Hotkey_List, &boardEditorSectionTitle },
  444. { NULL, NULL, NULL }
  445. };
  446. // list of sections and corresponding hotkey list for the footprint editor
  447. // (used to list current hotkeys in the module editor)
  448. struct EDA_HOTKEY_CONFIG g_Module_Editor_Hotkeys_Descr[] = {
  449. { &g_CommonSectionTag, common_Hotkey_List, &commonSectionTitle },
  450. { &moduleEditSectionTag, module_edit_Hotkey_List, &moduleEditSectionTitle },
  451. { NULL, NULL, NULL }
  452. };
  453. // list of sections and corresponding hotkey list for the footprint viewer
  454. // (used to list current hotkeys in the module viewer)
  455. struct EDA_HOTKEY_CONFIG g_Module_Viewer_Hotkeys_Descr[] = {
  456. { &g_CommonSectionTag, common_basic_Hotkey_List, &commonSectionTitle },
  457. { NULL, NULL, NULL }
  458. };
  459. EDA_HOTKEY* FOOTPRINT_VIEWER_FRAME::GetHotKeyDescription( int aCommand ) const
  460. {
  461. EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List );
  462. if( HK_Descr == NULL )
  463. HK_Descr = GetDescriptorFromCommand( aCommand, module_viewer_Hotkey_List );
  464. return HK_Descr;
  465. }
  466. bool FOOTPRINT_VIEWER_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
  467. EDA_ITEM* aItem )
  468. {
  469. if( aHotKey == 0 )
  470. return false;
  471. wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
  472. cmd.SetEventObject( this );
  473. /* Convert lower to upper case (the usual toupper function has problem with non ascii
  474. * codes like function keys */
  475. if( (aHotKey >= 'a') && (aHotKey <= 'z') )
  476. aHotKey += 'A' - 'a';
  477. EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List );
  478. if( HK_Descr == NULL )
  479. HK_Descr = GetDescriptorFromHotkey( aHotKey, module_viewer_Hotkey_List );
  480. if( HK_Descr == NULL )
  481. return false;
  482. switch( HK_Descr->m_Idcommand )
  483. {
  484. default:
  485. case HK_NOT_FOUND:
  486. return false;
  487. case HK_HELP: // Display Current hotkey list
  488. DisplayHotkeyList( this, g_Module_Viewer_Hotkeys_Descr );
  489. break;
  490. case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin
  491. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  492. break;
  493. case HK_LEFT_CLICK:
  494. OnLeftClick( aDC, aPosition );
  495. break;
  496. case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events
  497. OnLeftClick( aDC, aPosition );
  498. OnLeftDClick( aDC, aPosition );
  499. break;
  500. case HK_SWITCH_UNITS:
  501. cmd.SetId( (GetUserUnits() == INCHES) ?
  502. ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH );
  503. GetEventHandler()->ProcessEvent( cmd );
  504. break;
  505. case HK_ZOOM_IN:
  506. cmd.SetId( ID_KEY_ZOOM_IN );
  507. GetEventHandler()->ProcessEvent( cmd );
  508. break;
  509. case HK_ZOOM_OUT:
  510. cmd.SetId( ID_KEY_ZOOM_OUT );
  511. GetEventHandler()->ProcessEvent( cmd );
  512. break;
  513. case HK_ZOOM_REDRAW:
  514. cmd.SetId( ID_ZOOM_REDRAW );
  515. GetEventHandler()->ProcessEvent( cmd );
  516. break;
  517. case HK_ZOOM_CENTER:
  518. cmd.SetId( ID_POPUP_ZOOM_CENTER );
  519. GetEventHandler()->ProcessEvent( cmd );
  520. break;
  521. case HK_ZOOM_AUTO:
  522. cmd.SetId( ID_ZOOM_PAGE );
  523. GetEventHandler()->ProcessEvent( cmd );
  524. break;
  525. }
  526. return true;
  527. }
  528. EDA_HOTKEY* FOOTPRINT_WIZARD_FRAME::GetHotKeyDescription( int aCommand ) const
  529. {
  530. EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List );
  531. return HK_Descr;
  532. }
  533. bool FOOTPRINT_WIZARD_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
  534. EDA_ITEM* aItem )
  535. {
  536. if( aHotKey == 0 )
  537. return false;
  538. wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
  539. cmd.SetEventObject( this );
  540. /* Convert lower to upper case (the usual toupper function has problem with non ascii
  541. * codes like function keys */
  542. if( (aHotKey >= 'a') && (aHotKey <= 'z') )
  543. aHotKey += 'A' - 'a';
  544. EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List );
  545. if( HK_Descr == NULL )
  546. return false;
  547. switch( HK_Descr->m_Idcommand )
  548. {
  549. default:
  550. case HK_NOT_FOUND:
  551. return false;
  552. case HK_HELP: // Display Current hotkey list
  553. DisplayHotkeyList( this, g_Module_Viewer_Hotkeys_Descr );
  554. break;
  555. case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin
  556. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  557. break;
  558. case HK_LEFT_CLICK:
  559. OnLeftClick( aDC, aPosition );
  560. break;
  561. case HK_LEFT_DCLICK: // Simulate a double left click: generate 2 events
  562. OnLeftClick( aDC, aPosition );
  563. OnLeftDClick( aDC, aPosition );
  564. break;
  565. case HK_SWITCH_UNITS:
  566. cmd.SetId( (GetUserUnits() == INCHES) ?
  567. ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH );
  568. GetEventHandler()->ProcessEvent( cmd );
  569. break;
  570. case HK_ZOOM_IN:
  571. cmd.SetId( ID_KEY_ZOOM_IN );
  572. GetEventHandler()->ProcessEvent( cmd );
  573. break;
  574. case HK_ZOOM_OUT:
  575. cmd.SetId( ID_KEY_ZOOM_OUT );
  576. GetEventHandler()->ProcessEvent( cmd );
  577. break;
  578. case HK_ZOOM_REDRAW:
  579. cmd.SetId( ID_ZOOM_REDRAW );
  580. GetEventHandler()->ProcessEvent( cmd );
  581. break;
  582. case HK_ZOOM_CENTER:
  583. cmd.SetId( ID_POPUP_ZOOM_CENTER );
  584. GetEventHandler()->ProcessEvent( cmd );
  585. break;
  586. case HK_ZOOM_AUTO:
  587. cmd.SetId( ID_ZOOM_PAGE );
  588. GetEventHandler()->ProcessEvent( cmd );
  589. break;
  590. }
  591. return true;
  592. }