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