23#include <wx/propgrid/propgrid.h>
46 : wxAnyToVariantRegistration( factory )
68 return wxTypeId(a) == wxTypeId(b);
82 wxPGProperty* ret =
nullptr;
118 size_t typeId = aProperty->
TypeHash();
124 ret =
new wxEnumProperty( wxPG_LABEL, wxPG_LABEL,
125 const_cast<wxPGChoices&
>( aProperty->
Choices() ) );
129 ret =
new wxIntProperty();
131 else if( typeId ==
TYPE_HASH(
unsigned int ) || typeId ==
TYPE_HASH(
unsigned long ) )
133 ret =
new wxUIntProperty();
137 ret =
new wxFloatProperty();
143 else if( typeId ==
TYPE_HASH( wxString ) )
149 wxFAIL_MSG( wxString::Format( wxS(
"Property %s not supported by PGPropertyFactory" ),
150 aProperty->
Name() ) );
151 ret =
new wxPropertyCategory();
152 ret->Enable(
false );
160 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
161 ret->SetName( aProperty->
Name() );
162 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
163 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
172 m_coordType( aCoordType )
184 int aArgFlags )
const
187 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_DISTANCE::StringToDistance should not be used." ) );
193 wxCHECK( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG, wxEmptyString );
195 long distanceIU = aVariant.GetLong();
204 case EDA_UNITS::INCHES:
205 return wxString::Format( wxS(
"%g in" ),
pcbIUScale.
IUToMils( distanceIU ) / 1000.0 );
207 case EDA_UNITS::MILS:
210 case EDA_UNITS::MILLIMETRES:
213 case EDA_UNITS::UNSCALED:
214 return wxString::Format( wxS(
"%li" ), distanceIU );
222 return wxEmptyString;
241 wxIntProperty( aLabel, aName, aValue ),
257 if( !aText.ToDouble( &value ) )
265 if( aVariant.IsNull() || aVariant.GetDouble() != value )
277 if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
280 return wxString::Format( wxS(
"%g\u00B0" ), aVariant.GetDouble() /
m_scale );
282 else if( aVariant.GetType() == wxS(
"EDA_ANGLE" ) )
290 wxCHECK_MSG(
false, wxEmptyString, wxS(
"Unexpected variant type in PGPROPERTY_ANGLE" ) );
304 return wxSize( 16, 12 );
309 wxPGPaintData& aPaintData )
311 int index = aPaintData.m_choiceItem;
317 if( index < 0 || index >=
static_cast<int>( GetChoices().GetCount() ) )
322 if(
color == wxNullColour )
325 aDC.SetPen( *wxTRANSPARENT_PEN );
326 aDC.SetBrush( wxBrush(
color ) );
327 aDC.DrawRectangle( aRect );
329 aPaintData.m_drawnWidth = aRect.width;
335 if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING )
336 return wxEmptyString;
351 wxBoolProperty( aLabel, aName, aValue )
359 wxCHECK_MSG( m_customEditor, wxPGEditor_CheckBox,
360 wxT(
"Make sure to set custom editor for PGPROPERTY_BOOL!" ) );
361 return m_customEditor;
constexpr EDA_IU_SCALE pcbIUScale
static wxVariantData * VariantDataFactory(const wxAny &aAny)
The base class for create windows for drawing purpose.
A wxEnumProperty that displays a color next to the enum value.
void SetScale(double aScale)
wxString ValueToString(wxVariant &aVariant, int aArgFlags=0) const override
double m_scale
< Scale factor to convert between raw and displayed value
wxValidator * DoGetValidator() const override
Do not perform PG validation; the UX is not what we want.
bool StringToValue(wxVariant &aVariant, const wxString &aText, int aArgFlags=0) const override
const wxPGEditor * DoGetEditorClass() const override
PGPROPERTY_BOOL(const wxString &aLabel=wxPG_LABEL, const wxString &aName=wxPG_LABEL, bool aValue=false)
wxColour GetColor(int aValue)
wxSize OnMeasureImage(int aItem=-1) const override
void OnCustomPaint(wxDC &aDC, const wxRect &aRect, wxPGPaintData &aPaintData) override
Customized wxPGProperty class to handle angles.
PGPROPERTY_COORD(const wxString &aLabel=wxPG_LABEL, const wxString &aName=wxPG_LABEL, long aValue=0, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
wxValidator * DoGetValidator() const override
PGPROPERTY_DISTANCE(const wxString &aRegEx, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
wxString DistanceToString(wxVariant &aVariant, int aArgFlags=0) const
bool StringToDistance(wxVariant &aVariant, const wxString &aText, int aArgFlags=0) const
virtual ~PGPROPERTY_DISTANCE()=0
ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType
std::unique_ptr< REGEX_VALIDATOR > m_regExValidator
PGPROPERTY_SIZE(const wxString &aLabel=wxPG_LABEL, const wxString &aName=wxPG_LABEL, long aValue=0)
wxValidator * DoGetValidator() const override
wxString ValueToString(wxVariant &aValue, int aFlags=0) const override
bool StringToValue(wxVariant &aVariant, const wxString &aString, int aFlags=0) const override
static const wxString EDITOR_NAME
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
virtual size_t TypeHash() const =0
Return type-id of the property type.
PROPERTY_DISPLAY Display() const
ORIGIN_TRANSFORMS::COORD_TYPES_T CoordType() const
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
const wxString & Name() const
virtual const wxPGChoices & Choices() const
Return a limited set of possible values (e.g.
static PROPERTY_MANAGER & Instance()
ORIGIN_TRANSFORMS * GetTransforms() const
Custom validator that checks verifies that a string exactly matches a regular expression.
static wxAnyValueTypeScopedPtr s_instance
static bool IsSameClass(const wxAnyValueType *otherType)
virtual wxAnyValueType * GetAssociatedType() override
static wxAnyValueType * GetInstance()
wxAnyToEDA_ANGLE_VARIANTRegistrationImpl(wxVariantDataFactory factory)
static bool AreSameClasses(const wxAnyValueType &a, const wxAnyValueType &b)
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
static const wxChar REGEX_SIGNED_DISTANCE[]
wxPGProperty * PGPropertyFactory(const PROPERTY_BASE *aProperty, EDA_DRAW_FRAME *aFrame)
Customized abstract wxPGProperty class to handle coordinate/size units.
static const wxChar REGEX_UNSIGNED_DISTANCE[]
PROPERTY_DISPLAY
Common property types.
@ PT_DEGREE
Angle expressed in degrees.
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
@ PT_DECIDEGREE
Angle expressed in decidegrees.
@ PT_DEFAULT
Default property for a given type.
@ PT_SIZE
Size expressed in distance units (mm/inch)
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
constexpr double IUTomm(int iu) const
constexpr int IUToMils(int iu) const
Custom text control validator definitions.