46 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
48 wxWindow* eventSource =
nullptr;
50 for( wxWindow* win = aParent; win; win = win->GetParent() )
60 auto* optLengthField =
AddField<wxTextCtrl>( wxS(
"opt_length" ), positions[0], wxTE_CENTRE | wxTE_PROCESS_ENTER );
62 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, optLengthField->GetControl(),
63 optLengthField->GetLabel(),
false,
false );
68 auto* toleranceField =
AddField<wxTextCtrl>( wxS(
"tolerance" ), positions[1], wxTE_CENTRE | wxTE_PROCESS_ENTER );
70 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, toleranceField->GetControl(),
71 toleranceField->GetLabel(),
false,
false );
79 int fieldHeight = optLengthField->GetControl()->GetBestSize().GetHeight();
81 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
82 wxSize pmSize = plusMinus->GetBestSize();
83 wxStaticText* optMmLabel = optLengthField->GetLabel();
84 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
85 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
86 plusMinus->SetPosition(
87 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
91 auto* maxSkewField =
AddField<wxTextCtrl>( wxS(
"max_skew" ), positions[2], wxTE_CENTRE | wxTE_PROCESS_ENTER );
93 maxSkewField->GetLabel(),
false,
false );
99 wxStaticText* skewMmLabel = maxSkewField->GetLabel();
100 int afterSkewLabel = skewMmLabel->GetPosition().x + skewMmLabel->GetBestSize().GetWidth();
101 int fieldHeight = maxSkewField->GetControl()->GetBestSize().GetHeight();
106 wxPoint( afterSkewLabel + 8, skewPos.
yTop + ( fieldHeight - cbSize.GetHeight() ) / 2 ) );
109 auto notifyModified = [
this]( wxCommandEvent& )
116 optLengthField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
117 toleranceField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
118 maxSkewField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
121 auto notifySave = [
this]( wxCommandEvent& aEvent )
128 optLengthField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
129 toleranceField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
130 maxSkewField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
wxString result
Test unit parsing edge cases and error handling.