KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_get_footprint_by_name.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) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <wx/arrstr.h>
27
28
30 wxArrayString& aFpList ) :
32{
33 m_choiceFpList->Append( aFpList );
34
35 m_multipleHint->SetFont( KIUI::GetInfoFont( this ).Italic() );
36
37 // Hide help string until someone implements successive placement (#2227)
38 m_multipleHint->Show( false );
39
41
43
44 // Dialog should not shrink beyond it's minimal size.
45 GetSizer()->SetSizeHints( this );
46}
47
48
50{
51 return m_SearchTextCtrl->GetValue();
52}
53
54
55static wxString GetFootprintName( const wxString& aOptionCtrlString )
56{
57 return aOptionCtrlString.BeforeFirst( ' ' );
58}
59
60
62{
63 const int selection = m_choiceFpList->GetSelection();
64 if( selection >= 0 )
65 {
66 m_SearchTextCtrl->SetValue( GetFootprintName( m_choiceFpList->GetString( selection ) ) );
67 }
68}
69
70
72{
73 // Find the matching footprint in the list if there is one
74 const wxString entry = m_SearchTextCtrl->GetValue().Trim( true ).Trim( false );
75
76 for( unsigned ii = 0; ii < m_choiceFpList->GetCount(); ++ii )
77 {
78 if( GetFootprintName( m_choiceFpList->GetString( ii ) ).IsSameAs( entry, false ) )
79 {
80 m_choiceFpList->SetSelection( ii );
81 return;
82 }
83 }
84 m_choiceFpList->SetSelection( -1 );
85}
Class DIALOG_GET_FOOTPRINT_BY_NAME_BASE.
DIALOG_GET_FOOTPRINT_BY_NAME(PCB_BASE_FRAME *aParent, wxArrayString &aFpList)
void OnSelectFootprint(wxCommandEvent &aEvent) override
void OnSearchInputChanged(wxCommandEvent &event) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:102
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
static wxString GetFootprintName(const wxString &aOptionCtrlString)
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:154