KiCad PCB EDA Suite
dialog_choose_symbol.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-2021 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_SYMBOL_H
25 #define DIALOG_CHOOSE_SYMBOL_H
26 
27 #include "dialog_shim.h"
29 #include <footprint_info.h>
30 #include <html_window.h>
31 
32 class wxCheckBox;
33 class wxStaticBitmap;
34 class wxTextCtrl;
35 class wxStdDialogButtonSizer;
36 class wxDataViewCtrl;
37 class wxHtmlLinkEvent;
38 class wxPanel;
39 class wxChoice;
40 class wxButton;
41 class wxTimer;
42 class wxSplitterWindow;
43 
44 class LIB_TREE;
48 class LIB_ALIAS;
49 class SCH_BASE_FRAME;
50 class SCH_DRAW_PANEL;
51 
52 
89 {
90 public:
106  DIALOG_CHOOSE_SYMBOL( SCH_BASE_FRAME* aParent, const wxString& aTitle,
107  wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
108  int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints,
109  bool aAllowBrowser );
110 
112 
124  LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
125 
134  bool GetUseAllUnits() const;
135 
144  bool GetKeepSymbol() const;
145 
151  std::vector<std::pair<int, wxString>> GetFields() const
152  {
153  return m_field_edits;
154  }
155 
160  {
162  }
163 
164 protected:
165  static constexpr int DblClickDelay = 100; // milliseconds
166 
167  wxPanel* ConstructRightPanel( wxWindow* aParent );
168 
169  void OnInitDialog( wxInitDialogEvent& aEvent );
170  void OnCharHook( wxKeyEvent& aEvt ) override;
171  void OnCloseTimer( wxTimerEvent& aEvent );
172  void OnUseBrowser( wxCommandEvent& aEvent );
173 
174  void OnFootprintSelected( wxCommandEvent& aEvent );
175  void OnComponentPreselected( wxCommandEvent& aEvent );
176 
183  void OnComponentSelected( wxCommandEvent& aEvent );
184 
188  void ShowFootprintFor( const LIB_ID& aLibId );
189 
193  void ShowFootprint( const wxString& aFootprint );
194 
200  void PopulateFootprintSelector( const LIB_ID& aLibId );
201 
202 public:
203  static std::mutex g_Mutex;
204 
205 protected:
208  wxButton* m_browser_button;
209  wxSplitterWindow* m_hsplitter;
210  wxSplitterWindow* m_vsplitter;
211 
214  wxCheckBox* m_keepSymbol;
215  wxCheckBox* m_useUnits;
218 
224  wxString m_fp_override;
225 
226  std::vector<std::pair<int, wxString>> m_field_edits;
227 };
228 
229 #endif /* DIALOG_CHOOSE_SYMBOL_H */
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
void ShowFootprint(const wxString &aFootprint)
Display the given footprint by name.
void OnCharHook(wxKeyEvent &aEvt) override
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
DIALOG_CHOOSE_SYMBOL(SCH_BASE_FRAME *aParent, const wxString &aTitle, wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > &aAdapter, int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints, bool aAllowBrowser)
Create dialog to choose symbol.
void PopulateFootprintSelector(const LIB_ID &aLibId)
Populate the footprint selector for a given alias.
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
bool GetUseAllUnits() const
To be called after this dialog returns from ShowModal()
void OnFootprintSelected(wxCommandEvent &aEvent)
void OnComponentPreselected(wxCommandEvent &aEvent)
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:82
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
std::vector< std::pair< int, wxString > > m_field_edits
static std::mutex g_Mutex
Dialog class to select a symbol from the libraries.
void OnUseBrowser(wxCommandEvent &aEvent)
wxSplitterWindow * m_hsplitter
wxPanel * ConstructRightPanel(wxWindow *aParent)
wxSplitterWindow * m_vsplitter
void OnInitDialog(wxInitDialogEvent &aEvent)
static constexpr int DblClickDelay
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void ShowFootprintFor(const LIB_ID &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
bool IsExternalBrowserSelected() const
Add dark theme support to wxHtmlWindow.
Definition: html_window.h:33
void OnComponentSelected(wxCommandEvent &aEvent)
Handle the selection of an item.
void OnCloseTimer(wxTimerEvent &aEvent)
bool GetKeepSymbol() const
To be called after this dialog returns from ShowModal()
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Widget displaying a tree of symbols with optional search text control and description panel....
Definition: lib_tree.h:45