KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_footprint_wizard_list.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012-2014 Miguel Angel Ajo <[email protected]>
5 * Copyright (C) 1992-2023 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
29#include <wx/grid.h>
30
31#include <pcbnew_settings.h>
32#include <pgm_base.h>
34#include <string_utils.h>
35#include <kiface_base.h>
38
40
41
43{
47};
48
49
52{
53 initLists();
54
56 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
57
58 wxSize size;
59 size.x = cfg->m_FootprintWizardList.width;
60 size.y = cfg->m_FootprintWizardList.height;
61 SetSize( size );
62
65
66 Center();
67}
68
69
71{
73 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
74
75 if( cfg && !IsIconized() )
76 {
77
78 cfg->m_FootprintWizardList.width = GetSize().x;
79 cfg->m_FootprintWizardList.height = GetSize().y;
80 }
81}
82
83
85{
86 // Current wizard selection, empty or first
87 m_footprintWizard = NULL;
88
90
91 if( n_wizards )
93
94 // Choose selection mode and insert the needed rows
95
96 m_footprintGeneratorsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
97
98 int curr_row_cnt = m_footprintGeneratorsGrid->GetNumberRows();
99
100 if( curr_row_cnt )
101 m_footprintGeneratorsGrid->DeleteRows( 0, curr_row_cnt );
102
103 if( n_wizards )
104 m_footprintGeneratorsGrid->InsertRows( 0, n_wizards );
105
106 // Put all wizards in the list
107 for( int ii = 0; ii < n_wizards; ii++ )
108 {
109 wxString num = wxString::Format( wxT( "%d" ), ii+1 );
111 wxString name = wizard->GetName();
112 wxString description = wizard->GetDescription();
113
114 m_footprintGeneratorsGrid->SetCellValue( ii, FP_GEN_ROW_NUMBER, num );
115 m_footprintGeneratorsGrid->SetCellValue( ii, FP_GEN_ROW_NAME, name );
116 m_footprintGeneratorsGrid->SetCellValue( ii, FP_GEN_ROW_DESCR, description );
117
118 }
119
120 m_footprintGeneratorsGrid->AutoSizeColumns();
121
122 // Auto-expand the description column
123 int width = m_footprintGeneratorsGrid->GetClientSize().GetWidth() -
124 m_footprintGeneratorsGrid->GetRowLabelSize() -
126
127 if ( width > m_footprintGeneratorsGrid->GetColMinimalAcceptableWidth() )
128 m_footprintGeneratorsGrid->SetColSize( FP_GEN_ROW_DESCR, width );
129
130 // Select the first row if it exists
131 m_footprintGeneratorsGrid->ClearSelection();
132
133 if( m_footprintGeneratorsGrid->GetNumberRows() > 0 )
134 m_footprintGeneratorsGrid->SelectRow( 0, false );
135
136 // Display info about scripts: Search paths
137 wxString message;
139 m_tcSearchPaths->SetValue( message );
140
141 // Display info about scripts: unloadable scripts (due to syntax errors is python source).
143
144 if( message.IsEmpty() )
145 {
146 m_tcNotLoaded->SetValue( _( "All footprint generator scripts were loaded" ) );
147 m_buttonShowTrace->Show( false );
148 }
149 else
150 m_tcNotLoaded->SetValue( message );
151}
152
153
155{
156 FOOTPRINT_WIZARD_FRAME* fpw_frame = static_cast<FOOTPRINT_WIZARD_FRAME*>( GetParent() );
157 fpw_frame->PythonPluginsReload();
158
159 initLists();
160}
161
162
164{
165 int click_row = event.GetRow();
167 m_footprintGeneratorsGrid->SelectRow( event.GetRow(), false );
168
169 // Move the grid cursor to the active line, mainly for aesthetic reasons:
170 m_footprintGeneratorsGrid->GoToCell( event.GetRow(), FP_GEN_ROW_NUMBER );
171}
172
173
175{
176 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
177}
178
179
180void DIALOG_FOOTPRINT_WIZARD_LIST::onShowTrace( wxCommandEvent& event )
181{
182 wxString trace;
184
185 // Now display the filtered trace in our dialog
186 // (a simple wxMessageBox is really not suitable for long messages)
187 DIALOG_FOOTPRINT_WIZARD_LOG logWindow( this );
188 logWindow.m_Message->SetValue( trace );
189 logWindow.ShowModal();
190}
191
192
194{
195 return m_footprintWizard;
196}
const char * name
Definition: DXF_plotter.cpp:57
Class DIALOG_FOOTPRINT_WIZARD_LIST_BASE.
void onShowTrace(wxCommandEvent &event) override
void onUpdatePythonModulesClick(wxCommandEvent &event) override
void OnCellFpGeneratorDoubleClick(wxGridEvent &event) override
void OnCellFpGeneratorClick(wxGridEvent &event) override
FOOTPRINT_WIZARD * m_footprintWizard
The selected python script wizard.
Class DIALOG_FOOTPRINT_WIZARD_LOG.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
int ShowModal() override
void PythonPluginsReload()
Reload the Python plugins if they are newer than the already loaded, and load new plugins if any.
static FOOTPRINT_WIZARD * GetWizard(const wxString &aName)
The parent class from where any footprint wizard class must derive.
virtual wxString GetName()=0
virtual wxString GetDescription()=0
DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
#define _(s)
void pcbnewGetUnloadableScriptNames(wxString &aNames)
Collect the list of python scripts which could not be loaded.
void pcbnewGetScriptsSearchPaths(wxString &aNames)
Collect the list of paths where python scripts are searched.
void pcbnewGetWizardsBackTrace(wxString &aTrace)
Return the backtrace of errors (if any) when wizard python scripts are loaded.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE