43 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
45 wxWindow* eventSource =
nullptr;
47 for( wxWindow* win = aParent; win; win = win->GetParent() )
56 auto* optWidthField =
AddField<wxTextCtrl>( wxS(
"opt_width" ), positions[0], wxTE_CENTRE | wxTE_PROCESS_ENTER );
58 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, optWidthField->GetControl(),
59 optWidthField->GetLabel(),
false,
false );
63 AddField<wxTextCtrl>( wxS(
"width_tolerance" ), positions[1], wxTE_CENTRE | wxTE_PROCESS_ENTER );
65 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, widthTolField->GetControl(),
66 widthTolField->GetLabel(),
false,
false );
69 auto* optGapField =
AddField<wxTextCtrl>( wxS(
"opt_gap" ), positions[2], wxTE_CENTRE | wxTE_PROCESS_ENTER );
71 optGapField->GetLabel(),
false,
false );
74 auto* gapTolField =
AddField<wxTextCtrl>( wxS(
"gap_tolerance" ), positions[3], wxTE_CENTRE | wxTE_PROCESS_ENTER );
76 &
m_unitsProvider, eventSource,
nullptr, gapTolField->GetControl(), gapTolField->GetLabel(),
false,
false );
79 auto* maxUncoupledField =
82 std::make_unique<UNIT_BINDER>( &
m_unitsProvider, eventSource,
nullptr, maxUncoupledField->GetControl(),
83 maxUncoupledField->GetLabel(),
false,
false );
89 int fieldHeight = optWidthField->GetControl()->GetBestSize().GetHeight();
91 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
92 wxSize pmSize = plusMinus->GetBestSize();
93 wxStaticText* optMmLabel = optWidthField->GetLabel();
94 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
95 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
96 plusMinus->SetPosition(
97 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
103 int fieldHeight = optGapField->GetControl()->GetBestSize().GetHeight();
105 auto* plusMinus =
new wxStaticText(
this, wxID_ANY, wxS(
"\u00B1" ) );
106 wxSize pmSize = plusMinus->GetBestSize();
107 wxStaticText* optMmLabel = optGapField->GetLabel();
108 int afterOptLabel = optMmLabel->GetPosition().x + optMmLabel->GetBestSize().GetWidth();
109 int gapMid = ( afterOptLabel + tolPos.
xStart ) / 2;
110 plusMinus->SetPosition(
111 wxPoint( gapMid - pmSize.GetWidth() / 2, optPos.
yTop + ( fieldHeight - pmSize.GetHeight() ) / 2 ) );
114 auto notifyModified = [
this]( wxCommandEvent& )
121 optWidthField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
122 widthTolField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
123 optGapField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
124 gapTolField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
125 maxUncoupledField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
127 auto notifySave = [
this]( wxCommandEvent& aEvent )
134 optWidthField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
135 widthTolField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
136 optGapField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
137 gapTolField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
138 maxUncoupledField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
wxString result
Test unit parsing edge cases and error handling.