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.

325 lines
10 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
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 CERN
  5. * Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
  6. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #ifndef _PL_EDITOR_FRAME_H
  26. #define _PL_EDITOR_FRAME_H
  27. #include <config_params.h>
  28. #include <eda_draw_frame.h>
  29. #include <pl_editor_screen.h>
  30. #include <pl_editor_layout.h>
  31. #include <pl_draw_panel_gal.h>
  32. class PROPERTIES_FRAME;
  33. class WS_DATA_ITEM;
  34. /**
  35. * Class PL_EDITOR_FRAME
  36. * is the main window used in the page layout editor.
  37. */
  38. class PL_EDITOR_FRAME : public EDA_DRAW_FRAME
  39. {
  40. PL_EDITOR_LAYOUT m_pageLayout;
  41. int m_propertiesFrameWidth; // the last width (in pixels) of m_propertiesPagelayout
  42. wxChoice* m_originSelectBox; // Corner origin choice for coordinates
  43. int m_originSelectChoice; // the last choice for m_originSelectBox
  44. wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
  45. // usefull when there are some items which are
  46. // only on page 1, not on page 1
  47. wxPoint m_grid_origin;
  48. protected:
  49. /// The last filename chosen to be proposed to the user
  50. wxString m_lastFileName;
  51. PROPERTIES_FRAME* m_propertiesPagelayout;
  52. private:
  53. // list of PARAM_CFG_xxx to read/write parameters saved in config
  54. PARAM_CFG_ARRAY m_configSettings;
  55. public:
  56. PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
  57. ~PL_EDITOR_FRAME() {}
  58. PROPERTIES_FRAME* GetPropertiesFrame() { return m_propertiesPagelayout; }
  59. /**
  60. * Show the dialog displaying the list of WS_DATA_ITEM items in the page layout
  61. */
  62. void ShowDesignInspector();
  63. bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
  64. /**
  65. * Function LoadPageLayoutDescrFile
  66. * Loads a .kicad_wks page layout descr file
  67. * @param aFullFileName = the filename.
  68. */
  69. bool LoadPageLayoutDescrFile( const wxString& aFullFileName );
  70. /**
  71. * Function SavePageLayoutDescrFile
  72. * Save the current layout in a .kicad_wks page layout descr file
  73. * @param aFullFileName = the filename.
  74. */
  75. bool SavePageLayoutDescrFile( const wxString& aFullFileName );
  76. /**
  77. * Function InsertPageLayoutDescrFile
  78. * Loads a .kicad_wks page layout descr file, and add items to the current layout list
  79. * @param aFullFileName = the filename.
  80. */
  81. bool InsertPageLayoutDescrFile( const wxString& aFullFileName );
  82. /*
  83. * Function OnExit
  84. * Event handler for the wxID_EXIT and wxID_CLOSE events
  85. */
  86. void OnExit( wxCommandEvent& aEvent );
  87. /*
  88. * Function OnCloseWindow
  89. * Event handler for the close event
  90. */
  91. void OnCloseWindow( wxCloseEvent& aEvent );
  92. // The Tool Framework initalization
  93. void setupTools();
  94. // Virtual basic functions:
  95. void ReCreateHToolbar() override;
  96. void SetPageSettings(const PAGE_INFO&) override;
  97. const PAGE_INFO& GetPageSettings () const override;
  98. const wxSize GetPageSizeIU() const override;
  99. /**
  100. * Function GetZoomLevelIndicator
  101. * returns a human readable value which can be displayed in dialogs.
  102. */
  103. const wxString GetZoomLevelIndicator() const override;
  104. PL_DRAW_PANEL_GAL* GetCanvas() const override;
  105. PL_EDITOR_SCREEN* GetScreen() const override
  106. {
  107. return (PL_EDITOR_SCREEN*) EDA_DRAW_FRAME::GetScreen();
  108. }
  109. const wxPoint& GetAuxOrigin() const override
  110. {
  111. static wxPoint dummy; // ( 0,0 );
  112. return dummy;
  113. }
  114. void SetAuxOrigin( const wxPoint& aPosition ) override {}
  115. const wxPoint& GetGridOrigin() const override
  116. {
  117. return m_grid_origin;
  118. }
  119. void SetGridOrigin( const wxPoint& aPoint ) override
  120. {
  121. m_grid_origin = aPoint;
  122. }
  123. /**
  124. * calculate the position (in page, in iu) of the corner used as coordinate origin
  125. * of items
  126. */
  127. wxPoint ReturnCoordOriginCorner() const;
  128. const TITLE_BLOCK& GetTitleBlock() const override;
  129. void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
  130. void DisplayGridMsg();
  131. void UpdateStatusBar() override;
  132. /**
  133. * Must be called to initialize parameters when a new page layout description is loaded
  134. */
  135. void OnNewPageLayout();
  136. /**
  137. * creates or updates the right vertical toolbar.
  138. */
  139. void ReCreateVToolbar() override;
  140. /**
  141. * Create or update the left vertical toolbar (option toolbar
  142. * @note This is currently not used.
  143. */
  144. void ReCreateOptToolbar() override;
  145. void ReCreateMenuBar() override;
  146. void SyncToolbars() override;
  147. const PL_EDITOR_LAYOUT& GetPageLayout() const { return m_pageLayout; }
  148. PL_EDITOR_LAYOUT& GetPageLayout() { return m_pageLayout; }
  149. const BOX2I GetDocumentExtents() const override;
  150. /**
  151. * Page layout editor can show the title block using a page number 1 or another number.
  152. * This is because some items can be shown (or not) only on page 1 (a feature which
  153. * looks like word processing option "page 1 differs from other pages").
  154. * @return true if the page 1 is selected, and false if not
  155. */
  156. bool GetPageNumberOption() const
  157. {
  158. return m_pageSelectBox->GetSelection() == 0;
  159. }
  160. /**
  161. * Displays the short filename (if exists) loaded file on the caption of the main window
  162. */
  163. void UpdateTitleAndInfo();
  164. void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
  165. /**
  166. * Populates the applicatios settings list.
  167. * (list of parameters that must be saved in project parameters)
  168. * Currently, only the settings that are needed at start up by the main window are
  169. * defined here. There are other locally used settings scattered throughout the
  170. * source code (mainly in dialogs). If you need to define a configuration
  171. * setting that need to be loaded at run time, this is the place to define it.
  172. */
  173. PARAM_CFG_ARRAY& GetConfigurationSettings() { return m_configSettings; }
  174. void LoadSettings( wxConfigBase* aCfg ) override;
  175. void SaveSettings( wxConfigBase* aCfg ) override;
  176. void OnSelectPage( wxCommandEvent& event );
  177. /**
  178. * called when the user select one of the 4 page corner as corner reference (or the
  179. * left top paper corner)
  180. */
  181. void OnSelectCoordOriginCorner( wxCommandEvent& event );
  182. /**
  183. * Toggle the display mode between the normal mode and the editor mode:
  184. * In normal mode, title block texts are shown like they will be shown in other kicad
  185. * applications: the format symbols in texts are replaced by the actual text.
  186. * In editor mode, the format symbols in texts are not replaced by the actual text,
  187. * and therefore format symbols are displayed.
  188. */
  189. void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
  190. void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event );
  191. void OnUpdateTitleBlockDisplayEditMode( wxUpdateUIEvent& event );
  192. /**
  193. * Function ToPrinter
  194. * Open a dialog frame to print layers
  195. */
  196. void ToPrinter( bool doPreview );
  197. void Files_io( wxCommandEvent& event );
  198. /** Virtual function PrintPage
  199. * used to print a page
  200. * @param aDC = wxDC given by the calling print function
  201. */
  202. virtual void PrintPage( wxDC* aDC ) override;
  203. void OnFileHistory( wxCommandEvent& event );
  204. /**
  205. * @return the filename of the current layout descr file
  206. * If this is the default (no loaded file) returns a emtpy name
  207. * or a new design.
  208. */
  209. const wxString& GetCurrFileName() const;
  210. /**
  211. * Stores the current layout descr file filename
  212. */
  213. void SetCurrFileName( const wxString& aName );
  214. /**
  215. * Refresh the library tree and redraw the window
  216. */
  217. void HardRedraw() override;
  218. /**
  219. * Function AddPageLayoutItem
  220. * Add a new item to the page layout item list.
  221. * @param aType = the type of item:
  222. * WS_TEXT, WS_SEGMENT, WS_RECT, WS_POLYPOLYGON
  223. * @param aIdx = the position in list to insert the new item.
  224. * @return a reference to the new item
  225. */
  226. WS_DATA_ITEM* AddPageLayoutItem( int aType );
  227. /**
  228. * Must be called after a change in order to set the "modify" flag
  229. */
  230. void OnModify()
  231. {
  232. GetScreen()->SetModify();
  233. }
  234. /**
  235. * Save a copy of the description (in a S expr string) for Undo/redo commands.
  236. * Optionally save the pageInfo and titleBlock as well.
  237. */
  238. void SaveCopyInUndoList( bool aSavePageSettingsAndTitleBlock = false );
  239. /** Redo the last edit:
  240. * - Place the current edited layout in undo list
  241. * - Get the previous version of the current edited layput
  242. */
  243. void GetLayoutFromRedoList();
  244. /** Undo the last edit:
  245. * - Place the current layout in Redo list
  246. * - Get the previous version of the current edited layout
  247. */
  248. void GetLayoutFromUndoList();
  249. /**
  250. * Apply the last command in Undo List without stacking a Redo. Used to clean the
  251. * Undo stack after cancelling a command.
  252. */
  253. void RollbackFromUndo();
  254. protected:
  255. bool saveCurrentPageLayout();
  256. DECLARE_EVENT_TABLE()
  257. };
  258. #endif /* _PL_EDITOR_FRAME_H */