36 #include <wx/button.h> 37 #include <wx/checkbox.h> 38 #include <wx/clipbrd.h> 39 #include <wx/dataview.h> 43 #include <wx/splitter.h> 46 #include <wx/wxhtml.h> 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 ),
68 m_deMorganConvert( aDeMorganConvert >= 0 ? aDeMorganConvert : 0 ),
69 m_allow_field_edits( aAllowFieldEdits ),
70 m_show_footprints( aShowFootprints ),
71 m_external_browser_requested( false )
77 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
83 m_hsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
84 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
89 sizer->Add(
m_hsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
93 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
94 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
97 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
103 wxPanel* detailsPanel =
new wxPanel(
m_vsplitter );
104 wxBoxSizer* detailsSizer =
new wxBoxSizer( wxVERTICAL );
105 detailsPanel->SetSizer( detailsSizer );
108 wxHW_SCROLLBAR_AUTO );
109 detailsSizer->Add(
m_details, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
110 detailsPanel->Layout();
111 detailsSizer->Fit( detailsPanel );
117 sizer->Add(
m_vsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
121 wxBoxSizer* treeSizer =
new wxBoxSizer( wxVERTICAL );
122 treePanel->SetSizer( treeSizer );
127 treeSizer->Add(
m_tree, 1, wxEXPAND | wxALL, 5 );
129 treeSizer->Fit( treePanel );
131 aAdapter->FinishTreeInitialization();
139 wxBoxSizer* buttonsSizer =
new wxBoxSizer( wxHORIZONTAL );
144 buttonsSizer->Add(
m_browser_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
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." ) );
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." ) );
157 m_keepSymbol->SetValue( cfg->m_SymChooserPanel.keep_symbol );
158 m_useUnits->SetValue( cfg->m_SymChooserPanel.place_all_units );
161 buttonsSizer->Add(
m_keepSymbol, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
162 buttonsSizer->Add(
m_useUnits, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
164 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
165 wxButton* okButton =
new wxButton(
this, wxID_OK );
166 wxButton* cancelButton =
new wxButton(
this, wxID_CANCEL );
168 sdbSizer->AddButton( okButton );
169 sdbSizer->AddButton( cancelButton );
172 buttonsSizer->Add( sdbSizer, 1, wxALL, 5 );
174 sizer->Add( buttonsSizer, 0, wxEXPAND | wxLEFT, 5 );
200 okButton->SetDefault();
259 cfg->m_SymChooserPanel.width = GetSize().x;
260 cfg->m_SymChooserPanel.height = GetSize().y;
262 cfg->m_SymChooserPanel.keep_symbol =
m_keepSymbol->GetValue();
263 cfg->m_SymChooserPanel.place_all_units =
m_useUnits->GetValue();
265 cfg->m_SymChooserPanel.sash_pos_h =
m_hsplitter->GetSashPosition();
268 cfg->m_SymChooserPanel.sash_pos_v =
m_vsplitter->GetSashPosition();
275 wxPanel* panel =
new wxPanel( aParent );
276 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
297 sizer->Add(
m_fp_sel_ctrl, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 3 );
307 panel->SetSizer( sizer );
330 if(
m_details && e.GetKeyCode() ==
'C' && e.ControlDown() &&
331 !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
333 wxString txt =
m_details->SelectionToText();
336 if( wxTheClipboard->Open() )
338 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
339 wxTheClipboard->Flush();
340 wxTheClipboard->Close();
360 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
370 auto state = wxGetMouseState();
372 if( state.LeftIsDown() )
380 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
394 symbol =
Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
398 wxLogError(
_(
"Error loading symbol %s from library '%s'." ) + wxS(
"\n%s" ),
408 wxString fp_name = fp_field ? fp_field->
GetFullText() : wxString(
"" );
419 if( aName == wxEmptyString )
453 symbol =
Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
457 wxLogError(
_(
"Error loading symbol %s from library '%s'." ) + wxS(
"\n%s" ),
464 if( symbol !=
nullptr )
468 wxString fp_name = fp_field ? fp_field->
GetFullText() : wxString(
"" );
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
void ShowFootprint(const wxString &aFootprint)
Display the given footprint by name.
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.
const UTF8 & GetLibItemName() const
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
wxButton * m_browser_button
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.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
wxWindow * GetFocusTarget()
Field object used in symbol libraries.
bool GetUseAllUnits() const
To be called after this dialog returns from ShowModal()
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...
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
Define a library symbol object.
std::vector< std::pair< int, wxString > > m_field_edits
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
static std::mutex g_Mutex
void OnUseBrowser(wxCommandEvent &aEvent)
wxSplitterWindow * m_hsplitter
wxPanel * ConstructRightPanel(wxWindow *aParent)
wxSplitterWindow * m_vsplitter
void OnInitDialog(wxInitDialogEvent &aEvent)
static constexpr int DblClickDelay
virtual const wxString What() const
A composite of Problem() and Where()
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
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.
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 for symbol library class.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
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 m_external_browser_requested
Add dark theme support to wxHtmlWindow.
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.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
void OnCloseTimer(wxTimerEvent &aEvent)
SCH_BASE_FRAME * m_parent
bool GetKeepSymbol() const
To be called after this dialog returns from ShowModal()
wxString GetFullText(int unit=1) const
Return the text of a field.
int vertPixelsFromDU(int y) const
Convert an integer number of dialog units to pixels, vertically.
wxArrayString GetFPFilters() const
wxCheckBox * m_keepSymbol
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
wxTimer * m_dbl_click_timer
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.
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
Widget displaying a tree of symbols with optional search text control and description panel....
Field Name Module PCB, i.e. "16DIP300".