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, 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
25
#include <wx/grid.h>
26
27
#include <
api/api_plugin_manager.h
>
28
#include <
pgm_base.h
>
29
#include <
string_utils.h
>
30
#include <
kiface_base.h
>
31
#include <
dialog_footprint_wizard_list.h
>
32
#include <
footprint_wizard_frame.h
>
33
34
35
enum
FPGeneratorRowNames
36
{
37
FP_GEN_ROW_NAME
= 0,
38
FP_GEN_ROW_DESCR
,
39
};
40
41
42
DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST
(
FOOTPRINT_WIZARD_FRAME
* aParent ) :
43
DIALOG_FOOTPRINT_WIZARD_LIST_BASE
( aParent )
44
{
45
OptOut
(
this
);
46
initLists
();
47
48
SetupStandardButtons
();
49
finishDialogSettings
();
50
51
Center();
52
}
53
54
55
FOOTPRINT_WIZARD_FRAME
*
DIALOG_FOOTPRINT_WIZARD_LIST::ParentFrame
()
56
{
57
return
static_cast<
FOOTPRINT_WIZARD_FRAME
*
>
( m_parent );
58
}
59
60
61
void
DIALOG_FOOTPRINT_WIZARD_LIST::initLists
()
62
{
63
m_selectedWizard
= wxEmptyString;
64
m_footprintGeneratorsGrid
->ClearGrid();
65
66
FOOTPRINT_WIZARD_MANAGER
* manager =
ParentFrame
()->
Manager
();
67
68
manager->
ReloadWizards
();
69
std::vector<FOOTPRINT_WIZARD*> wizards = manager->
Wizards
();
70
71
m_footprintGeneratorsGrid
->SetSelectionMode( wxGrid::wxGridSelectRows );
72
73
if
( !wizards.empty() )
74
{
75
m_selectedWizard
= wizards[0]->Identifier();
76
m_footprintGeneratorsGrid
->InsertRows( 0, wizards.size() );
77
}
78
79
int
idx = 0;
80
81
for
(
FOOTPRINT_WIZARD
* wizard : wizards )
82
{
83
wxString
name
= wizard->Info().meta.name;
84
wxString description = wizard->Info().meta.description;
85
86
m_footprintGeneratorsGrid
->SetCellValue( idx,
FP_GEN_ROW_NAME
,
name
);
87
m_footprintGeneratorsGrid
->SetCellValue( idx++,
FP_GEN_ROW_DESCR
, description );
88
}
89
90
m_footprintGeneratorsGrid
->AutoSizeColumns();
91
92
// Auto-expand the description column
93
int
width =
m_footprintGeneratorsGrid
->GetClientSize().GetWidth()
94
-
m_footprintGeneratorsGrid
->GetRowLabelSize()
95
-
m_footprintGeneratorsGrid
->GetColSize(
FP_GEN_ROW_NAME
);
96
97
if
( width >
m_footprintGeneratorsGrid
->GetColMinimalAcceptableWidth() )
98
m_footprintGeneratorsGrid
->SetColSize(
FP_GEN_ROW_DESCR
, width );
99
100
// Select the first row if it exists
101
m_footprintGeneratorsGrid
->ClearSelection();
102
103
if
(
m_footprintGeneratorsGrid
->GetNumberRows() > 0 )
104
m_footprintGeneratorsGrid
->SelectRow( 0,
false
);
105
}
106
107
108
void
DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorClick
( wxGridEvent& event )
109
{
110
int
click_row =
event
.GetRow();
111
112
FOOTPRINT_WIZARD_MANAGER
* manager =
ParentFrame
()->
Manager
();
113
std::vector<FOOTPRINT_WIZARD*> wizards = manager->
Wizards
();
114
115
if
( click_row >= 0 && click_row <
static_cast<
int
>
( wizards.size() ) )
116
m_selectedWizard
= wizards[click_row]->Identifier();
117
118
m_footprintGeneratorsGrid
->SelectRow( event.GetRow(),
false
);
119
120
// Move the grid cursor to the active line, mainly for aesthetic reasons:
121
m_footprintGeneratorsGrid
->GoToCell( event.GetRow(),
FP_GEN_ROW_NAME
);
122
}
123
124
125
void
DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorDoubleClick
( wxGridEvent& event )
126
{
127
wxPostEvent(
this
, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
128
}
129
130
131
const
wxString&
DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard
()
132
{
133
return
m_selectedWizard
;
134
}
name
const char * name
Definition
DXF_plotter.cpp:65
api_plugin_manager.h
DIALOG_FOOTPRINT_WIZARD_LIST_BASE::m_footprintGeneratorsGrid
wxGrid * m_footprintGeneratorsGrid
Definition
dialog_footprint_wizard_list_base.h:35
DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE
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)
Definition
dialog_footprint_wizard_list_base.cpp:12
DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorDoubleClick
void OnCellFpGeneratorDoubleClick(wxGridEvent &event) override
Definition
dialog_footprint_wizard_list.cpp:125
DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorClick
void OnCellFpGeneratorClick(wxGridEvent &event) override
Definition
dialog_footprint_wizard_list.cpp:108
DIALOG_FOOTPRINT_WIZARD_LIST::ParentFrame
FOOTPRINT_WIZARD_FRAME * ParentFrame()
Definition
dialog_footprint_wizard_list.cpp:55
DIALOG_FOOTPRINT_WIZARD_LIST::initLists
void initLists()
Definition
dialog_footprint_wizard_list.cpp:61
DIALOG_FOOTPRINT_WIZARD_LIST::m_selectedWizard
wxString m_selectedWizard
The selected footprint wizard identifier.
Definition
dialog_footprint_wizard_list.h:48
DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard
const wxString & GetWizard()
Definition
dialog_footprint_wizard_list.cpp:131
DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST
DIALOG_FOOTPRINT_WIZARD_LIST(FOOTPRINT_WIZARD_FRAME *aParent)
Definition
dialog_footprint_wizard_list.cpp:42
DIALOG_SHIM::OptOut
void OptOut(wxWindow *aWindow)
Opt out of control state saving.
Definition
dialog_shim.cpp:831
DIALOG_SHIM::SetupStandardButtons
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Definition
dialog_shim.cpp:1758
DIALOG_SHIM::finishDialogSettings
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Definition
dialog_shim.cpp:295
FOOTPRINT_WIZARD_FRAME
Definition
footprint_wizard_frame.h:45
FOOTPRINT_WIZARD_FRAME::Manager
FOOTPRINT_WIZARD_MANAGER * Manager() const
Definition
footprint_wizard_frame.h:70
FOOTPRINT_WIZARD_MANAGER
The footprint wizard manager interfaces with API_PLUGINs that can generate footprints.
Definition
footprint_wizard.h:163
FOOTPRINT_WIZARD_MANAGER::ReloadWizards
void ReloadWizards()
Goes through the list of IPC API plugins that provide wizard actions and attempts to refresh the info...
Definition
footprint_wizard.cpp:39
FOOTPRINT_WIZARD_MANAGER::Wizards
std::vector< FOOTPRINT_WIZARD * > Wizards() const
Definition
footprint_wizard.cpp:59
FOOTPRINT_WIZARD
Definition
footprint_wizard.h:136
FPGeneratorRowNames
FPGeneratorRowNames
Definition
dialog_footprint_wizard_list.cpp:36
FP_GEN_ROW_NAME
@ FP_GEN_ROW_NAME
Definition
dialog_footprint_wizard_list.cpp:37
FP_GEN_ROW_DESCR
@ FP_GEN_ROW_DESCR
Definition
dialog_footprint_wizard_list.cpp:38
dialog_footprint_wizard_list.h
footprint_wizard_frame.h
kiface_base.h
pgm_base.h
see class PGM_BASE
string_utils.h
src
pcbnew
dialogs
dialog_footprint_wizard_list.cpp
Generated on Fri Apr 3 2026 00:07:18 for KiCad PCB EDA Suite by
1.13.2