KiCad PCB EDA Suite
dialog_choose_component.h
Go to the documentation of this file.
1 /* -*- c++ -*-
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-2018 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"
28 #include <cmp_tree_model_adapter.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 COMPONENT_TREE;
45 class LIB_ALIAS;
46 class LIB_PART;
47 class SCH_BASE_FRAME;
48 
49 
89 {
90 public:
105  DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
106  CMP_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert, bool aAllowFieldEdits,
107  bool aShowFootprints );
108 
110 
122  LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
123 
128  std::vector<std::pair<int, wxString>> GetFields() const
129  {
130  return m_field_edits;
131  }
132 
139  {
141  }
142 
143 protected:
144  static constexpr int DblClickDelay = 100; // milliseconds
145 
146  wxPanel* ConstructRightPanel( wxWindow* aParent );
147 
148  void OnInitDialog( wxInitDialogEvent& aEvent );
149  void OnCloseTimer( wxTimerEvent& aEvent );
150  void OnProgressTimer( wxTimerEvent& aEvent );
151 
152  void OnSchViewDClick( wxMouseEvent& aEvent );
153  void OnSchViewPaint( wxPaintEvent& aEvent );
154 
155  void OnFootprintSelected( wxCommandEvent& aEvent );
156 
157  void OnComponentPreselected( wxCommandEvent& aEvent );
158 
165  void OnComponentSelected( wxCommandEvent& aEvent );
166 
170  void ShowFootprintFor( LIB_ID const& aLibId );
171 
175  void ShowFootprint( wxString const& aFootprint );
176 
182  void PopulateFootprintSelector( LIB_ID const& aLibId );
183 
188  void RenderPreview( LIB_PART* aComponent, int aUnit );
189 
191  wxPanel* m_sch_view_ctrl;
192 
196 
202  wxString m_fp_override;
203 
205  static std::unique_ptr<FOOTPRINT_LIST> m_fp_list;
206  std::vector<std::pair<int, wxString>> m_field_edits;
207 
208  static wxSize m_default_size;
209 };
210 
211 #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)
void ShowFootprint(wxString const &aFootprint)
Display the given footprint by name.
This class can be used to populate a FOOTPRINT_LIST asynchronously.
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:70
static FOOTPRINT_ASYNC_LOADER m_fp_loader
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
DIALOG_CHOOSE_COMPONENT(SCH_BASE_FRAME *aParent, const wxString &aTitle, CMP_TREE_MODEL_ADAPTER::PTR &aAdapter, int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints)
Create dialog to choose component.
void OnComponentPreselected(wxCommandEvent &aEvent)
Dialog class to select a component from the libraries.
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
void OnInitDialog(wxInitDialogEvent &aEvent)
bool IsExternalBrowserSelected() const
Function IsExternalBrowserSelected.
wxObjectDataPtr< CMP_TREE_MODEL_ADAPTER_BASE > PTR
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE.
void OnProgressTimer(wxTimerEvent &aEvent)
Define a library symbol object.
static std::unique_ptr< FOOTPRINT_LIST > m_fp_list
void OnCloseTimer(wxTimerEvent &aEvent)
wxPanel * ConstructRightPanel(wxWindow *aParent)
Widget displaying a tree of components with optional search text control and description panel...
static constexpr int DblClickDelay
void OnSchViewDClick(wxMouseEvent &aEvent)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void ShowFootprintFor(LIB_ID const &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
FOOTPRINT_PREVIEW_WIDGET * m_fp_view_ctrl
void OnSchViewPaint(wxPaintEvent &aEvent)
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.
void OnComponentSelected(wxCommandEvent &aEvent)
Handle the selection of an item.
void RenderPreview(LIB_PART *aComponent, int aUnit)
Display a given symbol into the schematic symbol preview.