1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Propert sheet classes implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/deprecated/setup.h"
27 #include "wx/deprecated/prop.h"
34 #if !WXWIN_COMPATIBILITY_2_4
35 static inline wxChar
* copystring(const wxChar
* s
)
36 { return wxStrcpy(new wxChar
[wxStrlen(s
) + 1], s
); }
39 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue
, wxObject
)
41 wxPropertyValue::wxPropertyValue(void)
43 m_type
= wxPropertyValueNull
;
48 m_modifiedFlag
= false;
51 wxPropertyValue::wxPropertyValue(const wxPropertyValue
& copyFrom
)
54 m_value
.string
= (wxChar
*) NULL
;
55 m_modifiedFlag
= false;
56 Copy((wxPropertyValue
& )copyFrom
);
59 wxPropertyValue::wxPropertyValue(const wxChar
*val
)
61 m_modifiedFlag
= false;
62 m_type
= wxPropertyValueString
;
64 m_value
.string
= copystring(val
);
70 wxPropertyValue::wxPropertyValue(const wxString
& val
)
72 m_modifiedFlag
= false;
73 m_type
= wxPropertyValueString
;
75 m_value
.string
= copystring(val
.c_str());
81 wxPropertyValue::wxPropertyValue(long the_integer
)
83 m_modifiedFlag
= false;
84 m_type
= wxPropertyValueInteger
;
85 m_value
.integer
= the_integer
;
90 wxPropertyValue::wxPropertyValue(bool val
)
92 m_modifiedFlag
= false;
93 m_type
= wxPropertyValuebool
;
94 m_value
.integer
= val
;
99 wxPropertyValue::wxPropertyValue(float the_real
)
101 m_modifiedFlag
= false;
102 m_type
= wxPropertyValueReal
;
103 m_value
.real
= the_real
;
108 wxPropertyValue::wxPropertyValue(double the_real
)
110 m_modifiedFlag
= false;
111 m_type
= wxPropertyValueReal
;
112 m_value
.real
= (float)the_real
;
117 // Pointer versions: we have a pointer to the real C++ value.
118 wxPropertyValue::wxPropertyValue(wxChar
**val
)
120 m_modifiedFlag
= false;
121 m_type
= wxPropertyValueStringPtr
;
123 m_value
.stringPtr
= val
;
129 wxPropertyValue::wxPropertyValue(long *val
)
131 m_modifiedFlag
= false;
132 m_type
= wxPropertyValueIntegerPtr
;
133 m_value
.integerPtr
= val
;
138 wxPropertyValue::wxPropertyValue(bool *val
)
140 m_modifiedFlag
= false;
141 m_type
= wxPropertyValueboolPtr
;
142 m_value
.boolPtr
= val
;
147 wxPropertyValue::wxPropertyValue(float *val
)
149 m_modifiedFlag
= false;
150 m_type
= wxPropertyValueRealPtr
;
151 m_value
.realPtr
= val
;
156 wxPropertyValue::wxPropertyValue(wxList
*the_list
)
158 m_modifiedFlag
= false;
159 m_type
= wxPropertyValueList
;
162 m_value
.first
= NULL
;
164 wxObjectList::compatibility_iterator node
= the_list
->GetFirst();
167 wxPropertyValue
*expr
= (wxPropertyValue
*)node
->GetData();
169 node
= node
->GetNext();
175 wxPropertyValue::wxPropertyValue(wxStringList
*the_list
)
177 m_modifiedFlag
= false;
178 m_type
= wxPropertyValueList
;
181 m_value
.first
= NULL
;
183 wxStringList::compatibility_iterator node
= the_list
->GetFirst();
186 wxString s
= node
->GetData();
187 Append(new wxPropertyValue(s
));
188 node
= node
->GetNext();
193 wxPropertyValue::~wxPropertyValue(void)
197 case wxPropertyValueInteger
:
198 case wxPropertyValuebool
:
199 case wxPropertyValueReal
:
203 case wxPropertyValueString
:
205 delete[] m_value
.string
;
208 case wxPropertyValueList
:
210 wxPropertyValue
*expr
= m_value
.first
;
213 wxPropertyValue
*expr1
= expr
->m_next
;
221 case wxPropertyValueNull
: break;
225 void wxPropertyValue::Append(wxPropertyValue
*expr
)
227 m_modifiedFlag
= true;
229 m_value
.first
= expr
;
232 m_last
->m_next
= expr
;
236 void wxPropertyValue::Insert(wxPropertyValue
*expr
)
238 m_modifiedFlag
= true;
239 expr
->m_next
= m_value
.first
;
240 m_value
.first
= expr
;
247 void wxPropertyValue::Delete(wxPropertyValue
*node
)
249 wxPropertyValue
*expr
= GetFirst();
251 wxPropertyValue
*previous
= NULL
;
252 while (expr
&& (expr
!= node
))
255 expr
= expr
->GetNext();
261 previous
->m_next
= expr
->m_next
;
263 // If node was the first in the list,
264 // make the list point to the NEXT one.
265 if (GetFirst() == expr
)
267 m_value
.first
= expr
->m_next
;
270 // If node was the last in the list,
271 // make the list 'last' pointer point to the PREVIOUS one.
272 if (GetLast() == expr
)
279 m_modifiedFlag
= true;
285 void wxPropertyValue::ClearList(void)
287 wxPropertyValue
*val
= GetFirst();
289 m_modifiedFlag
= true;
293 wxPropertyValue
*next
= val
->GetNext();
297 m_value
.first
= NULL
;
301 wxPropertyValue
*wxPropertyValue::NewCopy(void) const
305 case wxPropertyValueInteger
:
306 return new wxPropertyValue(m_value
.integer
);
307 case wxPropertyValuebool
:
308 return new wxPropertyValue((bool) (m_value
.integer
!= 0));
309 case wxPropertyValueReal
:
310 return new wxPropertyValue(m_value
.real
);
311 case wxPropertyValueString
:
312 return new wxPropertyValue(m_value
.string
);
313 case wxPropertyValueList
:
315 wxPropertyValue
*expr
= m_value
.first
;
316 wxPropertyValue
*new_list
= new wxPropertyValue
;
317 new_list
->SetType(wxPropertyValueList
);
320 wxPropertyValue
*expr2
= expr
->NewCopy();
321 new_list
->Append(expr2
);
326 case wxPropertyValueIntegerPtr
:
327 return new wxPropertyValue(m_value
.integerPtr
);
328 case wxPropertyValueRealPtr
:
329 return new wxPropertyValue(m_value
.realPtr
);
330 case wxPropertyValueboolPtr
:
331 return new wxPropertyValue(m_value
.boolPtr
);
332 case wxPropertyValueStringPtr
:
333 return new wxPropertyValue(m_value
.stringPtr
);
335 case wxPropertyValueNull
:
336 wxFAIL_MSG( wxT("Should never get here!\n" ) );
342 void wxPropertyValue::Copy(wxPropertyValue
& copyFrom
)
344 if (m_type
== wxPropertyValueString
)
346 delete[] m_value
.string
;
347 m_value
.string
= NULL
;
349 m_type
= copyFrom
.Type();
353 case wxPropertyValueInteger
:
354 (*this) = copyFrom
.IntegerValue();
357 case wxPropertyValueReal
:
358 (*this) = copyFrom
.RealValue();
361 case wxPropertyValueString
:
362 (*this) = wxString(copyFrom
.StringValue());
365 case wxPropertyValuebool
:
366 (*this) = copyFrom
.BoolValue();
370 case wxPropertyValueboolPtr
:
371 (*this) = copyFrom
.BoolValuePtr();
373 case wxPropertyValueRealPtr
:
374 (*this) = copyFrom
.RealValuePtr();
376 case wxPropertyValueIntegerPtr
:
377 (*this) = copyFrom
.IntegerValuePtr();
379 case wxPropertyValueStringPtr
:
381 wxChar
** s
= copyFrom
.StringValuePtr();
384 // what is this? are you trying to assign a bool or a string? VA can't figure it out..
385 #if defined(__VISAGECPP__) || defined( __VISUALC__ )
392 (*this) = (bool)(s
!= 0);
397 case wxPropertyValueList
:
399 m_value
.first
= NULL
;
402 wxPropertyValue
*expr
= copyFrom
.m_value
.first
;
405 wxPropertyValue
*expr2
= expr
->NewCopy();
411 case wxPropertyValueNull
:
412 wxFAIL_MSG( wxT("Should never get here!\n" ) );
417 // Return nth argument of a clause (starting from 1)
418 wxPropertyValue
*wxPropertyValue::Arg(wxPropertyValueType type
, int arg
) const
420 wxPropertyValue
*expr
= m_value
.first
;
421 for (int i
= 1; i
< arg
; i
++)
425 if (expr
&& (expr
->m_type
== type
))
431 // Return nth argument of a list expression (starting from zero)
432 wxPropertyValue
*wxPropertyValue::Nth(int arg
) const
434 if (m_type
!= wxPropertyValueList
)
437 wxPropertyValue
*expr
= m_value
.first
;
438 for (int i
= 0; i
< arg
; i
++)
449 // Returns the number of elements in a list expression
450 int wxPropertyValue::Number(void) const
452 if (m_type
!= wxPropertyValueList
)
456 wxPropertyValue
*expr
= m_value
.first
;
465 void wxPropertyValue::WritePropertyClause(wxString
& stream
) // Write this expression as a top-level clause
467 if (m_type
!= wxPropertyValueList
)
470 wxPropertyValue
*node
= m_value
.first
;
473 node
->WritePropertyType(stream
);
474 stream
.Append( wxT("(") );
480 stream
.Append( wxT(" ") );
481 node
->WritePropertyType(stream
);
484 stream
.Append( wxT(",\n" ) );
487 stream
.Append( wxT(").\n\n") );
491 void wxPropertyValue::WritePropertyType(wxString
& stream
) // Write as any other subexpression
496 case wxPropertyValueInteger
:
498 tmp
.Printf( wxT("%ld"), m_value
.integer
);
499 stream
.Append( tmp
);
502 case wxPropertyValueIntegerPtr
:
504 tmp
.Printf( wxT("%ld"), *m_value
.integerPtr
);
505 stream
.Append( tmp
);
508 case wxPropertyValuebool
:
511 stream
.Append( wxT("True") );
513 stream
.Append( wxT("False") );
516 case wxPropertyValueboolPtr
:
518 if (*m_value
.integerPtr
)
519 stream
.Append( wxT("True") );
521 stream
.Append( wxT("False") );
524 case wxPropertyValueReal
:
526 double d
= m_value
.real
;
527 tmp
.Printf( wxT("%.6g"), d
);
528 stream
.Append( tmp
);
531 case wxPropertyValueRealPtr
:
533 double d
= *m_value
.realPtr
;
534 tmp
.Printf( wxT("%.6g"), d
);
535 stream
.Append( tmp
);
538 case wxPropertyValueString
:
540 stream
.Append( m_value
.string
);
543 case wxPropertyValueStringPtr
:
545 wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );
548 int len = strlen(*(m_value.stringPtr));
549 for (i = 0; i < len; i++)
551 char ch = *(m_value.stringPtr)[i];
557 case wxPropertyValueList
:
560 stream
.Append( wxT("[]") );
563 wxPropertyValue
*expr
= m_value
.first
;
565 stream
.Append( wxT("[") );
568 expr
->WritePropertyType(stream
);
571 stream
.Append( wxT(", ") );
573 stream
.Append( wxT("]") );
577 case wxPropertyValueNull
: break;
581 wxString
wxPropertyValue::GetStringRepresentation(void)
584 WritePropertyType(str
);
588 void wxPropertyValue::operator=(const wxPropertyValue
& val
)
590 m_modifiedFlag
= true;
591 Copy((wxPropertyValue
&)val
);
594 // void wxPropertyValue::operator=(const char *val)
595 void wxPropertyValue::operator=(const wxString
& val1
)
597 const wxChar
*val
= (const wxChar
*)val1
;
599 m_modifiedFlag
= true;
601 wxPropertyValueType oldType
= m_type
;
602 if (oldType
== wxPropertyValueString
)
604 delete[] m_value
.string
;
605 m_value
.string
= NULL
;
608 if (m_type
== wxPropertyValueNull
)
609 m_type
= wxPropertyValueString
;
611 if (m_type
== wxPropertyValueString
)
614 m_value
.string
= copystring(val
);
616 m_value
.string
= NULL
;
618 else if (m_type
== wxPropertyValueStringPtr
)
620 wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") );
622 *m_value
.stringPtr
= copystring(val
);
624 *m_value
.stringPtr
= NULL
;
633 void wxPropertyValue::operator=(const long val
)
635 wxPropertyValueType oldType
= m_type
;
636 if (oldType
== wxPropertyValueString
)
638 delete[] m_value
.string
;
639 m_value
.string
= NULL
;
642 m_modifiedFlag
= true;
643 if (m_type
== wxPropertyValueNull
)
644 m_type
= wxPropertyValueInteger
;
646 if (m_type
== wxPropertyValueInteger
)
647 m_value
.integer
= val
;
648 else if (m_type
== wxPropertyValueIntegerPtr
)
649 *m_value
.integerPtr
= val
;
650 else if (m_type
== wxPropertyValueReal
)
651 m_value
.real
= (float)val
;
652 else if (m_type
== wxPropertyValueRealPtr
)
653 *m_value
.realPtr
= (float)val
;
659 void wxPropertyValue::operator=(const bool val
)
661 wxPropertyValueType oldType
= m_type
;
662 if (oldType
== wxPropertyValueString
)
664 delete[] m_value
.string
;
665 m_value
.string
= NULL
;
668 m_modifiedFlag
= true;
669 if (m_type
== wxPropertyValueNull
)
670 m_type
= wxPropertyValuebool
;
672 if (m_type
== wxPropertyValuebool
)
673 m_value
.integer
= (long)val
;
674 else if (m_type
== wxPropertyValueboolPtr
)
675 *m_value
.boolPtr
= val
;
681 void wxPropertyValue::operator=(const float val
)
683 wxPropertyValueType oldType
= m_type
;
684 if (oldType
== wxPropertyValueString
)
686 delete[] m_value
.string
;
687 m_value
.string
= NULL
;
690 m_modifiedFlag
= true;
691 if (m_type
== wxPropertyValueNull
)
692 m_type
= wxPropertyValueReal
;
694 if (m_type
== wxPropertyValueInteger
)
695 m_value
.integer
= (long)val
;
696 else if (m_type
== wxPropertyValueIntegerPtr
)
697 *m_value
.integerPtr
= (long)val
;
698 else if (m_type
== wxPropertyValueReal
)
700 else if (m_type
== wxPropertyValueRealPtr
)
701 *m_value
.realPtr
= val
;
707 void wxPropertyValue::operator=(const wxChar
**val
)
709 wxPropertyValueType oldType
= m_type
;
710 if (oldType
== wxPropertyValueString
)
712 delete[] m_value
.string
;
713 m_value
.string
= NULL
;
716 m_modifiedFlag
= true;
717 m_type
= wxPropertyValueStringPtr
;
720 m_value
.stringPtr
= (wxChar
**)val
;
722 m_value
.stringPtr
= NULL
;
729 void wxPropertyValue::operator=(const long *val
)
731 m_modifiedFlag
= true;
732 m_type
= wxPropertyValueIntegerPtr
;
733 m_value
.integerPtr
= (long *)val
;
738 void wxPropertyValue::operator=(const bool *val
)
740 m_modifiedFlag
= true;
741 m_type
= wxPropertyValueboolPtr
;
742 m_value
.boolPtr
= (bool *)val
;
747 void wxPropertyValue::operator=(const float *val
)
749 m_modifiedFlag
= true;
750 m_type
= wxPropertyValueRealPtr
;
751 m_value
.realPtr
= (float *)val
;
756 long wxPropertyValue::IntegerValue(void) const
758 if (m_type
== wxPropertyValueInteger
)
759 return m_value
.integer
;
760 else if (m_type
== wxPropertyValueReal
)
761 return (long)m_value
.real
;
762 else if (m_type
== wxPropertyValueIntegerPtr
)
763 return *m_value
.integerPtr
;
764 else if (m_type
== wxPropertyValueRealPtr
)
765 return (long)(*m_value
.realPtr
);
769 long *wxPropertyValue::IntegerValuePtr(void) const
771 return m_value
.integerPtr
;
774 float wxPropertyValue::RealValue(void) const {
775 if (m_type
== wxPropertyValueReal
)
777 else if (m_type
== wxPropertyValueRealPtr
)
778 return *m_value
.realPtr
;
779 else if (m_type
== wxPropertyValueInteger
)
780 return (float)m_value
.integer
;
781 else if (m_type
== wxPropertyValueIntegerPtr
)
782 return (float)*(m_value
.integerPtr
);
786 float *wxPropertyValue::RealValuePtr(void) const
788 return m_value
.realPtr
;
791 bool wxPropertyValue::BoolValue(void) const {
792 if (m_type
== wxPropertyValueReal
)
793 return (m_value
.real
!= 0.0);
794 if (m_type
== wxPropertyValueRealPtr
)
795 return (*(m_value
.realPtr
) != 0.0);
796 else if (m_type
== wxPropertyValueInteger
)
797 return (m_value
.integer
!= 0);
798 else if (m_type
== wxPropertyValueIntegerPtr
)
799 return (*(m_value
.integerPtr
) != 0);
800 else if (m_type
== wxPropertyValuebool
)
801 return (m_value
.integer
!= 0);
802 else if (m_type
== wxPropertyValueboolPtr
)
803 return (*(m_value
.boolPtr
) != 0);
807 bool *wxPropertyValue::BoolValuePtr(void) const
809 return m_value
.boolPtr
;
812 wxChar
*wxPropertyValue::StringValue(void) const {
813 if (m_type
== wxPropertyValueString
)
814 return m_value
.string
;
815 else if (m_type
== wxPropertyValueStringPtr
)
816 return *(m_value
.stringPtr
);
820 wxChar
**wxPropertyValue::StringValuePtr(void) const
822 return m_value
.stringPtr
;
826 * A property (name plus value)
829 IMPLEMENT_DYNAMIC_CLASS(wxProperty
, wxObject
)
831 wxProperty::wxProperty(void)
833 m_propertyRole
= wxEmptyString
;
834 m_propertyValidator
= NULL
;
835 m_propertyWindow
= NULL
;
839 wxProperty::wxProperty(wxProperty
& copyFrom
)
842 m_value
= copyFrom
.GetValue();
843 m_name
= copyFrom
.GetName();
844 m_propertyRole
= copyFrom
.GetRole();
845 m_propertyValidator
= copyFrom
.GetValidator();
846 m_enabled
= copyFrom
.IsEnabled();
847 m_propertyWindow
= NULL
;
850 wxProperty::wxProperty(wxString nm
, wxString role
, wxPropertyValidator
*ed
):m_name(nm
), m_propertyRole(role
)
852 m_propertyValidator
= ed
;
853 m_propertyWindow
= NULL
;
857 wxProperty::wxProperty(wxString nm
, const wxPropertyValue
& val
, wxString role
, wxPropertyValidator
*ed
):
858 m_value(val
), m_name(nm
), m_propertyRole(role
)
860 m_propertyValidator
= ed
;
861 m_propertyWindow
= NULL
;
865 wxProperty::~wxProperty(void)
867 if (m_propertyValidator
)
868 delete m_propertyValidator
;
871 wxPropertyValue
& wxProperty::GetValue(void) const
873 return (wxPropertyValue
&) m_value
;
876 wxPropertyValidator
*wxProperty::GetValidator(void) const
878 return m_propertyValidator
;
881 wxString
& wxProperty::GetName(void) const
883 return (wxString
&) m_name
;
886 wxString
& wxProperty::GetRole(void) const
888 return (wxString
&) m_propertyRole
;
891 void wxProperty::SetValue(const wxPropertyValue
& val
)
896 void wxProperty::SetValidator(wxPropertyValidator
*ed
)
898 m_propertyValidator
= ed
;
901 void wxProperty::SetRole(wxString
& role
)
903 m_propertyRole
= role
;
906 void wxProperty::SetName(wxString
& nm
)
911 void wxProperty::operator=(const wxPropertyValue
& val
)
917 * Base property view class
920 IMPLEMENT_DYNAMIC_CLASS(wxPropertyView
, wxEvtHandler
)
922 wxPropertyView::wxPropertyView(long flags
)
924 m_buttonFlags
= flags
;
925 m_propertySheet
= NULL
;
926 m_currentValidator
= NULL
;
927 m_currentProperty
= NULL
;
930 wxPropertyView::~wxPropertyView(void)
934 void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry
*registry
)
936 m_validatorRegistryList
.Append(registry
);
939 wxPropertyValidator
*wxPropertyView::FindPropertyValidator(wxProperty
*property
)
941 if (property
->GetValidator())
942 return property
->GetValidator();
944 wxObjectList::compatibility_iterator node
= m_validatorRegistryList
.GetFirst();
947 wxPropertyValidatorRegistry
*registry
= (wxPropertyValidatorRegistry
*)node
->GetData();
948 wxPropertyValidator
*validator
= registry
->GetValidator(property
->GetRole());
951 node
= node
->GetNext();
955 if (!wxDefaultPropertyValidator)
956 wxDefaultPropertyValidator = new wxPropertyListValidator;
957 return wxDefaultPropertyValidator;
965 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet
, wxObject
)
967 wxPropertySheet::wxPropertySheet(const wxString
& name
)
968 :m_properties(wxKEY_STRING
),m_name(name
)
972 wxPropertySheet::~wxPropertySheet(void)
977 void wxPropertySheet::UpdateAllViews( wxPropertyView
*WXUNUSED(thisView
) )
982 void wxPropertySheet::AddProperty(wxProperty
*property
)
984 m_properties
.Append((const wxChar
*) property
->GetName(), property
);
987 // Get property by name
988 wxProperty
*wxPropertySheet::GetProperty(const wxString
& name
) const
990 wxObjectList::compatibility_iterator node
= m_properties
.Find((const wxChar
*) name
);
994 return (wxProperty
*)node
->GetData();
997 bool wxPropertySheet::SetProperty(const wxString
& name
, const wxPropertyValue
& value
)
999 wxProperty
* prop
= GetProperty(name
);
1001 prop
->SetValue(value
);
1008 void wxPropertySheet::RemoveProperty(const wxString
& name
)
1010 wxObjectList::compatibility_iterator node
= m_properties
.Find(name
);
1013 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1015 m_properties
.Erase(node
);
1019 bool wxPropertySheet::HasProperty(const wxString
& name
) const
1021 return (GetProperty(name
)?true:false);
1024 // Clear all properties
1025 void wxPropertySheet::Clear(void)
1027 wxObjectList::compatibility_iterator node
= m_properties
.GetFirst();
1030 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1031 wxObjectList::compatibility_iterator next
= node
->GetNext();
1038 // Sets/clears the modified flag for each property value
1039 void wxPropertySheet::SetAllModified(bool flag
)
1041 wxObjectList::compatibility_iterator node
= m_properties
.GetFirst();
1044 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1045 prop
->GetValue().SetModified(flag
);
1046 node
= node
->GetNext();
1051 * Property validator registry
1055 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry
, wxHashTable
)
1057 wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING
)
1061 wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
1066 void wxPropertyValidatorRegistry::RegisterValidator(const wxString
& typeName
, wxPropertyValidator
*validator
)
1068 Put((const wxChar
*) typeName
, validator
);
1071 wxPropertyValidator
*wxPropertyValidatorRegistry::GetValidator(const wxString
& typeName
)
1073 return (wxPropertyValidator
*)Get((const wxChar
*) typeName
);
1076 void wxPropertyValidatorRegistry::ClearRegistry(void)
1079 wxHashTable::Node
*node
;
1080 while ((node
= Next()) != NULL
)
1082 delete (wxPropertyValidator
*)node
->GetData();
1087 * Property validator
1091 IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator
, wxEvtHandler
)
1093 wxPropertyValidator::wxPropertyValidator(long flags
)
1095 m_validatorFlags
= flags
;
1096 m_validatorProperty
= NULL
;
1099 wxPropertyValidator::~wxPropertyValidator(void)
1102 bool wxPropertyValidator::StringToFloat (wxChar
*s
, float *number
) {
1104 bool ok
= StringToDouble (s
, &num
);
1105 *number
= (float) num
;
1109 bool wxPropertyValidator::StringToDouble (wxChar
*s
, double *number
) {
1112 *number
= wxStrtod (s
, &value_ptr
);
1114 int len
= wxStrlen (value_ptr
);
1115 for (int i
= 0; i
< len
; i
++) {
1116 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1117 if (!ok
) return false;
1123 bool wxPropertyValidator::StringToInt (wxChar
*s
, int *number
) {
1125 bool ok
= StringToLong (s
, &num
);
1126 *number
= (int) num
;
1130 bool wxPropertyValidator::StringToLong (wxChar
*s
, long *number
) {
1133 *number
= wxStrtol (s
, &value_ptr
, 10);
1135 int len
= wxStrlen (value_ptr
);
1136 for (int i
= 0; i
< len
; i
++) {
1137 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1138 if (!ok
) return false;
1144 wxChar
*wxPropertyValidator::FloatToString (float number
) {
1145 static wxChar buf
[20];
1146 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1150 wxChar
*wxPropertyValidator::DoubleToString (double number
) {
1151 static wxChar buf
[20];
1152 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1156 wxChar
*wxPropertyValidator::IntToString (int number
) {
1157 static wxChar buf
[20];
1159 wxSprintf (buf
, wxT("%d"), number
);
1163 wxChar
*wxPropertyValidator::LongToString (long number
) {
1164 static wxChar buf
[20];
1166 wxSprintf (buf
, wxT("%ld"), number
);
1170 #endif // wxUSE_PROPSHEET