KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pg_properties.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright (C) 2020-2023 CERN
5 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <wx/dc.h>
23#include <wx/propgrid/propgrid.h>
24
25#include <macros.h>
26#include <validators.h>
27#include <eda_draw_frame.h>
28#include <eda_units.h>
35#include <properties/property.h>
36#include <string_utils.h>
38
39
40class wxAnyToSTD_OPTIONAL_INT_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
41{
42public:
44 : wxAnyToVariantRegistration( factory )
45 {
46 }
47
48public:
49 static bool IsSameClass(const wxAnyValueType* otherType)
50 {
51 return AreSameClasses( *s_instance.get(), *otherType );
52 }
53
54 static wxAnyValueType* GetInstance()
55 {
56 return s_instance.get();
57 }
58
59 virtual wxAnyValueType* GetAssociatedType() override
60 {
62 }
63private:
64 static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
65 {
66 return wxTypeId(a) == wxTypeId(b);
67 }
68
69 static wxAnyValueTypeScopedPtr s_instance;
70};
71
72
74 new wxAnyValueTypeImpl<std::optional<int>>() );
75
76
78 s_wxAnyToSTD_OPTIONAL_INT_VARIANTRegistration(
80
81
82class wxAnyToSTD_OPTIONAL_DOUBLE_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
83{
84public:
86 : wxAnyToVariantRegistration( factory )
87 {
88 }
89
90public:
91 static bool IsSameClass(const wxAnyValueType* otherType)
92 {
93 return AreSameClasses( *s_instance.get(), *otherType );
94 }
95
96 static wxAnyValueType* GetInstance()
97 {
98 return s_instance.get();
99 }
100
101 virtual wxAnyValueType* GetAssociatedType() override
102 {
104 }
105private:
106 static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
107 {
108 return wxTypeId(a) == wxTypeId(b);
109 }
110
111 static wxAnyValueTypeScopedPtr s_instance;
112};
113
114
116 new wxAnyValueTypeImpl<std::optional<double>>() );
117
118
120 s_wxAnyToSTD_OPTIONAL_DOUBLE_VARIANTRegistration(
122
123
124class wxAnyToEDA_ANGLE_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
125{
126public:
127 wxAnyToEDA_ANGLE_VARIANTRegistrationImpl( wxVariantDataFactory factory )
128 : wxAnyToVariantRegistration( factory )
129 {
130 }
131
132public:
133 static bool IsSameClass(const wxAnyValueType* otherType)
134 {
135 return AreSameClasses( *s_instance.get(), *otherType );
136 }
137
138 static wxAnyValueType* GetInstance()
139 {
140 return s_instance.get();
141 }
142
143 virtual wxAnyValueType* GetAssociatedType() override
144 {
146 }
147private:
148 static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
149 {
150 return wxTypeId(a) == wxTypeId(b);
151 }
152
153 static wxAnyValueTypeScopedPtr s_instance;
154};
155
156
157wxAnyValueTypeScopedPtr
158 wxAnyToEDA_ANGLE_VARIANTRegistrationImpl::s_instance( new wxAnyValueTypeImpl<EDA_ANGLE>() );
159
160
162 s_wxAnyToEDA_ANGLE_VARIANTRegistration( &EDA_ANGLE_VARIANT_DATA::VariantDataFactory );
163
164
165class wxAnyToCOLOR4D_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
166{
167public:
168 wxAnyToCOLOR4D_VARIANTRegistrationImpl( wxVariantDataFactory factory )
169 : wxAnyToVariantRegistration( factory )
170 {
171 }
172
173public:
174 static bool IsSameClass(const wxAnyValueType* otherType)
175 {
176 return AreSameClasses( *s_instance.get(), *otherType );
177 }
178
179 static wxAnyValueType* GetInstance()
180 {
181 return s_instance.get();
182 }
183
184 virtual wxAnyValueType* GetAssociatedType() override
185 {
187 }
188private:
189 static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
190 {
191 return wxTypeId(a) == wxTypeId(b);
192 }
193
194 static wxAnyValueTypeScopedPtr s_instance;
195};
196
197
199 new wxAnyValueTypeImpl<KIGFX::COLOR4D>() );
200
201
203 s_wxAnyToCOLOR4D_VARIANTRegistration( &COLOR4D_VARIANT_DATA::VariantDataFactory );
204
205
206wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty, EDA_DRAW_FRAME* aFrame )
207{
208 wxPGProperty* ret = nullptr;
209 PROPERTY_DISPLAY display = aProperty->Display();
210
211 switch( display )
212 {
214 ret = new PGPROPERTY_SIZE( aFrame );
215 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
216 break;
217
219 ret = new PGPROPERTY_AREA( aFrame );
220 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
221 break;
222
224 ret = new PGPROPERTY_COORD( aFrame, aProperty->CoordType() );
225 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
226 break;
227
230 {
232
233 if( display == PROPERTY_DISPLAY::PT_DECIDEGREE )
234 prop->SetScale( 10.0 );
235
236 ret = prop;
237 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
238 break;
239 }
240
242 ret = new PGPROPERTY_RATIO();
243 break;
244
245 default:
246 wxFAIL;
248 /* fall through */
250 {
251 // Create a corresponding wxPGProperty
252 size_t typeId = aProperty->TypeHash();
253
254 // Enum property
255 if( aProperty->HasChoices() )
256 {
257 // I do not know why enum property takes a non-const reference to wxPGChoices..
258 ret = new wxEnumProperty( wxPG_LABEL, wxPG_LABEL,
259 const_cast<wxPGChoices&>( aProperty->Choices() ) );
260 }
261 else if( typeId == TYPE_HASH( int ) || typeId == TYPE_HASH( long ) )
262 {
263 ret = new wxIntProperty();
264 }
265 else if( typeId == TYPE_HASH( unsigned int ) || typeId == TYPE_HASH( unsigned long ) )
266 {
267 ret = new wxUIntProperty();
268 }
269 else if( typeId == TYPE_HASH( float ) || typeId == TYPE_HASH( double ) )
270 {
271 ret = new wxFloatProperty();
272 }
273 else if( typeId == TYPE_HASH( bool ) )
274 {
275 ret = new PGPROPERTY_BOOL();
276 }
277 else if( typeId == TYPE_HASH( wxString ) )
278 {
279 ret = new PGPROPERTY_STRING();
280 }
281 else if( typeId == TYPE_HASH( COLOR4D ) )
282 {
283 ret = new PGPROPERTY_COLOR4D();
284 }
285 else
286 {
287 wxFAIL_MSG( wxString::Format( wxS( "Property %s not supported by PGPropertyFactory" ),
288 aProperty->Name() ) );
289 ret = new wxPropertyCategory();
290 ret->Enable( false );
291 }
292
293 break;
294 }
295 }
296
297 if( ret )
298 {
299 ret->SetLabel( wxGetTranslation( aProperty->Name() ) );
300 ret->SetName( aProperty->Name() );
301 ret->SetHelpString( wxGetTranslation( aProperty->Name() ) );
302 ret->SetClientData( const_cast<PROPERTY_BASE*>( aProperty ) );
303 }
304
305 return ret;
306}
307
308
311 m_parentFrame( aParentFrame ),
312 m_coordType( aCoordType )
313{
314}
315
316
318{
319}
320
321
322#if wxCHECK_VERSION( 3, 3, 0 )
323bool PGPROPERTY_DISTANCE::StringToDistance( wxVariant& aVariant, const wxString& aText,
324 wxPGPropValFormatFlags aFlags ) const
325#else
326bool PGPROPERTY_DISTANCE::StringToDistance( wxVariant& aVariant, const wxString& aText,
327 int aFlags ) const
328#endif
329{
330 // TODO(JE): Are there actual use cases for this?
331 wxCHECK_MSG( false, false, wxS( "PGPROPERTY_DISTANCE::StringToDistance should not be used." ) );
332}
333
334
335#if wxCHECK_VERSION( 3, 3, 0 )
336wxString PGPROPERTY_DISTANCE::DistanceToString( wxVariant& aVariant,
337 wxPGPropValFormatFlags aFlags ) const
338#else
339wxString PGPROPERTY_DISTANCE::DistanceToString( wxVariant& aVariant, int aFlags ) const
340#endif
341{
342 long distanceIU;
343
344 if( aVariant.GetType() == wxT( "std::optional<int>" ) )
345 {
346 auto* variantData = static_cast<STD_OPTIONAL_INT_VARIANT_DATA*>( aVariant.GetData() );
347
348 if( !variantData->Value().has_value() )
349 return wxEmptyString;
350
351 distanceIU = variantData->Value().value();
352 }
353 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG )
354 {
355 distanceIU = aVariant.GetLong();
356 }
357 else
358 {
359 wxFAIL_MSG( wxT( "Expected int (or std::optional<int>) value type" ) );
360 return wxEmptyString;
361 }
362
363 ORIGIN_TRANSFORMS& transforms = m_parentFrame->GetOriginTransforms();
364
365 distanceIU = transforms.ToDisplay( static_cast<long long int>( distanceIU ), m_coordType );
366
367 return m_parentFrame->StringFromValue( distanceIU, true, EDA_DATA_TYPE::DISTANCE );
368}
369
370
372 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
373 m_parentFrame( aParentFrame )
374{
375}
376
377
378#if wxCHECK_VERSION( 3, 3, 0 )
379bool PGPROPERTY_AREA::StringToValue( wxVariant& aVariant, const wxString& aText,
380 wxPGPropValFormatFlags aArgFlags ) const
381#else
382bool PGPROPERTY_AREA::StringToValue( wxVariant& aVariant, const wxString& aText,
383 int aArgFlags ) const
384#endif
385{
386 // TODO(JE): Are there actual use cases for this?
387 wxCHECK_MSG( false, false, wxS( "PGPROPERTY_AREA::StringToValue should not be used." ) );
388}
389
390
391#if wxCHECK_VERSION( 3, 3, 0 )
392wxString PGPROPERTY_AREA::ValueToString( wxVariant& aVariant,
393 wxPGPropValFormatFlags aArgFlags ) const
394#else
395wxString PGPROPERTY_AREA::ValueToString( wxVariant& aVariant, int aArgFlags ) const
396#endif
397{
398 wxCHECK( aVariant.GetType() == wxPG_VARIANT_TYPE_LONGLONG, wxEmptyString );
399
400 wxLongLongNative areaIU = aVariant.GetLongLong();
401
402 return m_parentFrame->StringFromValue( areaIU.ToDouble(), true, EDA_DATA_TYPE::AREA );
403}
404
405
407{
408 return nullptr;
409}
410
411
413 wxUIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
414 PGPROPERTY_DISTANCE( aParentFrame, ORIGIN_TRANSFORMS::NOT_A_COORD )
415{
416}
417
418
419bool PGPROPERTY_SIZE::ValidateValue( wxVariant& aValue, wxPGValidationInfo& aValidationInfo ) const
420{
421 if( aValue.GetType() == wxT( "std::optional<int>" ) )
422 {
423 auto* data = static_cast<STD_OPTIONAL_INT_VARIANT_DATA*>( aValue.GetData() );
424
425 if( !data->Value().has_value() )
426 return wxEmptyString;
427
428 wxVariant value( data->Value().value() );
429 return wxUIntProperty::ValidateValue( value, aValidationInfo );
430 }
431
432 return wxUIntProperty::ValidateValue( aValue, aValidationInfo );
433}
434
435
437{
438 return nullptr;
439}
440
441
444 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
445 PGPROPERTY_DISTANCE( aParentFrame, aCoordType )
446{
447}
448
449
451{
452 return nullptr;
453}
454
455
457 wxFloatProperty( wxPG_LABEL, wxPG_LABEL, 0 )
458{
459 SetEditor( PG_RATIO_EDITOR::EDITOR_NAME );
460}
461
462
463const wxPGEditor* PGPROPERTY_RATIO::DoGetEditorClass() const
464{
465 wxCHECK_MSG( m_customEditor, wxPGEditor_TextCtrl,
466 wxT( "Make sure to RegisterEditorClass() for PGPROPERTY_RATIO!" ) );
467 return m_customEditor;
468}
469
470
471#if wxCHECK_VERSION( 3, 3, 0 )
472bool PGPROPERTY_RATIO::StringToValue( wxVariant& aVariant, const wxString& aText,
473 wxPGPropValFormatFlags aArgFlags ) const
474#else
475bool PGPROPERTY_RATIO::StringToValue( wxVariant& aVariant, const wxString& aText,
476 int aArgFlags ) const
477#endif
478{
479 // TODO(JE): Are there actual use cases for this?
480 wxCHECK_MSG( false, false, wxS( "PGPROPERTY_RATIO::StringToValue should not be used." ) );
481}
482
483
484#if wxCHECK_VERSION( 3, 3, 0 )
485wxString PGPROPERTY_RATIO::ValueToString( wxVariant& aVariant,
486 wxPGPropValFormatFlags aArgFlags ) const
487#else
488wxString PGPROPERTY_RATIO::ValueToString( wxVariant& aVariant, int aArgFlags ) const
489#endif
490{
491 double value;
492
493 if( aVariant.GetType() == wxT( "std::optional<double>" ) )
494 {
495 auto* variantData = static_cast<STD_OPTIONAL_DOUBLE_VARIANT_DATA*>( aVariant.GetData() );
496
497 if( !variantData->Value().has_value() )
498 return wxEmptyString;
499
500 value = variantData->Value().value();
501 }
502 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
503 {
504 value = aVariant.GetDouble();
505 }
506 else
507 {
508 wxFAIL_MSG( wxT( "Expected double (or std::optional<double>) value type" ) );
509 return wxEmptyString;
510 }
511
512 return wxString::Format( wxS( "%g" ), value );
513}
514
515
516bool PGPROPERTY_RATIO::ValidateValue( wxVariant& aValue, wxPGValidationInfo& aValidationInfo ) const
517{
518 if( aValue.GetType() == wxT( "std::optional<double>" ) )
519 {
520 auto* data = static_cast<STD_OPTIONAL_DOUBLE_VARIANT_DATA*>( aValue.GetData() );
521
522 if( !data->Value().has_value() )
523 return wxEmptyString;
524
525 wxVariant value( data->Value().value() );
526 return wxFloatProperty::ValidateValue( value, aValidationInfo );
527 }
528
529 return wxFloatProperty::ValidateValue( aValue, aValidationInfo );
530}
531
532
534{
535 return nullptr;
536}
537
538
539#if wxCHECK_VERSION( 3, 3, 0 )
540bool PGPROPERTY_ANGLE::StringToValue( wxVariant& aVariant, const wxString& aText,
541 wxPGPropValFormatFlags aArgFlags ) const
542#else
543bool PGPROPERTY_ANGLE::StringToValue( wxVariant& aVariant, const wxString& aText,
544 int aArgFlags ) const
545#endif
546{
547 double value = 0.0;
548
549 if( !aText.ToDouble( &value ) )
550 {
551 aVariant.MakeNull();
552 return true;
553 }
554
555 value *= m_scale;
556
557 if( aVariant.IsNull() || aVariant.GetDouble() != value )
558 {
559 aVariant = value;
560 return true;
561 }
562
563 return false;
564}
565
566
567#if wxCHECK_VERSION( 3, 3, 0 )
568wxString PGPROPERTY_ANGLE::ValueToString( wxVariant& aVariant,
569 wxPGPropValFormatFlags aArgFlags ) const
570#else
571wxString PGPROPERTY_ANGLE::ValueToString( wxVariant& aVariant, int aArgFlags ) const
572#endif
573{
574 if( aVariant.GetType() == wxT( "std::optional<double>" ) )
575 {
576 auto* variantData = static_cast<STD_OPTIONAL_DOUBLE_VARIANT_DATA*>( aVariant.GetData() );
577
578 if( variantData->Value().has_value() )
579 return wxString::Format( wxS( "%g\u00B0" ), variantData->Value().value() / m_scale );
580 else
581 return wxEmptyString;
582 }
583 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
584 {
585 return wxString::Format( wxS( "%g\u00B0" ), aVariant.GetDouble() / m_scale );
586 }
587 else if( aVariant.GetType() == wxS( "EDA_ANGLE" ) )
588 {
589 wxString ret;
590 static_cast<EDA_ANGLE_VARIANT_DATA*>( aVariant.GetData() )->Write( ret );
591 return ret;
592 }
593 else
594 {
595 wxCHECK_MSG( false, wxEmptyString, wxS( "Unexpected variant type in PGPROPERTY_ANGLE" ) );
596 }
597}
598
599
601{
602 return nullptr;
603}
604
605
607{
608 wxSize size( 16, -1 );
609
610 if( wxPropertyGrid* pg = GetGrid() )
611 size = pg->FromDIP( size );
612
613 return size;
614}
615
616
617void PGPROPERTY_COLORENUM::OnCustomPaint( wxDC& aDC, const wxRect& aRect,
618 wxPGPaintData& aPaintData )
619{
620 int index = aPaintData.m_choiceItem;
621
622 if( index < 0 )
623 index = GetIndex();
624
625 // GetIndex can return -1 when the control hasn't been set up yet
626 if( index < 0 || index >= static_cast<int>( GetChoices().GetCount() ) )
627 return;
628
629 wxColour color = GetColor( GetChoices().GetValue( index ) );
630
631 if( color == wxNullColour )
632 return;
633
634 aDC.SetPen( *wxTRANSPARENT_PEN );
635 aDC.SetBrush( wxBrush( color ) );
636 aDC.DrawRectangle( aRect );
637
638 aPaintData.m_drawnWidth = aRect.width;
639}
640
641
642#if wxCHECK_VERSION( 3, 3, 0 )
643wxString PGPROPERTY_STRING::ValueToString( wxVariant& aValue,
644 wxPGPropValFormatFlags aFlags ) const
645#else
646wxString PGPROPERTY_STRING::ValueToString( wxVariant& aValue, int aFlags ) const
647#endif
648{
649 if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING )
650 return wxEmptyString;
651
652 return UnescapeString( aValue.GetString() );
653}
654
655
656#if wxCHECK_VERSION( 3, 3, 0 )
657bool PGPROPERTY_STRING::StringToValue( wxVariant& aVariant, const wxString& aString,
658 wxPGPropValFormatFlags aArgFlags ) const
659#else
660bool PGPROPERTY_STRING::StringToValue( wxVariant& aVariant, const wxString& aString,
661 int aFlags ) const
662#endif
663{
664 aVariant = EscapeString( aString, CTX_QUOTED_STR );
665 return true;
666}
667
668
669PGPROPERTY_BOOL::PGPROPERTY_BOOL( const wxString& aLabel, const wxString& aName, bool aValue ) :
670 wxBoolProperty( aLabel, aName, aValue )
671{
673}
674
675
676const wxPGEditor* PGPROPERTY_BOOL::DoGetEditorClass() const
677{
678 wxCHECK_MSG( m_customEditor, wxPGEditor_CheckBox,
679 wxT( "Make sure to RegisterEditorClass() for PGPROPERTY_BOOL!" ) );
680 return m_customEditor;
681}
682
683
684PGPROPERTY_COLOR4D::PGPROPERTY_COLOR4D( const wxString& aLabel, const wxString& aName,
685 COLOR4D aValue, COLOR4D aBackgroundColor ) :
686 wxStringProperty( aLabel, aName, aValue.ToCSSString() ),
687 m_backgroundColor( aBackgroundColor )
688{
689 SetEditor( PG_COLOR_EDITOR::EDITOR_NAME );
690#if wxCHECK_VERSION( 3, 3, 0 )
691 SetFlag( wxPGPropertyFlags::NoEditor );
692#else
693 SetFlag( wxPG_PROP_NOEDITOR );
694#endif
695}
696
697
698#if wxCHECK_VERSION( 3, 3, 0 )
699bool PGPROPERTY_COLOR4D::StringToValue( wxVariant& aVariant, const wxString& aString,
700 wxPGPropValFormatFlags aArgFlags ) const
701#else
702bool PGPROPERTY_COLOR4D::StringToValue( wxVariant& aVariant, const wxString& aString,
703 int aFlags ) const
704#endif
705{
706 aVariant.SetData( new COLOR4D_VARIANT_DATA( aString ) );
707 return true;
708}
709
710
711#if wxCHECK_VERSION( 3, 3, 0 )
712wxString PGPROPERTY_COLOR4D::ValueToString( wxVariant& aValue,
713 wxPGPropValFormatFlags aFlags ) const
714#else
715wxString PGPROPERTY_COLOR4D::ValueToString( wxVariant& aValue, int aFlags ) const
716#endif
717{
718 wxString ret;
719
720 if( aValue.IsType( wxS( "COLOR4D" ) ) )
721 static_cast<COLOR4D_VARIANT_DATA*>( aValue.GetData() )->Write( ret );
722 else
723 return wxStringProperty::ValueToString( aValue, aFlags );
724
725 return ret;
726}
int color
Definition: DXF_plotter.cpp:60
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.
Definition: color4d.h:104
A class to perform either relative or absolute display origin transforms for a single axis of a point...
virtual int ToDisplay(int aValue, COORD_TYPES_T aCoordType) const
COORD_TYPES_T
The supported Display Origin Transform types.
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
Definition: pg_editors.h:75
static const wxString EDITOR_NAME
Definition: pg_editors.h:91
static const wxString EDITOR_NAME
Definition: pg_editors.h:117
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
Definition: pg_editors.cpp:52
virtual size_t TypeHash() const =0
Return type-id of the property type.
PROPERTY_DISPLAY Display() const
Definition: property.h:289
ORIGIN_TRANSFORMS::COORD_TYPES_T CoordType() const
Definition: property.h:292
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
Definition: property.h:241
const wxString & Name() const
Definition: property.h:217
virtual const wxPGChoices & Choices() const
Return a limited set of possible values (e.g.
Definition: property.h:223
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
wxAnyToEDA_ANGLE_VARIANTRegistrationImpl(wxVariantDataFactory factory)
static bool AreSameClasses(const wxAnyValueType &a, const wxAnyValueType &b)
static bool IsSameClass(const wxAnyValueType *otherType)
wxAnyToSTD_OPTIONAL_DOUBLE_VARIANTRegistrationImpl(wxVariantDataFactory factory)
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 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 ...
Definition: macros.h:83
wxPGProperty * PGPropertyFactory(const PROPERTY_BASE *aProperty, EDA_DRAW_FRAME *aFrame)
Customized abstract wxPGProperty class to handle coordinate/size units.
#define TYPE_HASH(x)
Definition: property.h:71
PROPERTY_DISPLAY
Common property types.
Definition: property.h:60
@ PT_DEGREE
Angle expressed in degrees.
Definition: property.h:65
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Definition: property.h:64
@ PT_RATIO
Definition: property.h:67
@ PT_DECIDEGREE
Angle expressed in decidegrees.
Definition: property.h:66
@ PT_AREA
Area expressed in distance units-squared (mm/inch)
Definition: property.h:63
@ PT_DEFAULT
Default property for a given type.
Definition: property.h:61
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition: property.h:62
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:...
@ CTX_QUOTED_STR
Definition: string_utils.h:57
Custom text control validator definitions.