23#include <wx/propgrid/propgrid.h>
44 wxAnyToVariantRegistration( factory )
67 return wxTypeId(a) == wxTypeId(b);
74wxAnyValueTypeScopedPtr
86 wxAnyToVariantRegistration( factory )
109 return wxTypeId(a) == wxTypeId(b);
116wxAnyValueTypeScopedPtr
128 wxAnyToVariantRegistration( factory )
151 return wxTypeId(a) == wxTypeId(b);
169 wxAnyToVariantRegistration( factory )
192 return wxTypeId(a) == wxTypeId(b);
208 wxPGProperty* ret =
nullptr;
261 size_t typeId = aProperty->
TypeHash();
269 ret =
new wxEnumProperty( wxPG_LABEL, wxPG_LABEL,
270 const_cast<wxPGChoices&
>( aProperty->
Choices() ) );
274 ret =
new wxIntProperty();
276 else if( typeId ==
TYPE_HASH(
unsigned int ) || typeId ==
TYPE_HASH(
unsigned long ) )
278 ret =
new wxUIntProperty();
282 ret =
new wxFloatProperty();
288 else if( typeId ==
TYPE_HASH( wxString ) )
298 wxFAIL_MSG( wxString::Format( wxS(
"Property %s not supported by PGPropertyFactory" ),
299 aProperty->
Name() ) );
300 ret =
new wxPropertyCategory();
301 ret->Enable(
false );
312 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
313 ret->SetName( aProperty->
Name() );
314 ret->SetHelpString( wxGetTranslation(
help.IsEmpty() ? aProperty->
Name() :
help ) );
315 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
335#if wxCHECK_VERSION( 3, 3, 0 )
337 wxPGPropValFormatFlags aFlags )
const
343 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_DISTANCE::StringToDistance should not be used." ) );
347#if wxCHECK_VERSION( 3, 3, 0 )
349 wxPGPropValFormatFlags aFlags )
const
354 if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
356 double distanceIU = aVariant.GetDouble();
364 if( aVariant.GetType() == wxT(
"std::optional<int>" ) )
368 if( !variantData->OptValue().has_value() )
369 return wxEmptyString;
371 distanceIU = variantData->
OptValue().value();
373 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG )
375 distanceIU = aVariant.GetLong();
377 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONGLONG )
379 distanceIU =
static_cast<long>( aVariant.GetLongLong().GetValue() );
381 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_ULONGLONG )
383 distanceIU =
static_cast<long>( aVariant.GetULongLong().GetValue() );
387 wxFAIL_MSG( wxT(
"Expected int (or std::optional<int>) value type" ) );
388 return wxEmptyString;
400 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
406#if wxCHECK_VERSION( 3, 3, 0 )
408 wxPGPropValFormatFlags aArgFlags )
const
413 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_AREA::StringToValue should not be used." ) );
417#if wxCHECK_VERSION( 3, 3, 0 )
423 wxLongLongNative areaIU;
425 if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONGLONG )
427 areaIU = aVariant.GetLongLong();
429 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG )
431 areaIU = wxLongLongNative( aVariant.GetLong() );
435 wxFAIL_MSG( wxString::Format( wxS(
"Unexpected variant type in PGPROPERTY_AREA: %s" ), aVariant.GetType() ) );
436 return wxEmptyString;
450 wxUIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
458 if( aValue.GetType() == wxT(
"std::optional<int>" ) )
462 if( !data->OptValue().has_value() )
463 return wxEmptyString;
465 wxVariant value( data->OptValue().value() );
466 return wxUIntProperty::ValidateValue( value, aValidationInfo );
469 return wxUIntProperty::ValidateValue( aValue, aValidationInfo );
480 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
493 wxFloatProperty( wxPG_LABEL, wxPG_LABEL, 0 )
501 wxCHECK_MSG( m_customEditor, wxPGEditor_TextCtrl,
502 wxT(
"Make sure to RegisterEditorClass() for PGPROPERTY_RATIO!" ) );
503 return m_customEditor;
507#if wxCHECK_VERSION( 3, 3, 0 )
509 wxPGPropValFormatFlags aArgFlags )
const
514 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_RATIO::StringToValue should not be used." ) );
518#if wxCHECK_VERSION( 3, 3, 0 )
526 if( aVariant.GetType() == wxT(
"std::optional<double>" ) )
530 if( !variantData->OptValue().has_value() )
531 return wxEmptyString;
533 value = variantData->
OptValue().value();
535 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
537 value = aVariant.GetDouble();
541 wxFAIL_MSG( wxT(
"Expected double (or std::optional<double>) value type" ) );
542 return wxEmptyString;
545 return wxString::Format( wxS(
"%g" ), value );
551 if( aValue.GetType() == wxT(
"std::optional<double>" ) )
555 if( !data->OptValue().has_value() )
556 return wxEmptyString;
558 wxVariant value( data->OptValue().value() );
559 return wxFloatProperty::ValidateValue( value, aValidationInfo );
562 return wxFloatProperty::ValidateValue( aValue, aValidationInfo );
572#if wxCHECK_VERSION( 3, 3, 0 )
574 wxPGPropValFormatFlags aArgFlags )
const
581 if( !aText.ToDouble( &value ) )
589 if( aVariant.IsNull() || aVariant.GetDouble() != value )
599#if wxCHECK_VERSION( 3, 3, 0 )
605 if( aVariant.GetType() == wxT(
"std::optional<double>" ) )
609 if( variantData->OptValue().has_value() )
610 return wxString::Format( wxS(
"%g\u00B0" ), variantData->OptValue().value() /
m_scale );
612 return wxEmptyString;
614 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
616 return wxString::Format( wxS(
"%g\u00B0" ), aVariant.GetDouble() /
m_scale );
618 else if( aVariant.GetType() == wxS(
"EDA_ANGLE" ) )
624 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG )
626 return wxString::Format( wxS(
"%g\u00B0" ), (
double) aVariant.GetLong() /
m_scale );
630 wxCHECK_MSG(
false, wxEmptyString, wxS(
"Unexpected variant type in PGPROPERTY_ANGLE" ) );
643 wxSize size( 16, -1 );
645 if( wxPropertyGrid* pg = GetGrid() )
646 size = pg->FromDIP( size );
654 int index = aPaintData.m_choiceItem;
665 if( color == wxNullColour )
668 aDC.SetPen( *wxTRANSPARENT_PEN );
669 aDC.SetBrush( wxBrush( color ) );
670 aDC.DrawRectangle( aRect );
672 aPaintData.m_drawnWidth = aRect.width;
676#if wxCHECK_VERSION( 3, 3, 0 )
682 if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING )
683 return wxEmptyString;
689#if wxCHECK_VERSION( 3, 3, 0 )
691 wxPGPropValFormatFlags aArgFlags )
const
702 wxBoolProperty( aLabel, aName, aValue )
710 wxCHECK_MSG( m_customEditor, wxPGEditor_CheckBox,
711 wxT(
"Make sure to RegisterEditorClass() for PGPROPERTY_BOOL!" ) );
712 return m_customEditor;
718 wxStringProperty( aLabel, aName, aValue.ToCSSString() ),
722#if wxCHECK_VERSION( 3, 3, 1 )
723 SetFlag( wxPGFlags::NoEditor );
724#elif wxCHECK_VERSION( 3, 3, 0 )
725 SetFlag( wxPGPropertyFlags::NoEditor );
727 SetFlag( wxPG_PROP_NOEDITOR );
732#if wxCHECK_VERSION( 3, 3, 0 )
734 wxPGPropValFormatFlags aArgFlags )
const
744#if wxCHECK_VERSION( 3, 3, 0 )
752 if( aValue.IsType( wxS(
"COLOR4D" ) ) )
755 return wxStringProperty::ValueToString( aValue, aFlags );
762 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
768#if wxCHECK_VERSION( 3, 3, 0 )
770 wxPGPropValFormatFlags aArgFlags )
const
775 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_RATIO::StringToValue should not be used." ) );
779#if wxCHECK_VERSION( 3, 3, 0 )
787 if( aVariant.GetType() == wxT(
"std::optional<int>" ) )
791 if( !variantData->OptValue().has_value() )
792 return wxEmptyString;
794 value = variantData->
OptValue().value();
796 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG )
798 value =
static_cast<int>( aVariant.GetInteger() );
802 wxFAIL_MSG( wxT(
"Expected int (or std::optional<int>) value type" ) );
803 return wxEmptyString;
823 wxEnumProperty( wxPG_LABEL, wxPG_LABEL, const_cast<wxPGChoices&>( aChoices ) )
825 SetEditor( wxS(
"PG_NET_SELECTOR_EDITOR" ) );
831 wxCHECK_MSG( m_customEditor, wxPGEditor_Choice,
832 wxT(
"Make sure to RegisterEditorClass() for PGPROPERTY_NET!" ) );
834 return m_customEditor;
bool Write(wxString &aString) const override
static wxVariantData * VariantDataFactory(const wxAny &aAny)
static wxVariantData * VariantDataFactory(const wxAny &aAny)
bool Write(wxString &aString) const override
The base class for create windows for drawing purpose.
A color representation with 4 components: red, green, blue, alpha.
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
PGPROPERTY_AREA(EDA_DRAW_FRAME *aParentFrame)
wxString ValueToString(wxVariant &aVariant, int aArgFlags=0) const override
wxValidator * DoGetValidator() const override
bool StringToValue(wxVariant &aVariant, const wxString &aText, int aArgFlags=0) const override
EDA_DRAW_FRAME * m_parentFrame
const wxPGEditor * DoGetEditorClass() const override
PGPROPERTY_BOOL(const wxString &aLabel=wxPG_LABEL, const wxString &aName=wxPG_LABEL, bool aValue=false)
KIGFX::COLOR4D m_backgroundColor
Used for rendering colors with opacity.
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
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
PGPROPERTY_DISTANCE(EDA_DRAW_FRAME *aParentFrame, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
PGPROPERTY_NET(const wxPGChoices &aChoices=wxPGChoices())
const wxPGEditor * DoGetEditorClass() const override
wxValidator * DoGetValidator() const override
bool ValidateValue(wxVariant &aValue, wxPGValidationInfo &aValidationInfo) const override
bool StringToValue(wxVariant &aVariant, const wxString &aText, int aArgFlags=0) const override
wxString ValueToString(wxVariant &aVariant, int aArgFlags=0) const override
const wxPGEditor * DoGetEditorClass() const override
wxValidator * DoGetValidator() const override
bool ValidateValue(wxVariant &aValue, wxPGValidationInfo &aValidationInfo) 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
bool StringToValue(wxVariant &aVariant, const wxString &aText, int aArgFlags=0) const override
wxString ValueToString(wxVariant &aVariant, int aArgFlags=0) const override
EDA_DRAW_FRAME * m_parentFrame
PGPROPERTY_TIME(EDA_DRAW_FRAME *aParentFrame)
wxValidator * DoGetValidator() const override
bool ValidateValue(wxVariant &aValue, wxPGValidationInfo &aValidationInfo) const override
static const wxString EDITOR_NAME
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
const wxString & HelpString() 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 wxVariantData * VariantDataFactory(const wxAny &aAny)
std::optional< double > OptValue() const
static wxVariantData * VariantDataFactory(const wxAny &aAny)
std::optional< int > OptValue() 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)
static bool IsSameClass(const wxAnyValueType *otherType)
static wxAnyValueType * GetInstance()
wxAnyToSTD_OPTIONAL_DOUBLE_VARIANTRegistrationImpl(wxVariantDataFactory factory)
static wxAnyValueTypeScopedPtr s_instance
virtual wxAnyValueType * GetAssociatedType() override
static bool AreSameClasses(const wxAnyValueType &a, const wxAnyValueType &b)
static bool AreSameClasses(const wxAnyValueType &a, const wxAnyValueType &b)
static wxAnyValueTypeScopedPtr s_instance
virtual wxAnyValueType * GetAssociatedType() override
static wxAnyValueType * GetInstance()
static bool IsSameClass(const wxAnyValueType *otherType)
wxAnyToSTD_OPTIONAL_INT_VARIANTRegistrationImpl(wxVariantDataFactory factory)
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 ...
wxPGProperty * PGPropertyFactory(const PROPERTY_BASE *aProperty, EDA_DRAW_FRAME *aFrame)
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
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_AREA
Area expressed in distance units-squared (mm/inch)
@ PT_DEFAULT
Default property for a given type.
@ PT_SIZE
Size expressed in distance units (mm/inch)
@ PT_NET
Net selection property.
@ PT_TIME
Time expressed in ps.
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:...
Custom text control validator definitions.