41 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
43 wxWindow* eventSource =
nullptr;
45 for( wxWindow* win = aParent; win; win = win->GetParent() )
55 auto* optLengthField =
AddField<wxTextCtrl>( wxS(
"opt_length" ), positions[0], wxTE_CENTRE | wxTE_PROCESS_ENTER );
57 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, optLengthField->GetControl(),
58 optLengthField->GetLabel(),
false,
false );
63 auto* toleranceField =
AddField<wxTextCtrl>( wxS(
"tolerance" ), positions[1], wxTE_CENTRE | wxTE_PROCESS_ENTER );
65 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, toleranceField->GetControl(),
66 toleranceField->GetLabel(),
false,
false );
74 int fieldHeight = optLengthField->GetControl()->GetBestSize().GetHeight();
76 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
77 wxSize pmSize = plusMinus->GetBestSize();
78 wxStaticText* optMmLabel = optLengthField->GetLabel();
79 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
80 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
81 plusMinus->SetPosition(
82 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
85 auto notifyModified = [
this]( wxCommandEvent& )
92 optLengthField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
93 toleranceField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
95 auto notifySave = [
this]( wxCommandEvent& aEvent )
102 optLengthField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
103 toleranceField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
wxString result
Test unit parsing edge cases and error handling.