30#include <wx/checkbox.h>
42 const wxArrayString& aItemHeaders,
43 const std::vector<wxArrayString>& aItemList,
44 const wxString& aPreselectText,
bool aSortList ) :
52 initDialog( aItemHeaders, aItemList, aPreselectText );
54 if( aItemList.size() > 16 )
68 GetSizer()->Fit(
this );
84 wxCHECK2_MSG( aValuePtr,
return, wxT(
"Null pointer for checkbox value." ) );
91 wxCheckBox* cb =
new wxCheckBox(
this, wxID_ANY, aLabel );
92 cb->SetValue( *aValuePtr );
113 const std::vector<wxArrayString>& aItemList,
114 const wxString& aPreselectText )
116 if( aItemHeaders.Count() == 1 )
118 m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
124 else if( aItemHeaders.Count() == 2 )
126 for(
unsigned i = 0; i < aItemHeaders.Count(); i++ )
128 m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
139 if( !aPreselectText.IsEmpty() )
141 long sel =
m_listBox->FindItem( -1, aPreselectText );
143 if( sel != wxNOT_FOUND )
145 m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
159 m_listBox->SetSingleStyle( wxLC_NO_HEADER,
true );
186 itemName = row.Item( 0 );
188 if( itemName.MakeLower().Matches(
filter ) )
198 return m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
204 wxCHECK_MSG(
unsigned( aColumn ) <
unsigned(
m_listBox->GetColumnCount() ), wxEmptyString,
205 wxT(
"Invalid list control column." ) );
207 long item =
m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
214 info.m_mask = wxLIST_MASK_TEXT;
215 info.m_itemId = item;
216 info.m_col = aColumn;
232 *valuePtr = checkbox->GetValue();
240 m_listBox->SetItemPtrData( itemIndex, wxUIntPtr( &itemList[0] ) );
243 for(
unsigned i = 1; i < itemList.size(); i++ )
244 m_listBox->SetItem( itemIndex, i, itemList[i] );
250 for(
unsigned row = 0; row < itemList.size(); row++ )
252 wxASSERT( (
int) itemList[row].GetCount() ==
m_listBox->GetColumnCount() );
254 for(
unsigned col = 0; col < itemList[row].GetCount(); col++ )
257 info.m_itemId = row + position;
259 info.m_text = itemList[row].Item( col );
261 info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH;
265 info.m_data = wxUIntPtr( &itemList[row].Item( col ) );
266 info.m_mask |= wxLIST_MASK_DATA;
283 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
293 else if(
m_listBox->GetColumnCount() == 2 )
308 wxIntPtr WXUNUSED( aSortData ) )
310 wxString* component1Name = (wxString*) aItem1;
311 wxString* component2Name = (wxString*) aItem2;
313 return StrNumCmp( *component1Name, *component2Name,
true );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
bool Show(bool show) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
wxStaticText * m_listLabel
EDA_LIST_DIALOG_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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 AddExtraCheckbox(const wxString &aLabel, bool *aValuePtr)
Add a checkbox value to the dialog.
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)
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.