40 const wxArrayString& aItemHeaders,
41 const std::vector<wxArrayString>& aItemList,
42 const wxString& aPreselectText,
bool aSortList ) :
44 m_sortList( aSortList )
48 initDialog( aItemHeaders, aItemList, aPreselectText );
50 if( aItemList.size() > 16 )
64 GetSizer()->Fit(
this );
72 m_sortList( aSortList )
93 const std::vector<wxArrayString>& aItemList,
94 const wxString& aPreselectText )
96 if( aItemHeaders.Count() == 1 )
98 m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
104 else if( aItemHeaders.Count() == 2 )
106 for(
unsigned i = 0; i < aItemHeaders.Count(); i++ )
108 m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
119 if( !aPreselectText.IsEmpty() )
121 long sel =
m_listBox->FindItem( -1, aPreselectText );
123 if( sel != wxNOT_FOUND )
125 m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
139 m_listBox->SetSingleStyle( wxLC_NO_HEADER,
true );
166 itemName = row.Item( 0 );
168 if( itemName.MakeLower().Matches(
filter ) )
178 return m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
184 wxCHECK_MSG(
unsigned( aColumn ) <
unsigned(
m_listBox->GetColumnCount() ), wxEmptyString,
185 wxT(
"Invalid list control column." ) );
187 long item =
m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
194 info.m_mask = wxLIST_MASK_TEXT;
195 info.m_itemId = item;
196 info.m_col = aColumn;
213 m_listBox->SetItemPtrData( itemIndex, wxUIntPtr( &itemList[0] ) );
216 for(
unsigned i = 1; i < itemList.size(); i++ )
217 m_listBox->SetItem( itemIndex, i, itemList[i] );
223 for(
unsigned row = 0; row < itemList.size(); row++ )
225 wxASSERT( (
int) itemList[row].GetCount() ==
m_listBox->GetColumnCount() );
227 for(
unsigned col = 0; col < itemList[row].GetCount(); col++ )
230 info.m_itemId = row + position;
232 info.m_text = itemList[row].Item( col );
234 info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH;
238 info.m_data = wxUIntPtr( &itemList[row].Item( col ) );
239 info.m_mask |= wxLIST_MASK_DATA;
256 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
266 else if(
m_listBox->GetColumnCount() == 2 )
281 wxIntPtr WXUNUSED( aSortData ) )
283 wxString* component1Name = (wxString*) aItem1;
284 wxString* component2Name = (wxString*) aItem2;
286 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
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)
virtual void onSize(wxSizeEvent &event) override
std::vector< wxArrayString > m_itemsList
void Append(const wxArrayString &aItemStr)
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)
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.