40 const wxArrayString& aItemHeaders,
41 const std::vector<wxArrayString>& aItemList,
42 const wxString& aPreselectText,
bool aSortList ) :
44 m_itemsList( aItemList ),
45 m_sortList( aSortList )
59 GetSizer()->Fit(
this );
81 if( aItemHeaders.Count() == 1 )
83 m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
89 else if( aItemHeaders.Count() == 2 )
91 for(
unsigned i = 0; i < aItemHeaders.Count(); i++ )
93 m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
103 if( !aSelection.IsEmpty() )
105 long sel =
m_listBox->FindItem( -1, aSelection );
107 if( sel != wxNOT_FOUND )
109 m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
123 m_listBox->SetSingleStyle( wxLC_NO_HEADER,
true );
150 itemName = row.Item( 0 );
152 if( itemName.MakeLower().Matches(
filter ) )
162 return m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
168 wxCHECK_MSG(
unsigned( aColumn ) <
unsigned(
m_listBox->GetColumnCount() ), wxEmptyString,
169 wxT(
"Invalid list control column." ) );
171 long item =
m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
178 info.m_mask = wxLIST_MASK_TEXT;
179 info.m_itemId = item;
180 info.m_col = aColumn;
197 m_listBox->SetItemPtrData( itemIndex, wxUIntPtr( &itemList[0] ) );
200 for(
unsigned i = 1; i < itemList.size(); i++ )
201 m_listBox->SetItem( itemIndex, i, itemList[i] );
207 for(
unsigned row = 0; row < itemList.size(); row++ )
209 wxASSERT( (
int) itemList[row].GetCount() ==
m_listBox->GetColumnCount() );
211 for(
unsigned col = 0; col < itemList[row].GetCount(); col++ )
214 info.m_itemId = row + position;
216 info.m_text = itemList[row].Item( col );
218 info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH;
222 info.m_data = wxUIntPtr( &itemList[row].Item( col ) );
223 info.m_mask |= wxLIST_MASK_DATA;
240 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
250 else if(
m_listBox->GetColumnCount() == 2 )
265 wxIntPtr WXUNUSED( aSortData ) )
267 wxString* component1Name = (wxString*) aItem1;
268 wxString* component2Name = (wxString*) aItem2;
270 return StrNumCmp( *component1Name, *component2Name,
true );
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 wxString &aSelection)
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.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".