26#include <wx/checkbox.h>
38 const std::vector<wxArrayString>& aItemList,
const wxString& aPreselectText,
47 initDialog( aItemHeaders, aItemList, aPreselectText );
49 if( aItemList.size() > 16 )
60 GetSizer()->Fit(
this );
76 wxCHECK2_MSG( aValuePtr,
return, wxT(
"Null pointer for checkbox value." ) );
83 wxCheckBox* cb =
new wxCheckBox(
this, wxID_ANY, aLabel );
84 cb->SetValue( *aValuePtr );
105 const wxString& aPreselectText )
107 if( aItemHeaders.Count() == 1 )
109 m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
115 else if( aItemHeaders.Count() == 2 )
117 for(
unsigned i = 0; i < aItemHeaders.Count(); i++ )
119 m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
130 if( !aPreselectText.IsEmpty() )
135 long sel =
m_listBox->FindItem( -1, aPreselectText );
137 if( sel != wxNOT_FOUND )
139 m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
153 m_listBox->SetSingleStyle( wxLC_NO_HEADER,
true );
180 itemName = row.Item( 0 );
182 if( itemName.MakeLower().Matches(
filter ) )
192 return m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
198 wxCHECK_MSG(
unsigned( aColumn ) <
unsigned(
m_listBox->GetColumnCount() ), wxEmptyString,
199 wxT(
"Invalid list control column." ) );
201 long item =
m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
208 info.m_mask = wxLIST_MASK_TEXT;
209 info.m_itemId = item;
210 info.m_col = aColumn;
226 *valuePtr = checkbox->GetValue();
234 m_listBox->SetItemPtrData( itemIndex, wxUIntPtr( &itemList[0] ) );
237 for(
unsigned i = 1; i < itemList.size(); i++ )
238 m_listBox->SetItem( itemIndex, i, itemList[i] );
244 for(
unsigned row = 0; row < itemList.size(); row++ )
246 wxASSERT( (
int) itemList[row].GetCount() ==
m_listBox->GetColumnCount() );
248 for(
unsigned col = 0; col < itemList[row].GetCount(); col++ )
251 info.m_itemId = row + position;
253 info.m_text = itemList[row].Item( col );
255 info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH;
259 info.m_data = wxUIntPtr( &itemList[row].Item( col ) );
260 info.m_mask |= wxLIST_MASK_DATA;
277 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
287 else if(
m_listBox->GetColumnCount() == 2 )
301static int wxCALLBACK
myCompareFunction( wxIntPtr aItem1, wxIntPtr aItem2, wxIntPtr WXUNUSED( aSortData ) )
303 wxString* component1Name = (wxString*) aItem1;
304 wxString* component2Name = (wxString*) aItem2;
306 return StrNumCmp( *component1Name, *component2Name,
true );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
bool Show(bool show) override
void OptOut(wxWindow *aWindow)
Opt out of control state saving.
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
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.