45 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
47 wxWindow* eventSource =
nullptr;
49 for( wxWindow* win = aParent; win; win = win->GetParent() )
59 auto* optLengthField =
AddField<wxTextCtrl>( wxS(
"opt_length" ), positions[0], wxTE_CENTRE | wxTE_PROCESS_ENTER );
61 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, optLengthField->GetControl(),
62 optLengthField->GetLabel(),
false,
false );
67 auto* toleranceField =
AddField<wxTextCtrl>( wxS(
"tolerance" ), positions[1], wxTE_CENTRE | wxTE_PROCESS_ENTER );
69 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, toleranceField->GetControl(),
70 toleranceField->GetLabel(),
false,
false );
78 int fieldHeight = optLengthField->GetControl()->GetBestSize().GetHeight();
80 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
81 wxSize pmSize = plusMinus->GetBestSize();
82 wxStaticText* optMmLabel = optLengthField->GetLabel();
83 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
84 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
85 plusMinus->SetPosition(
86 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
89 auto notifyModified = [
this]( wxCommandEvent& )
96 optLengthField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
97 toleranceField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
99 auto notifySave = [
this]( wxCommandEvent& aEvent )
106 optLengthField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
107 toleranceField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
wxString result
Test unit parsing edge cases and error handling.