23#include <wx/propgrid/propgrid.h>
47 : wxAnyToVariantRegistration( factory )
69 return wxTypeId(a) == wxTypeId(b);
85 : wxAnyToVariantRegistration( factory )
107 return wxTypeId(a) == wxTypeId(b);
120 wxPGProperty* ret =
nullptr;
155 size_t typeId = aProperty->
TypeHash();
161 ret =
new wxEnumProperty( wxPG_LABEL, wxPG_LABEL,
162 const_cast<wxPGChoices&
>( aProperty->
Choices() ) );
166 ret =
new wxIntProperty();
168 else if( typeId ==
TYPE_HASH(
unsigned int ) || typeId ==
TYPE_HASH(
unsigned long ) )
170 ret =
new wxUIntProperty();
174 ret =
new wxFloatProperty();
180 else if( typeId ==
TYPE_HASH( wxString ) )
190 wxFAIL_MSG( wxString::Format( wxS(
"Property %s not supported by PGPropertyFactory" ),
191 aProperty->
Name() ) );
192 ret =
new wxPropertyCategory();
193 ret->Enable(
false );
201 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
202 ret->SetName( aProperty->
Name() );
203 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
204 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
213 m_parentFrame( aParentFrame ),
214 m_coordType( aCoordType )
226 int aArgFlags )
const
229 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_DISTANCE::StringToDistance should not be used." ) );
235 wxCHECK( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG, wxEmptyString );
237 long distanceIU = aVariant.GetLong();
246 case EDA_UNITS::INCHES:
247 return wxString::Format( wxS(
"%g in" ), iuScale.
IUToMils( distanceIU ) / 1000.0 );
249 case EDA_UNITS::MILS:
250 return wxString::Format( wxS(
"%d mils" ), iuScale.
IUToMils( distanceIU ) );
252 case EDA_UNITS::MILLIMETRES:
253 return wxString::Format( wxS(
"%g mm" ), iuScale.
IUTomm( distanceIU ) );
255 case EDA_UNITS::UNSCALED:
256 return wxString::Format( wxS(
"%li" ), distanceIU );
264 return wxEmptyString;
269 wxUIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
283 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
299 if( !aText.ToDouble( &value ) )
307 if( aVariant.IsNull() || aVariant.GetDouble() != value )
319 if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
322 return wxString::Format( wxS(
"%g\u00B0" ), aVariant.GetDouble() /
m_scale );
324 else if( aVariant.GetType() == wxS(
"EDA_ANGLE" ) )
332 wxCHECK_MSG(
false, wxEmptyString, wxS(
"Unexpected variant type in PGPROPERTY_ANGLE" ) );
346 return wxSize( 16, 12 );
351 wxPGPaintData& aPaintData )
353 int index = aPaintData.m_choiceItem;
359 if( index < 0 || index >=
static_cast<int>( GetChoices().GetCount() ) )
364 if(
color == wxNullColour )
367 aDC.SetPen( *wxTRANSPARENT_PEN );
368 aDC.SetBrush( wxBrush(
color ) );
369 aDC.DrawRectangle( aRect );
371 aPaintData.m_drawnWidth = aRect.width;
377 if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING )
378 return wxEmptyString;
393 wxBoolProperty( aLabel, aName, aValue )
401 wxCHECK_MSG( m_customEditor, wxPGEditor_CheckBox,
402 wxT(
"Make sure to set custom editor for PGPROPERTY_BOOL!" ) );
403 return m_customEditor;
409 wxStringProperty( aLabel, aName, aValue.ToCSSString() ),
410 m_backgroundColor( aBackgroundColor )
413 SetFlag( wxPG_PROP_NOEDITOR );
429 if( aValue.IsType( wxS(
"COLOR4D" ) ) )
432 return wxStringProperty::ValueToString( aValue, aFlags );
static wxVariantData * VariantDataFactory(const wxAny &aAny)
static wxVariantData * VariantDataFactory(const wxAny &aAny)
ORIGIN_TRANSFORMS & GetOriginTransforms() override
Return a reference to the default ORIGIN_TRANSFORMS object.
The base class for create windows for drawing purpose.
A color representation with 4 components: red, green, blue, alpha.
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)
bool StringToValue(wxVariant &aVariant, const wxString &aText, int aFlags=0) const override
wxString ValueToString(wxVariant &aValue, int aFlags=0) const override
PGPROPERTY_COLOR4D(const wxString &aLabel=wxPG_LABEL, const wxString &aName=wxPG_LABEL, KIGFX::COLOR4D aValue=KIGFX::COLOR4D::UNSPECIFIED, KIGFX::COLOR4D aBackground=KIGFX::COLOR4D::UNSPECIFIED)
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(EDA_DRAW_FRAME *aParentFrame, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
wxValidator * DoGetValidator() const override
EDA_DRAW_FRAME * m_parentFrame
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_DISTANCE(EDA_DRAW_FRAME *aParentFrame, const wxString &aRegEx, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
wxValidator * DoGetValidator() const override
PGPROPERTY_SIZE(EDA_DRAW_FRAME *aParentFrame)
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
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.
Custom validator that checks verifies that a string exactly matches a regular expression.
const EDA_IU_SCALE & GetIuScale() const
EDA_UNITS GetUserUnits() const
wxAnyToCOLOR4D_VARIANTRegistrationImpl(wxVariantDataFactory factory)
static wxAnyValueType * GetInstance()
static bool AreSameClasses(const wxAnyValueType &a, const wxAnyValueType &b)
static bool IsSameClass(const wxAnyValueType *otherType)
virtual wxAnyValueType * GetAssociatedType() override
static wxAnyValueTypeScopedPtr s_instance
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.