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 #if !WXWIN_COMPATIBILITY_2_4
39 static inline wxChar
* copystring(const wxChar
* s
)
40 { return wxStrcpy(new wxChar
[wxStrlen(s
) + 1], s
); }
43 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue
, wxObject
)
45 wxPropertyValue::wxPropertyValue(void)
47 m_type
= wxPropertyValueNull
;
52 m_modifiedFlag
= FALSE
;
55 wxPropertyValue::wxPropertyValue(const wxPropertyValue
& copyFrom
)
58 m_value
.string
= (wxChar
*) NULL
;
59 m_modifiedFlag
= FALSE
;
60 Copy((wxPropertyValue
& )copyFrom
);
63 wxPropertyValue::wxPropertyValue(const wxChar
*val
)
65 m_modifiedFlag
= FALSE
;
66 m_type
= wxPropertyValueString
;
68 m_value
.string
= copystring(val
);
74 wxPropertyValue::wxPropertyValue(const wxString
& val
)
76 m_modifiedFlag
= FALSE
;
77 m_type
= wxPropertyValueString
;
79 m_value
.string
= copystring((const wxChar
*)val
);
85 wxPropertyValue::wxPropertyValue(long the_integer
)
87 m_modifiedFlag
= FALSE
;
88 m_type
= wxPropertyValueInteger
;
89 m_value
.integer
= the_integer
;
94 wxPropertyValue::wxPropertyValue(bool val
)
96 m_modifiedFlag
= FALSE
;
97 m_type
= wxPropertyValuebool
;
98 m_value
.integer
= val
;
103 wxPropertyValue::wxPropertyValue(float the_real
)
105 m_modifiedFlag
= FALSE
;
106 m_type
= wxPropertyValueReal
;
107 m_value
.real
= the_real
;
112 wxPropertyValue::wxPropertyValue(double the_real
)
114 m_modifiedFlag
= FALSE
;
115 m_type
= wxPropertyValueReal
;
116 m_value
.real
= (float)the_real
;
121 // Pointer versions: we have a pointer to the real C++ value.
122 wxPropertyValue::wxPropertyValue(wxChar
**val
)
124 m_modifiedFlag
= FALSE
;
125 m_type
= wxPropertyValueStringPtr
;
127 m_value
.stringPtr
= val
;
133 wxPropertyValue::wxPropertyValue(long *val
)
135 m_modifiedFlag
= FALSE
;
136 m_type
= wxPropertyValueIntegerPtr
;
137 m_value
.integerPtr
= val
;
142 wxPropertyValue::wxPropertyValue(bool *val
)
144 m_modifiedFlag
= FALSE
;
145 m_type
= wxPropertyValueboolPtr
;
146 m_value
.boolPtr
= val
;
151 wxPropertyValue::wxPropertyValue(float *val
)
153 m_modifiedFlag
= FALSE
;
154 m_type
= wxPropertyValueRealPtr
;
155 m_value
.realPtr
= val
;
160 wxPropertyValue::wxPropertyValue(wxList
*the_list
)
162 m_modifiedFlag
= FALSE
;
163 m_type
= wxPropertyValueList
;
166 m_value
.first
= NULL
;
168 wxNode
*node
= the_list
->GetFirst();
171 wxPropertyValue
*expr
= (wxPropertyValue
*)node
->GetData();
173 node
= node
->GetNext();
179 wxPropertyValue::wxPropertyValue(wxStringList
*the_list
)
181 m_modifiedFlag
= FALSE
;
182 m_type
= wxPropertyValueList
;
185 m_value
.first
= NULL
;
187 wxStringList::Node
*node
= the_list
->GetFirst();
190 wxChar
*s
= node
->GetData();
191 Append(new wxPropertyValue(s
));
192 node
= node
->GetNext();
197 wxPropertyValue::~wxPropertyValue(void)
201 case wxPropertyValueInteger
:
202 case wxPropertyValuebool
:
203 case wxPropertyValueReal
:
207 case wxPropertyValueString
:
209 delete[] m_value
.string
;
212 case wxPropertyValueList
:
214 wxPropertyValue
*expr
= m_value
.first
;
217 wxPropertyValue
*expr1
= expr
->m_next
;
225 case wxPropertyValueNull
: break;
229 void wxPropertyValue::Append(wxPropertyValue
*expr
)
231 m_modifiedFlag
= TRUE
;
233 m_value
.first
= expr
;
236 m_last
->m_next
= expr
;
240 void wxPropertyValue::Insert(wxPropertyValue
*expr
)
242 m_modifiedFlag
= TRUE
;
243 expr
->m_next
= m_value
.first
;
244 m_value
.first
= expr
;
251 void wxPropertyValue::Delete(wxPropertyValue
*node
)
253 wxPropertyValue
*expr
= GetFirst();
255 wxPropertyValue
*previous
= NULL
;
256 while (expr
&& (expr
!= node
))
259 expr
= expr
->GetNext();
265 previous
->m_next
= expr
->m_next
;
267 // If node was the first in the list,
268 // make the list point to the NEXT one.
269 if (GetFirst() == expr
)
271 m_value
.first
= expr
->m_next
;
274 // If node was the last in the list,
275 // make the list 'last' pointer point to the PREVIOUS one.
276 if (GetLast() == expr
)
283 m_modifiedFlag
= TRUE
;
289 void wxPropertyValue::ClearList(void)
291 wxPropertyValue
*val
= GetFirst();
293 m_modifiedFlag
= TRUE
;
297 wxPropertyValue
*next
= val
->GetNext();
301 m_value
.first
= NULL
;
305 wxPropertyValue
*wxPropertyValue::NewCopy(void) const
309 case wxPropertyValueInteger
:
310 return new wxPropertyValue(m_value
.integer
);
311 case wxPropertyValuebool
:
312 return new wxPropertyValue((bool) (m_value
.integer
!= 0));
313 case wxPropertyValueReal
:
314 return new wxPropertyValue(m_value
.real
);
315 case wxPropertyValueString
:
316 return new wxPropertyValue(m_value
.string
);
317 case wxPropertyValueList
:
319 wxPropertyValue
*expr
= m_value
.first
;
320 wxPropertyValue
*new_list
= new wxPropertyValue
;
321 new_list
->SetType(wxPropertyValueList
);
324 wxPropertyValue
*expr2
= expr
->NewCopy();
325 new_list
->Append(expr2
);
330 case wxPropertyValueIntegerPtr
:
331 return new wxPropertyValue(m_value
.integerPtr
);
332 case wxPropertyValueRealPtr
:
333 return new wxPropertyValue(m_value
.realPtr
);
334 case wxPropertyValueboolPtr
:
335 return new wxPropertyValue(m_value
.boolPtr
);
336 case wxPropertyValueStringPtr
:
337 return new wxPropertyValue(m_value
.stringPtr
);
339 case wxPropertyValueNull
:
340 wxFAIL_MSG( wxT("Should never get here!\n" ) );
346 void wxPropertyValue::Copy(wxPropertyValue
& copyFrom
)
348 if (m_type
== wxPropertyValueString
)
350 delete[] m_value
.string
;
351 m_value
.string
= NULL
;
353 m_type
= copyFrom
.Type();
357 case wxPropertyValueInteger
:
358 (*this) = copyFrom
.IntegerValue();
361 case wxPropertyValueReal
:
362 (*this) = copyFrom
.RealValue();
365 case wxPropertyValueString
:
366 (*this) = wxString(copyFrom
.StringValue());
369 case wxPropertyValuebool
:
370 (*this) = copyFrom
.BoolValue();
374 case wxPropertyValueboolPtr
:
375 (*this) = copyFrom
.BoolValuePtr();
377 case wxPropertyValueRealPtr
:
378 (*this) = copyFrom
.RealValuePtr();
380 case wxPropertyValueIntegerPtr
:
381 (*this) = copyFrom
.IntegerValuePtr();
383 case wxPropertyValueStringPtr
:
385 wxChar
** s
= copyFrom
.StringValuePtr();
388 // what is this? are you trying to assign a bool or a string? VA can't figure it out..
389 #if defined(__VISAGECPP__) || defined( __VISUALC__ )
396 (*this) = (bool)(s
!= 0);
401 case wxPropertyValueList
:
403 m_value
.first
= NULL
;
406 wxPropertyValue
*expr
= copyFrom
.m_value
.first
;
409 wxPropertyValue
*expr2
= expr
->NewCopy();
415 case wxPropertyValueNull
:
416 wxFAIL_MSG( wxT("Should never get here!\n" ) );
421 // Return nth argument of a clause (starting from 1)
422 wxPropertyValue
*wxPropertyValue::Arg(wxPropertyValueType type
, int arg
) const
424 wxPropertyValue
*expr
= m_value
.first
;
425 for (int i
= 1; i
< arg
; i
++)
429 if (expr
&& (expr
->m_type
== type
))
435 // Return nth argument of a list expression (starting from zero)
436 wxPropertyValue
*wxPropertyValue::Nth(int arg
) const
438 if (m_type
!= wxPropertyValueList
)
441 wxPropertyValue
*expr
= m_value
.first
;
442 for (int i
= 0; i
< arg
; i
++)
453 // Returns the number of elements in a list expression
454 int wxPropertyValue::Number(void) const
456 if (m_type
!= wxPropertyValueList
)
460 wxPropertyValue
*expr
= m_value
.first
;
469 void wxPropertyValue::WritePropertyClause(wxString
& stream
) // Write this expression as a top-level clause
471 if (m_type
!= wxPropertyValueList
)
474 wxPropertyValue
*node
= m_value
.first
;
477 node
->WritePropertyType(stream
);
478 stream
.Append( wxT("(") );
484 stream
.Append( wxT(" ") );
485 node
->WritePropertyType(stream
);
488 stream
.Append( wxT(",\n" ) );
491 stream
.Append( wxT(").\n\n") );
495 void wxPropertyValue::WritePropertyType(wxString
& stream
) // Write as any other subexpression
500 case wxPropertyValueInteger
:
502 tmp
.Printf( wxT("%ld"), m_value
.integer
);
503 stream
.Append( tmp
);
506 case wxPropertyValueIntegerPtr
:
508 tmp
.Printf( wxT("%ld"), *m_value
.integerPtr
);
509 stream
.Append( tmp
);
512 case wxPropertyValuebool
:
515 stream
.Append( wxT("True") );
517 stream
.Append( wxT("False") );
520 case wxPropertyValueboolPtr
:
522 if (*m_value
.integerPtr
)
523 stream
.Append( wxT("True") );
525 stream
.Append( wxT("False") );
528 case wxPropertyValueReal
:
530 double d
= m_value
.real
;
531 tmp
.Printf( wxT("%.6g"), d
);
532 stream
.Append( tmp
);
535 case wxPropertyValueRealPtr
:
537 double d
= *m_value
.realPtr
;
538 tmp
.Printf( wxT("%.6g"), d
);
539 stream
.Append( tmp
);
542 case wxPropertyValueString
:
544 stream
.Append( m_value
.string
);
547 case wxPropertyValueStringPtr
:
549 wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );
552 int len = strlen(*(m_value.stringPtr));
553 for (i = 0; i < len; i++)
555 char ch = *(m_value.stringPtr)[i];
561 case wxPropertyValueList
:
564 stream
.Append( wxT("[]") );
567 wxPropertyValue
*expr
= m_value
.first
;
569 stream
.Append( wxT("[") );
572 expr
->WritePropertyType(stream
);
575 stream
.Append( wxT(", ") );
577 stream
.Append( wxT("]") );
581 case wxPropertyValueNull
: break;
585 wxString
wxPropertyValue::GetStringRepresentation(void)
588 WritePropertyType(str
);
592 void wxPropertyValue::operator=(const wxPropertyValue
& val
)
594 m_modifiedFlag
= TRUE
;
595 Copy((wxPropertyValue
&)val
);
598 // void wxPropertyValue::operator=(const char *val)
599 void wxPropertyValue::operator=(const wxString
& val1
)
601 const wxChar
*val
= (const wxChar
*)val1
;
603 m_modifiedFlag
= TRUE
;
605 wxPropertyValueType oldType
= m_type
;
606 if (oldType
== wxPropertyValueString
)
608 delete[] m_value
.string
;
609 m_value
.string
= NULL
;
612 if (m_type
== wxPropertyValueNull
)
613 m_type
= wxPropertyValueString
;
615 if (m_type
== wxPropertyValueString
)
618 m_value
.string
= copystring(val
);
620 m_value
.string
= NULL
;
622 else if (m_type
== wxPropertyValueStringPtr
)
624 wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") );
626 *m_value
.stringPtr
= copystring(val
);
628 *m_value
.stringPtr
= NULL
;
637 void wxPropertyValue::operator=(const long val
)
639 wxPropertyValueType oldType
= m_type
;
640 if (oldType
== wxPropertyValueString
)
642 delete[] m_value
.string
;
643 m_value
.string
= NULL
;
646 m_modifiedFlag
= TRUE
;
647 if (m_type
== wxPropertyValueNull
)
648 m_type
= wxPropertyValueInteger
;
650 if (m_type
== wxPropertyValueInteger
)
651 m_value
.integer
= val
;
652 else if (m_type
== wxPropertyValueIntegerPtr
)
653 *m_value
.integerPtr
= val
;
654 else if (m_type
== wxPropertyValueReal
)
655 m_value
.real
= (float)val
;
656 else if (m_type
== wxPropertyValueRealPtr
)
657 *m_value
.realPtr
= (float)val
;
663 void wxPropertyValue::operator=(const bool val
)
665 wxPropertyValueType oldType
= m_type
;
666 if (oldType
== wxPropertyValueString
)
668 delete[] m_value
.string
;
669 m_value
.string
= NULL
;
672 m_modifiedFlag
= TRUE
;
673 if (m_type
== wxPropertyValueNull
)
674 m_type
= wxPropertyValuebool
;
676 if (m_type
== wxPropertyValuebool
)
677 m_value
.integer
= (long)val
;
678 else if (m_type
== wxPropertyValueboolPtr
)
679 *m_value
.boolPtr
= val
;
685 void wxPropertyValue::operator=(const float val
)
687 wxPropertyValueType oldType
= m_type
;
688 if (oldType
== wxPropertyValueString
)
690 delete[] m_value
.string
;
691 m_value
.string
= NULL
;
694 m_modifiedFlag
= TRUE
;
695 if (m_type
== wxPropertyValueNull
)
696 m_type
= wxPropertyValueReal
;
698 if (m_type
== wxPropertyValueInteger
)
699 m_value
.integer
= (long)val
;
700 else if (m_type
== wxPropertyValueIntegerPtr
)
701 *m_value
.integerPtr
= (long)val
;
702 else if (m_type
== wxPropertyValueReal
)
704 else if (m_type
== wxPropertyValueRealPtr
)
705 *m_value
.realPtr
= val
;
711 void wxPropertyValue::operator=(const wxChar
**val
)
713 wxPropertyValueType oldType
= m_type
;
714 if (oldType
== wxPropertyValueString
)
716 delete[] m_value
.string
;
717 m_value
.string
= NULL
;
720 m_modifiedFlag
= TRUE
;
721 m_type
= wxPropertyValueStringPtr
;
724 m_value
.stringPtr
= (wxChar
**)val
;
726 m_value
.stringPtr
= NULL
;
733 void wxPropertyValue::operator=(const long *val
)
735 m_modifiedFlag
= TRUE
;
736 m_type
= wxPropertyValueIntegerPtr
;
737 m_value
.integerPtr
= (long *)val
;
742 void wxPropertyValue::operator=(const bool *val
)
744 m_modifiedFlag
= TRUE
;
745 m_type
= wxPropertyValueboolPtr
;
746 m_value
.boolPtr
= (bool *)val
;
751 void wxPropertyValue::operator=(const float *val
)
753 m_modifiedFlag
= TRUE
;
754 m_type
= wxPropertyValueRealPtr
;
755 m_value
.realPtr
= (float *)val
;
760 long wxPropertyValue::IntegerValue(void) const
762 if (m_type
== wxPropertyValueInteger
)
763 return m_value
.integer
;
764 else if (m_type
== wxPropertyValueReal
)
765 return (long)m_value
.real
;
766 else if (m_type
== wxPropertyValueIntegerPtr
)
767 return *m_value
.integerPtr
;
768 else if (m_type
== wxPropertyValueRealPtr
)
769 return (long)(*m_value
.realPtr
);
773 long *wxPropertyValue::IntegerValuePtr(void) const
775 return m_value
.integerPtr
;
778 float wxPropertyValue::RealValue(void) const {
779 if (m_type
== wxPropertyValueReal
)
781 else if (m_type
== wxPropertyValueRealPtr
)
782 return *m_value
.realPtr
;
783 else if (m_type
== wxPropertyValueInteger
)
784 return (float)m_value
.integer
;
785 else if (m_type
== wxPropertyValueIntegerPtr
)
786 return (float)*(m_value
.integerPtr
);
790 float *wxPropertyValue::RealValuePtr(void) const
792 return m_value
.realPtr
;
795 bool wxPropertyValue::BoolValue(void) const {
796 if (m_type
== wxPropertyValueReal
)
797 return (m_value
.real
!= 0.0);
798 if (m_type
== wxPropertyValueRealPtr
)
799 return (*(m_value
.realPtr
) != 0.0);
800 else if (m_type
== wxPropertyValueInteger
)
801 return (m_value
.integer
!= 0);
802 else if (m_type
== wxPropertyValueIntegerPtr
)
803 return (*(m_value
.integerPtr
) != 0);
804 else if (m_type
== wxPropertyValuebool
)
805 return (m_value
.integer
!= 0);
806 else if (m_type
== wxPropertyValueboolPtr
)
807 return (*(m_value
.boolPtr
) != 0);
811 bool *wxPropertyValue::BoolValuePtr(void) const
813 return m_value
.boolPtr
;
816 wxChar
*wxPropertyValue::StringValue(void) const {
817 if (m_type
== wxPropertyValueString
)
818 return m_value
.string
;
819 else if (m_type
== wxPropertyValueStringPtr
)
820 return *(m_value
.stringPtr
);
824 wxChar
**wxPropertyValue::StringValuePtr(void) const
826 return m_value
.stringPtr
;
830 * A property (name plus value)
833 IMPLEMENT_DYNAMIC_CLASS(wxProperty
, wxObject
)
835 wxProperty::wxProperty(void)
837 m_propertyRole
= wxEmptyString
;
838 m_propertyValidator
= NULL
;
839 m_propertyWindow
= NULL
;
843 wxProperty::wxProperty(wxProperty
& copyFrom
)
846 m_value
= copyFrom
.GetValue();
847 m_name
= copyFrom
.GetName();
848 m_propertyRole
= copyFrom
.GetRole();
849 m_propertyValidator
= copyFrom
.GetValidator();
850 m_enabled
= copyFrom
.IsEnabled();
851 m_propertyWindow
= NULL
;
854 wxProperty::wxProperty(wxString nm
, wxString role
, wxPropertyValidator
*ed
):m_name(nm
), m_propertyRole(role
)
856 m_propertyValidator
= ed
;
857 m_propertyWindow
= NULL
;
861 wxProperty::wxProperty(wxString nm
, const wxPropertyValue
& val
, wxString role
, wxPropertyValidator
*ed
):
862 m_value(val
), m_name(nm
), m_propertyRole(role
)
864 m_propertyValidator
= ed
;
865 m_propertyWindow
= NULL
;
869 wxProperty::~wxProperty(void)
871 if (m_propertyValidator
)
872 delete m_propertyValidator
;
875 wxPropertyValue
& wxProperty::GetValue(void) const
877 return (wxPropertyValue
&) m_value
;
880 wxPropertyValidator
*wxProperty::GetValidator(void) const
882 return m_propertyValidator
;
885 wxString
& wxProperty::GetName(void) const
887 return (wxString
&) m_name
;
890 wxString
& wxProperty::GetRole(void) const
892 return (wxString
&) m_propertyRole
;
895 void wxProperty::SetValue(const wxPropertyValue
& val
)
900 void wxProperty::SetValidator(wxPropertyValidator
*ed
)
902 m_propertyValidator
= ed
;
905 void wxProperty::SetRole(wxString
& role
)
907 m_propertyRole
= role
;
910 void wxProperty::SetName(wxString
& nm
)
915 void wxProperty::operator=(const wxPropertyValue
& val
)
921 * Base property view class
924 IMPLEMENT_DYNAMIC_CLASS(wxPropertyView
, wxEvtHandler
)
926 wxPropertyView::wxPropertyView(long flags
)
928 m_buttonFlags
= flags
;
929 m_propertySheet
= NULL
;
930 m_currentValidator
= NULL
;
931 m_currentProperty
= NULL
;
934 wxPropertyView::~wxPropertyView(void)
938 void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry
*registry
)
940 m_validatorRegistryList
.Append(registry
);
943 wxPropertyValidator
*wxPropertyView::FindPropertyValidator(wxProperty
*property
)
945 if (property
->GetValidator())
946 return property
->GetValidator();
948 wxNode
*node
= m_validatorRegistryList
.GetFirst();
951 wxPropertyValidatorRegistry
*registry
= (wxPropertyValidatorRegistry
*)node
->GetData();
952 wxPropertyValidator
*validator
= registry
->GetValidator(property
->GetRole());
955 node
= node
->GetNext();
959 if (!wxDefaultPropertyValidator)
960 wxDefaultPropertyValidator = new wxPropertyListValidator;
961 return wxDefaultPropertyValidator;
969 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet
, wxObject
)
971 wxPropertySheet::wxPropertySheet(const wxString
& name
)
972 :m_properties(wxKEY_STRING
),m_name(name
)
976 wxPropertySheet::~wxPropertySheet(void)
981 void wxPropertySheet::UpdateAllViews( wxPropertyView
*WXUNUSED(thisView
) )
986 void wxPropertySheet::AddProperty(wxProperty
*property
)
988 m_properties
.Append((const wxChar
*) property
->GetName(), property
);
991 // Get property by name
992 wxProperty
*wxPropertySheet::GetProperty(const wxString
& name
) const
994 wxNode
*node
= m_properties
.Find((const wxChar
*) name
);
998 return (wxProperty
*)node
->GetData();
1001 bool wxPropertySheet::SetProperty(const wxString
& name
, const wxPropertyValue
& value
)
1003 wxProperty
* prop
= GetProperty(name
);
1005 prop
->SetValue(value
);
1012 void wxPropertySheet::RemoveProperty(const wxString
& name
)
1014 wxNode
*node
= m_properties
.Find(name
);
1017 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1019 m_properties
.DeleteNode(node
);
1023 bool wxPropertySheet::HasProperty(const wxString
& name
) const
1025 return (GetProperty(name
)?TRUE
:FALSE
);
1028 // Clear all properties
1029 void wxPropertySheet::Clear(void)
1031 wxNode
*node
= m_properties
.GetFirst();
1034 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1035 wxNode
*next
= node
->GetNext();
1042 // Sets/clears the modified flag for each property value
1043 void wxPropertySheet::SetAllModified(bool flag
)
1045 wxNode
*node
= m_properties
.GetFirst();
1048 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1049 prop
->GetValue().SetModified(flag
);
1050 node
= node
->GetNext();
1055 * Property validator registry
1059 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry
, wxHashTable
)
1061 wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING
)
1065 wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
1070 void wxPropertyValidatorRegistry::RegisterValidator(const wxString
& typeName
, wxPropertyValidator
*validator
)
1072 Put((const wxChar
*) typeName
, validator
);
1075 wxPropertyValidator
*wxPropertyValidatorRegistry::GetValidator(const wxString
& typeName
)
1077 return (wxPropertyValidator
*)Get((const wxChar
*) typeName
);
1080 void wxPropertyValidatorRegistry::ClearRegistry(void)
1083 wxHashTable::Node
*node
;
1084 while ((node
= Next()) != NULL
)
1086 delete (wxPropertyValidator
*)node
->GetData();
1091 * Property validator
1095 IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator
, wxEvtHandler
)
1097 wxPropertyValidator::wxPropertyValidator(long flags
)
1099 m_validatorFlags
= flags
;
1100 m_validatorProperty
= NULL
;
1103 wxPropertyValidator::~wxPropertyValidator(void)
1106 bool wxPropertyValidator::StringToFloat (wxChar
*s
, float *number
) {
1108 bool ok
= StringToDouble (s
, &num
);
1109 *number
= (float) num
;
1113 bool wxPropertyValidator::StringToDouble (wxChar
*s
, double *number
) {
1116 *number
= wxStrtod (s
, &value_ptr
);
1118 int len
= wxStrlen (value_ptr
);
1119 for (int i
= 0; i
< len
; i
++) {
1120 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1121 if (!ok
) return FALSE
;
1127 bool wxPropertyValidator::StringToInt (wxChar
*s
, int *number
) {
1129 bool ok
= StringToLong (s
, &num
);
1130 *number
= (int) num
;
1134 bool wxPropertyValidator::StringToLong (wxChar
*s
, long *number
) {
1137 *number
= wxStrtol (s
, &value_ptr
, 10);
1139 int len
= wxStrlen (value_ptr
);
1140 for (int i
= 0; i
< len
; i
++) {
1141 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1142 if (!ok
) return FALSE
;
1148 wxChar
*wxPropertyValidator::FloatToString (float number
) {
1149 static wxChar buf
[20];
1150 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1154 wxChar
*wxPropertyValidator::DoubleToString (double number
) {
1155 static wxChar buf
[20];
1156 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1160 wxChar
*wxPropertyValidator::IntToString (int number
) {
1161 static wxChar buf
[20];
1163 wxSprintf (buf
, wxT("%d"), number
);
1167 wxChar
*wxPropertyValidator::LongToString (long number
) {
1168 static wxChar buf
[20];
1170 wxSprintf (buf
, wxT("%ld"), number
);
1174 #endif // wxUSE_PROPSHEET