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.

251 lines
8.9 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. /**
  24. * @file hotkeys_basic.h
  25. * @brief Some functions to handle hotkeys in KiCad
  26. */
  27. #ifndef HOTKEYS_BASIC_H
  28. #define HOTKEYS_BASIC_H
  29. #include <common.h>
  30. #define DEFAULT_HOTKEY_FILENAME_EXT wxT( "hotkeys" )
  31. // A define to allow translation of Hot Key message Info in hotkey help menu
  32. // We do not want to use the _( x ) usual macro from wxWidgets, which calls wxGetTranslation(),
  33. // because the English string is used in key file configuration
  34. // The translated string is used only when displaying the help window.
  35. // Therefore translation tools have to use the "_" and the "_HKI" prefix to extract
  36. // strings to translate
  37. #include <i18n_utility.h> // _HKI definition
  38. class EDA_BASE_FRAME;
  39. /* Identifiers (tags) in key code configuration file (or section names)
  40. * .m_SectionTag member of a EDA_HOTKEY_CONFIG
  41. */
  42. extern wxString g_CommonSectionTag;
  43. /**
  44. * class EDA_HOTKEY
  45. * is a class to handle hot key commands. Hot keys have a default value.
  46. * This class allows the real key code changed by user(from a key code list file)
  47. */
  48. class EDA_HOTKEY
  49. {
  50. private:
  51. int m_defaultKeyCode; // Key code assigned upon object construction, to be used as default value
  52. public:
  53. int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key
  54. wxString m_InfoMsg; // info message.
  55. int m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
  56. int m_IdMenuEvent; // id to call the corresponding event (if any) (see id.h)
  57. public:
  58. EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent = 0 );
  59. EDA_HOTKEY( const EDA_HOTKEY* base);
  60. void ResetKeyCodeToDefault() { m_KeyCode = m_defaultKeyCode; }
  61. };
  62. /**
  63. * Structure EDA_HOTKEY_CONFIG
  64. * contains the information required to save hot key information to a configuration file.
  65. * a Section name and the corresponding list of hotkeys (EDA_HOTKEY list)
  66. * hotkeys are grouped by section.
  67. * a section is a list of hotkey infos ( a EDA_HOTKEY list).
  68. * A full list of hotkeys can used one or many sections
  69. * for instance:
  70. * the schematic editor uses a common section (zoom hotkeys list ..) and a specific section
  71. * the library editor uses the same common section and a specific section
  72. * this feature avoid duplications and made hotkey file config easier to understand and edit
  73. */
  74. struct EDA_HOTKEY_CONFIG
  75. {
  76. public:
  77. wxString* m_SectionTag; // The configuration file section name.
  78. EDA_HOTKEY** m_HK_InfoList; // List of EDA_HOTKEY pointers
  79. wxString* m_Title; // Title displayed in hotkey editor and used as comment in file
  80. };
  81. /**
  82. * Class EDA_HOTKEY_CLIENT_DATA
  83. * provides client data member for hotkeys to include in command events generated
  84. * by the hot key.
  85. */
  86. class EDA_HOTKEY_CLIENT_DATA : public wxClientData
  87. {
  88. //< Logical position of the mouse cursor when the hot key was pressed.
  89. wxPoint m_position;
  90. public:
  91. EDA_HOTKEY_CLIENT_DATA( const wxPoint& aPosition = wxDefaultPosition ) :
  92. m_position( aPosition ) {}
  93. ~EDA_HOTKEY_CLIENT_DATA();
  94. void SetPosition( const wxPoint& aPosition ) { m_position = aPosition; }
  95. wxPoint GetPosition() { return m_position; }
  96. };
  97. /* Functions:
  98. */
  99. void AddHotkeyConfigMenu( wxMenu* menu );
  100. void HandleHotkeyConfigMenuSelection( EDA_BASE_FRAME* frame, int id );
  101. /**
  102. * Function KeyNameFromKeyCode
  103. * return the key name from the key code
  104. * * Only some wxWidgets key values are handled for function key ( see
  105. * s_Hotkey_Name_List[] )
  106. * @param aKeycode = key code (ascii value, or wxWidgets value for function keys)
  107. * @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default)
  108. * @return the key name in a wxString
  109. */
  110. wxString KeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL );
  111. /**
  112. * Function KeyNameFromCommandId
  113. * return the key name from the Command id value ( m_Idcommand member value)
  114. * @param aList = pointer to a EDA_HOTKEY list of commands
  115. * @param aCommandId = Command Id value
  116. * @return the key name in a wxString
  117. */
  118. wxString KeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId );
  119. /**
  120. * Function KeyCodeFromKeyName
  121. * return the key code from its key name
  122. * Only some wxWidgets key values are handled for function key
  123. * @param keyname = wxString key name to find in s_Hotkey_Name_List[],
  124. * like F2 or space or an usual (ascii) char.
  125. * @return the key code
  126. */
  127. int KeyCodeFromKeyName( const wxString& keyname );
  128. /**
  129. * An helper enum for AddHotkeyName function
  130. * In menus we can add a hot key, or an accelerator , or sometimes just a comment
  131. * Hot keys can perform actions using the current mouse cursor position
  132. * Accelerators perform the same action as the associated menu
  133. * A comment is used in tool tips for some tools (zoom ..)
  134. * to show the hot key that performs this action
  135. */
  136. enum HOTKEY_ACTION_TYPE
  137. {
  138. IS_HOTKEY,
  139. IS_ACCELERATOR,
  140. IS_COMMENT
  141. };
  142. /**
  143. * Function AddHotkeyName
  144. * Add the key name from the Command id value ( m_Idcommand member value)
  145. * @param aText = a wxString. returns aText + key name
  146. * @param aList = pointer to a EDA_HOTKEY list of commands
  147. * @param aCommandId = Command Id value
  148. * @param aShortCutType The #HOTKEY_ACTION_TYPE of the shortcut.
  149. * @return a wxString (aTest + key name) if key found or aText without modification
  150. */
  151. wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList, int aCommandId,
  152. HOTKEY_ACTION_TYPE aShortCutType = IS_HOTKEY);
  153. /**
  154. * Function AddHotkeyName
  155. * Add the key name from the Command id value ( m_Idcommand member value)
  156. * @param aText = a wxString. returns aText + key name
  157. * @param aDescrList = pointer to a EDA_HOTKEY_CONFIG DescrList of commands
  158. * @param aCommandId = Command Id value
  159. * @param aShortCutType The #HOTKEY_ACTION_TYPE of the shortcut.
  160. * @return a wxString (aTest + key name) if key found or aText without modification
  161. */
  162. wxString AddHotkeyName( const wxString& aText,
  163. struct EDA_HOTKEY_CONFIG* aDescrList,
  164. int aCommandId,
  165. HOTKEY_ACTION_TYPE aShortCutType = IS_HOTKEY );
  166. /**
  167. * Function DisplayHotkeyList
  168. * Displays the current hotkey list
  169. * @param aFrame = current active frame
  170. * @param aList = pointer to a EDA_HOTKEY_CONFIG list (Null terminated)
  171. */
  172. void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aList );
  173. /**
  174. * Function GetDescriptorFromHotkey
  175. * Returns a EDA_HOTKEY* pointer from a key code for OnHotKey() function
  176. * @param aKey = key code (ascii value, or wxWidgets value for function keys
  177. * @param aList = pointer to a EDA_HOTKEY list of commands
  178. * @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List
  179. */
  180. EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList );
  181. /**
  182. * Function GetDescriptorFromCommand
  183. * Returns a EDA_HOTKEY* pointer from a hot key identifier.
  184. * @param aCommand = hot key identifier (@see hotkeys.h)
  185. * @param aList = pointer to a EDA_HOTKEY list of commands
  186. * @return the corresponding EDA_HOTKEY pointer from the EDA_HOTKEY List
  187. */
  188. EDA_HOTKEY* GetDescriptorFromCommand( int aCommand, EDA_HOTKEY** aList );
  189. /**
  190. * Function ReadHotkeyConfig
  191. * Read hotkey configuration for a given app,
  192. * possibly before the frame for that app has been created
  193. * @param Appname = the value of the app's m_FrameName
  194. * @param aDescList = the hotkey data
  195. */
  196. void ReadHotkeyConfig( const wxString& Appname, struct EDA_HOTKEY_CONFIG* aDescList );
  197. void ParseHotkeyConfig( const wxString& data, struct EDA_HOTKEY_CONFIG* aDescList );
  198. // common hotkeys event id
  199. // these hotkey ID are used in many files, so they are define here only once.
  200. enum common_hotkey_id_commnand {
  201. HK_NOT_FOUND = 0,
  202. HK_RESET_LOCAL_COORD,
  203. HK_SET_GRID_ORIGIN,
  204. HK_RESET_GRID_ORIGIN,
  205. HK_HELP,
  206. HK_ZOOM_IN,
  207. HK_ZOOM_OUT,
  208. HK_ZOOM_REDRAW,
  209. HK_ZOOM_CENTER,
  210. HK_ZOOM_AUTO,
  211. HK_UNDO,
  212. HK_REDO,
  213. HK_COMMON_END
  214. };
  215. #endif // HOTKEYS_BASIC_H