38 std::vector<ENTRY> aEntries ) :
42 SetSizeHints( wxDefaultSize, wxDefaultSize );
44 wxBoxSizer* bSizerMain =
new wxBoxSizer( wxVERTICAL );
46 wxGridBagSizer* bSizerContent;
48 bSizerContent =
new wxGridBagSizer( 0, 0 );
49 bSizerContent->SetFlexibleDirection( wxHORIZONTAL );
50 bSizerContent->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );
52 bSizerMain->Add( bSizerContent, 1, wxEXPAND | wxRIGHT | wxLEFT, 5 );
59 [&](
const auto& aValue )
61 using EntryType = std::decay_t<
decltype( aValue )>;
63 if constexpr( std::is_same_v<EntryType, UNIT_BOUND> )
67 wxStaticText* label =
new wxStaticText(
this, wxID_ANY, entry.m_label );
69 bSizerContent->Add( label, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 1 ),
70 wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxLEFT, 5 );
72 wxTextCtrl* textCtrl =
new wxTextCtrl(
this, wxID_ANY );
73 bSizerContent->Add( textCtrl, wxGBPosition( gbRow, 1 ), wxGBSpan( 1, 1 ),
74 wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
76 wxStaticText* units =
new wxStaticText(
this, wxID_ANY,
_(
"unit" ) );
78 bSizerContent->Add( units, wxGBPosition( gbRow, 2 ), wxGBSpan( 1, 1 ),
79 wxTOP | wxBOTTOM | wxRIGHT | wxALIGN_CENTER_VERTICAL, 5 );
81 if( !entry.m_tooltip.IsEmpty() )
82 textCtrl->SetToolTip( entry.m_tooltip );
85 m_unit_binders.push_back( std::make_unique<UNIT_BINDER>( aParent, label, textCtrl, units ) );
89 else if constexpr( std::is_same_v<EntryType, CHECKBOX> )
92 wxCheckBox* checkBox =
new wxCheckBox(
this, wxID_ANY, entry.m_label );
93 checkBox->SetValue( aValue.m_default );
94 bSizerContent->Add( checkBox, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 3 ),
95 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
97 if( !entry.m_tooltip.IsEmpty() )
98 checkBox->SetToolTip( entry.m_tooltip );
114 bSizerContent->AddGrowableCol( 1 );
116 wxStdDialogButtonSizer* sdbSizer1 =
new wxStdDialogButtonSizer();
117 wxButton* sdbSizer1OK =
new wxButton(
this, wxID_OK );
118 sdbSizer1->AddButton( sdbSizer1OK );
119 wxButton* sdbSizer1Cancel =
new wxButton(
this, wxID_CANCEL );
120 sdbSizer1->AddButton( sdbSizer1Cancel );
121 sdbSizer1->Realize();
123 bSizerMain->Add( sdbSizer1, 0, wxALL | wxEXPAND, 5 );
129 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