34#include <wx/textctrl.h>
45 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
47 wxWindow* eventSource =
nullptr;
49 for( wxWindow* win = aParent; win; win = win->GetParent() )
58 auto* valueField =
AddField<wxTextCtrl>( wxS(
"value" ), positions[0], wxTE_PROCESS_ENTER | wxTE_CENTRE );
60 valueField->GetLabel(),
false,
false );
65 auto notifyModified = [
this]( wxCommandEvent& )
72 auto notifySave = [
this]( wxCommandEvent& aEvent )
79 valueField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
80 valueField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
92 if(
m_data->IsIntegerOnly() )
94 auto* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
97 ctrl->ChangeValue( wxString::Format(
"%d", (
int)
m_data->GetNumericInputValue() ) );
113 if(
m_data->IsIntegerOnly() )
115 auto* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
120 ctrl->GetValue().Strip( wxString::both ).ToLong( &val );
121 m_data->SetNumericInputValue(
static_cast<double>( val ) );
134 wxString* aValidationMessage )
138 wxTextCtrl* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
142 wxValidator* validator = ctrl->GetValidator();
144 if( validator && !validator->Validate(
this ) )
152 switch( numValidator->GetValidationState() )
156 errorMsg = wxS(
"Value must be a number." );
159 errorMsg = wxS(
"Value must be a whole number." );
162 errorMsg = wxS(
"Value must be greater than 0." );
167 if( !errorMsg.IsEmpty() )
184 *aErrorCount =
result.errors.size();
186 for(
size_t i = 0; i <
result.errors.size(); i++ )
199 return wxEmptyString;
201 return m_data->GenerateRule( aContext );
constexpr EDA_IU_SCALE pcbIUScale
void ShowFieldError(const wxString &aFieldId)
Show an error indicator on the specified field.
DRC_RE_OVERLAY_FIELD * AddField(const wxString &aId, const DRC_RE_FIELD_POSITION &aPosition, long aStyle=0)
Create and position a field control on the bitmap overlay.
void SetBackgroundBitmap(BITMAPS aBitmap)
Set the background bitmap for this panel.
DRC_RE_BITMAP_OVERLAY_PANEL(wxWindow *aParent, wxWindowID aId=wxID_ANY)
void ClearFieldErrors()
Clear error indicators from all fields.
void PositionFields()
Position all fields based on the current scale factor.
std::vector< std::unique_ptr< DRC_RE_OVERLAY_FIELD > > m_fields
All overlay fields.
static wxString FormatErrorMessage(int aErrorCount, const wxString &aErrorMessage)
The base frame for deriving all KiCad main window classes.
void SetModified()
Marks the dialog as modified, indicating unsaved changes.
static RULE_EDITOR_DIALOG_BASE * GetDialog(wxWindow *aWindow)
Static method to retrieve the rule editor dialog instance associated with a given window.
virtual void OnSave(wxCommandEvent &aEvent)=0
Base window classes and related definitions.
Result of a validation operation.
wxString result
Test unit parsing edge cases and error handling.