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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <wx/arrstr.h>
23
24
26 wxArrayString& aFpList ) :
28{
29 m_choiceFpList->Append( aFpList );
30
31 m_multipleHint->SetFont( KIUI::GetInfoFont( this ).Italic() );
32
33 // Hide help string until someone implements successive placement (#2227)
34 m_multipleHint->Show( false );
35
37
39
40 // Dialog should not shrink beyond it's minimal size.
41 GetSizer()->SetSizeHints( this );
42}
43
44
46{
47 return m_SearchTextCtrl->GetValue();
48}
49
50
51static wxString GetFootprintName( const wxString& aOptionCtrlString )
52{
53 return aOptionCtrlString.BeforeFirst( ' ' );
54}
55
56
58{
59 const int selection = m_choiceFpList->GetSelection();
60 if( selection >= 0 )
61 {
62 m_SearchTextCtrl->SetValue( GetFootprintName( m_choiceFpList->GetString( selection ) ) );
63 }
64}
65
66
68{
69 // Find the matching footprint in the list if there is one
70 const wxString entry = m_SearchTextCtrl->GetValue().Trim( true ).Trim( false );
71
72 for( unsigned ii = 0; ii < m_choiceFpList->GetCount(); ++ii )
73 {
74 if( GetFootprintName( m_choiceFpList->GetString( ii ) ).IsSameAs( entry, false ) )
75 {
76 m_choiceFpList->SetSelection( ii );
77 return;
78 }
79 }
80 m_choiceFpList->SetSelection( -1 );
81}
DIALOG_GET_FOOTPRINT_BY_NAME_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Get and Move Footprint"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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:79
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)