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 /** 27 * @file footprint_wizard_frame.h 28 */ 29 30 #ifndef FOOTPRINT_WIZARD_FRAME_H_ 31 #define FOOTPRINT_WIZARD_FRAME_H_ 32 33 #include <wx/gdicmn.h> 34 #include <footprint_wizard.h> 35 #include <pcb_base_edit_frame.h> 36 37 class wxSashLayoutWindow; 38 class wxSashEvent; 39 class wxListBox; 40 class WX_GRID; 41 class wxGridEvent; 42 class FOOTPRINT_EDIT_FRAME; 43 44 45 enum WizardParameterColumnNames 46 { 47 WIZ_COL_NAME = 0, 48 WIZ_COL_VALUE, 49 WIZ_COL_UNITS 50 }; 51 52 class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_EDIT_FRAME 53 { 54 public: 55 FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* parent, FRAME_T aFrameType ); 56 57 ~FOOTPRINT_WIZARD_FRAME(); 58 59 ///< @copydoc PCB_BASE_FRAME::GetModel() 60 BOARD_ITEM_CONTAINER* GetModel() const override; 61 62 FOOTPRINT* GetBuiltFootprint(); 63 64 /** 65 * Reload the Python plugins if they are newer than 66 * the already loaded, and load new plugins if any 67 */ 68 void PythonPluginsReload(); 69 70 COLOR_SETTINGS* GetColorSettings() const override; 71 72 private: 73 74 void OnSize( wxSizeEvent& event ) override; 75 void OnGridSize( wxSizeEvent& aSizeEvent ); 76 77 /** 78 * Redraw the message panel. 79 * 80 * Display the current footprint info, or clear the message panel if nothing is loaded. 81 */ 82 void UpdateMsgPanel() override; 83 84 /** 85 * Rebuild the GAL view (reint tool manager, colors and drawings) must be run after any 86 * footprint change. 87 */ 88 void updateView(); 89 90 /** 91 * Will let the caller exit from the wait loop, and get the built footprint. 92 * 93 */ 94 void ExportSelectedFootprint( wxCommandEvent& aEvent ); 95 96 /** 97 * Resize the child windows when dragging a sash window border. 98 */ 99 void OnSashDrag( wxSashEvent& event ); 100 101 /** 102 * Create or recreate the list of parameter pages for the current wizard. 103 * 104 * This list is sorted 105 */ 106 void ReCreatePageList(); 107 108 /** 109 * Create the list of parameters for the current page. 110 */ 111 void ReCreateParameterList(); 112 113 /** 114 * Expand the 'Value' column to fill available. 115 */ 116 void ResizeParamColumns(); 117 118 /** 119 * Prepare the grid where parameters are displayed. 120 */ 121 void initParameterGrid(); 122 123 /** 124 * Show the list of footprint wizards available into the system. 125 */ 126 void SelectFootprintWizard(); 127 128 /** 129 * Reload the current footprint. 130 */ 131 void ReloadFootprint(); 132 133 /** 134 * Display the message generated by the python build footprint script. 135 */ 136 void DisplayBuildMessage( wxString& aMessage ); 137 138 /** 139 * Reloads the wizard by name. 140 */ 141 FOOTPRINT_WIZARD* GetMyWizard(); 142 143 void Process_Special_Functions( wxCommandEvent& event ); 144 145 /** 146 * Show all the details about the current wizard. 147 */ 148 void DisplayWizardInfos(); 149 150 void doCloseWindow() override; 151 void ReCreateHToolbar() override; 152 void ReCreateVToolbar() override; 153 void ClickOnPageList( wxCommandEvent& event ); 154 155 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; 156 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; 157 158 WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override; 159 160 /** 161 * Called when the frame frame is activate to reload the libraries and component lists 162 * that can be changed by the schematic editor or the library editor. 163 */ 164 void OnActivate( wxActivateEvent& event ); 165 166 void SelectCurrentWizard( wxCommandEvent& event ); 167 168 void DefaultParameters( wxCommandEvent& event ); 169 170 /** 171 * Update the footprint python parameters values from the values in grid. 172 */ 173 void ParametersUpdated( wxGridEvent& event ); 174 175 /// @copydoc PCB_BASE_FRAME::Update3DView 176 void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr ) override; 177 178 /* 179 * Not used here but needed by PCB_BASE_EDIT_FRAME. 180 */ SaveCopyInUndoList(EDA_ITEM *,UNDO_REDO)181 void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {} SaveCopyInUndoList(const PICKED_ITEMS_LIST &,UNDO_REDO)182 void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {} OnEditItemRequest(BOARD_ITEM * aItem)183 void OnEditItemRequest( BOARD_ITEM* aItem ) override {} 184 185 DECLARE_EVENT_TABLE() 186 187 protected: 188 wxString m_wizardName; ///< name of the current wizard 189 wxString m_wizardDescription; ///< description of the wizard 190 wxString m_wizardStatus; ///< current wizard status 191 192 private: 193 wxPanel* m_parametersPanel; ///< Panel for the page list and parameter grid 194 wxListBox* m_pageList; ///< The list of pages 195 WX_GRID* m_parameterGrid; ///< The list of parameters 196 int m_parameterGridPage; ///< the page currently displayed by m_parameterGrid 197 ///< it is most of time the m_pageList selection, but 198 ///< can differ during transitions between pages. 199 wxTextCtrl* m_buildMessageBox; 200 201 wxString m_auiPerspective; ///< Encoded string describing the AUI layout 202 203 bool m_wizardListShown; ///< A show-once flag for the wizard list 204 }; 205 206 207 208 #endif // FOOTPRINT_WIZARD_FRM_H_ 209