37#include <wx/checkbox.h>
38#include <wx/clipbrd.h>
39#include <wx/dataview.h>
43#include <wx/splitter.h>
55 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
56 int aDeMorganConvert,
bool aAllowFieldEdits,
57 bool aShowFootprints,
bool aAllowBrowser )
58 :
DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
59 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
60 m_symbol_preview( nullptr ),
61 m_browser_button( nullptr ),
62 m_hsplitter( nullptr ),
63 m_vsplitter( nullptr ),
64 m_fp_sel_ctrl( nullptr ),
65 m_fp_preview( nullptr ),
66 m_keepSymbol( nullptr ),
67 m_useUnits( nullptr ),
71 m_deMorganConvert( aDeMorganConvert >= 0 ? aDeMorganConvert : 0 ),
72 m_allow_field_edits( aAllowFieldEdits ),
73 m_show_footprints( aShowFootprints ),
74 m_external_browser_requested( false )
82 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
88 m_hsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
89 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
94 sizer->Add(
m_hsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
98 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
99 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
102 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
108 wxPanel* detailsPanel =
new wxPanel(
m_vsplitter );
109 wxBoxSizer* detailsSizer =
new wxBoxSizer( wxVERTICAL );
110 detailsPanel->SetSizer( detailsSizer );
113 wxHW_SCROLLBAR_AUTO );
114 detailsSizer->Add(
m_details, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
115 detailsPanel->Layout();
116 detailsSizer->Fit( detailsPanel );
122 sizer->Add(
m_vsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
126 wxBoxSizer* treeSizer =
new wxBoxSizer( wxVERTICAL );
127 treePanel->SetSizer( treeSizer );
133 treeSizer->Add(
m_tree, 1, wxEXPAND | wxALL, 5 );
135 treeSizer->Fit( treePanel );
137 aAdapter->FinishTreeInitialization();
150 wxBoxSizer* buttonsSizer =
new wxBoxSizer( wxHORIZONTAL );
155 buttonsSizer->Add(
m_browser_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
158 m_keepSymbol =
new wxCheckBox(
this, wxID_ANY,
_(
"Place repeated copies" ) );
159 m_keepSymbol->SetToolTip(
_(
"Keep the symbol selected for subsequent clicks." ) );
161 m_useUnits =
new wxCheckBox(
this, wxID_ANY,
_(
"Place all units" ) );
162 m_useUnits->SetToolTip(
_(
"Sequentially place all units of the symbol." ) );
166 m_keepSymbol->SetValue( cfg->m_SymChooserPanel.keep_symbol );
167 m_useUnits->SetValue( cfg->m_SymChooserPanel.place_all_units );
170 buttonsSizer->Add(
m_keepSymbol, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 30 );
171 buttonsSizer->Add(
m_useUnits, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 30 );
173 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
174 wxButton* okButton =
new wxButton(
this, wxID_OK );
175 wxButton* cancelButton =
new wxButton(
this, wxID_CANCEL );
177 sdbSizer->AddButton( okButton );
178 sdbSizer->AddButton( cancelButton );
181 buttonsSizer->Add( sdbSizer, 1, wxALL, 5 );
183 sizer->Add( buttonsSizer, 0, wxEXPAND | wxLEFT, 5 );
275 cfg->m_SymChooserPanel.width = GetSize().x;
276 cfg->m_SymChooserPanel.height = GetSize().y;
278 cfg->m_SymChooserPanel.keep_symbol =
m_keepSymbol->GetValue();
279 cfg->m_SymChooserPanel.place_all_units =
m_useUnits->GetValue();
281 cfg->m_SymChooserPanel.sash_pos_h =
m_hsplitter->GetSashPosition();
284 cfg->m_SymChooserPanel.sash_pos_v =
m_vsplitter->GetSashPosition();
293 wxPanel* panel =
new wxPanel( aParent );
294 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
319 sizer->Add(
m_fp_preview, 10, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
326 panel->SetSizer( sizer );
349 if(
m_details && e.GetKeyCode() ==
'C' && e.ControlDown() &&
350 !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
352 wxString txt =
m_details->SelectionToText();
355 if( wxTheClipboard->Open() )
357 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
358 wxTheClipboard->Flush();
359 wxTheClipboard->Close();
379 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
389 auto state = wxGetMouseState();
391 if( state.LeftIsDown() )
399 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
413 symbol =
Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
417 wxLogError(
_(
"Error loading symbol %s from library '%s'." ) + wxS(
"\n%s" ),
427 wxString fp_name = fp_field ? fp_field->
GetFullText() : wxString(
"" );
438 if( aName == wxEmptyString )
472 symbol =
Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
476 wxLogError(
_(
"Error loading symbol %s from library '%s'." ) + wxS(
"\n%s" ),
483 if( symbol !=
nullptr )
487 wxString fp_name = fp_field ? fp_field->
GetFullText() : wxString(
"" );
491 symbol->
GetPins( temp_pins, 0, 1 );
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void OnFootprintSelected(wxCommandEvent &aEvent)
static constexpr int DblClickDelay
wxPanel * ConstructRightPanel(wxWindow *aParent)
void ShowFootprintFor(const LIB_ID &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
wxButton * m_browser_button
void OnCharHook(wxKeyEvent &aEvt) override
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
static std::mutex g_Mutex
void ShowFootprint(const wxString &aFootprint)
Display the given footprint by name.
bool GetUseAllUnits() const
To be called after this dialog returns from ShowModal()
void OnInitDialog(wxInitDialogEvent &aEvent)
static wxString g_powerSearchString
SCH_BASE_FRAME * m_parent
void OnUseBrowser(wxCommandEvent &aEvent)
static wxString g_symbolSearchString
wxCheckBox * m_keepSymbol
bool m_external_browser_requested
wxTimer * m_dbl_click_timer
bool GetKeepSymbol() const
To be called after this dialog returns from ShowModal()
void OnComponentSelected(wxCommandEvent &aEvent)
Handle the selection of an item.
wxSplitterWindow * m_vsplitter
std::vector< std::pair< int, wxString > > m_field_edits
wxSplitterWindow * m_hsplitter
void PopulateFootprintSelector(const LIB_ID &aLibId)
Populate the footprint selector for a given alias.
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
void OnCloseTimer(wxTimerEvent &aEvent)
void OnComponentPreselected(wxCommandEvent &aEvent)
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
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.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
int vertPixelsFromDU(int y) const
Convert an integer number of dialog units to pixels, vertically.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
int horizPixelsFromDU(int x) const
Convert an integer number of dialog units to pixels, horizontally.
EDA_UNITS GetUserUnits() const
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
Add dark theme support to wxHtmlWindow.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Field object used in symbol libraries.
wxString GetFullText(int unit=1) const
Return the text of a field.
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
bool IsValid() const
Check if this LID_ID is valid.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
wxArrayString GetFPFilters() const
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
@ SYM_FILTER_POWER
list symbols flagged PWR
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
Widget displaying a tree of symbols with optional search text control and description panel....
LIB_TREE_NODE * GetCurrentTreeNode() const
wxWindow * GetFocusTarget()
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
wxString GetSearchString() const
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
void SetSearchString(const wxString &aSearchString)
Save/restore search string.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
Definition for symbol library class.
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".