KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_footprint_chooser.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) 2023 CERN
5 * Copyright (C) 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
26#include <wx/sizer.h>
27#include <wx/button.h>
28#include <pcb_base_frame.h>
30
31
33 const LIB_ID& aPreselect,
34 const wxArrayString& aFootprintHistoryList ) :
35 DIALOG_SHIM( aParent, wxID_ANY, _( "Choose Footprint" ), wxDefaultPosition, wxDefaultSize,
36 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
37{
38 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
39 m_chooserPanel = new PANEL_FOOTPRINT_CHOOSER( aParent, this, aFootprintHistoryList,
40 // Filter
41 []( LIB_TREE_NODE& aNode ) -> bool
42 {
43 return true;
44 },
45 // Close handler
46 [this]()
47 {
48 EndModal( wxID_OK );
49 } );
50
51 sizer->Add( m_chooserPanel, 1, wxEXPAND, 5 );
52
53 if( aPreselect.IsValid() )
54 m_chooserPanel->SetPreselect( aPreselect );
55
56 SetTitle( GetTitle() + wxString::Format( _( " (%d items loaded)" ),
58
59 wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer();
60 wxButton* okButton = new wxButton( this, wxID_OK );
61 wxButton* cancelButton = new wxButton( this, wxID_CANCEL );
62 sdbSizer->AddButton( okButton );
63 sdbSizer->AddButton( cancelButton );
64 sdbSizer->Realize();
65
66 sizer->Add( sdbSizer, 0, wxEXPAND | wxALL, 5 );
67 SetSizer( sizer );
68
71
73 Layout();
74}
75
76
78{
80}
LIB_ID GetSelectedLibId() const
To be called after this dialog returns from ShowModal().
DIALOG_FOOTPRINT_CHOOSER(PCB_BASE_FRAME *aParent, const LIB_ID &aPreselect, const wxArrayString &aFootprintHistoryList)
PANEL_FOOTPRINT_CHOOSER * m_chooserPanel
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
void SetupStandardButtons(std::map< int, wxString > aLabels={})
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
wxWindow * GetFocusTarget() const
void SetPreselect(const LIB_ID &aPreselect)
LIB_ID GetSelectedLibId() const
To be called after this dialog returns from ShowModal().
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
#define _(s)