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 (C) 2021-2024 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
73wxAnyValueTypeScopedPtr wxAnyToSTD_OPTIONAL_INT_VARIANTRegistrationImpl::s_instance( new wxAnyValueTypeImpl<std::optional<int>>() );
74
76
77
78class wxAnyToSTD_OPTIONAL_DOUBLE_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
79{
80public:
82 : wxAnyToVariantRegistration( factory )
83 {
84 }
85
86public:
87 static bool IsSameClass(const wxAnyValueType* otherType)
88 {
89 return AreSameClasses( *s_instance.get(), *otherType );
90 }
91
92 static wxAnyValueType* GetInstance()
93 {
94 return s_instance.get();
95 }
96
97 virtual wxAnyValueType* GetAssociatedType() override
98 {
100 }
101private:
102 static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
103 {
104 return wxTypeId(a) == wxTypeId(b);
105 }
106
107 static wxAnyValueTypeScopedPtr s_instance;
108};
109
110
111wxAnyValueTypeScopedPtr wxAnyToSTD_OPTIONAL_DOUBLE_VARIANTRegistrationImpl::s_instance( new wxAnyValueTypeImpl<std::optional<double>>() );
112
114
115
116class wxAnyToEDA_ANGLE_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
117{
118public:
119 wxAnyToEDA_ANGLE_VARIANTRegistrationImpl( wxVariantDataFactory factory )
120 : wxAnyToVariantRegistration( factory )
121 {
122 }
123
124public:
125 static bool IsSameClass(const wxAnyValueType* otherType)
126 {
127 return AreSameClasses( *s_instance.get(), *otherType );
128 }
129
130 static wxAnyValueType* GetInstance()
131 {
132 return s_instance.get();
133 }
134
135 virtual wxAnyValueType* GetAssociatedType() override
136 {
138 }
139private:
140 static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
141 {
142 return wxTypeId(a) == wxTypeId(b);
143 }
144
145 static wxAnyValueTypeScopedPtr s_instance;
146};
147
148
149wxAnyValueTypeScopedPtr wxAnyToEDA_ANGLE_VARIANTRegistrationImpl::s_instance( new wxAnyValueTypeImpl<EDA_ANGLE>() );
150
151static wxAnyToEDA_ANGLE_VARIANTRegistrationImpl s_wxAnyToEDA_ANGLE_VARIANTRegistration( &EDA_ANGLE_VARIANT_DATA::VariantDataFactory );
152
153
154class wxAnyToCOLOR4D_VARIANTRegistrationImpl : public wxAnyToVariantRegistration
155{
156public:
157 wxAnyToCOLOR4D_VARIANTRegistrationImpl( wxVariantDataFactory factory )
158 : wxAnyToVariantRegistration( factory )
159 {
160 }
161
162public:
163 static bool IsSameClass(const wxAnyValueType* otherType)
164 {
165 return AreSameClasses( *s_instance.get(), *otherType );
166 }
167
168 static wxAnyValueType* GetInstance()
169 {
170 return s_instance.get();
171 }
172
173 virtual wxAnyValueType* GetAssociatedType() override
174 {
176 }
177private:
178 static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b)
179 {
180 return wxTypeId(a) == wxTypeId(b);
181 }
182
183 static wxAnyValueTypeScopedPtr s_instance;
184};
185
186wxAnyValueTypeScopedPtr wxAnyToCOLOR4D_VARIANTRegistrationImpl::s_instance( new wxAnyValueTypeImpl<KIGFX::COLOR4D>() );
187
188static wxAnyToCOLOR4D_VARIANTRegistrationImpl s_wxAnyToCOLOR4D_VARIANTRegistration( &COLOR4D_VARIANT_DATA::VariantDataFactory );
189
190
191wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty, EDA_DRAW_FRAME* aFrame )
192{
193 wxPGProperty* ret = nullptr;
194 PROPERTY_DISPLAY display = aProperty->Display();
195
196 switch( display )
197 {
199 ret = new PGPROPERTY_SIZE( aFrame );
200 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
201 break;
202
204 ret = new PGPROPERTY_AREA( aFrame );
205 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
206 break;
207
209 ret = new PGPROPERTY_COORD( aFrame, aProperty->CoordType() );
210 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
211 break;
212
215 {
217
218 if( display == PROPERTY_DISPLAY::PT_DECIDEGREE )
219 prop->SetScale( 10.0 );
220
221 ret = prop;
222 ret->SetEditor( PG_UNIT_EDITOR::BuildEditorName( aFrame ) );
223 break;
224 }
225
227 ret = new PGPROPERTY_RATIO();
228 break;
229
230 default:
231 wxFAIL;
233 /* fall through */
235 {
236 // Create a corresponding wxPGProperty
237 size_t typeId = aProperty->TypeHash();
238
239 // Enum property
240 if( aProperty->HasChoices() )
241 {
242 // I do not know why enum property takes a non-const reference to wxPGChoices..
243 ret = new wxEnumProperty( wxPG_LABEL, wxPG_LABEL,
244 const_cast<wxPGChoices&>( aProperty->Choices() ) );
245 }
246 else if( typeId == TYPE_HASH( int ) || typeId == TYPE_HASH( long ) )
247 {
248 ret = new wxIntProperty();
249 }
250 else if( typeId == TYPE_HASH( unsigned int ) || typeId == TYPE_HASH( unsigned long ) )
251 {
252 ret = new wxUIntProperty();
253 }
254 else if( typeId == TYPE_HASH( float ) || typeId == TYPE_HASH( double ) )
255 {
256 ret = new wxFloatProperty();
257 }
258 else if( typeId == TYPE_HASH( bool ) )
259 {
260 ret = new PGPROPERTY_BOOL();
261 }
262 else if( typeId == TYPE_HASH( wxString ) )
263 {
264 ret = new PGPROPERTY_STRING();
265 }
266 else if( typeId == TYPE_HASH( COLOR4D ) )
267 {
268 ret = new PGPROPERTY_COLOR4D();
269 }
270 else
271 {
272 wxFAIL_MSG( wxString::Format( wxS( "Property %s not supported by PGPropertyFactory" ),
273 aProperty->Name() ) );
274 ret = new wxPropertyCategory();
275 ret->Enable( false );
276 }
277 break;
278 }
279 }
280
281 if( ret )
282 {
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 ) );
287 }
288
289 return ret;
290}
291
292
295 m_parentFrame( aParentFrame ),
296 m_coordType( aCoordType )
297{
298}
299
300
302{
303}
304
305
306#if wxCHECK_VERSION( 3, 3, 0 )
307bool PGPROPERTY_DISTANCE::StringToDistance( wxVariant& aVariant, const wxString& aText,
308 wxPGPropValFormatFlags aFlags ) const
309#else
310bool PGPROPERTY_DISTANCE::StringToDistance( wxVariant& aVariant, const wxString& aText,
311 int aFlags ) const
312#endif
313{
314 // TODO(JE): Are there actual use cases for this?
315 wxCHECK_MSG( false, false, wxS( "PGPROPERTY_DISTANCE::StringToDistance should not be used." ) );
316}
317
318
319#if wxCHECK_VERSION( 3, 3, 0 )
320wxString PGPROPERTY_DISTANCE::DistanceToString( wxVariant& aVariant,
321 wxPGPropValFormatFlags aFlags ) const
322#else
323wxString PGPROPERTY_DISTANCE::DistanceToString( wxVariant& aVariant, int aFlags ) const
324#endif
325{
326 long distanceIU;
327
328 if( aVariant.GetType() == wxT( "std::optional<int>" ) )
329 {
330 auto* variantData = static_cast<STD_OPTIONAL_INT_VARIANT_DATA*>( aVariant.GetData() );
331
332 if( !variantData->Value().has_value() )
333 return wxEmptyString;
334
335 distanceIU = variantData->Value().value();
336 }
337 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG )
338 {
339 distanceIU = aVariant.GetLong();
340 }
341 else
342 {
343 wxFAIL_MSG( wxT( "Expected int (or std::optional<int>) value type" ) );
344 return wxEmptyString;
345 }
346
347 ORIGIN_TRANSFORMS& transforms = m_parentFrame->GetOriginTransforms();
348
349 distanceIU = transforms.ToDisplay( static_cast<long long int>( distanceIU ), m_coordType );
350
351 return m_parentFrame->StringFromValue( distanceIU, true, EDA_DATA_TYPE::DISTANCE );
352}
353
354
356 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
357 m_parentFrame( aParentFrame )
358{
359}
360
361
362#if wxCHECK_VERSION( 3, 3, 0 )
363bool PGPROPERTY_AREA::StringToValue( wxVariant& aVariant, const wxString& aText,
364 wxPGPropValFormatFlags aArgFlags ) const
365#else
366bool PGPROPERTY_AREA::StringToValue( wxVariant& aVariant, const wxString& aText,
367 int aArgFlags ) const
368#endif
369{
370 // TODO(JE): Are there actual use cases for this?
371 wxCHECK_MSG( false, false, wxS( "PGPROPERTY_AREA::StringToValue should not be used." ) );
372}
373
374
375#if wxCHECK_VERSION( 3, 3, 0 )
376wxString PGPROPERTY_AREA::ValueToString( wxVariant& aVariant,
377 wxPGPropValFormatFlags aArgFlags ) const
378#else
379wxString PGPROPERTY_AREA::ValueToString( wxVariant& aVariant, int aArgFlags ) const
380#endif
381{
382 wxCHECK( aVariant.GetType() == wxPG_VARIANT_TYPE_LONGLONG, wxEmptyString );
383
384 wxLongLongNative areaIU = aVariant.GetLongLong();
385
386 return m_parentFrame->StringFromValue( areaIU.ToDouble(), true, EDA_DATA_TYPE::AREA );
387}
388
389
391{
392 return nullptr;
393}
394
395
397 wxUIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
398 PGPROPERTY_DISTANCE( aParentFrame, ORIGIN_TRANSFORMS::NOT_A_COORD )
399{
400}
401
402
403bool PGPROPERTY_SIZE::ValidateValue( wxVariant& aValue, wxPGValidationInfo& aValidationInfo ) const
404{
405 if( aValue.GetType() == wxT( "std::optional<int>" ) )
406 {
407 auto* data = static_cast<STD_OPTIONAL_INT_VARIANT_DATA*>( aValue.GetData() );
408
409 if( !data->Value().has_value() )
410 return wxEmptyString;
411
412 wxVariant value( data->Value().value() );
413 return wxUIntProperty::ValidateValue( value, aValidationInfo );
414 }
415
416 return wxUIntProperty::ValidateValue( aValue, aValidationInfo );
417}
418
419
421{
422 return nullptr;
423}
424
425
428 wxIntProperty( wxPG_LABEL, wxPG_LABEL, 0 ),
429 PGPROPERTY_DISTANCE( aParentFrame, aCoordType )
430{
431}
432
433
435{
436 return nullptr;
437}
438
439
441 wxFloatProperty( wxPG_LABEL, wxPG_LABEL, 0 )
442{
443 SetEditor( PG_RATIO_EDITOR::EDITOR_NAME );
444}
445
446
447const wxPGEditor* PGPROPERTY_RATIO::DoGetEditorClass() const
448{
449 wxCHECK_MSG( m_customEditor, wxPGEditor_TextCtrl,
450 wxT( "Make sure to RegisterEditorClass() for PGPROPERTY_RATIO!" ) );
451 return m_customEditor;
452}
453
454
455#if wxCHECK_VERSION( 3, 3, 0 )
456bool PGPROPERTY_RATIO::StringToValue( wxVariant& aVariant, const wxString& aText,
457 wxPGPropValFormatFlags aArgFlags ) const
458#else
459bool PGPROPERTY_RATIO::StringToValue( wxVariant& aVariant, const wxString& aText,
460 int aArgFlags ) const
461#endif
462{
463 // TODO(JE): Are there actual use cases for this?
464 wxCHECK_MSG( false, false, wxS( "PGPROPERTY_RATIO::StringToValue should not be used." ) );
465}
466
467
468#if wxCHECK_VERSION( 3, 3, 0 )
469wxString PGPROPERTY_RATIO::ValueToString( wxVariant& aVariant,
470 wxPGPropValFormatFlags aArgFlags ) const
471#else
472wxString PGPROPERTY_RATIO::ValueToString( wxVariant& aVariant, int aArgFlags ) const
473#endif
474{
475 double value;
476
477 if( aVariant.GetType() == wxT( "std::optional<double>" ) )
478 {
479 auto* variantData = static_cast<STD_OPTIONAL_DOUBLE_VARIANT_DATA*>( aVariant.GetData() );
480
481 if( !variantData->Value().has_value() )
482 return wxEmptyString;
483
484 value = variantData->Value().value();
485 }
486 else if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
487 {
488 value = aVariant.GetDouble();
489 }
490 else
491 {
492 wxFAIL_MSG( wxT( "Expected double (or std::optional<double>) value type" ) );
493 return wxEmptyString;
494 }
495
496 return wxString::Format( wxS( "%g" ), value );
497}
498
499
500bool PGPROPERTY_RATIO::ValidateValue( wxVariant& aValue, wxPGValidationInfo& aValidationInfo ) const
501{
502 if( aValue.GetType() == wxT( "std::optional<double>" ) )
503 {
504 auto* data = static_cast<STD_OPTIONAL_DOUBLE_VARIANT_DATA*>( aValue.GetData() );
505
506 if( !data->Value().has_value() )
507 return wxEmptyString;
508
509 wxVariant value( data->Value().value() );
510 return wxFloatProperty::ValidateValue( value, aValidationInfo );
511 }
512
513 return wxFloatProperty::ValidateValue( aValue, aValidationInfo );
514}
515
516
518{
519 return nullptr;
520}
521
522
523#if wxCHECK_VERSION( 3, 3, 0 )
524bool PGPROPERTY_ANGLE::StringToValue( wxVariant& aVariant, const wxString& aText,
525 wxPGPropValFormatFlags aArgFlags ) const
526#else
527bool PGPROPERTY_ANGLE::StringToValue( wxVariant& aVariant, const wxString& aText,
528 int aArgFlags ) const
529#endif
530{
531 double value = 0.0;
532
533 if( !aText.ToDouble( &value ) )
534 {
535 aVariant.MakeNull();
536 return true;
537 }
538
539 value *= m_scale;
540
541 if( aVariant.IsNull() || aVariant.GetDouble() != value )
542 {
543 aVariant = value;
544 return true;
545 }
546
547 return false;
548}
549
550
551#if wxCHECK_VERSION( 3, 3, 0 )
552wxString PGPROPERTY_ANGLE::ValueToString( wxVariant& aVariant,
553 wxPGPropValFormatFlags aArgFlags ) const
554#else
555wxString PGPROPERTY_ANGLE::ValueToString( wxVariant& aVariant, int aArgFlags ) const
556#endif
557{
558 if( aVariant.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
559 {
560 // TODO(JE) Is this still needed?
561 return wxString::Format( wxS( "%g\u00B0" ), aVariant.GetDouble() / m_scale );
562 }
563 else if( aVariant.GetType() == wxS( "EDA_ANGLE" ) )
564 {
565 wxString ret;
566 static_cast<EDA_ANGLE_VARIANT_DATA*>( aVariant.GetData() )->Write( ret );
567 return ret;
568 }
569 else
570 {
571 wxCHECK_MSG( false, wxEmptyString, wxS( "Unexpected variant type in PGPROPERTY_ANGLE" ) );
572 }
573}
574
575
577{
578 return nullptr;
579}
580
581
583{
584 // TODO(JE) calculate size from window metrics?
585 return wxSize( 16, 12 );
586}
587
588
589void PGPROPERTY_COLORENUM::OnCustomPaint( wxDC& aDC, const wxRect& aRect,
590 wxPGPaintData& aPaintData )
591{
592 int index = aPaintData.m_choiceItem;
593
594 if( index < 0 )
595 index = GetIndex();
596
597 // GetIndex can return -1 when the control hasn't been set up yet
598 if( index < 0 || index >= static_cast<int>( GetChoices().GetCount() ) )
599 return;
600
601 wxColour color = GetColor( GetChoices().GetValue( index ) );
602
603 if( color == wxNullColour )
604 return;
605
606 aDC.SetPen( *wxTRANSPARENT_PEN );
607 aDC.SetBrush( wxBrush( color ) );
608 aDC.DrawRectangle( aRect );
609
610 aPaintData.m_drawnWidth = aRect.width;
611}
612
613
614#if wxCHECK_VERSION( 3, 3, 0 )
615wxString PGPROPERTY_STRING::ValueToString( wxVariant& aValue,
616 wxPGPropValFormatFlags aFlags ) const
617#else
618wxString PGPROPERTY_STRING::ValueToString( wxVariant& aValue, int aFlags ) const
619#endif
620{
621 if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING )
622 return wxEmptyString;
623
624 return UnescapeString( aValue.GetString() );
625}
626
627
628#if wxCHECK_VERSION( 3, 3, 0 )
629bool PGPROPERTY_STRING::StringToValue( wxVariant& aVariant, const wxString& aString,
630 wxPGPropValFormatFlags aArgFlags ) const
631#else
632bool PGPROPERTY_STRING::StringToValue( wxVariant& aVariant, const wxString& aString,
633 int aFlags ) const
634#endif
635{
636 aVariant = EscapeString( aString, CTX_QUOTED_STR );
637 return true;
638}
639
640
641PGPROPERTY_BOOL::PGPROPERTY_BOOL( const wxString& aLabel, const wxString& aName, bool aValue ) :
642 wxBoolProperty( aLabel, aName, aValue )
643{
645}
646
647
648const wxPGEditor* PGPROPERTY_BOOL::DoGetEditorClass() const
649{
650 wxCHECK_MSG( m_customEditor, wxPGEditor_CheckBox,
651 wxT( "Make sure to RegisterEditorClass() for PGPROPERTY_BOOL!" ) );
652 return m_customEditor;
653}
654
655
656PGPROPERTY_COLOR4D::PGPROPERTY_COLOR4D( const wxString& aLabel, const wxString& aName,
657 COLOR4D aValue, COLOR4D aBackgroundColor ) :
658 wxStringProperty( aLabel, aName, aValue.ToCSSString() ),
659 m_backgroundColor( aBackgroundColor )
660{
661 SetEditor( PG_COLOR_EDITOR::EDITOR_NAME );
662#if wxCHECK_VERSION( 3, 3, 0 )
663 SetFlag( wxPGPropertyFlags::NoEditor );
664#else
665 SetFlag( wxPG_PROP_NOEDITOR );
666#endif
667}
668
669
670#if wxCHECK_VERSION( 3, 3, 0 )
671bool PGPROPERTY_COLOR4D::StringToValue( wxVariant& aVariant, const wxString& aString,
672 wxPGPropValFormatFlags aArgFlags ) const
673#else
674bool PGPROPERTY_COLOR4D::StringToValue( wxVariant& aVariant, const wxString& aString,
675 int aFlags ) const
676#endif
677{
678 aVariant.SetData( new COLOR4D_VARIANT_DATA( aString ) );
679 return true;
680}
681
682
683#if wxCHECK_VERSION( 3, 3, 0 )
684wxString PGPROPERTY_COLOR4D::ValueToString( wxVariant& aValue,
685 wxPGPropValFormatFlags aFlags ) const
686#else
687wxString PGPROPERTY_COLOR4D::ValueToString( wxVariant& aValue, int aFlags ) const
688#endif
689{
690 wxString ret;
691
692 if( aValue.IsType( wxS( "COLOR4D" ) ) )
693 static_cast<COLOR4D_VARIANT_DATA*>( aValue.GetData() )->Write( ret );
694 else
695 return wxStringProperty::ValueToString( aValue, aFlags );
696
697 return ret;
698}
int color
Definition: DXF_plotter.cpp:58
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.