KiCad PCB EDA Suite
dialog_choose_symbol.cpp
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) 2016-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 
25 #include <algorithm>
26 #include <symbol_library.h>
27 #include <dialog_choose_symbol.h>
28 #include <eeschema_settings.h>
29 #include <kiface_i.h>
30 #include <sch_base_frame.h>
31 #include <template_fieldnames.h>
34 #include <widgets/lib_tree.h>
36 #include <wx/button.h>
37 #include <wx/checkbox.h>
38 #include <wx/clipbrd.h>
39 #include <wx/dataview.h>
40 #include <wx/log.h>
41 #include <wx/panel.h>
42 #include <wx/sizer.h>
43 #include <wx/splitter.h>
44 #include <wx/timer.h>
45 #include <wx/utils.h>
46 #include <wx/wxhtml.h>
47 
49 
50 
52  wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
53  int aDeMorganConvert, bool aAllowFieldEdits,
54  bool aShowFootprints, bool aAllowBrowser )
55  : DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
56  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
57  m_symbol_preview( nullptr ),
58  m_browser_button( nullptr ),
59  m_hsplitter( nullptr ),
60  m_vsplitter( nullptr ),
61  m_fp_sel_ctrl( nullptr ),
62  m_fp_preview( nullptr ),
63  m_keepSymbol( nullptr ),
64  m_useUnits( nullptr ),
65  m_tree( nullptr ),
66  m_details( nullptr ),
67  m_parent( aParent ),
68  m_deMorganConvert( aDeMorganConvert >= 0 ? aDeMorganConvert : 0 ),
69  m_allow_field_edits( aAllowFieldEdits ),
70  m_show_footprints( aShowFootprints ),
71  m_external_browser_requested( false )
72 {
73  // Never show footprints in power symbol mode
74  if( aAdapter->GetFilter() == SYMBOL_TREE_MODEL_ADAPTER::SYM_FILTER_POWER )
75  m_show_footprints = false;
76 
77  wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
78 
79  // Use a slightly different layout, with a details pane spanning the entire window,
80  // if we're not showing footprints.
81  if( m_show_footprints )
82  {
83  m_hsplitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
84  wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
85 
86  //Avoid the splitter window being assigned as the Parent to additional windows
87  m_hsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
88 
89  sizer->Add( m_hsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
90  }
91  else
92  {
93  m_vsplitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
94  wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
95 
96  m_hsplitter = new wxSplitterWindow( m_vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize,
97  wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
98 
99  //Avoid the splitter window being assigned as the Parent to additional windows
100  m_vsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
101  m_hsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
102 
103  wxPanel* detailsPanel = new wxPanel( m_vsplitter );
104  wxBoxSizer* detailsSizer = new wxBoxSizer( wxVERTICAL );
105  detailsPanel->SetSizer( detailsSizer );
106 
107  m_details = new wxHtmlWindow( detailsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
108  wxHW_SCROLLBAR_AUTO );
109  detailsSizer->Add( m_details, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
110  detailsPanel->Layout();
111  detailsSizer->Fit( detailsPanel );
112 
113  m_vsplitter->SetSashGravity( 0.5 );
114  m_vsplitter->SetMinimumPaneSize( 20 );
115  m_vsplitter->SplitHorizontally( m_hsplitter, detailsPanel );
116 
117  sizer->Add( m_vsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
118  }
119 
120  wxPanel* treePanel = new wxPanel( m_hsplitter );
121  wxBoxSizer* treeSizer = new wxBoxSizer( wxVERTICAL );
122  treePanel->SetSizer( treeSizer );
123 
124  m_tree = new LIB_TREE( treePanel, Prj().SchSymbolLibTable(), aAdapter, LIB_TREE::WIDGETS::ALL,
125  m_details );
126 
127  treeSizer->Add( m_tree, 1, wxEXPAND | wxALL, 5 );
128  treePanel->Layout();
129  treeSizer->Fit( treePanel );
130 
131  aAdapter->FinishTreeInitialization();
132 
133  m_hsplitter->SetSashGravity( 0.8 );
134  m_hsplitter->SetMinimumPaneSize( 20 );
135  m_hsplitter->SplitVertically( treePanel, ConstructRightPanel( m_hsplitter ) );
136 
137  m_dbl_click_timer = new wxTimer( this );
138 
139  wxBoxSizer* buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
140 
141  if( aAllowBrowser )
142  {
143  m_browser_button = new wxButton( this, wxID_ANY, _( "Select with Browser" ) );
144  buttonsSizer->Add( m_browser_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
145  }
146 
147  m_keepSymbol = new wxCheckBox( this, wxID_ANY, _("Place repeated copies"), wxDefaultPosition,
148  wxDefaultSize, wxALIGN_RIGHT );
149  m_keepSymbol->SetToolTip( _( "Keep the symbol selected for subsequent clicks." ) );
150 
151  m_useUnits = new wxCheckBox( this, wxID_ANY, _("Place all units"), wxDefaultPosition,
152  wxDefaultSize, wxALIGN_RIGHT );
153  m_useUnits->SetToolTip( _( "Sequentially place all units of the symbol." ) );
154 
155  if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
156  {
157  m_keepSymbol->SetValue( cfg->m_SymChooserPanel.keep_symbol );
158  m_useUnits->SetValue( cfg->m_SymChooserPanel.place_all_units );
159  }
160 
161  buttonsSizer->Add( m_keepSymbol, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
162  buttonsSizer->Add( m_useUnits, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
163 
164  wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer();
165  wxButton* okButton = new wxButton( this, wxID_OK );
166  wxButton* cancelButton = new wxButton( this, wxID_CANCEL );
167 
168  sdbSizer->AddButton( okButton );
169  sdbSizer->AddButton( cancelButton );
170  sdbSizer->Realize();
171 
172  buttonsSizer->Add( sdbSizer, 1, wxALL, 5 );
173 
174  sizer->Add( buttonsSizer, 0, wxEXPAND | wxLEFT, 5 );
175  SetSizer( sizer );
176 
177  Layout();
178 
179  if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
180  {
181  EESCHEMA_SETTINGS::PANEL_SYM_CHOOSER& panelCfg = cfg->m_SymChooserPanel;
182 
183  // We specify the width of the right window (m_symbol_view_panel), because specify
184  // the width of the left window does not work as expected when SetSashGravity() is called
185  m_hsplitter->SetSashPosition( panelCfg.sash_pos_h > 0 ? panelCfg.sash_pos_h :
186  horizPixelsFromDU( 220 ) );
187 
188  if( m_vsplitter )
189  {
190  m_vsplitter->SetSashPosition( panelCfg.sash_pos_v > 0 ? panelCfg.sash_pos_v :
191  vertPixelsFromDU( 230 ) );
192  }
193 
194  wxSize dlgSize( panelCfg.width > 0 ? panelCfg.width : horizPixelsFromDU( 390 ),
195  panelCfg.height > 0 ? panelCfg.height : vertPixelsFromDU( 300 ) );
196  SetSize( dlgSize );
197  }
198 
200  okButton->SetDefault();
201 
202  Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_SYMBOL::OnInitDialog, this );
203  Bind( wxEVT_TIMER, &DIALOG_CHOOSE_SYMBOL::OnCloseTimer, this, m_dbl_click_timer->GetId() );
204  Bind( SYMBOL_PRESELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentPreselected, this );
205  Bind( SYMBOL_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentSelected, this );
206 
207  if( m_browser_button )
208  {
209  m_browser_button->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_CHOOSE_SYMBOL::OnUseBrowser,
210  this );
211  }
212 
213  if( m_fp_sel_ctrl )
214  {
215  m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnFootprintSelected,
216  this );
217  }
218 
219  if( m_details )
220  {
221  m_details->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_CHOOSE_SYMBOL::OnCharHook ),
222  NULL, this );
223  }
224 }
225 
226 
228 {
229  Unbind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_SYMBOL::OnInitDialog, this );
230  Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_SYMBOL::OnCloseTimer, this );
231  Unbind( SYMBOL_PRESELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentPreselected, this );
232  Unbind( SYMBOL_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentSelected, this );
233 
234  if( m_browser_button )
235  {
236  m_browser_button->Unbind( wxEVT_COMMAND_BUTTON_CLICKED,
238  }
239 
240  if( m_fp_sel_ctrl )
241  {
242  m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnFootprintSelected,
243  this );
244  }
245 
246  if( m_details )
247  {
248  m_details->Disconnect( wxEVT_CHAR_HOOK,
249  wxKeyEventHandler( DIALOG_CHOOSE_SYMBOL::OnCharHook ), NULL, this );
250  }
251 
252  // I am not sure the following two lines are necessary, but they will not hurt anyone
253  m_dbl_click_timer->Stop();
254  delete m_dbl_click_timer;
255 
256  if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
257  {
258  cfg->m_SymChooserPanel.width = GetSize().x;
259  cfg->m_SymChooserPanel.height = GetSize().y;
260 
261  cfg->m_SymChooserPanel.keep_symbol = m_keepSymbol->GetValue();
262  cfg->m_SymChooserPanel.place_all_units = m_useUnits->GetValue();
263 
264  cfg->m_SymChooserPanel.sash_pos_h = m_hsplitter->GetSashPosition();
265 
266  if( m_vsplitter )
267  cfg->m_SymChooserPanel.sash_pos_v = m_vsplitter->GetSashPosition();
268  }
269 }
270 
271 
272 wxPanel* DIALOG_CHOOSE_SYMBOL::ConstructRightPanel( wxWindow* aParent )
273 {
274  wxPanel* panel = new wxPanel( aParent );
275  wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
277 
278  m_symbol_preview = new SYMBOL_PREVIEW_WIDGET( panel, Kiway(), backend );
279  m_symbol_preview->SetLayoutDirection( wxLayout_LeftToRight );
280 
281  if( m_show_footprints )
282  {
284 
285  sizer->Add( m_symbol_preview, 1, wxEXPAND | wxALL, 5 );
286 
287  if ( fp_list )
288  {
289  if( m_allow_field_edits )
290  m_fp_sel_ctrl = new FOOTPRINT_SELECT_WIDGET( m_parent, panel, fp_list, true );
291 
292  m_fp_preview = new FOOTPRINT_PREVIEW_WIDGET( panel, Kiway() );
293  }
294 
295  if( m_fp_sel_ctrl )
296  sizer->Add( m_fp_sel_ctrl, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 3 );
297 
298  if( m_fp_preview )
299  sizer->Add( m_fp_preview, 1, wxEXPAND | wxALL, 5 );
300  }
301  else
302  {
303  sizer->Add( m_symbol_preview, 1, wxEXPAND | wxALL, 5 );
304  }
305 
306  panel->SetSizer( sizer );
307  panel->Layout();
308  sizer->Fit( panel );
309 
310  return panel;
311 }
312 
313 
314 void DIALOG_CHOOSE_SYMBOL::OnInitDialog( wxInitDialogEvent& aEvent )
315 {
317  {
318  // This hides the GAL panel and shows the status label
319  m_fp_preview->SetStatusText( wxEmptyString );
320  }
321 
322  if( m_fp_sel_ctrl )
323  m_fp_sel_ctrl->Load( Kiway(), Prj() );
324 }
325 
326 
327 void DIALOG_CHOOSE_SYMBOL::OnCharHook( wxKeyEvent& e )
328 {
329  if( m_details && e.GetKeyCode() == 'C' && e.ControlDown() &&
330  !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
331  {
332  wxString txt = m_details->SelectionToText();
333  wxLogNull doNotLog; // disable logging of failed clipboard actions
334 
335  if( wxTheClipboard->Open() )
336  {
337  wxTheClipboard->SetData( new wxTextDataObject( txt ) );
338  wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
339  wxTheClipboard->Close();
340  }
341  }
342  else
343  {
344  e.Skip();
345  }
346 }
347 
348 
350 {
351  return m_tree->GetSelectedLibId( aUnit );
352 }
353 
354 
355 void DIALOG_CHOOSE_SYMBOL::OnUseBrowser( wxCommandEvent& aEvent )
356 {
358 
359  if( IsQuasiModal() )
360  EndQuasiModal( wxID_OK );
361  else if( IsModal() )
362  EndModal( wxID_OK );
363  else
364  wxFAIL_MSG( "Dialog called with neither Modal nor QuasiModal" );
365 }
366 
367 
368 void DIALOG_CHOOSE_SYMBOL::OnCloseTimer( wxTimerEvent& aEvent )
369 {
370  // Hack handler because of eaten MouseUp event. See
371  // DIALOG_CHOOSE_SYMBOL::OnComponentSelected for the beginning
372  // of this spaghetti noodle.
373 
374  auto state = wxGetMouseState();
375 
376  if( state.LeftIsDown() )
377  {
378  // Mouse hasn't been raised yet, so fire the timer again. Otherwise the
379  // purpose of this timer is defeated.
381  }
382  else
383  {
384  if( IsQuasiModal() )
385  EndQuasiModal( wxID_OK );
386  else if( IsModal() )
387  EndModal( wxID_OK );
388  else
389  wxFAIL_MSG( "Dialog called with neither Modal nor QuasiModal" );
390  }
391 }
392 
393 
395 {
397  return;
398 
399  LIB_SYMBOL* symbol = nullptr;
400 
401  try
402  {
403  symbol = Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
404  }
405  catch( const IO_ERROR& ioe )
406  {
407  wxLogError( wxString::Format( _( "Error loading symbol %s from library %s.\n\n%s" ),
408  aLibId.GetLibItemName().wx_str(),
409  aLibId.GetLibNickname().wx_str(),
410  ioe.What() ) );
411  }
412 
413  if( !symbol )
414  return;
415 
416  LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
417  wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
418 
419  ShowFootprint( fp_name );
420 }
421 
422 
423 void DIALOG_CHOOSE_SYMBOL::ShowFootprint( wxString const& aName )
424 {
426  return;
427 
428  if( aName == wxEmptyString )
429  {
430  m_fp_preview->SetStatusText( _( "No footprint specified" ) );
431  }
432  else
433  {
434  LIB_ID lib_id;
435 
436  if( lib_id.Parse( aName ) == -1 && lib_id.IsValid() )
437  {
439  m_fp_preview->DisplayFootprint( lib_id );
440  }
441  else
442  {
443  m_fp_preview->SetStatusText( _( "Invalid footprint specified" ) );
444  }
445  }
446 }
447 
448 
450 {
451  if( !m_fp_sel_ctrl )
452  return;
453 
455 
456  LIB_SYMBOL* symbol = nullptr;
457 
458  if( aLibId.IsValid() )
459  {
460  try
461  {
462  symbol = Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
463  }
464  catch( const IO_ERROR& ioe )
465  {
466  wxLogError( wxString::Format( _( "Error occurred loading symbol %s from library %s."
467  "\n\n%s" ),
468  aLibId.GetLibItemName().wx_str(),
469  aLibId.GetLibNickname().wx_str(),
470  ioe.What() ) );
471  }
472  }
473 
474  if( symbol != nullptr )
475  {
476  LIB_PINS temp_pins;
477  LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
478  wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
479 
480  symbol->GetPins( temp_pins );
481 
482  m_fp_sel_ctrl->FilterByPinCount( temp_pins.size() );
487  }
488  else
489  {
491  m_fp_sel_ctrl->Disable();
492  }
493 }
494 
495 
496 void DIALOG_CHOOSE_SYMBOL::OnFootprintSelected( wxCommandEvent& aEvent )
497 {
498  m_fp_override = aEvent.GetString();
499 
500  m_field_edits.erase( std::remove_if( m_field_edits.begin(), m_field_edits.end(),
501  []( std::pair<int, wxString> const& i )
502  {
503  return i.first == FOOTPRINT_FIELD;
504  } ),
505  m_field_edits.end() );
506 
507  m_field_edits.emplace_back( std::make_pair( FOOTPRINT_FIELD, m_fp_override ) );
508 
510 }
511 
512 
513 void DIALOG_CHOOSE_SYMBOL::OnComponentPreselected( wxCommandEvent& aEvent )
514 {
515  int unit = 0;
516 
517  LIB_ID id = m_tree->GetSelectedLibId( &unit );
518 
519  if( id.IsValid() )
520  {
521  m_symbol_preview->DisplaySymbol( id, unit );
522 
523  ShowFootprintFor( id );
525  }
526  else
527  {
528  m_symbol_preview->SetStatusText( _( "No symbol selected" ) );
529 
531  m_fp_preview->SetStatusText( wxEmptyString );
532 
534  }
535 }
536 
537 
538 void DIALOG_CHOOSE_SYMBOL::OnComponentSelected( wxCommandEvent& aEvent )
539 {
540  if( m_tree->GetSelectedLibId().IsValid() )
541  {
542  // Got a selection. We can't just end the modal dialog here, because
543  // wx leaks some events back to the parent window (in particular, the
544  // MouseUp following a double click).
545  //
546  // NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp.
547  // This isn't really feasible to bypass without a fully custom
548  // wxDataViewCtrl implementation, and even then might not be fully
549  // possible (docs are vague). To get around this, we use a one-shot
550  // timer to schedule the dialog close.
551  //
552  // See DIALOG_CHOOSE_SYMBOL::OnCloseTimer for the other end of this
553  // spaghetti noodle.
555  }
556 }
557 
558 
560 {
561  return m_useUnits->GetValue();
562 }
563 
564 
566 {
567  return m_keepSymbol->GetValue();
568 }
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
void OnCharHook(wxKeyEvent &aEvt) override
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:695
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
void FilterByFootprintFilters(wxArrayString const &aFilters, bool aZeroFilters)
Filter by footprint filter list.
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.
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
wxWindow * GetFocusTarget()
Definition: lib_tree.cpp:226
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetDefaultFootprint(wxString const &aFp)
Set the default footprint for a part.
bool GetUseAllUnits() const
To be called after this dialog returns from ShowModal()
bool IsQuasiModal() const
Definition: dialog_shim.h:106
void OnFootprintSelected(wxCommandEvent &aEvent)
int horizPixelsFromDU(int x) const
Convert an integer number of dialog units to pixels, horizontally.
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
All except INITIAL_ADD.
Definition: view_item.h:58
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:168
void ShowFootprintFor(LIB_ID const &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
Define a library symbol object.
Definition: lib_symbol.h:96
std::vector< std::pair< int, wxString > > m_field_edits
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
static std::mutex g_Mutex
void ClearFilters()
Clear all filters.
void OnUseBrowser(wxCommandEvent &aEvent)
wxSplitterWindow * m_hsplitter
bool UpdateList()
Update the contents of the list to match the filters.
wxPanel * ConstructRightPanel(wxWindow *aParent)
wxSplitterWindow * m_vsplitter
void OnInitDialog(wxInitDialogEvent &aEvent)
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
static constexpr int DblClickDelay
#define NULL
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
void ClearStatus()
Clear the contents of the status label and hide it.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:150
Definition for symbol library class.
virtual bool Enable(bool aEnable=true) override
Enable or disable the control for input.
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void EndQuasiModal(int retCode)
void DisplaySymbol(const LIB_ID &aSymbolID, int aUnit, int aConvert=0)
Set the currently displayed symbol.
void OnComponentSelected(wxCommandEvent &aEvent)
Handle the selection of an item.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
Definition: lib_symbol.cpp:941
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
void OnCloseTimer(wxTimerEvent &aEvent)
void DisplayFootprint(const LIB_ID &aFPID)
Set the currently displayed footprint.
bool GetKeepSymbol() const
To be called after this dialog returns from ShowModal()
wxString wx_str() const
Definition: utf8.cpp:51
void PopulateFootprintSelector(LIB_ID const &aLibId)
Populate the footprint selector for a given alias.
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:295
int vertPixelsFromDU(int y) const
Convert an integer number of dialog units to pixels, vertically.
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:183
void Load(KIWAY &aKiway, PROJECT &aProject)
Start loading.
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
bool IsInitialized() const
Return whether the widget initialized properly.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void FilterByPinCount(int aPinCount)
Filter by pin count.
Widget displaying a tree of symbols with optional search text control and description panel....
Definition: lib_tree.h:42
void ShowFootprint(wxString const &aFootprint)
Display the given footprint by name.
Field Name Module PCB, i.e. "16DIP300".