30#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 );
74 auto* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
78 const double value =
m_data->GetNumericInputValue();
80 if(
m_data->IsIntegerOnly() )
81 ctrl->ChangeValue( wxString::Format(
"%d", (
int) value ) );
83 ctrl->ChangeValue( wxString::Format(
"%g", value ) );
102 auto* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
106 wxString
text = ctrl->GetValue().Strip( wxString::both );
108 if(
m_data->IsIntegerOnly() )
112 m_data->SetNumericInputValue(
static_cast<double>( val ) );
117 m_data->SetNumericInputValue( val );
131 wxString* aValidationMessage )
135 wxTextCtrl* ctrl =
dynamic_cast<wxTextCtrl*
>(
m_fields[0]->GetControl() );
139 wxValidator*
validator = ctrl->GetValidator();
149 switch( numValidator->GetValidationState() )
152 errorMsg =
_(
"Value is required." );
155 errorMsg =
_(
"Value must be a number." );
158 errorMsg =
_(
"Value must be a whole number." );
161 errorMsg =
_(
"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
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.
Base window classes and related definitions.
Some functions to handle hotkeys in KiCad.
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
Result of a validation operation.
JSON_SCHEMA_VALIDATOR validator(schema)
wxString result
Test unit parsing edge cases and error handling.