31#include <wx/checkbox.h>
32#include <wx/gbsizer.h>
33#include <wx/stattext.h>
37 std::vector<ENTRY> aEntries ) :
39 m_entries(
std::
move( 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 );
139 std::vector<RESULT> results;
141 for(
size_t ii = 0; ii <
m_entries.size(); ++ii )
147 [&](
const auto& aValueDef )
149 using ArgType = std::decay_t<
decltype( aValueDef )>;
150 if constexpr( std::is_same_v<ArgType, UNIT_BOUND> )
154 results.push_back( binder ? binder->
GetValue() : 0 );
156 else if constexpr( std::is_same_v<ArgType, CHECKBOX> )
158 wxCheckBox* checkBox =
static_cast<wxCheckBox*
>( control );
159 results.push_back( checkBox->GetValue() );
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
The base class for create windows for drawing purpose.
virtual long long int GetValue()
Return the current value in Internal Units.
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
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
A type that is always false.