23#include <wx/propgrid/propgrid.h>
45 : wxAnyToVariantRegistration( factory )
67 return wxTypeId(a) == wxTypeId(b);
81 wxPGProperty* ret =
nullptr;
117 size_t typeId = aProperty->
TypeHash();
123 ret =
new wxEnumProperty( wxPG_LABEL, wxPG_LABEL,
124 const_cast<wxPGChoices&
>( aProperty->
Choices() ) );
128 ret =
new wxIntProperty();
130 else if( typeId ==
TYPE_HASH(
unsigned int ) || typeId ==
TYPE_HASH(
unsigned long ) )
132 ret =
new wxUIntProperty();
136 ret =
new wxFloatProperty();
142 else if( typeId ==
TYPE_HASH( wxString ) )
148 wxFAIL_MSG(
wxString::Format( wxS(
"Property %s not supported by PGPropertyFactory" ),
149 aProperty->
Name() ) );
150 ret =
new wxPropertyCategory();
151 ret->Enable(
false );
159 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
160 ret->SetName( aProperty->
Name() );
161 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
162 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
171 m_coordType( aCoordType )
183 int aArgFlags )
const
186 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_DISTANCE::StringToDistance should not be used." ) );
192 wxCHECK( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG, wxEmptyString );
194 long distanceIU = aVariant.GetLong();
221 return wxEmptyString;
240 wxIntProperty( aLabel, aName, aValue ),
256 if( !aText.ToDouble( &value ) )
264 if( aVariant.IsNull() || aVariant.GetDouble() != value )
276 if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
281 else if( aVariant.GetType() == wxS(
"EDA_ANGLE" ) )
289 wxCHECK_MSG(
false, wxEmptyString, wxS(
"Unexpected variant type in PGPROPERTY_ANGLE" ) );
303 return wxSize( 16, 12 );
308 wxPGPaintData& aPaintData )
310 int index = aPaintData.m_choiceItem;
316 if( index < 0 || index >=
static_cast<int>( GetChoices().GetCount() ) )
321 if(
color == wxNullColour )
324 aDC.SetPen( *wxTRANSPARENT_PEN );
325 aDC.SetBrush( wxBrush(
color ) );
326 aDC.DrawRectangle( aRect );
328 aPaintData.m_drawnWidth = aRect.width;
334 if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING )
335 return wxEmptyString;
350 wxBoolProperty( aLabel, aName, aValue )
358 wxCHECK_MSG( m_customEditor, wxPGEditor_CheckBox,
359 wxT(
"Make sure to set custom editor for PGPROPERTY_BOOL!" ) );
360 return m_customEditor;
constexpr EDA_IU_SCALE pcbIUScale
static wxVariantData * VariantDataFactory(const wxAny &aAny)
Customized wxPGProperty class to handle angles
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
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
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
Customized abstract wxPGProperty class to handle coordinate/size units
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 const wxString EDITOR_NAME
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)
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)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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.