42 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
44 wxWindow* eventSource =
nullptr;
46 for( wxWindow* win = aParent; win; win = win->GetParent() )
56 auto* optLengthField =
AddField<wxTextCtrl>( wxS(
"opt_length" ), positions[0], wxTE_CENTRE | wxTE_PROCESS_ENTER );
58 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, optLengthField->GetControl(),
59 optLengthField->GetLabel(),
false,
false );
64 auto* toleranceField =
AddField<wxTextCtrl>( wxS(
"tolerance" ), positions[1], wxTE_CENTRE | wxTE_PROCESS_ENTER );
66 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, toleranceField->GetControl(),
67 toleranceField->GetLabel(),
false,
false );
75 int fieldHeight = optLengthField->GetControl()->GetBestSize().GetHeight();
77 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
78 wxSize pmSize = plusMinus->GetBestSize();
79 wxStaticText* optMmLabel = optLengthField->GetLabel();
80 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
81 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
82 plusMinus->SetPosition(
83 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
87 auto* maxSkewField =
AddField<wxTextCtrl>( wxS(
"max_skew" ), positions[2], wxTE_CENTRE | wxTE_PROCESS_ENTER );
89 maxSkewField->GetLabel(),
false,
false );
95 wxStaticText* skewMmLabel = maxSkewField->GetLabel();
96 int afterSkewLabel = skewMmLabel->GetPosition().x + skewMmLabel->GetBestSize().GetWidth();
97 int fieldHeight = maxSkewField->GetControl()->GetBestSize().GetHeight();
102 wxPoint( afterSkewLabel + 8, skewPos.
yTop + ( fieldHeight - cbSize.GetHeight() ) / 2 ) );
105 auto notifyModified = [
this]( wxCommandEvent& )
112 optLengthField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
113 toleranceField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
114 maxSkewField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
117 auto notifySave = [
this]( wxCommandEvent& aEvent )
124 optLengthField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
125 toleranceField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
126 maxSkewField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
wxString result
Test unit parsing edge cases and error handling.