30#include <wx/checkbox.h>
42 const wxArrayString& aItemHeaders,
43 const std::vector<wxArrayString>& aItemList,
44 const wxString& aPreselectText,
bool aSortList,
45 const std::vector<std::pair<wxString, bool*>>& aExtraCheckboxes ) :
47 m_sortList( aSortList )
53 initDialog( aItemHeaders, aItemList, aPreselectText );
55 if( aItemList.size() > 16 )
66 if( !aExtraCheckboxes.empty() )
70 for(
const auto& [label, valuePtr] : aExtraCheckboxes )
72 wxCheckBox* cb =
new wxCheckBox(
this, wxID_ANY, label );
73 cb->SetValue( *valuePtr );
82 GetSizer()->Fit(
this );
90 m_sortList( aSortList )
111 const std::vector<wxArrayString>& aItemList,
112 const wxString& aPreselectText )
114 if( aItemHeaders.Count() == 1 )
116 m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
122 else if( aItemHeaders.Count() == 2 )
124 for(
unsigned i = 0; i < aItemHeaders.Count(); i++ )
126 m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
137 if( !aPreselectText.IsEmpty() )
139 long sel =
m_listBox->FindItem( -1, aPreselectText );
141 if( sel != wxNOT_FOUND )
143 m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
157 m_listBox->SetSingleStyle( wxLC_NO_HEADER,
true );
184 itemName = row.Item( 0 );
186 if( itemName.MakeLower().Matches(
filter ) )
196 return m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
202 wxCHECK_MSG(
unsigned( aColumn ) <
unsigned(
m_listBox->GetColumnCount() ), wxEmptyString,
203 wxT(
"Invalid list control column." ) );
205 long item =
m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
212 info.m_mask = wxLIST_MASK_TEXT;
213 info.m_itemId = item;
214 info.m_col = aColumn;
230 *valuePtr = checkbox->GetValue();
238 m_listBox->SetItemPtrData( itemIndex, wxUIntPtr( &itemList[0] ) );
241 for(
unsigned i = 1; i < itemList.size(); i++ )
242 m_listBox->SetItem( itemIndex, i, itemList[i] );
248 for(
unsigned row = 0; row < itemList.size(); row++ )
250 wxASSERT( (
int) itemList[row].GetCount() ==
m_listBox->GetColumnCount() );
252 for(
unsigned col = 0; col < itemList[row].GetCount(); col++ )
255 info.m_itemId = row + position;
257 info.m_text = itemList[row].Item( col );
259 info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH;
263 info.m_data = wxUIntPtr( &itemList[row].Item( col ) );
264 info.m_mask |= wxLIST_MASK_DATA;
281 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
291 else if(
m_listBox->GetColumnCount() == 2 )
306 wxIntPtr WXUNUSED( aSortData ) )
308 wxString* component1Name = (wxString*) aItem1;
309 wxString* component2Name = (wxString*) aItem2;
311 return StrNumCmp( *component1Name, *component2Name,
true );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
bool Show(bool show) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Class EDA_LIST_DIALOG_BASE.
wxStaticText * m_listLabel
wxBoxSizer * m_ExtrasSizer
void textChangeInFilterBox(wxCommandEvent &event) override
bool Show(bool show) override
void SetOKLabel(const wxString &aLabel)
void initDialog(const wxArrayString &aItemHeaders, const std::vector< wxArrayString > &aItemList, const wxString &aPreselectText)
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void onListItemActivated(wxListEvent &event) override
void SetListLabel(const wxString &aLabel)
std::map< wxCheckBox *, bool * > m_extraCheckboxMap
virtual void onSize(wxSizeEvent &event) override
std::vector< wxArrayString > m_itemsList
void Append(const wxArrayString &aItemStr)
void GetExtraCheckboxValues()
Fills in the value pointers from the checkboxes after the dialog has run.
void InsertItems(const std::vector< wxArrayString > &aItemList, int aPosition=0)
EDA_LIST_DIALOG(wxWindow *aParent, const wxString &aTitle, const wxArrayString &aItemHeaders, const std::vector< wxArrayString > &aItemList, const wxString &aPreselectText=wxEmptyString, bool aSortList=true, const std::vector< std::pair< wxString, bool * > > &aExtraCheckboxes={})
static const wxString GetPinningSymbol()
static int wxCALLBACK myCompareFunction(wxIntPtr aItem1, wxIntPtr aItem2, wxIntPtr WXUNUSED(aSortData))
static int DEFAULT_SINGLE_COL_WIDTH
static int DEFAULT_COL_WIDTHS[]
This file contains miscellaneous commonly used macros and functions.
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.