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 
45 class LIB_ALIAS;
46 class LIB_PART;
47 class SCH_BASE_FRAME;
48 
49 
85 {
86 public:
99  DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
100  CMP_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert, bool aAllowFieldEdits );
101 
103 
115  LIB_ALIAS* GetSelectedAlias( int* aUnit ) const;
116 
121  std::vector<std::pair<int, wxString>> GetFields() const;
122 
129  {
131  }
132 
133 protected:
134  static constexpr int DblClickDelay = 100; // milliseconds
135 
136  wxPanel* ConstructLeftPanel( wxWindow* aParent );
137  wxPanel* ConstructRightPanel( wxWindow* aParent );
138 
139  void OnInitDialog( wxInitDialogEvent& aEvent );
140  void OnCloseTimer( wxTimerEvent& aEvent );
141  void OnProgressTimer( wxTimerEvent& aEvent );
142 
143  void OnQueryText( wxCommandEvent& aEvent );
144  void OnQueryEnter( wxCommandEvent& aEvent );
145  void OnQueryCharHook( wxKeyEvent& aEvent );
146 
147  void OnTreeSelect( wxDataViewEvent& aEvent );
148  void OnTreeActivate( wxDataViewEvent& aEvent );
149 
150  void OnDetailsLink( wxHtmlLinkEvent& aEvent );
151 
152  void OnSchViewDClick( wxMouseEvent& aEvent );
153  void OnSchViewPaint( wxPaintEvent& aEvent );
154 
155  void OnFootprintSelected( wxCommandEvent& aEvent );
156 
160  void ShowFootprintFor( LIB_ALIAS* aAlias );
161 
165  void ShowFootprint( wxString const& aName );
166 
172  void PopulateFootprintSelector( LIB_ALIAS* aAlias );
173 
177  void SelectIfValid( const wxDataViewItem& aTreeId );
178 
183  void PostSelectEvent();
184 
188  void RenderPreview( LIB_PART* aComponent, int aUnit );
189 
196  void HandleItemSelection();
197 
199  wxTextCtrl* m_query_ctrl;
200  wxDataViewCtrl* m_tree_ctrl;
201  wxHtmlWindow* m_details_ctrl;
202  wxPanel* m_sch_view_ctrl;
203 
206 
212  wxString m_fp_override;
213 
215  static std::unique_ptr<FOOTPRINT_LIST> m_fp_list;
216  std::vector<std::pair<int, wxString>> m_field_edits;
217 };
218 
219 #endif /* DIALOG_CHOOSE_COMPONENT_H */
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
void OnTreeSelect(wxDataViewEvent &aEvent)
void OnQueryText(wxCommandEvent &aEvent)
Part library alias object definition.
std::vector< std::pair< int, wxString > > m_field_edits
void OnTreeActivate(wxDataViewEvent &aEvent)
void OnFootprintSelected(wxCommandEvent &aEvent)
void OnQueryCharHook(wxKeyEvent &aEvent)
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
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
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.
void OnQueryEnter(wxCommandEvent &aEvent)
Dialog class to select a component from the libraries.
void PostSelectEvent()
Post a wxEVT_DATAVIEW_SELECTION_CHANGED to notify the selection handler that a new part has been sele...
void OnInitDialog(wxInitDialogEvent &aEvent)
bool IsExternalBrowserSelected() const
Function IsExternalBrowserSelected.
void ShowFootprint(wxString const &aName)
Display the given footprint by name.
CMP_TREE_MODEL_ADAPTER::PTR m_adapter
void SelectIfValid(const wxDataViewItem &aTreeId)
If a wxDataViewitem is valid, select it and post a selection event.
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)
LIB_ALIAS * GetSelectedAlias(int *aUnit) const
Function GetSelectedAlias To be called after this dialog returns from ShowModal().
void PopulateFootprintSelector(LIB_ALIAS *aAlias)
Populate the footprint selector for a given alias.
static constexpr int DblClickDelay
void HandleItemSelection()
Handle the selection of an item.
void OnSchViewDClick(wxMouseEvent &aEvent)
void OnDetailsLink(wxHtmlLinkEvent &aEvent)
FOOTPRINT_PREVIEW_WIDGET * m_fp_view_ctrl
void OnSchViewPaint(wxPaintEvent &aEvent)
wxPanel * ConstructLeftPanel(wxWindow *aParent)
Class SCH_BASE_FRAME is a shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRA...
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.