28#include <wx/clipbrd.h>
32#include <wx/splitter.h>
54 const wxArrayString& aFootprintHistoryList,
56 std::function<
void()> aAcceptHandler,
57 std::function<
void()> aEscapeHandler ) :
58 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize ),
59 m_hsplitter( nullptr ),
60 m_vsplitter( nullptr ),
62 m_filter(
std::
move( aFilter ) ),
63 m_acceptHandler(
std::
move( aAcceptHandler ) ),
64 m_escapeHandler(
std::
move( aEscapeHandler ) )
79 delete progressReporter;
87 std::vector<LIB_TREE_ITEM*> historyInfos;
89 for(
const wxString& item : aFootprintHistoryList )
94 if( fp_info !=
nullptr )
95 historyInfos.push_back( fp_info );
98 adapter->
DoAddLibrary( wxT(
"-- " ) +
_(
"Recently Used" ) + wxT(
" --" ), wxEmptyString,
99 historyInfos,
false, true )
100 .m_IsRecentlyUsedGroup =
true;
102 if( historyInfos.size() )
112 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
114 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
115 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
118 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
125 auto detailsSizer =
new wxBoxSizer( wxVERTICAL );
129 detailsSizer->Add(
m_details, 1, wxEXPAND, 5 );
177 Bind( wxEVT_CHAR_HOOK,
178 [&]( wxKeyEvent& aEvent )
180 if( aEvent.GetKeyCode() == WXK_ESCAPE )
182 wxObject* eventSource = aEvent.GetEventObject();
184 if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( eventSource ) )
187 if( textCtrl->GetValue() == m_tree->GetSearchString()
188 && !m_tree->GetSearchString().IsEmpty() )
190 m_tree->SetSearchString( wxEmptyString );
202 aEvent.DoAllowNextEvent();
213 m_open_libs_timer->StartOnce( 300 );
234 if(
PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>(
"pcbnew" ) )
239 cfg->m_FootprintChooser.width = GetParent()->GetSize().x;
240 cfg->m_FootprintChooser.height = GetParent()->GetSize().y;
241 cfg->m_FootprintChooser.sash_h =
m_hsplitter->GetSashPosition();
244 cfg->m_FootprintChooser.sash_v =
m_vsplitter->GetSashPosition();
267 if(
PCBNEW_SETTINGS* settings = GetAppSettings<PCBNEW_SETTINGS>(
"pcbnew" ) )
269 auto horizPixelsFromDU =
273 return GetParent()->ConvertDialogToPixels( sz ).x;
278 int w = cfg.
width < 40 ? horizPixelsFromDU( 440 ) : cfg.
width;
279 int h = cfg.
height < 40 ? horizPixelsFromDU( 340 ) : cfg.
height;
281 GetParent()->SetSize( wxSize( w, h ) );
282 GetParent()->Layout();
287 cfg.
sash_h = horizPixelsFromDU( 220 );
292 cfg.
sash_v = horizPixelsFromDU( 230 );
304 m_adapter->SetPreselectNode( aPreselect, 0 );
319 auto state = wxGetMouseState();
321 if( state.LeftIsDown() )
337 m_adapter->OpenLibs( cfg->m_LibTree.open_libs );
361 wxCommandEvent event( FP_SELECTION_EVENT, GetId() );
362 event.SetEventObject(
this );
364 ProcessWindowEvent( event );
388 if(
m_details && e.GetKeyCode() ==
'C' && e.ControlDown() &&
389 !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
391 wxString txt =
m_details->SelectionToText();
394 if( wxTheClipboard->Open() )
396 wxTheClipboard->SetData(
new wxTextDataObject( txt ) );
397 wxTheClipboard->Flush();
398 wxTheClipboard->Close();
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void AddLibraries(EDA_BASE_FRAME *aParent)
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(PCB_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
Add dark theme support to wxHtmlWindow.
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.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
void SetPreselectNode(const LIB_ID &aLibId, int aUnit)
Set the symbol name to be selected if there are no search results.
LIB_TREE_NODE_LIBRARY & DoAddLibrary(const wxString &aNodeName, const wxString &aDesc, const std::vector< LIB_TREE_ITEM * > &aItemList, bool pinned, bool presorted)
Add the given list of symbols by alias.
void SetFilter(std::function< bool(LIB_TREE_NODE &aNode)> *aFilter)
Set the filter.
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_MODEL_ADAPTER::SORT_MODE GetSortMode() 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 BlockPreview(bool aBlock)
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
EDA_UNITS GetUserUnits() const
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...