23#include <wx/propgrid/propgrid.h>
44 : wxAnyToVariantRegistration( factory )
66 return wxTypeId(a) == wxTypeId(b);
82 : wxAnyToVariantRegistration( factory )
104 return wxTypeId(a) == wxTypeId(b);
120 : wxAnyToVariantRegistration( factory )
142 return wxTypeId(a) == wxTypeId(b);
158 : wxAnyToVariantRegistration( factory )
180 return wxTypeId(a) == wxTypeId(b);
193 wxPGProperty* ret =
nullptr;
237 size_t typeId = aProperty->
TypeHash();
243 ret =
new wxEnumProperty( wxPG_LABEL, wxPG_LABEL,
244 const_cast<wxPGChoices&
>( aProperty->
Choices() ) );
248 ret =
new wxIntProperty();
250 else if( typeId ==
TYPE_HASH(
unsigned int ) || typeId ==
TYPE_HASH(
unsigned long ) )
252 ret =
new wxUIntProperty();
256 ret =
new wxFloatProperty();
262 else if( typeId ==
TYPE_HASH( wxString ) )
272 wxFAIL_MSG( wxString::Format( wxS(
"Property %s not supported by PGPropertyFactory" ),
273 aProperty->
Name() ) );
274 ret =
new wxPropertyCategory();
275 ret->Enable(
false );
283 ret->SetLabel( wxGetTranslation( aProperty->
Name() ) );
284 ret->SetName( aProperty->
Name() );
285 ret->SetHelpString( wxGetTranslation( aProperty->
Name() ) );
286 ret->SetClientData(
const_cast<PROPERTY_BASE*
>( aProperty ) );
295 m_parentFrame( aParentFrame ),
296 m_coordType( aCoordType )
306#if wxCHECK_VERSION( 3, 3, 0 )
308 wxPGPropValFormatFlags aFlags )
const
315 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_DISTANCE::StringToDistance should not be used." ) );
319#if wxCHECK_VERSION( 3, 3, 0 )
321 wxPGPropValFormatFlags aFlags )
const
328 if( aVariant.GetType() == wxT(
"std::optional<int>" ) )
332 if( !variantData->Value().has_value() )
333 return wxEmptyString;
335 distanceIU = variantData->
Value().value();
337 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG )
339 distanceIU = aVariant.GetLong();
343 wxFAIL_MSG( wxT(
"Expected int (or std::optional<int>) value type" ) );
344 return wxEmptyString;
349 distanceIU = transforms.
ToDisplay(
static_cast<long long int>( distanceIU ), m_coordType );
356 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
357 m_parentFrame( aParentFrame )
362#if wxCHECK_VERSION( 3, 3, 0 )
364 wxPGPropValFormatFlags aArgFlags )
const
367 int aArgFlags )
const
371 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_AREA::StringToValue should not be used." ) );
375#if wxCHECK_VERSION( 3, 3, 0 )
377 wxPGPropValFormatFlags aArgFlags )
const
382 wxCHECK( aVariant.GetType() == wxPG_VARIANT_TYPE_LONGLONG, wxEmptyString );
384 wxLongLongNative areaIU = aVariant.GetLongLong();
397 wxUIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
405 if( aValue.GetType() == wxT(
"std::optional<int>" ) )
409 if( !data->Value().has_value() )
410 return wxEmptyString;
412 wxVariant value( data->Value().value() );
413 return wxUIntProperty::ValidateValue( value, aValidationInfo );
416 return wxUIntProperty::ValidateValue( aValue, aValidationInfo );
428 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
441 wxFloatProperty( wxPG_LABEL, wxPG_LABEL, 0 )
449 wxCHECK_MSG( m_customEditor, wxPGEditor_TextCtrl,
450 wxT(
"Make sure to RegisterEditorClass() for PGPROPERTY_RATIO!" ) );
451 return m_customEditor;
455#if wxCHECK_VERSION( 3, 3, 0 )
457 wxPGPropValFormatFlags aArgFlags )
const
460 int aArgFlags )
const
464 wxCHECK_MSG(
false,
false, wxS(
"PGPROPERTY_RATIO::StringToValue should not be used." ) );
468#if wxCHECK_VERSION( 3, 3, 0 )
470 wxPGPropValFormatFlags aArgFlags )
const
477 if( aVariant.GetType() == wxT(
"std::optional<double>" ) )
481 if( !variantData->Value().has_value() )
482 return wxEmptyString;
484 value = variantData->
Value().value();
486 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
488 value = aVariant.GetDouble();
492 wxFAIL_MSG( wxT(
"Expected double (or std::optional<double>) value type" ) );
493 return wxEmptyString;
496 return wxString::Format( wxS(
"%g" ), value );
502 if( aValue.GetType() == wxT(
"std::optional<double>" ) )
506 if( !data->Value().has_value() )
507 return wxEmptyString;
509 wxVariant value( data->Value().value() );
510 return wxFloatProperty::ValidateValue( value, aValidationInfo );
513 return wxFloatProperty::ValidateValue( aValue, aValidationInfo );
523#if wxCHECK_VERSION( 3, 3, 0 )
525 wxPGPropValFormatFlags aArgFlags )
const
528 int aArgFlags )
const
533 if( !aText.ToDouble( &value ) )
541 if( aVariant.IsNull() || aVariant.GetDouble() != value )
551#if wxCHECK_VERSION( 3, 3, 0 )
553 wxPGPropValFormatFlags aArgFlags )
const
558 if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
561 return wxString::Format( wxS(
"%g\u00B0" ), aVariant.GetDouble() / m_scale );
563 else if( aVariant.GetType() == wxS(
"EDA_ANGLE" ) )
571 wxCHECK_MSG(
false, wxEmptyString, wxS(
"Unexpected variant type in PGPROPERTY_ANGLE" ) );
585 return wxSize( 16, 12 );
590 wxPGPaintData& aPaintData )
592 int index = aPaintData.m_choiceItem;
598 if( index < 0 || index >=
static_cast<int>( GetChoices().GetCount() ) )
603 if(
color == wxNullColour )
606 aDC.SetPen( *wxTRANSPARENT_PEN );
607 aDC.SetBrush( wxBrush(
color ) );
608 aDC.DrawRectangle( aRect );
610 aPaintData.m_drawnWidth = aRect.width;
614#if wxCHECK_VERSION( 3, 3, 0 )
616 wxPGPropValFormatFlags aFlags )
const
621 if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING )
622 return wxEmptyString;
628#if wxCHECK_VERSION( 3, 3, 0 )
630 wxPGPropValFormatFlags aArgFlags )
const
642 wxBoolProperty( aLabel, aName, aValue )
650 wxCHECK_MSG( m_customEditor, wxPGEditor_CheckBox,
651 wxT(
"Make sure to RegisterEditorClass() for PGPROPERTY_BOOL!" ) );
652 return m_customEditor;
658 wxStringProperty( aLabel, aName, aValue.ToCSSString() ),
659 m_backgroundColor( aBackgroundColor )
662#if wxCHECK_VERSION( 3, 3, 0 )
663 SetFlag( wxPGPropertyFlags::NoEditor );
665 SetFlag( wxPG_PROP_NOEDITOR );
670#if wxCHECK_VERSION( 3, 3, 0 )
672 wxPGPropValFormatFlags aArgFlags )
const
683#if wxCHECK_VERSION( 3, 3, 0 )
685 wxPGPropValFormatFlags aFlags )
const
692 if( aValue.IsType( wxS(
"COLOR4D" ) ) )
695 return wxStringProperty::ValueToString( aValue, aFlags );
static wxVariantData * VariantDataFactory(const wxAny &aAny)
static wxVariantData * VariantDataFactory(const wxAny &aAny)
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
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
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
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
wxString DistanceToString(wxVariant &aVariant, int aArgFlags=0) const
bool StringToDistance(wxVariant &aVariant, const wxString &aText, int aArgFlags=0) const
virtual ~PGPROPERTY_DISTANCE()=0
PGPROPERTY_DISTANCE(EDA_DRAW_FRAME *aParentFrame, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
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
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
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.
std::optional< double > Value() const
static wxVariantData * VariantDataFactory(const wxAny &aAny)
std::optional< int > Value() const
static wxVariantData * VariantDataFactory(const wxAny &aAny)
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)
Customized abstract wxPGProperty class to handle coordinate/size units.
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)
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.