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"
37 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue
, wxObject
)
39 wxPropertyValue::wxPropertyValue(void)
41 m_type
= wxPropertyValueNull
;
46 m_modifiedFlag
= FALSE
;
49 wxPropertyValue::wxPropertyValue(const wxPropertyValue
& copyFrom
)
51 m_value
.string
= (wxChar
*) NULL
;
52 m_modifiedFlag
= FALSE
;
53 Copy((wxPropertyValue
& )copyFrom
);
56 wxPropertyValue::wxPropertyValue(const wxChar
*val
)
58 m_modifiedFlag
= FALSE
;
59 m_type
= wxPropertyValueString
;
61 m_value
.string
= copystring(val
);
67 wxPropertyValue::wxPropertyValue(const wxString
& val
)
69 m_modifiedFlag
= FALSE
;
70 m_type
= wxPropertyValueString
;
72 m_value
.string
= copystring((const wxChar
*)val
);
78 wxPropertyValue::wxPropertyValue(long the_integer
)
80 m_modifiedFlag
= FALSE
;
81 m_type
= wxPropertyValueInteger
;
82 m_value
.integer
= the_integer
;
87 wxPropertyValue::wxPropertyValue(bool val
)
89 m_modifiedFlag
= FALSE
;
90 m_type
= wxPropertyValuebool
;
91 m_value
.integer
= val
;
96 wxPropertyValue::wxPropertyValue(float the_real
)
98 m_modifiedFlag
= FALSE
;
99 m_type
= wxPropertyValueReal
;
100 m_value
.real
= the_real
;
105 wxPropertyValue::wxPropertyValue(double the_real
)
107 m_modifiedFlag
= FALSE
;
108 m_type
= wxPropertyValueReal
;
109 m_value
.real
= (float)the_real
;
114 // Pointer versions: we have a pointer to the real C++ value.
115 wxPropertyValue::wxPropertyValue(wxChar
**val
)
117 m_modifiedFlag
= FALSE
;
118 m_type
= wxPropertyValueStringPtr
;
120 m_value
.stringPtr
= val
;
126 wxPropertyValue::wxPropertyValue(long *val
)
128 m_modifiedFlag
= FALSE
;
129 m_type
= wxPropertyValueIntegerPtr
;
130 m_value
.integerPtr
= val
;
135 wxPropertyValue::wxPropertyValue(bool *val
)
137 m_modifiedFlag
= FALSE
;
138 m_type
= wxPropertyValueboolPtr
;
139 m_value
.boolPtr
= val
;
144 wxPropertyValue::wxPropertyValue(float *val
)
146 m_modifiedFlag
= FALSE
;
147 m_type
= wxPropertyValueRealPtr
;
148 m_value
.realPtr
= val
;
153 wxPropertyValue::wxPropertyValue(wxList
*the_list
)
155 m_modifiedFlag
= FALSE
;
156 m_type
= wxPropertyValueList
;
159 m_value
.first
= NULL
;
161 wxNode
*node
= the_list
->First();
164 wxPropertyValue
*expr
= (wxPropertyValue
*)node
->Data();
172 wxPropertyValue::wxPropertyValue(wxStringList
*the_list
)
174 m_modifiedFlag
= FALSE
;
175 m_type
= wxPropertyValueList
;
178 m_value
.first
= NULL
;
180 wxNode
*node
= the_list
->First();
183 wxChar
*s
= (wxChar
*)node
->Data();
184 Append(new wxPropertyValue(s
));
190 wxPropertyValue::~wxPropertyValue(void)
194 case wxPropertyValueInteger
:
195 case wxPropertyValuebool
:
196 case wxPropertyValueReal
:
200 case wxPropertyValueString
:
202 delete[] m_value
.string
;
205 case wxPropertyValueList
:
207 wxPropertyValue
*expr
= m_value
.first
;
210 wxPropertyValue
*expr1
= expr
->m_next
;
218 case wxPropertyValueNull
: break;
222 void wxPropertyValue::Append(wxPropertyValue
*expr
)
224 m_modifiedFlag
= TRUE
;
226 m_value
.first
= expr
;
229 m_last
->m_next
= expr
;
233 void wxPropertyValue::Insert(wxPropertyValue
*expr
)
235 m_modifiedFlag
= TRUE
;
236 expr
->m_next
= m_value
.first
;
237 m_value
.first
= expr
;
244 void wxPropertyValue::Delete(wxPropertyValue
*node
)
246 wxPropertyValue
*expr
= GetFirst();
248 wxPropertyValue
*previous
= NULL
;
249 while (expr
&& (expr
!= node
))
252 expr
= expr
->GetNext();
258 previous
->m_next
= expr
->m_next
;
260 // If node was the first in the list,
261 // make the list point to the NEXT one.
262 if (GetFirst() == expr
)
264 m_value
.first
= expr
->m_next
;
267 // If node was the last in the list,
268 // make the list 'last' pointer point to the PREVIOUS one.
269 if (GetLast() == expr
)
276 m_modifiedFlag
= TRUE
;
282 void wxPropertyValue::ClearList(void)
284 wxPropertyValue
*val
= GetFirst();
286 m_modifiedFlag
= TRUE
;
290 wxPropertyValue
*next
= val
->GetNext();
294 m_value
.first
= NULL
;
298 wxPropertyValue
*wxPropertyValue::NewCopy(void) const
302 case wxPropertyValueInteger
:
303 return new wxPropertyValue(m_value
.integer
);
304 case wxPropertyValuebool
:
305 return new wxPropertyValue((bool) (m_value
.integer
!= 0));
306 case wxPropertyValueReal
:
307 return new wxPropertyValue(m_value
.real
);
308 case wxPropertyValueString
:
309 return new wxPropertyValue(m_value
.string
);
310 case wxPropertyValueList
:
312 wxPropertyValue
*expr
= m_value
.first
;
313 wxPropertyValue
*new_list
= new wxPropertyValue
;
314 new_list
->SetType(wxPropertyValueList
);
317 wxPropertyValue
*expr2
= expr
->NewCopy();
318 new_list
->Append(expr2
);
323 case wxPropertyValueIntegerPtr
:
324 return new wxPropertyValue(m_value
.integerPtr
);
325 case wxPropertyValueRealPtr
:
326 return new wxPropertyValue(m_value
.realPtr
);
327 case wxPropertyValueboolPtr
:
328 return new wxPropertyValue(m_value
.boolPtr
);
329 case wxPropertyValueStringPtr
:
330 return new wxPropertyValue(m_value
.stringPtr
);
332 case wxPropertyValueNull
:
333 wxFAIL_MSG( wxT("Should never get here!\n" ) );
339 void wxPropertyValue::Copy(wxPropertyValue
& copyFrom
)
341 if (m_type
== wxPropertyValueString
)
343 delete[] m_value
.string
;
344 m_value
.string
= NULL
;
346 m_type
= copyFrom
.Type();
350 case wxPropertyValueInteger
:
351 (*this) = copyFrom
.IntegerValue();
354 case wxPropertyValueReal
:
355 (*this) = copyFrom
.RealValue();
358 case wxPropertyValueString
:
359 (*this) = wxString(copyFrom
.StringValue());
362 case wxPropertyValuebool
:
363 (*this) = copyFrom
.BoolValue();
367 case wxPropertyValueboolPtr
:
368 (*this) = copyFrom
.BoolValuePtr();
370 case wxPropertyValueRealPtr
:
371 (*this) = copyFrom
.RealValuePtr();
373 case wxPropertyValueIntegerPtr
:
374 (*this) = copyFrom
.IntegerValuePtr();
376 case wxPropertyValueStringPtr
:
378 wxChar
** s
= copyFrom
.StringValuePtr();
381 // what is this? are you trying to assign a bool or a string? VA can't figure it out..
382 #if defined(__VISAGECPP__) || defined( __VISUALC__ )
389 (*this) = (bool)(s
!= 0);
394 case wxPropertyValueList
:
396 m_value
.first
= NULL
;
399 wxPropertyValue
*expr
= copyFrom
.m_value
.first
;
402 wxPropertyValue
*expr2
= expr
->NewCopy();
408 case wxPropertyValueNull
:
409 wxFAIL_MSG( wxT("Should never get here!\n" ) );
414 // Return nth argument of a clause (starting from 1)
415 wxPropertyValue
*wxPropertyValue::Arg(wxPropertyValueType type
, int arg
) const
417 wxPropertyValue
*expr
= m_value
.first
;
418 for (int i
= 1; i
< arg
; i
++)
422 if (expr
&& (expr
->m_type
== type
))
428 // Return nth argument of a list expression (starting from zero)
429 wxPropertyValue
*wxPropertyValue::Nth(int arg
) const
431 if (m_type
!= wxPropertyValueList
)
434 wxPropertyValue
*expr
= m_value
.first
;
435 for (int i
= 0; i
< arg
; i
++)
446 // Returns the number of elements in a list expression
447 int wxPropertyValue::Number(void) const
449 if (m_type
!= wxPropertyValueList
)
453 wxPropertyValue
*expr
= m_value
.first
;
462 void wxPropertyValue::WritePropertyClause(wxString
& stream
) // Write this expression as a top-level clause
464 if (m_type
!= wxPropertyValueList
)
467 wxPropertyValue
*node
= m_value
.first
;
470 node
->WritePropertyType(stream
);
471 stream
.Append( wxT("(") );
477 stream
.Append( wxT(" ") );
478 node
->WritePropertyType(stream
);
481 stream
.Append( wxT(",\n" ) );
484 stream
.Append( wxT(").\n\n") );
488 void wxPropertyValue::WritePropertyType(wxString
& stream
) // Write as any other subexpression
493 case wxPropertyValueInteger
:
495 tmp
.Printf( wxT("%ld"), m_value
.integer
);
496 stream
.Append( tmp
);
499 case wxPropertyValueIntegerPtr
:
501 tmp
.Printf( wxT("%ld"), *m_value
.integerPtr
);
502 stream
.Append( tmp
);
505 case wxPropertyValuebool
:
508 stream
.Append( wxT("True") );
510 stream
.Append( wxT("False") );
513 case wxPropertyValueboolPtr
:
515 if (*m_value
.integerPtr
)
516 stream
.Append( wxT("True") );
518 stream
.Append( wxT("False") );
521 case wxPropertyValueReal
:
523 double d
= m_value
.real
;
524 tmp
.Printf( wxT("%.6g"), d
);
525 stream
.Append( tmp
);
528 case wxPropertyValueRealPtr
:
530 double d
= *m_value
.realPtr
;
531 tmp
.Printf( wxT("%.6g"), d
);
532 stream
.Append( tmp
);
535 case wxPropertyValueString
:
537 stream
.Append( m_value
.string
);
540 case wxPropertyValueStringPtr
:
542 wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );
545 int len = strlen(*(m_value.stringPtr));
546 for (i = 0; i < len; i++)
548 char ch = *(m_value.stringPtr)[i];
554 case wxPropertyValueList
:
557 stream
.Append( wxT("[]") );
560 wxPropertyValue
*expr
= m_value
.first
;
562 stream
.Append( wxT("[") );
565 expr
->WritePropertyType(stream
);
568 stream
.Append( wxT(", ") );
570 stream
.Append( wxT("]") );
574 case wxPropertyValueNull
: break;
578 wxString
wxPropertyValue::GetStringRepresentation(void)
581 WritePropertyType(str
);
585 void wxPropertyValue::operator=(const wxPropertyValue
& val
)
587 m_modifiedFlag
= TRUE
;
588 Copy((wxPropertyValue
&)val
);
591 // void wxPropertyValue::operator=(const char *val)
592 void wxPropertyValue::operator=(const wxString
& val1
)
594 const wxChar
*val
= (const wxChar
*)val1
;
596 m_modifiedFlag
= TRUE
;
598 wxPropertyValueType oldType
= m_type
;
599 if (oldType
== wxPropertyValueString
)
601 delete[] m_value
.string
;
602 m_value
.string
= NULL
;
605 if (m_type
== wxPropertyValueNull
)
606 m_type
= wxPropertyValueString
;
608 if (m_type
== wxPropertyValueString
)
611 m_value
.string
= copystring(val
);
613 m_value
.string
= NULL
;
615 else if (m_type
== wxPropertyValueStringPtr
)
617 wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") );
619 *m_value
.stringPtr
= copystring(val
);
621 *m_value
.stringPtr
= NULL
;
630 void wxPropertyValue::operator=(const long val
)
632 wxPropertyValueType oldType
= m_type
;
633 if (oldType
== wxPropertyValueString
)
635 delete[] m_value
.string
;
636 m_value
.string
= NULL
;
639 m_modifiedFlag
= TRUE
;
640 if (m_type
== wxPropertyValueNull
)
641 m_type
= wxPropertyValueInteger
;
643 if (m_type
== wxPropertyValueInteger
)
644 m_value
.integer
= val
;
645 else if (m_type
== wxPropertyValueIntegerPtr
)
646 *m_value
.integerPtr
= val
;
647 else if (m_type
== wxPropertyValueReal
)
648 m_value
.real
= (float)val
;
649 else if (m_type
== wxPropertyValueRealPtr
)
650 *m_value
.realPtr
= (float)val
;
656 void wxPropertyValue::operator=(const bool val
)
658 wxPropertyValueType oldType
= m_type
;
659 if (oldType
== wxPropertyValueString
)
661 delete[] m_value
.string
;
662 m_value
.string
= NULL
;
665 m_modifiedFlag
= TRUE
;
666 if (m_type
== wxPropertyValueNull
)
667 m_type
= wxPropertyValuebool
;
669 if (m_type
== wxPropertyValuebool
)
670 m_value
.integer
= (long)val
;
671 else if (m_type
== wxPropertyValueboolPtr
)
672 *m_value
.boolPtr
= val
;
678 void wxPropertyValue::operator=(const float val
)
680 wxPropertyValueType oldType
= m_type
;
681 if (oldType
== wxPropertyValueString
)
683 delete[] m_value
.string
;
684 m_value
.string
= NULL
;
687 m_modifiedFlag
= TRUE
;
688 if (m_type
== wxPropertyValueNull
)
689 m_type
= wxPropertyValueReal
;
691 if (m_type
== wxPropertyValueInteger
)
692 m_value
.integer
= (long)val
;
693 else if (m_type
== wxPropertyValueIntegerPtr
)
694 *m_value
.integerPtr
= (long)val
;
695 else if (m_type
== wxPropertyValueReal
)
697 else if (m_type
== wxPropertyValueRealPtr
)
698 *m_value
.realPtr
= val
;
704 void wxPropertyValue::operator=(const wxChar
**val
)
706 wxPropertyValueType oldType
= m_type
;
707 if (oldType
== wxPropertyValueString
)
709 delete[] m_value
.string
;
710 m_value
.string
= NULL
;
713 m_modifiedFlag
= TRUE
;
714 m_type
= wxPropertyValueStringPtr
;
717 m_value
.stringPtr
= (wxChar
**)val
;
719 m_value
.stringPtr
= NULL
;
726 void wxPropertyValue::operator=(const long *val
)
728 m_modifiedFlag
= TRUE
;
729 m_type
= wxPropertyValueIntegerPtr
;
730 m_value
.integerPtr
= (long *)val
;
735 void wxPropertyValue::operator=(const bool *val
)
737 m_modifiedFlag
= TRUE
;
738 m_type
= wxPropertyValueboolPtr
;
739 m_value
.boolPtr
= (bool *)val
;
744 void wxPropertyValue::operator=(const float *val
)
746 m_modifiedFlag
= TRUE
;
747 m_type
= wxPropertyValueRealPtr
;
748 m_value
.realPtr
= (float *)val
;
753 long wxPropertyValue::IntegerValue(void) const
755 if (m_type
== wxPropertyValueInteger
)
756 return m_value
.integer
;
757 else if (m_type
== wxPropertyValueReal
)
758 return (long)m_value
.real
;
759 else if (m_type
== wxPropertyValueIntegerPtr
)
760 return *m_value
.integerPtr
;
761 else if (m_type
== wxPropertyValueRealPtr
)
762 return (long)(*m_value
.realPtr
);
766 long *wxPropertyValue::IntegerValuePtr(void) const
768 return m_value
.integerPtr
;
771 float wxPropertyValue::RealValue(void) const {
772 if (m_type
== wxPropertyValueReal
)
774 else if (m_type
== wxPropertyValueRealPtr
)
775 return *m_value
.realPtr
;
776 else if (m_type
== wxPropertyValueInteger
)
777 return (float)m_value
.integer
;
778 else if (m_type
== wxPropertyValueIntegerPtr
)
779 return (float)*(m_value
.integerPtr
);
783 float *wxPropertyValue::RealValuePtr(void) const
785 return m_value
.realPtr
;
788 bool wxPropertyValue::BoolValue(void) const {
789 if (m_type
== wxPropertyValueReal
)
790 return (m_value
.real
!= 0.0);
791 if (m_type
== wxPropertyValueRealPtr
)
792 return (*(m_value
.realPtr
) != 0.0);
793 else if (m_type
== wxPropertyValueInteger
)
794 return (m_value
.integer
!= 0);
795 else if (m_type
== wxPropertyValueIntegerPtr
)
796 return (*(m_value
.integerPtr
) != 0);
797 else if (m_type
== wxPropertyValuebool
)
798 return (m_value
.integer
!= 0);
799 else if (m_type
== wxPropertyValueboolPtr
)
800 return (*(m_value
.boolPtr
) != 0);
804 bool *wxPropertyValue::BoolValuePtr(void) const
806 return m_value
.boolPtr
;
809 wxChar
*wxPropertyValue::StringValue(void) const {
810 if (m_type
== wxPropertyValueString
)
811 return m_value
.string
;
812 else if (m_type
== wxPropertyValueStringPtr
)
813 return *(m_value
.stringPtr
);
817 wxChar
**wxPropertyValue::StringValuePtr(void) const
819 return m_value
.stringPtr
;
823 * A property (name plus value)
826 IMPLEMENT_DYNAMIC_CLASS(wxProperty
, wxObject
)
828 wxProperty::wxProperty(void)
830 m_propertyRole
= wxEmptyString
;
831 m_propertyValidator
= NULL
;
832 m_propertyWindow
= NULL
;
836 wxProperty::wxProperty(wxProperty
& copyFrom
)
838 m_value
= copyFrom
.GetValue();
839 m_name
= copyFrom
.GetName();
840 m_propertyRole
= copyFrom
.GetRole();
841 m_propertyValidator
= copyFrom
.GetValidator();
842 m_enabled
= copyFrom
.IsEnabled();
843 m_propertyWindow
= NULL
;
846 wxProperty::wxProperty(wxString nm
, wxString role
, wxPropertyValidator
*ed
):m_name(nm
), m_propertyRole(role
)
848 m_propertyValidator
= ed
;
849 m_propertyWindow
= NULL
;
853 wxProperty::wxProperty(wxString nm
, const wxPropertyValue
& val
, wxString role
, wxPropertyValidator
*ed
):
854 m_value(val
), m_name(nm
), m_propertyRole(role
)
856 m_propertyValidator
= ed
;
857 m_propertyWindow
= NULL
;
861 wxProperty::~wxProperty(void)
863 if (m_propertyValidator
)
864 delete m_propertyValidator
;
867 wxPropertyValue
& wxProperty::GetValue(void) const
869 return (wxPropertyValue
&) m_value
;
872 wxPropertyValidator
*wxProperty::GetValidator(void) const
874 return m_propertyValidator
;
877 wxString
& wxProperty::GetName(void) const
879 return (wxString
&) m_name
;
882 wxString
& wxProperty::GetRole(void) const
884 return (wxString
&) m_propertyRole
;
887 void wxProperty::SetValue(const wxPropertyValue
& val
)
892 void wxProperty::SetValidator(wxPropertyValidator
*ed
)
894 m_propertyValidator
= ed
;
897 void wxProperty::SetRole(wxString
& role
)
899 m_propertyRole
= role
;
902 void wxProperty::SetName(wxString
& nm
)
907 void wxProperty::operator=(const wxPropertyValue
& val
)
913 * Base property view class
916 IMPLEMENT_DYNAMIC_CLASS(wxPropertyView
, wxEvtHandler
)
918 wxPropertyView::wxPropertyView(long flags
)
920 m_buttonFlags
= flags
;
921 m_propertySheet
= NULL
;
922 m_currentValidator
= NULL
;
923 m_currentProperty
= NULL
;
926 wxPropertyView::~wxPropertyView(void)
930 void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry
*registry
)
932 m_validatorRegistryList
.Append(registry
);
935 wxPropertyValidator
*wxPropertyView::FindPropertyValidator(wxProperty
*property
)
937 if (property
->GetValidator())
938 return property
->GetValidator();
940 wxNode
*node
= m_validatorRegistryList
.First();
943 wxPropertyValidatorRegistry
*registry
= (wxPropertyValidatorRegistry
*)node
->Data();
944 wxPropertyValidator
*validator
= registry
->GetValidator(property
->GetRole());
951 if (!wxDefaultPropertyValidator)
952 wxDefaultPropertyValidator = new wxPropertyListValidator;
953 return wxDefaultPropertyValidator;
961 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet
, wxObject
)
963 wxPropertySheet::wxPropertySheet(const wxString
& name
)
964 :m_properties(wxKEY_STRING
),m_name(name
)
968 wxPropertySheet::~wxPropertySheet(void)
973 void wxPropertySheet::UpdateAllViews( wxPropertyView
*WXUNUSED(thisView
) )
978 void wxPropertySheet::AddProperty(wxProperty
*property
)
980 m_properties
.Append((const wxChar
*) property
->GetName(), property
);
983 // Get property by name
984 wxProperty
*wxPropertySheet::GetProperty(const wxString
& name
) const
986 wxNode
*node
= m_properties
.Find((const wxChar
*) name
);
990 return (wxProperty
*)node
->Data();
993 bool wxPropertySheet::SetProperty(const wxString
& name
, const wxPropertyValue
& value
)
995 wxProperty
* prop
= GetProperty(name
);
997 prop
->SetValue(value
);
1004 void wxPropertySheet::RemoveProperty(const wxString
& name
)
1006 wxNode
*node
= m_properties
.Find(name
);
1009 wxProperty
*prop
= (wxProperty
*)node
->Data();
1011 m_properties
.DeleteNode(node
);
1015 bool wxPropertySheet::HasProperty(const wxString
& name
) const
1017 return (GetProperty(name
)?TRUE
:FALSE
);
1020 // Clear all properties
1021 void wxPropertySheet::Clear(void)
1023 wxNode
*node
= m_properties
.First();
1026 wxProperty
*prop
= (wxProperty
*)node
->Data();
1027 wxNode
*next
= node
->Next();
1034 // Sets/clears the modified flag for each property value
1035 void wxPropertySheet::SetAllModified(bool flag
)
1037 wxNode
*node
= m_properties
.First();
1040 wxProperty
*prop
= (wxProperty
*)node
->Data();
1041 prop
->GetValue().SetModified(flag
);
1042 node
= node
->Next();
1047 * Property validator registry
1051 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry
, wxHashTable
)
1053 wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING
)
1057 wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
1062 void wxPropertyValidatorRegistry::RegisterValidator(const wxString
& typeName
, wxPropertyValidator
*validator
)
1064 Put((const wxChar
*) typeName
, validator
);
1067 wxPropertyValidator
*wxPropertyValidatorRegistry::GetValidator(const wxString
& typeName
)
1069 return (wxPropertyValidator
*)Get((const wxChar
*) typeName
);
1072 void wxPropertyValidatorRegistry::ClearRegistry(void)
1076 while ((node
= Next()) != NULL
)
1078 delete (wxPropertyValidator
*)node
->Data();
1083 * Property validator
1087 IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator
, wxEvtHandler
)
1089 wxPropertyValidator::wxPropertyValidator(long flags
)
1091 m_validatorFlags
= flags
;
1092 m_validatorProperty
= NULL
;
1095 wxPropertyValidator::~wxPropertyValidator(void)
1098 bool wxPropertyValidator::StringToFloat (wxChar
*s
, float *number
) {
1100 bool ok
= StringToDouble (s
, &num
);
1101 *number
= (float) num
;
1105 bool wxPropertyValidator::StringToDouble (wxChar
*s
, double *number
) {
1108 *number
= wxStrtod (s
, &value_ptr
);
1110 int len
= wxStrlen (value_ptr
);
1111 for (int i
= 0; i
< len
; i
++) {
1112 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1113 if (!ok
) return FALSE
;
1119 bool wxPropertyValidator::StringToInt (wxChar
*s
, int *number
) {
1121 bool ok
= StringToLong (s
, &num
);
1122 *number
= (int) num
;
1126 bool wxPropertyValidator::StringToLong (wxChar
*s
, long *number
) {
1129 *number
= wxStrtol (s
, &value_ptr
, 10);
1131 int len
= wxStrlen (value_ptr
);
1132 for (int i
= 0; i
< len
; i
++) {
1133 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1134 if (!ok
) return FALSE
;
1140 wxChar
*wxPropertyValidator::FloatToString (float number
) {
1141 static wxChar buf
[20];
1142 wxSprintf (buf
, wxT("%.6g"), number
);
1146 wxChar
*wxPropertyValidator::DoubleToString (double number
) {
1147 static wxChar buf
[20];
1148 wxSprintf (buf
, wxT("%.6g"), number
);
1152 wxChar
*wxPropertyValidator::IntToString (int number
) {
1153 return ::IntToString (number
);
1156 wxChar
*wxPropertyValidator::LongToString (long number
) {
1157 return ::LongToString (number
);
1160 #endif // wxUSE_PROPSHEET