34 std::vector<ENTRY> aEntries ) :
38 SetSizeHints( wxDefaultSize, wxDefaultSize );
40 wxBoxSizer* bSizerMain =
new wxBoxSizer( wxVERTICAL );
42 wxGridBagSizer* bSizerContent;
44 bSizerContent =
new wxGridBagSizer( 0, 0 );
45 bSizerContent->SetFlexibleDirection( wxHORIZONTAL );
46 bSizerContent->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );
48 bSizerMain->Add( bSizerContent, 1, wxEXPAND | wxRIGHT | wxLEFT, 5 );
55 [&](
const auto& aValue )
57 using EntryType = std::decay_t<
decltype( aValue )>;
59 if constexpr( std::is_same_v<EntryType, UNIT_BOUND> )
63 wxStaticText* label =
new wxStaticText(
this, wxID_ANY, entry.m_label );
65 bSizerContent->Add( label, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 1 ),
66 wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxLEFT, 5 );
68 wxTextCtrl* textCtrl =
new wxTextCtrl(
this, wxID_ANY );
69 bSizerContent->Add( textCtrl, wxGBPosition( gbRow, 1 ), wxGBSpan( 1, 1 ),
70 wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
72 wxStaticText* units =
new wxStaticText(
this, wxID_ANY,
_(
"unit" ) );
74 bSizerContent->Add( units, wxGBPosition( gbRow, 2 ), wxGBSpan( 1, 1 ),
75 wxTOP | wxBOTTOM | wxRIGHT | wxALIGN_CENTER_VERTICAL, 5 );
77 if( !entry.m_tooltip.IsEmpty() )
78 textCtrl->SetToolTip( entry.m_tooltip );
81 m_unit_binders.push_back( std::make_unique<UNIT_BINDER>( aParent, label, textCtrl, units ) );
85 else if constexpr( std::is_same_v<EntryType, CHECKBOX> )
88 wxCheckBox* checkBox =
new wxCheckBox(
this, wxID_ANY, entry.m_label );
89 checkBox->SetValue( aValue.m_default );
90 bSizerContent->Add( checkBox, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 3 ),
91 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
93 if( !entry.m_tooltip.IsEmpty() )
94 checkBox->SetToolTip( entry.m_tooltip );
110 bSizerContent->AddGrowableCol( 1 );
112 wxStdDialogButtonSizer* sdbSizer1 =
new wxStdDialogButtonSizer();
113 wxButton* sdbSizer1OK =
new wxButton(
this, wxID_OK );
114 sdbSizer1->AddButton( sdbSizer1OK );
115 wxButton* sdbSizer1Cancel =
new wxButton(
this, wxID_CANCEL );
116 sdbSizer1->AddButton( sdbSizer1Cancel );
117 sdbSizer1->Realize();
119 bSizerMain->Add( sdbSizer1, 0, wxALL | wxEXPAND, 5 );
125 SetSizer( bSizerMain );
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, const wxString &name=wxDialogNameStr)
std::vector< std::unique_ptr< UNIT_BINDER > > m_unit_binders
WX_MULTI_ENTRY_DIALOG(EDA_DRAW_FRAME *aParent, const wxString &aCaption, std::vector< ENTRY > aEntries)
Create a multi-entry dialog.
std::vector< RESULT > GetValues() const
Returns the values in the order they were added.
std::vector< ENTRY > m_entries
std::vector< wxWindow * > m_controls