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 );
58 GetSizer()->Fit(
this );
66 m_sortList( aSortList )
87 const std::vector<wxArrayString>& aItemList,
88 const wxString& aPreselectText )
90 if( aItemHeaders.Count() == 1 )
92 m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
98 else if( aItemHeaders.Count() == 2 )
100 for(
unsigned i = 0; i < aItemHeaders.Count(); i++ )
102 m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
113 if( !aPreselectText.IsEmpty() )
115 long sel =
m_listBox->FindItem( -1, aPreselectText );
117 if( sel != wxNOT_FOUND )
119 m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
133 m_listBox->SetSingleStyle( wxLC_NO_HEADER,
true );
160 itemName = row.Item( 0 );
162 if( itemName.MakeLower().Matches(
filter ) )
172 return m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
178 wxCHECK_MSG(
unsigned( aColumn ) <
unsigned(
m_listBox->GetColumnCount() ), wxEmptyString,
179 wxT(
"Invalid list control column." ) );
181 long item =
m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
188 info.m_mask = wxLIST_MASK_TEXT;
189 info.m_itemId = item;
190 info.m_col = aColumn;
207 m_listBox->SetItemPtrData( itemIndex, wxUIntPtr( &itemList[0] ) );
210 for(
unsigned i = 1; i < itemList.size(); i++ )
211 m_listBox->SetItem( itemIndex, i, itemList[i] );
217 for(
unsigned row = 0; row < itemList.size(); row++ )
219 wxASSERT( (
int) itemList[row].GetCount() ==
m_listBox->GetColumnCount() );
221 for(
unsigned col = 0; col < itemList[row].GetCount(); col++ )
224 info.m_itemId = row + position;
226 info.m_text = itemList[row].Item( col );
228 info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH;
232 info.m_data = wxUIntPtr( &itemList[row].Item( col ) );
233 info.m_mask |= wxLIST_MASK_DATA;
250 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
260 else if(
m_listBox->GetColumnCount() == 2 )
275 wxIntPtr WXUNUSED( aSortData ) )
277 wxString* component1Name = (wxString*) aItem1;
278 wxString* component2Name = (wxString*) aItem2;
280 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.