37 std::vector<ENTRY> aEntries ) :
41 SetSizeHints( wxDefaultSize, wxDefaultSize );
43 wxBoxSizer* bSizerMain =
new wxBoxSizer( wxVERTICAL );
45 wxGridBagSizer* bSizerContent;
47 bSizerContent =
new wxGridBagSizer( 0, 0 );
48 bSizerContent->SetFlexibleDirection( wxHORIZONTAL );
49 bSizerContent->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );
51 bSizerMain->Add( bSizerContent, 1, wxEXPAND | wxRIGHT | wxLEFT, 5 );
58 [&](
const auto& aValue )
60 using EntryType = std::decay_t<
decltype( aValue )>;
62 if constexpr( std::is_same_v<EntryType, UNIT_BOUND> )
66 wxStaticText* label =
new wxStaticText(
this, wxID_ANY, entry.m_label );
68 bSizerContent->Add( label, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 1 ),
69 wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxLEFT, 5 );
71 wxTextCtrl* textCtrl =
new wxTextCtrl(
this, wxID_ANY );
72 bSizerContent->Add( textCtrl, wxGBPosition( gbRow, 1 ), wxGBSpan( 1, 1 ),
73 wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
75 wxStaticText* units =
new wxStaticText(
this, wxID_ANY,
_(
"unit" ) );
77 bSizerContent->Add( units, wxGBPosition( gbRow, 2 ), wxGBSpan( 1, 1 ),
78 wxTOP | wxBOTTOM | wxRIGHT | wxALIGN_CENTER_VERTICAL, 5 );
80 if( !entry.m_tooltip.IsEmpty() )
81 textCtrl->SetToolTip( entry.m_tooltip );
84 m_unit_binders.push_back( std::make_unique<UNIT_BINDER>( aParent, label, textCtrl, units ) );
88 else if constexpr( std::is_same_v<EntryType, CHECKBOX> )
91 wxCheckBox* checkBox =
new wxCheckBox(
this, wxID_ANY, entry.m_label );
92 checkBox->SetValue( aValue.m_default );
93 bSizerContent->Add( checkBox, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 3 ),
94 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
96 if( !entry.m_tooltip.IsEmpty() )
97 checkBox->SetToolTip( entry.m_tooltip );
113 bSizerContent->AddGrowableCol( 1 );
115 wxStdDialogButtonSizer* sdbSizer1 =
new wxStdDialogButtonSizer();
116 wxButton* sdbSizer1OK =
new wxButton(
this, wxID_OK );
117 sdbSizer1->AddButton( sdbSizer1OK );
118 wxButton* sdbSizer1Cancel =
new wxButton(
this, wxID_CANCEL );
119 sdbSizer1->AddButton( sdbSizer1Cancel );
120 sdbSizer1->Realize();
122 bSizerMain->Add( sdbSizer1, 0, wxALL | wxEXPAND, 5 );
128 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