31#include <wx/textctrl.h>
42 std::vector<DRC_RE_FIELD_POSITION> positions =
m_data->GetFieldPositions();
44 wxWindow* eventSource =
nullptr;
46 for( wxWindow* win = aParent; win; win = win->GetParent() )
55 auto* valueField =
AddField<wxTextCtrl>( wxS(
"value" ), positions[0], wxTE_PROCESS_ENTER | wxTE_CENTRE );
57 valueField->GetLabel(),
false,
false );
62 auto notifyModified = [
this]( wxCommandEvent& )
69 auto notifySave = [
this]( wxCommandEvent& aEvent )
76 valueField->GetControl()->Bind( wxEVT_TEXT, notifyModified );
77 valueField->GetControl()->Bind( wxEVT_TEXT_ENTER, notifySave );
89 if(
m_data->IsIntegerOnly() )
91 auto* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
94 ctrl->ChangeValue( wxString::Format(
"%d", (
int)
m_data->GetNumericInputValue() ) );
110 if(
m_data->IsIntegerOnly() )
112 auto* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
117 ctrl->GetValue().Strip( wxString::both ).ToLong( &val );
118 m_data->SetNumericInputValue(
static_cast<double>( val ) );
131 wxString* aValidationMessage )
135 wxTextCtrl* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
139 wxValidator*
validator = ctrl->GetValidator();
149 switch( numValidator->GetValidationState() )
153 errorMsg =
_(
"Value must be a number." );
156 errorMsg =
_(
"Value must be a whole number." );
159 errorMsg =
_(
"Value must be greater than 0." );
164 if( !errorMsg.IsEmpty() )
181 *aErrorCount =
result.errors.size();
183 for(
size_t i = 0; i <
result.errors.size(); i++ )
196 return wxEmptyString;
198 return m_data->GenerateRule( aContext );
constexpr EDA_IU_SCALE pcbIUScale
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 ShowFieldError(const wxString &aFieldId, const wxString &aMessage)
Show an error indicator on the specified field.
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.
Some functions to handle hotkeys in KiCad.
Result of a validation operation.
JSON_SCHEMA_VALIDATOR validator(schema)
wxString result
Test unit parsing edge cases and error handling.