KiCad PCB EDA Suite
dialog_choose_component.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) 2014 Henner Zeller <h.zeller@acm.org>
5  * Copyright (C) 2014-2019 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 #ifndef DIALOG_CHOOSE_COMPONENT_H
25 #define DIALOG_CHOOSE_COMPONENT_H
26 
27 #include "dialog_shim.h"
29 #include <footprint_info.h>
30 
31 class wxStaticBitmap;
32 class wxTextCtrl;
33 class wxStdDialogButtonSizer;
34 class wxDataViewCtrl;
35 class wxHtmlWindow;
36 class wxHtmlLinkEvent;
37 class wxPanel;
38 class wxChoice;
39 class wxButton;
40 class wxTimer;
41 
42 class LIB_TREE;
46 class LIB_ALIAS;
47 class LIB_PART;
48 class SCH_BASE_FRAME;
49 class SCH_DRAW_PANEL;
50 
51 
89 {
90 public:
106  DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
107  SYMBOL_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert,
108  bool aAllowFieldEdits, bool aShowFootprints, bool aAllowBrowser );
109 
111 
123  LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
124 
132  bool GetUseAllUnits() const { return m_useUnits->GetValue(); }
133 
142  bool GetKeepSymbol() const { return m_keepSymbol->GetValue(); }
143 
148  std::vector<std::pair<int, wxString>> GetFields() const
149  {
150  return m_field_edits;
151  }
152 
159  {
161  }
162 
163  static std::mutex g_Mutex;
164 
165 protected:
166  static constexpr int DblClickDelay = 100; // milliseconds
167 
168  wxPanel* ConstructRightPanel( wxWindow* aParent );
169 
170  void OnInitDialog( wxInitDialogEvent& aEvent );
171  void OnCharHook( wxKeyEvent& aEvt );
172  void OnCloseTimer( wxTimerEvent& aEvent );
173  void OnUseBrowser( wxCommandEvent& aEvent );
174 
175  void OnFootprintSelected( wxCommandEvent& aEvent );
176  void OnComponentPreselected( wxCommandEvent& aEvent );
177 
184  void OnComponentSelected( wxCommandEvent& aEvent );
185 
189  void ShowFootprintFor( LIB_ID const& aLibId );
190 
194  void ShowFootprint( wxString const& aFootprint );
195 
201  void PopulateFootprintSelector( LIB_ID const& aLibId );
202 
203  wxConfigBase* m_config;
204 
207  wxButton* m_browser_button;
208  wxSplitterWindow* m_hsplitter;
209  wxSplitterWindow* m_vsplitter;
210 
213  wxCheckBox* m_keepSymbol;
214  wxCheckBox* m_useUnits;
216  wxHtmlWindow* m_details;
217 
223  wxString m_fp_override;
224 
225  std::vector<std::pair<int, wxString>> m_field_edits;
226 };
227 
228 #endif /* DIALOG_CHOOSE_COMPONENT_H */
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
Part library alias object definition.
std::vector< std::pair< int, wxString > > m_field_edits
void PopulateFootprintSelector(LIB_ID const &aLibId)
Populate the footprint selector for a given alias.
void OnFootprintSelected(wxCommandEvent &aEvent)
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
void ShowFootprint(wxString const &aFootprint)
Display the given footprint by name.
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:83
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void OnComponentPreselected(wxCommandEvent &aEvent)
void OnCharHook(wxKeyEvent &aEvt)
Dialog class to select a component from the libraries.
bool IsExternalBrowserSelected() const
Function IsExternalBrowserSelected.
DIALOG_CHOOSE_COMPONENT(SCH_BASE_FRAME *aParent, const wxString &aTitle, SYMBOL_TREE_MODEL_ADAPTER::PTR &aAdapter, int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints, bool aAllowBrowser)
Create dialog to choose component.
void OnInitDialog(wxInitDialogEvent &aEvent)
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
Define a library symbol object.
void OnCloseTimer(wxTimerEvent &aEvent)
wxPanel * ConstructRightPanel(wxWindow *aParent)
void OnUseBrowser(wxCommandEvent &aEvent)
bool GetUseAllUnits() const
To be called after this dialog returns from ShowModal()
static constexpr int DblClickDelay
bool GetKeepSymbol() const
To be called after this dialog returns from ShowModal()
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
void ShowFootprintFor(LIB_ID const &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > PTR
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE.
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
void OnComponentSelected(wxCommandEvent &aEvent)
Handle the selection of an item.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
Widget displaying a tree of components with optional search text control and description panel.
Definition: lib_tree.h:42