KiCad PCB EDA Suite
footprint_select_widget.h
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) 2017 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef FOOTPRINT_SELECT_WIDGET_H
21 #define FOOTPRINT_SELECT_WIDGET_H
22 
23 #include <footprint_filter.h>
24 #include <footprint_info.h>
25 #include <vector>
26 #include <wx/panel.h>
27 #include <wx/wx.h>
28 
29 class KIWAY;
30 class PROJECT;
31 class FOOTPRINT_CHOICE;
32 class wxGauge;
33 class wxMenu;
34 class wxTimer;
35 class wxTimerEvent;
36 class wxWindow;
37 class wxSimplebook;
38 
43 wxDECLARE_EVENT( EVT_FOOTPRINT_SELECTED, wxCommandEvent );
44 
45 class FOOTPRINT_SELECT_WIDGET : public wxPanel
46 {
47 public:
68  FOOTPRINT_SELECT_WIDGET( wxWindow* aParent, FOOTPRINT_ASYNC_LOADER& aLoader,
69  std::unique_ptr<FOOTPRINT_LIST>& aFpList, bool aUpdate = true, int aMaxItems = 400 );
70 
72  {
73  }
74 
83  void Load( KIWAY& aKiway, PROJECT& aProject );
84 
88  void ClearFilters();
89 
93  void FilterByPinCount( int aPinCount );
94 
105  void FilterByFootprintFilters( wxArrayString const& aFilters, bool aZeroFilters );
106 
111  void SetDefaultFootprint( wxString const& aFp );
112 
120  bool UpdateList();
121 
125  void SelectDefault();
126 
130  virtual bool Enable( bool aEnable = true ) override;
131 
132 private:
134  wxGauge* m_progress_ctrl;
136  wxSizer* m_sizer;
137  wxSimplebook* m_book;
138 
139  std::unique_ptr<wxTimer> m_progress_timer;
140 
141  bool m_update;
147 
149  std::unique_ptr<FOOTPRINT_LIST>& m_fp_list;
152 
153  void OnProgressTimer( wxTimerEvent& aEvent );
154  void OnComboBox( wxCommandEvent& aEvent );
155  void OnComboInteractive( wxCommandEvent& aEvent );
156 
158  wxString ShowPicker();
159 
161  void DoOther();
162 };
163 
164 
165 #endif // FOOTPRINT_SELECT_WIDGET
wxDECLARE_EVENT(EVT_FOOTPRINT_SELECTED, wxCommandEvent)
This event is fired when a footprint is selected.
Class PROJECT holds project specific data.
Definition: project.h:52
void FilterByFootprintFilters(wxArrayString const &aFilters, bool aZeroFilters)
Filter by footprint filter list.
void OnComboInteractive(wxCommandEvent &aEvent)
void DoOther()
Handle activation of the "Other..." item.
FOOTPRINT_ASYNC_LOADER & m_fp_loader
void SetDefaultFootprint(wxString const &aFp)
Set the default footprint for a part.
std::unique_ptr< FOOTPRINT_LIST > & m_fp_list
Customized combo box for footprint selection.
This class can be used to populate a FOOTPRINT_LIST asynchronously.
wxString ShowPicker()
Show the component picker and return the selected component. Used by DoOther()
void ClearFilters()
Clear all filters.
bool UpdateList()
Update the contents of the list to match the filters.
void OnComboBox(wxCommandEvent &aEvent)
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
virtual bool Enable(bool aEnable=true) override
Enable or disable the control for input.
void OnProgressTimer(wxTimerEvent &aEvent)
Footprint display filter.
void SelectDefault()
Set current selection to the default footprint.
FOOTPRINT_SELECT_WIDGET(wxWindow *aParent, FOOTPRINT_ASYNC_LOADER &aLoader, std::unique_ptr< FOOTPRINT_LIST > &aFpList, bool aUpdate=true, int aMaxItems=400)
Construct a footprint selector widget.
void Load(KIWAY &aKiway, PROJECT &aProject)
Start loading.
std::unique_ptr< wxTimer > m_progress_timer
void FilterByPinCount(int aPinCount)
Filter by pin count.