31#include <wx/checkbox.h>
32#include <wx/gbsizer.h>
33#include <wx/stattext.h>
37 std::vector<ENTRY> aEntries ) :
40 SetSizeHints( wxDefaultSize, wxDefaultSize );
42 wxBoxSizer* bSizerMain =
new wxBoxSizer( wxVERTICAL );
44 wxGridBagSizer* bSizerContent;
46 bSizerContent =
new wxGridBagSizer( 0, 0 );
47 bSizerContent->SetFlexibleDirection( wxHORIZONTAL );
48 bSizerContent->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );
50 bSizerMain->Add( bSizerContent, 1, wxEXPAND | wxRIGHT | wxLEFT, 5 );
57 [&](
const auto& aValue )
59 using EntryType = std::decay_t<
decltype( aValue )>;
60 if constexpr( std::is_same_v<EntryType, UNIT_BOUND> )
65 new wxStaticText(
this, wxID_ANY, entry.m_label, wxDefaultPosition,
68 bSizerContent->Add( label, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 1 ),
69 wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxLEFT,
72 wxTextCtrl* textCtrl =
73 new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition,
75 bSizerContent->Add( textCtrl, wxGBPosition( gbRow, 1 ), wxGBSpan( 1, 1 ),
76 wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5 );
78 wxStaticText* unit_label =
new wxStaticText(
79 this, wxID_ANY,
_(
"unit" ), wxDefaultPosition, wxDefaultSize, 0 );
80 unit_label->Wrap( -1 );
81 bSizerContent->Add( unit_label, wxGBPosition( gbRow, 2 ), wxGBSpan( 1, 1 ),
82 wxTOP | wxBOTTOM | wxRIGHT | wxALIGN_CENTER_VERTICAL,
85 if( !entry.m_tooltip.IsEmpty() )
86 textCtrl->SetToolTip( entry.m_tooltip );
90 aParent, label, textCtrl, unit_label ) );
94 else if constexpr( std::is_same_v<EntryType, CHECKBOX> )
97 wxCheckBox* checkBox =
98 new wxCheckBox(
this, wxID_ANY, wxEmptyString, wxDefaultPosition,
100 bSizerContent->Add( checkBox, wxGBPosition( gbRow, 0 ), wxGBSpan( 1, 3 ),
101 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
103 checkBox->SetLabel( entry.m_label );
104 checkBox->SetValue( aValue.m_default );
106 if( !entry.m_tooltip.IsEmpty() )
107 checkBox->SetToolTip( entry.m_tooltip );
123 bSizerContent->AddGrowableCol( 1 );
125 wxStdDialogButtonSizer* sdbSizer1 =
new wxStdDialogButtonSizer();
126 wxButton* sdbSizer1OK =
new wxButton(
this, wxID_OK );
127 sdbSizer1->AddButton( sdbSizer1OK );
128 wxButton* sdbSizer1Cancel =
new wxButton(
this, wxID_CANCEL );
129 sdbSizer1->AddButton( sdbSizer1Cancel );
130 sdbSizer1->Realize();
132 bSizerMain->Add( sdbSizer1, 0, wxALL | wxEXPAND, 5 );
134 SetSizer( bSizerMain );
145 std::vector<RESULT> results;
147 for(
size_t ii = 0; ii <
m_entries.size(); ++ii )
153 [&](
const auto& aValueDef )
155 using ArgType = std::decay_t<
decltype( aValueDef )>;
156 if constexpr( std::is_same_v<ArgType, UNIT_BOUND> )
160 results.push_back( binder ? binder->
GetValue() : 0 );
162 else if constexpr( std::is_same_v<ArgType, CHECKBOX> )
164 wxCheckBox* checkBox =
static_cast<wxCheckBox*
>( control );
165 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
A type that is always false.