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) 2017 Chris Pavlina <pavlina.chris@gmail.com>
6  * Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 #ifndef DIALOG_CHOOSE_COMPONENT_H
26 #define DIALOG_CHOOSE_COMPONENT_H
27 
28 #include "dialog_shim.h"
29 #include <cmp_tree_model_adapter.h>
30 #include <footprint_info.h>
31 
32 class wxStaticBitmap;
33 class wxTextCtrl;
34 class wxStdDialogButtonSizer;
35 class wxDataViewCtrl;
36 class wxHtmlWindow;
37 class wxHtmlLinkEvent;
38 class wxPanel;
39 class wxChoice;
40 class wxButton;
41 class wxTimer;
42 
43 class COMPONENT_TREE;
46 class LIB_ALIAS;
47 class LIB_PART;
48 class SCH_BASE_FRAME;
49 
50 
86 {
87 public:
100  DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
101  CMP_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert, bool aAllowFieldEdits );
102 
104 
116  LIB_ALIAS* GetSelectedAlias( int* aUnit = nullptr ) const;
117 
122  std::vector<std::pair<int, wxString>> GetFields() const
123  {
124  return m_field_edits;
125  }
126 
133  {
135  }
136 
137 protected:
138  static constexpr int DblClickDelay = 100; // milliseconds
139 
140  wxPanel* ConstructRightPanel( wxWindow* aParent );
141 
142  void OnInitDialog( wxInitDialogEvent& aEvent );
143  void OnCloseTimer( wxTimerEvent& aEvent );
144  void OnProgressTimer( wxTimerEvent& aEvent );
145 
146  void OnSchViewDClick( wxMouseEvent& aEvent );
147  void OnSchViewPaint( wxPaintEvent& aEvent );
148 
149  void OnFootprintSelected( wxCommandEvent& aEvent );
150 
151  void OnComponentPreselected( wxCommandEvent& aEvent );
152 
159  void OnComponentSelected( wxCommandEvent& aEvent );
160 
164  void ShowFootprintFor( LIB_ALIAS* aAlias );
165 
169  void ShowFootprint( wxString const& aName );
170 
176  void PopulateFootprintSelector( LIB_ALIAS* aAlias );
177 
181  void RenderPreview( LIB_PART* aComponent, int aUnit );
182 
184  wxPanel* m_sch_view_ctrl;
185 
189 
194  wxString m_fp_override;
195 
197  static std::unique_ptr<FOOTPRINT_LIST> m_fp_list;
198  std::vector<std::pair<int, wxString>> m_field_edits;
199 };
200 
201 #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 OnFootprintSelected(wxCommandEvent &aEvent)
This class can be used to populate a FOOTPRINT_LIST asynchronously.
wxObjectDataPtr< CMP_TREE_MODEL_ADAPTER > PTR
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER.
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:60
static FOOTPRINT_ASYNC_LOADER m_fp_loader
void OnComponentPreselected(wxCommandEvent &aEvent)
DIALOG_CHOOSE_COMPONENT(SCH_BASE_FRAME *aParent, const wxString &aTitle, CMP_TREE_MODEL_ADAPTER::PTR &aAdapter, int aDeMorganConvert, bool aAllowFieldEdits)
Create dialog to choose component.
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.
void ShowFootprint(wxString const &aName)
Display the given footprint by name.
LIB_ALIAS * GetSelectedAlias(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void OnProgressTimer(wxTimerEvent &aEvent)
Class LIB_PART defines a library part 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...
void PopulateFootprintSelector(LIB_ALIAS *aAlias)
Populate the footprint selector for a given alias.
static constexpr int DblClickDelay
void OnSchViewDClick(wxMouseEvent &aEvent)
FOOTPRINT_PREVIEW_WIDGET * m_fp_view_ctrl
void OnSchViewPaint(wxPaintEvent &aEvent)
Class SCH_BASE_FRAME is a shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRA...
void OnComponentSelected(wxCommandEvent &aEvent)
Handle the selection of an item.
void ShowFootprintFor(LIB_ALIAS *aAlias)
Look up the footprint for a given alias and display it.
void RenderPreview(LIB_PART *aComponent, int aUnit)
Display a given component into the schematic symbol preview.