47 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
49 wxWindow* eventSource =
nullptr;
51 for( wxWindow* win = aParent; win; win = win->GetParent() )
60 auto* optWidthField =
AddField<wxTextCtrl>( wxS(
"opt_width" ), positions[0], wxTE_CENTRE | wxTE_PROCESS_ENTER );
62 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, optWidthField->GetControl(),
63 optWidthField->GetLabel(),
false,
false );
67 AddField<wxTextCtrl>( wxS(
"width_tolerance" ), positions[1], wxTE_CENTRE | wxTE_PROCESS_ENTER );
69 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, widthTolField->GetControl(),
70 widthTolField->GetLabel(),
false,
false );
73 auto* optGapField =
AddField<wxTextCtrl>( wxS(
"opt_gap" ), positions[2], wxTE_CENTRE | wxTE_PROCESS_ENTER );
75 optGapField->GetLabel(),
false,
false );
78 auto* gapTolField =
AddField<wxTextCtrl>( wxS(
"gap_tolerance" ), positions[3], wxTE_CENTRE | wxTE_PROCESS_ENTER );
80 &
m_unitsProvider, eventSource,
nullptr, gapTolField->GetControl(), gapTolField->GetLabel(),
false,
false );
83 auto* maxUncoupledField =
86 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, maxUncoupledField->GetControl(),
87 maxUncoupledField->GetLabel(),
false,
false );
93 int fieldHeight = optWidthField->GetControl()->GetBestSize().GetHeight();
95 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
96 wxSize pmSize = plusMinus->GetBestSize();
97 wxStaticText* optMmLabel = optWidthField->GetLabel();
98 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
99 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
100 plusMinus->SetPosition(
101 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
107 int fieldHeight = optGapField->GetControl()->GetBestSize().GetHeight();
109 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
110 wxSize pmSize = plusMinus->GetBestSize();
111 wxStaticText* optMmLabel = optGapField->GetLabel();
112 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
113 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
114 plusMinus->SetPosition(
115 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
118 auto notifyModified = [
this]( wxCommandEvent& )
125 optWidthField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
126 widthTolField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
127 optGapField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
128 gapTolField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
129 maxUncoupledField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
131 auto notifySave = [
this]( wxCommandEvent& aEvent )
138 optWidthField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
139 widthTolField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
140 optGapField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
141 gapTolField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
142 maxUncoupledField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
wxString result
Test unit parsing edge cases and error handling.