1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Propert sheet classes implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "prop.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
23 #include "wx/deprecated/setup.h"
31 #include "wx/deprecated/prop.h"
38 static inline wxChar
* copystring(const wxChar
* s
)
39 { return wxStrcpy(new wxChar
[wxStrlen(s
) + 1], s
); }
41 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue
, wxObject
)
43 wxPropertyValue::wxPropertyValue(void)
45 m_type
= wxPropertyValueNull
;
50 m_modifiedFlag
= FALSE
;
53 wxPropertyValue::wxPropertyValue(const wxPropertyValue
& copyFrom
)
56 m_value
.string
= (wxChar
*) NULL
;
57 m_modifiedFlag
= FALSE
;
58 Copy((wxPropertyValue
& )copyFrom
);
61 wxPropertyValue::wxPropertyValue(const wxChar
*val
)
63 m_modifiedFlag
= FALSE
;
64 m_type
= wxPropertyValueString
;
66 m_value
.string
= copystring(val
);
72 wxPropertyValue::wxPropertyValue(const wxString
& val
)
74 m_modifiedFlag
= FALSE
;
75 m_type
= wxPropertyValueString
;
77 m_value
.string
= copystring((const wxChar
*)val
);
83 wxPropertyValue::wxPropertyValue(long the_integer
)
85 m_modifiedFlag
= FALSE
;
86 m_type
= wxPropertyValueInteger
;
87 m_value
.integer
= the_integer
;
92 wxPropertyValue::wxPropertyValue(bool val
)
94 m_modifiedFlag
= FALSE
;
95 m_type
= wxPropertyValuebool
;
96 m_value
.integer
= val
;
101 wxPropertyValue::wxPropertyValue(float the_real
)
103 m_modifiedFlag
= FALSE
;
104 m_type
= wxPropertyValueReal
;
105 m_value
.real
= the_real
;
110 wxPropertyValue::wxPropertyValue(double the_real
)
112 m_modifiedFlag
= FALSE
;
113 m_type
= wxPropertyValueReal
;
114 m_value
.real
= (float)the_real
;
119 // Pointer versions: we have a pointer to the real C++ value.
120 wxPropertyValue::wxPropertyValue(wxChar
**val
)
122 m_modifiedFlag
= FALSE
;
123 m_type
= wxPropertyValueStringPtr
;
125 m_value
.stringPtr
= val
;
131 wxPropertyValue::wxPropertyValue(long *val
)
133 m_modifiedFlag
= FALSE
;
134 m_type
= wxPropertyValueIntegerPtr
;
135 m_value
.integerPtr
= val
;
140 wxPropertyValue::wxPropertyValue(bool *val
)
142 m_modifiedFlag
= FALSE
;
143 m_type
= wxPropertyValueboolPtr
;
144 m_value
.boolPtr
= val
;
149 wxPropertyValue::wxPropertyValue(float *val
)
151 m_modifiedFlag
= FALSE
;
152 m_type
= wxPropertyValueRealPtr
;
153 m_value
.realPtr
= val
;
158 wxPropertyValue::wxPropertyValue(wxList
*the_list
)
160 m_modifiedFlag
= FALSE
;
161 m_type
= wxPropertyValueList
;
164 m_value
.first
= NULL
;
166 wxNode
*node
= the_list
->GetFirst();
169 wxPropertyValue
*expr
= (wxPropertyValue
*)node
->GetData();
171 node
= node
->GetNext();
177 wxPropertyValue::wxPropertyValue(wxStringList
*the_list
)
179 m_modifiedFlag
= FALSE
;
180 m_type
= wxPropertyValueList
;
183 m_value
.first
= NULL
;
185 wxStringList::Node
*node
= the_list
->GetFirst();
188 wxChar
*s
= node
->GetData();
189 Append(new wxPropertyValue(s
));
190 node
= node
->GetNext();
195 wxPropertyValue::~wxPropertyValue(void)
199 case wxPropertyValueInteger
:
200 case wxPropertyValuebool
:
201 case wxPropertyValueReal
:
205 case wxPropertyValueString
:
207 delete[] m_value
.string
;
210 case wxPropertyValueList
:
212 wxPropertyValue
*expr
= m_value
.first
;
215 wxPropertyValue
*expr1
= expr
->m_next
;
223 case wxPropertyValueNull
: break;
227 void wxPropertyValue::Append(wxPropertyValue
*expr
)
229 m_modifiedFlag
= TRUE
;
231 m_value
.first
= expr
;
234 m_last
->m_next
= expr
;
238 void wxPropertyValue::Insert(wxPropertyValue
*expr
)
240 m_modifiedFlag
= TRUE
;
241 expr
->m_next
= m_value
.first
;
242 m_value
.first
= expr
;
249 void wxPropertyValue::Delete(wxPropertyValue
*node
)
251 wxPropertyValue
*expr
= GetFirst();
253 wxPropertyValue
*previous
= NULL
;
254 while (expr
&& (expr
!= node
))
257 expr
= expr
->GetNext();
263 previous
->m_next
= expr
->m_next
;
265 // If node was the first in the list,
266 // make the list point to the NEXT one.
267 if (GetFirst() == expr
)
269 m_value
.first
= expr
->m_next
;
272 // If node was the last in the list,
273 // make the list 'last' pointer point to the PREVIOUS one.
274 if (GetLast() == expr
)
281 m_modifiedFlag
= TRUE
;
287 void wxPropertyValue::ClearList(void)
289 wxPropertyValue
*val
= GetFirst();
291 m_modifiedFlag
= TRUE
;
295 wxPropertyValue
*next
= val
->GetNext();
299 m_value
.first
= NULL
;
303 wxPropertyValue
*wxPropertyValue::NewCopy(void) const
307 case wxPropertyValueInteger
:
308 return new wxPropertyValue(m_value
.integer
);
309 case wxPropertyValuebool
:
310 return new wxPropertyValue((bool) (m_value
.integer
!= 0));
311 case wxPropertyValueReal
:
312 return new wxPropertyValue(m_value
.real
);
313 case wxPropertyValueString
:
314 return new wxPropertyValue(m_value
.string
);
315 case wxPropertyValueList
:
317 wxPropertyValue
*expr
= m_value
.first
;
318 wxPropertyValue
*new_list
= new wxPropertyValue
;
319 new_list
->SetType(wxPropertyValueList
);
322 wxPropertyValue
*expr2
= expr
->NewCopy();
323 new_list
->Append(expr2
);
328 case wxPropertyValueIntegerPtr
:
329 return new wxPropertyValue(m_value
.integerPtr
);
330 case wxPropertyValueRealPtr
:
331 return new wxPropertyValue(m_value
.realPtr
);
332 case wxPropertyValueboolPtr
:
333 return new wxPropertyValue(m_value
.boolPtr
);
334 case wxPropertyValueStringPtr
:
335 return new wxPropertyValue(m_value
.stringPtr
);
337 case wxPropertyValueNull
:
338 wxFAIL_MSG( wxT("Should never get here!\n" ) );
344 void wxPropertyValue::Copy(wxPropertyValue
& copyFrom
)
346 if (m_type
== wxPropertyValueString
)
348 delete[] m_value
.string
;
349 m_value
.string
= NULL
;
351 m_type
= copyFrom
.Type();
355 case wxPropertyValueInteger
:
356 (*this) = copyFrom
.IntegerValue();
359 case wxPropertyValueReal
:
360 (*this) = copyFrom
.RealValue();
363 case wxPropertyValueString
:
364 (*this) = wxString(copyFrom
.StringValue());
367 case wxPropertyValuebool
:
368 (*this) = copyFrom
.BoolValue();
372 case wxPropertyValueboolPtr
:
373 (*this) = copyFrom
.BoolValuePtr();
375 case wxPropertyValueRealPtr
:
376 (*this) = copyFrom
.RealValuePtr();
378 case wxPropertyValueIntegerPtr
:
379 (*this) = copyFrom
.IntegerValuePtr();
381 case wxPropertyValueStringPtr
:
383 wxChar
** s
= copyFrom
.StringValuePtr();
386 // what is this? are you trying to assign a bool or a string? VA can't figure it out..
387 #if defined(__VISAGECPP__) || defined( __VISUALC__ )
394 (*this) = (bool)(s
!= 0);
399 case wxPropertyValueList
:
401 m_value
.first
= NULL
;
404 wxPropertyValue
*expr
= copyFrom
.m_value
.first
;
407 wxPropertyValue
*expr2
= expr
->NewCopy();
413 case wxPropertyValueNull
:
414 wxFAIL_MSG( wxT("Should never get here!\n" ) );
419 // Return nth argument of a clause (starting from 1)
420 wxPropertyValue
*wxPropertyValue::Arg(wxPropertyValueType type
, int arg
) const
422 wxPropertyValue
*expr
= m_value
.first
;
423 for (int i
= 1; i
< arg
; i
++)
427 if (expr
&& (expr
->m_type
== type
))
433 // Return nth argument of a list expression (starting from zero)
434 wxPropertyValue
*wxPropertyValue::Nth(int arg
) const
436 if (m_type
!= wxPropertyValueList
)
439 wxPropertyValue
*expr
= m_value
.first
;
440 for (int i
= 0; i
< arg
; i
++)
451 // Returns the number of elements in a list expression
452 int wxPropertyValue::Number(void) const
454 if (m_type
!= wxPropertyValueList
)
458 wxPropertyValue
*expr
= m_value
.first
;
467 void wxPropertyValue::WritePropertyClause(wxString
& stream
) // Write this expression as a top-level clause
469 if (m_type
!= wxPropertyValueList
)
472 wxPropertyValue
*node
= m_value
.first
;
475 node
->WritePropertyType(stream
);
476 stream
.Append( wxT("(") );
482 stream
.Append( wxT(" ") );
483 node
->WritePropertyType(stream
);
486 stream
.Append( wxT(",\n" ) );
489 stream
.Append( wxT(").\n\n") );
493 void wxPropertyValue::WritePropertyType(wxString
& stream
) // Write as any other subexpression
498 case wxPropertyValueInteger
:
500 tmp
.Printf( wxT("%ld"), m_value
.integer
);
501 stream
.Append( tmp
);
504 case wxPropertyValueIntegerPtr
:
506 tmp
.Printf( wxT("%ld"), *m_value
.integerPtr
);
507 stream
.Append( tmp
);
510 case wxPropertyValuebool
:
513 stream
.Append( wxT("True") );
515 stream
.Append( wxT("False") );
518 case wxPropertyValueboolPtr
:
520 if (*m_value
.integerPtr
)
521 stream
.Append( wxT("True") );
523 stream
.Append( wxT("False") );
526 case wxPropertyValueReal
:
528 double d
= m_value
.real
;
529 tmp
.Printf( wxT("%.6g"), d
);
530 stream
.Append( tmp
);
533 case wxPropertyValueRealPtr
:
535 double d
= *m_value
.realPtr
;
536 tmp
.Printf( wxT("%.6g"), d
);
537 stream
.Append( tmp
);
540 case wxPropertyValueString
:
542 stream
.Append( m_value
.string
);
545 case wxPropertyValueStringPtr
:
547 wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );
550 int len = strlen(*(m_value.stringPtr));
551 for (i = 0; i < len; i++)
553 char ch = *(m_value.stringPtr)[i];
559 case wxPropertyValueList
:
562 stream
.Append( wxT("[]") );
565 wxPropertyValue
*expr
= m_value
.first
;
567 stream
.Append( wxT("[") );
570 expr
->WritePropertyType(stream
);
573 stream
.Append( wxT(", ") );
575 stream
.Append( wxT("]") );
579 case wxPropertyValueNull
: break;
583 wxString
wxPropertyValue::GetStringRepresentation(void)
586 WritePropertyType(str
);
590 void wxPropertyValue::operator=(const wxPropertyValue
& val
)
592 m_modifiedFlag
= TRUE
;
593 Copy((wxPropertyValue
&)val
);
596 // void wxPropertyValue::operator=(const char *val)
597 void wxPropertyValue::operator=(const wxString
& val1
)
599 const wxChar
*val
= (const wxChar
*)val1
;
601 m_modifiedFlag
= TRUE
;
603 wxPropertyValueType oldType
= m_type
;
604 if (oldType
== wxPropertyValueString
)
606 delete[] m_value
.string
;
607 m_value
.string
= NULL
;
610 if (m_type
== wxPropertyValueNull
)
611 m_type
= wxPropertyValueString
;
613 if (m_type
== wxPropertyValueString
)
616 m_value
.string
= copystring(val
);
618 m_value
.string
= NULL
;
620 else if (m_type
== wxPropertyValueStringPtr
)
622 wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") );
624 *m_value
.stringPtr
= copystring(val
);
626 *m_value
.stringPtr
= NULL
;
635 void wxPropertyValue::operator=(const long val
)
637 wxPropertyValueType oldType
= m_type
;
638 if (oldType
== wxPropertyValueString
)
640 delete[] m_value
.string
;
641 m_value
.string
= NULL
;
644 m_modifiedFlag
= TRUE
;
645 if (m_type
== wxPropertyValueNull
)
646 m_type
= wxPropertyValueInteger
;
648 if (m_type
== wxPropertyValueInteger
)
649 m_value
.integer
= val
;
650 else if (m_type
== wxPropertyValueIntegerPtr
)
651 *m_value
.integerPtr
= val
;
652 else if (m_type
== wxPropertyValueReal
)
653 m_value
.real
= (float)val
;
654 else if (m_type
== wxPropertyValueRealPtr
)
655 *m_value
.realPtr
= (float)val
;
661 void wxPropertyValue::operator=(const bool val
)
663 wxPropertyValueType oldType
= m_type
;
664 if (oldType
== wxPropertyValueString
)
666 delete[] m_value
.string
;
667 m_value
.string
= NULL
;
670 m_modifiedFlag
= TRUE
;
671 if (m_type
== wxPropertyValueNull
)
672 m_type
= wxPropertyValuebool
;
674 if (m_type
== wxPropertyValuebool
)
675 m_value
.integer
= (long)val
;
676 else if (m_type
== wxPropertyValueboolPtr
)
677 *m_value
.boolPtr
= val
;
683 void wxPropertyValue::operator=(const float val
)
685 wxPropertyValueType oldType
= m_type
;
686 if (oldType
== wxPropertyValueString
)
688 delete[] m_value
.string
;
689 m_value
.string
= NULL
;
692 m_modifiedFlag
= TRUE
;
693 if (m_type
== wxPropertyValueNull
)
694 m_type
= wxPropertyValueReal
;
696 if (m_type
== wxPropertyValueInteger
)
697 m_value
.integer
= (long)val
;
698 else if (m_type
== wxPropertyValueIntegerPtr
)
699 *m_value
.integerPtr
= (long)val
;
700 else if (m_type
== wxPropertyValueReal
)
702 else if (m_type
== wxPropertyValueRealPtr
)
703 *m_value
.realPtr
= val
;
709 void wxPropertyValue::operator=(const wxChar
**val
)
711 wxPropertyValueType oldType
= m_type
;
712 if (oldType
== wxPropertyValueString
)
714 delete[] m_value
.string
;
715 m_value
.string
= NULL
;
718 m_modifiedFlag
= TRUE
;
719 m_type
= wxPropertyValueStringPtr
;
722 m_value
.stringPtr
= (wxChar
**)val
;
724 m_value
.stringPtr
= NULL
;
731 void wxPropertyValue::operator=(const long *val
)
733 m_modifiedFlag
= TRUE
;
734 m_type
= wxPropertyValueIntegerPtr
;
735 m_value
.integerPtr
= (long *)val
;
740 void wxPropertyValue::operator=(const bool *val
)
742 m_modifiedFlag
= TRUE
;
743 m_type
= wxPropertyValueboolPtr
;
744 m_value
.boolPtr
= (bool *)val
;
749 void wxPropertyValue::operator=(const float *val
)
751 m_modifiedFlag
= TRUE
;
752 m_type
= wxPropertyValueRealPtr
;
753 m_value
.realPtr
= (float *)val
;
758 long wxPropertyValue::IntegerValue(void) const
760 if (m_type
== wxPropertyValueInteger
)
761 return m_value
.integer
;
762 else if (m_type
== wxPropertyValueReal
)
763 return (long)m_value
.real
;
764 else if (m_type
== wxPropertyValueIntegerPtr
)
765 return *m_value
.integerPtr
;
766 else if (m_type
== wxPropertyValueRealPtr
)
767 return (long)(*m_value
.realPtr
);
771 long *wxPropertyValue::IntegerValuePtr(void) const
773 return m_value
.integerPtr
;
776 float wxPropertyValue::RealValue(void) const {
777 if (m_type
== wxPropertyValueReal
)
779 else if (m_type
== wxPropertyValueRealPtr
)
780 return *m_value
.realPtr
;
781 else if (m_type
== wxPropertyValueInteger
)
782 return (float)m_value
.integer
;
783 else if (m_type
== wxPropertyValueIntegerPtr
)
784 return (float)*(m_value
.integerPtr
);
788 float *wxPropertyValue::RealValuePtr(void) const
790 return m_value
.realPtr
;
793 bool wxPropertyValue::BoolValue(void) const {
794 if (m_type
== wxPropertyValueReal
)
795 return (m_value
.real
!= 0.0);
796 if (m_type
== wxPropertyValueRealPtr
)
797 return (*(m_value
.realPtr
) != 0.0);
798 else if (m_type
== wxPropertyValueInteger
)
799 return (m_value
.integer
!= 0);
800 else if (m_type
== wxPropertyValueIntegerPtr
)
801 return (*(m_value
.integerPtr
) != 0);
802 else if (m_type
== wxPropertyValuebool
)
803 return (m_value
.integer
!= 0);
804 else if (m_type
== wxPropertyValueboolPtr
)
805 return (*(m_value
.boolPtr
) != 0);
809 bool *wxPropertyValue::BoolValuePtr(void) const
811 return m_value
.boolPtr
;
814 wxChar
*wxPropertyValue::StringValue(void) const {
815 if (m_type
== wxPropertyValueString
)
816 return m_value
.string
;
817 else if (m_type
== wxPropertyValueStringPtr
)
818 return *(m_value
.stringPtr
);
822 wxChar
**wxPropertyValue::StringValuePtr(void) const
824 return m_value
.stringPtr
;
828 * A property (name plus value)
831 IMPLEMENT_DYNAMIC_CLASS(wxProperty
, wxObject
)
833 wxProperty::wxProperty(void)
835 m_propertyRole
= wxEmptyString
;
836 m_propertyValidator
= NULL
;
837 m_propertyWindow
= NULL
;
841 wxProperty::wxProperty(wxProperty
& copyFrom
)
844 m_value
= copyFrom
.GetValue();
845 m_name
= copyFrom
.GetName();
846 m_propertyRole
= copyFrom
.GetRole();
847 m_propertyValidator
= copyFrom
.GetValidator();
848 m_enabled
= copyFrom
.IsEnabled();
849 m_propertyWindow
= NULL
;
852 wxProperty::wxProperty(wxString nm
, wxString role
, wxPropertyValidator
*ed
):m_name(nm
), m_propertyRole(role
)
854 m_propertyValidator
= ed
;
855 m_propertyWindow
= NULL
;
859 wxProperty::wxProperty(wxString nm
, const wxPropertyValue
& val
, wxString role
, wxPropertyValidator
*ed
):
860 m_value(val
), m_name(nm
), m_propertyRole(role
)
862 m_propertyValidator
= ed
;
863 m_propertyWindow
= NULL
;
867 wxProperty::~wxProperty(void)
869 if (m_propertyValidator
)
870 delete m_propertyValidator
;
873 wxPropertyValue
& wxProperty::GetValue(void) const
875 return (wxPropertyValue
&) m_value
;
878 wxPropertyValidator
*wxProperty::GetValidator(void) const
880 return m_propertyValidator
;
883 wxString
& wxProperty::GetName(void) const
885 return (wxString
&) m_name
;
888 wxString
& wxProperty::GetRole(void) const
890 return (wxString
&) m_propertyRole
;
893 void wxProperty::SetValue(const wxPropertyValue
& val
)
898 void wxProperty::SetValidator(wxPropertyValidator
*ed
)
900 m_propertyValidator
= ed
;
903 void wxProperty::SetRole(wxString
& role
)
905 m_propertyRole
= role
;
908 void wxProperty::SetName(wxString
& nm
)
913 void wxProperty::operator=(const wxPropertyValue
& val
)
919 * Base property view class
922 IMPLEMENT_DYNAMIC_CLASS(wxPropertyView
, wxEvtHandler
)
924 wxPropertyView::wxPropertyView(long flags
)
926 m_buttonFlags
= flags
;
927 m_propertySheet
= NULL
;
928 m_currentValidator
= NULL
;
929 m_currentProperty
= NULL
;
932 wxPropertyView::~wxPropertyView(void)
936 void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry
*registry
)
938 m_validatorRegistryList
.Append(registry
);
941 wxPropertyValidator
*wxPropertyView::FindPropertyValidator(wxProperty
*property
)
943 if (property
->GetValidator())
944 return property
->GetValidator();
946 wxNode
*node
= m_validatorRegistryList
.GetFirst();
949 wxPropertyValidatorRegistry
*registry
= (wxPropertyValidatorRegistry
*)node
->GetData();
950 wxPropertyValidator
*validator
= registry
->GetValidator(property
->GetRole());
953 node
= node
->GetNext();
957 if (!wxDefaultPropertyValidator)
958 wxDefaultPropertyValidator = new wxPropertyListValidator;
959 return wxDefaultPropertyValidator;
967 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet
, wxObject
)
969 wxPropertySheet::wxPropertySheet(const wxString
& name
)
970 :m_properties(wxKEY_STRING
),m_name(name
)
974 wxPropertySheet::~wxPropertySheet(void)
979 void wxPropertySheet::UpdateAllViews( wxPropertyView
*WXUNUSED(thisView
) )
984 void wxPropertySheet::AddProperty(wxProperty
*property
)
986 m_properties
.Append((const wxChar
*) property
->GetName(), property
);
989 // Get property by name
990 wxProperty
*wxPropertySheet::GetProperty(const wxString
& name
) const
992 wxNode
*node
= m_properties
.Find((const wxChar
*) name
);
996 return (wxProperty
*)node
->GetData();
999 bool wxPropertySheet::SetProperty(const wxString
& name
, const wxPropertyValue
& value
)
1001 wxProperty
* prop
= GetProperty(name
);
1003 prop
->SetValue(value
);
1010 void wxPropertySheet::RemoveProperty(const wxString
& name
)
1012 wxNode
*node
= m_properties
.Find(name
);
1015 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1017 m_properties
.DeleteNode(node
);
1021 bool wxPropertySheet::HasProperty(const wxString
& name
) const
1023 return (GetProperty(name
)?TRUE
:FALSE
);
1026 // Clear all properties
1027 void wxPropertySheet::Clear(void)
1029 wxNode
*node
= m_properties
.GetFirst();
1032 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1033 wxNode
*next
= node
->GetNext();
1040 // Sets/clears the modified flag for each property value
1041 void wxPropertySheet::SetAllModified(bool flag
)
1043 wxNode
*node
= m_properties
.GetFirst();
1046 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1047 prop
->GetValue().SetModified(flag
);
1048 node
= node
->GetNext();
1053 * Property validator registry
1057 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry
, wxHashTable
)
1059 wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING
)
1063 wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
1068 void wxPropertyValidatorRegistry::RegisterValidator(const wxString
& typeName
, wxPropertyValidator
*validator
)
1070 Put((const wxChar
*) typeName
, validator
);
1073 wxPropertyValidator
*wxPropertyValidatorRegistry::GetValidator(const wxString
& typeName
)
1075 return (wxPropertyValidator
*)Get((const wxChar
*) typeName
);
1078 void wxPropertyValidatorRegistry::ClearRegistry(void)
1082 while ((node
= Next()) != NULL
)
1084 delete (wxPropertyValidator
*)node
->GetData();
1089 * Property validator
1093 IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator
, wxEvtHandler
)
1095 wxPropertyValidator::wxPropertyValidator(long flags
)
1097 m_validatorFlags
= flags
;
1098 m_validatorProperty
= NULL
;
1101 wxPropertyValidator::~wxPropertyValidator(void)
1104 bool wxPropertyValidator::StringToFloat (wxChar
*s
, float *number
) {
1106 bool ok
= StringToDouble (s
, &num
);
1107 *number
= (float) num
;
1111 bool wxPropertyValidator::StringToDouble (wxChar
*s
, double *number
) {
1114 *number
= wxStrtod (s
, &value_ptr
);
1116 int len
= wxStrlen (value_ptr
);
1117 for (int i
= 0; i
< len
; i
++) {
1118 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1119 if (!ok
) return FALSE
;
1125 bool wxPropertyValidator::StringToInt (wxChar
*s
, int *number
) {
1127 bool ok
= StringToLong (s
, &num
);
1128 *number
= (int) num
;
1132 bool wxPropertyValidator::StringToLong (wxChar
*s
, long *number
) {
1135 *number
= wxStrtol (s
, &value_ptr
, 10);
1137 int len
= wxStrlen (value_ptr
);
1138 for (int i
= 0; i
< len
; i
++) {
1139 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1140 if (!ok
) return FALSE
;
1146 wxChar
*wxPropertyValidator::FloatToString (float number
) {
1147 static wxChar buf
[20];
1148 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1152 wxChar
*wxPropertyValidator::DoubleToString (double number
) {
1153 static wxChar buf
[20];
1154 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1158 wxChar
*wxPropertyValidator::IntToString (int number
) {
1159 static wxChar buf
[20];
1161 wxSprintf (buf
, wxT("%d"), number
);
1165 wxChar
*wxPropertyValidator::LongToString (long number
) {
1166 static wxChar buf
[20];
1168 wxSprintf (buf
, wxT("%ld"), number
);
1172 #endif // wxUSE_PROPSHEET