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.

208 lines
6.2 KiB

Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es
  5. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  6. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
  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. /**
  26. * @file footprint_wizard_frame.h
  27. */
  28. #ifndef FOOTPRINT_WIZARD_FRAME_H_
  29. #define FOOTPRINT_WIZARD_FRAME_H_
  30. #include <wx/gdicmn.h>
  31. #include <footprint_wizard.h>
  32. #include <pcb_base_edit_frame.h>
  33. class wxSashLayoutWindow;
  34. class wxSashEvent;
  35. class wxListBox;
  36. class WX_GRID;
  37. class wxGridEvent;
  38. class FOOTPRINT_EDIT_FRAME;
  39. enum WizardParameterColumnNames
  40. {
  41. WIZ_COL_NAME = 0,
  42. WIZ_COL_VALUE,
  43. WIZ_COL_UNITS
  44. };
  45. class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_EDIT_FRAME
  46. {
  47. public:
  48. FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* parent, FRAME_T aFrameType );
  49. ~FOOTPRINT_WIZARD_FRAME();
  50. ///< @copydoc PCB_BASE_FRAME::GetModel()
  51. BOARD_ITEM_CONTAINER* GetModel() const override;
  52. FOOTPRINT* GetBuiltFootprint();
  53. /**
  54. * Reload the Python plugins if they are newer than
  55. * the already loaded, and load new plugins if any
  56. */
  57. void PythonPluginsReload();
  58. COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
  59. private:
  60. void OnSize( wxSizeEvent& event ) override;
  61. void OnGridSize( wxSizeEvent& aSizeEvent );
  62. /**
  63. * Redraw the message panel.
  64. *
  65. * Display the current footprint info, or clear the message panel if nothing is loaded.
  66. */
  67. void UpdateMsgPanel() override;
  68. /**
  69. * Rebuild the GAL view (reint tool manager, colors and drawings) must be run after any
  70. * footprint change.
  71. */
  72. void updateView();
  73. /**
  74. * Will let the caller exit from the wait loop, and get the built footprint.
  75. *
  76. */
  77. void ExportSelectedFootprint( wxCommandEvent& aEvent );
  78. /**
  79. * Resize the child windows when dragging a sash window border.
  80. */
  81. void OnSashDrag( wxSashEvent& event );
  82. /**
  83. * Create or recreate the list of parameter pages for the current wizard.
  84. *
  85. * This list is sorted
  86. */
  87. void ReCreatePageList();
  88. /**
  89. * Create the list of parameters for the current page.
  90. */
  91. void ReCreateParameterList();
  92. /**
  93. * Expand the 'Value' column to fill available.
  94. */
  95. void ResizeParamColumns();
  96. /**
  97. * Prepare the grid where parameters are displayed.
  98. */
  99. void initParameterGrid();
  100. /**
  101. * Show the list of footprint wizards available into the system.
  102. */
  103. void SelectFootprintWizard();
  104. /**
  105. * Reload the current footprint.
  106. */
  107. void ReloadFootprint();
  108. /**
  109. * Display the message generated by the python build footprint script.
  110. */
  111. void DisplayBuildMessage( wxString& aMessage );
  112. /**
  113. * Reloads the wizard by name.
  114. */
  115. FOOTPRINT_WIZARD* GetMyWizard();
  116. void Process_Special_Functions( wxCommandEvent& event );
  117. /**
  118. * Show all the details about the current wizard.
  119. */
  120. void DisplayWizardInfos();
  121. void doCloseWindow() override;
  122. void ReCreateHToolbar() override;
  123. void ReCreateVToolbar() override;
  124. void ClickOnPageList( wxCommandEvent& event );
  125. void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
  126. void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
  127. WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override;
  128. /**
  129. * Called when the frame frame is activate to reload the libraries and component lists
  130. * that can be changed by the schematic editor or the library editor.
  131. */
  132. void OnActivate( wxActivateEvent& event );
  133. void SelectCurrentWizard( wxCommandEvent& event );
  134. void DefaultParameters( wxCommandEvent& event );
  135. /**
  136. * Update the footprint python parameters values from the values in grid.
  137. */
  138. void ParametersUpdated( wxGridEvent& event );
  139. /// @copydoc PCB_BASE_FRAME::Update3DView
  140. void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr ) override;
  141. /*
  142. * Not used here but needed by PCB_BASE_EDIT_FRAME.
  143. */
  144. void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {}
  145. void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {}
  146. void OnEditItemRequest( BOARD_ITEM* aItem ) override {}
  147. DECLARE_EVENT_TABLE()
  148. protected:
  149. wxString m_wizardName; ///< name of the current wizard
  150. wxString m_wizardDescription; ///< description of the wizard
  151. wxString m_wizardStatus; ///< current wizard status
  152. private:
  153. wxPanel* m_parametersPanel; ///< Panel for the page list and parameter grid
  154. wxListBox* m_pageList; ///< The list of pages
  155. WX_GRID* m_parameterGrid; ///< The list of parameters
  156. int m_parameterGridPage; ///< the page currently displayed by m_parameterGrid
  157. ///< it is most of time the m_pageList selection, but
  158. ///< can differ during transitions between pages.
  159. wxTextCtrl* m_buildMessageBox;
  160. wxString m_auiPerspective; ///< Encoded string describing the AUI layout
  161. bool m_wizardListShown; ///< A show-once flag for the wizard list
  162. };
  163. #endif // FOOTPRINT_WIZARD_FRM_H_