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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <wx/grid.h>
22
24#include <pgm_base.h>
25#include <reporter.h>
26#include <string_utils.h>
27#include <kiface_base.h>
30#include <widgets/kistatusbar.h>
31
32
38
39
51
52
57
58
60{
61 m_selectedWizard = wxEmptyString;
62 m_footprintGeneratorsGrid->ClearGrid();
63
65 std::vector<FOOTPRINT_WIZARD*> wizards = manager->Wizards();
66
67 if( wizards.empty() )
68 {
69 std::shared_ptr<REPORTER> reporter;
70
71 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( ParentFrame()->GetStatusBar() ) )
72 reporter = std::make_shared<STATUSBAR_WARNING_REPORTER>( statusBar, wxS( "plugin" ) );
73
74 manager->ReloadWizards( reporter );
75 wizards = manager->Wizards();
76 }
77
78 m_footprintGeneratorsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
79
80 if( !wizards.empty() )
81 {
82 m_selectedWizard = wizards[0]->Identifier();
83 m_footprintGeneratorsGrid->InsertRows( 0, wizards.size() );
84 }
85
86 int idx = 0;
87
88 for( FOOTPRINT_WIZARD* wizard : wizards )
89 {
90 wxString name = wizard->Info().meta.name;
91 wxString description = wizard->Info().meta.description;
92
93 m_footprintGeneratorsGrid->SetCellValue( idx, FP_GEN_ROW_NAME, name );
94 m_footprintGeneratorsGrid->SetCellValue( idx++, FP_GEN_ROW_DESCR, description );
95 }
96
97 m_footprintGeneratorsGrid->AutoSizeColumns();
98
99 // Auto-expand the description column
100 int width = m_footprintGeneratorsGrid->GetClientSize().GetWidth()
101 - m_footprintGeneratorsGrid->GetRowLabelSize()
103
104 if ( width > m_footprintGeneratorsGrid->GetColMinimalAcceptableWidth() )
105 m_footprintGeneratorsGrid->SetColSize( FP_GEN_ROW_DESCR, width );
106
107 // Select the first row if it exists
108 m_footprintGeneratorsGrid->ClearSelection();
109
110 if( m_footprintGeneratorsGrid->GetNumberRows() > 0 )
111 m_footprintGeneratorsGrid->SelectRow( 0, false );
112}
113
114
116{
117 int click_row = event.GetRow();
118
120 std::vector<FOOTPRINT_WIZARD*> wizards = manager->Wizards();
121
122 if( click_row >= 0 && click_row < static_cast<int>( wizards.size() ) )
123 m_selectedWizard = wizards[click_row]->Identifier();
124
125 m_footprintGeneratorsGrid->SelectRow( event.GetRow(), false );
126
127 // Move the grid cursor to the active line, mainly for aesthetic reasons:
128 m_footprintGeneratorsGrid->GoToCell( event.GetRow(), FP_GEN_ROW_NAME );
129}
130
131
133{
134 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
135}
136
137
139{
140 return m_selectedWizard;
141}
const char * name
DIALOG_FOOTPRINT_WIZARD_LIST_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Footprint Wizards"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnCellFpGeneratorDoubleClick(wxGridEvent &event) override
void OnCellFpGeneratorClick(wxGridEvent &event) override
wxString m_selectedWizard
The selected footprint wizard identifier.
DIALOG_FOOTPRINT_WIZARD_LIST(FOOTPRINT_WIZARD_FRAME *aParent)
void OptOut(wxWindow *aWindow)
Opt out of control state saving.
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...
FOOTPRINT_WIZARD_MANAGER * Manager() const
The footprint wizard manager interfaces with API_PLUGINs that can generate footprints.
std::vector< FOOTPRINT_WIZARD * > Wizards() const
void ReloadWizards(std::shared_ptr< REPORTER > aReporter=nullptr)
Goes through the list of IPC API plugins that provide wizard actions and attempts to refresh the info...
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:50
see class PGM_BASE
IbisParser parser & reporter