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"
36 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue
, wxObject
)
38 wxPropertyValue::wxPropertyValue(void)
40 m_type
= wxPropertyValueNull
;
45 m_modifiedFlag
= FALSE
;
48 wxPropertyValue::wxPropertyValue(const wxPropertyValue
& copyFrom
)
50 m_value
.string
= (wxChar
*) NULL
;
51 m_modifiedFlag
= FALSE
;
52 Copy((wxPropertyValue
& )copyFrom
);
55 wxPropertyValue::wxPropertyValue(const wxChar
*val
)
57 m_modifiedFlag
= FALSE
;
58 m_type
= wxPropertyValueString
;
60 m_value
.string
= copystring(val
);
66 wxPropertyValue::wxPropertyValue(const wxString
& val
)
68 m_modifiedFlag
= FALSE
;
69 m_type
= wxPropertyValueString
;
71 m_value
.string
= copystring((const wxChar
*)val
);
77 wxPropertyValue::wxPropertyValue(long the_integer
)
79 m_modifiedFlag
= FALSE
;
80 m_type
= wxPropertyValueInteger
;
81 m_value
.integer
= the_integer
;
86 wxPropertyValue::wxPropertyValue(bool val
)
88 m_modifiedFlag
= FALSE
;
89 m_type
= wxPropertyValuebool
;
90 m_value
.integer
= val
;
95 wxPropertyValue::wxPropertyValue(float the_real
)
97 m_modifiedFlag
= FALSE
;
98 m_type
= wxPropertyValueReal
;
99 m_value
.real
= the_real
;
104 wxPropertyValue::wxPropertyValue(double the_real
)
106 m_modifiedFlag
= FALSE
;
107 m_type
= wxPropertyValueReal
;
108 m_value
.real
= (float)the_real
;
113 // Pointer versions: we have a pointer to the real C++ value.
114 wxPropertyValue::wxPropertyValue(wxChar
**val
)
116 m_modifiedFlag
= FALSE
;
117 m_type
= wxPropertyValueStringPtr
;
119 m_value
.stringPtr
= val
;
125 wxPropertyValue::wxPropertyValue(long *val
)
127 m_modifiedFlag
= FALSE
;
128 m_type
= wxPropertyValueIntegerPtr
;
129 m_value
.integerPtr
= val
;
134 wxPropertyValue::wxPropertyValue(bool *val
)
136 m_modifiedFlag
= FALSE
;
137 m_type
= wxPropertyValueboolPtr
;
138 m_value
.boolPtr
= val
;
143 wxPropertyValue::wxPropertyValue(float *val
)
145 m_modifiedFlag
= FALSE
;
146 m_type
= wxPropertyValueRealPtr
;
147 m_value
.realPtr
= val
;
152 wxPropertyValue::wxPropertyValue(wxList
*the_list
)
154 m_modifiedFlag
= FALSE
;
155 m_type
= wxPropertyValueList
;
158 m_value
.first
= NULL
;
160 wxNode
*node
= the_list
->First();
163 wxPropertyValue
*expr
= (wxPropertyValue
*)node
->Data();
171 wxPropertyValue::wxPropertyValue(wxStringList
*the_list
)
173 m_modifiedFlag
= FALSE
;
174 m_type
= wxPropertyValueList
;
177 m_value
.first
= NULL
;
179 wxNode
*node
= the_list
->First();
182 char *s
= (char *)node
->Data();
183 Append(new wxPropertyValue(s
));
189 wxPropertyValue::~wxPropertyValue(void)
193 case wxPropertyValueInteger
:
194 case wxPropertyValuebool
:
195 case wxPropertyValueReal
:
199 case wxPropertyValueString
:
201 delete[] m_value
.string
;
204 case wxPropertyValueList
:
206 wxPropertyValue
*expr
= m_value
.first
;
209 wxPropertyValue
*expr1
= expr
->m_next
;
217 case wxPropertyValueNull
: break;
221 void wxPropertyValue::Append(wxPropertyValue
*expr
)
223 m_modifiedFlag
= TRUE
;
225 m_value
.first
= expr
;
228 m_last
->m_next
= expr
;
232 void wxPropertyValue::Insert(wxPropertyValue
*expr
)
234 m_modifiedFlag
= TRUE
;
235 expr
->m_next
= m_value
.first
;
236 m_value
.first
= expr
;
243 void wxPropertyValue::Delete(wxPropertyValue
*node
)
245 wxPropertyValue
*expr
= GetFirst();
247 wxPropertyValue
*previous
= NULL
;
248 while (expr
&& (expr
!= node
))
251 expr
= expr
->GetNext();
257 previous
->m_next
= expr
->m_next
;
259 // If node was the first in the list,
260 // make the list point to the NEXT one.
261 if (GetFirst() == expr
)
263 m_value
.first
= expr
->m_next
;
266 // If node was the last in the list,
267 // make the list 'last' pointer point to the PREVIOUS one.
268 if (GetLast() == expr
)
275 m_modifiedFlag
= TRUE
;
281 void wxPropertyValue::ClearList(void)
283 wxPropertyValue
*val
= GetFirst();
285 m_modifiedFlag
= TRUE
;
289 wxPropertyValue
*next
= val
->GetNext();
293 m_value
.first
= NULL
;
297 wxPropertyValue
*wxPropertyValue::NewCopy(void) const
301 case wxPropertyValueInteger
:
302 return new wxPropertyValue(m_value
.integer
);
303 case wxPropertyValuebool
:
304 return new wxPropertyValue((bool) (m_value
.integer
!= 0));
305 case wxPropertyValueReal
:
306 return new wxPropertyValue(m_value
.real
);
307 case wxPropertyValueString
:
308 return new wxPropertyValue(m_value
.string
);
309 case wxPropertyValueList
:
311 wxPropertyValue
*expr
= m_value
.first
;
312 wxPropertyValue
*new_list
= new wxPropertyValue
;
313 new_list
->SetType(wxPropertyValueList
);
316 wxPropertyValue
*expr2
= expr
->NewCopy();
317 new_list
->Append(expr2
);
322 case wxPropertyValueIntegerPtr
:
323 return new wxPropertyValue(m_value
.integerPtr
);
324 case wxPropertyValueRealPtr
:
325 return new wxPropertyValue(m_value
.realPtr
);
326 case wxPropertyValueboolPtr
:
327 return new wxPropertyValue(m_value
.boolPtr
);
328 case wxPropertyValueStringPtr
:
329 return new wxPropertyValue(m_value
.stringPtr
);
331 case wxPropertyValueNull
:
332 wxFAIL_MSG( wxT("Should never get here!\n" ) );
338 void wxPropertyValue::Copy(wxPropertyValue
& copyFrom
)
340 if (m_type
== wxPropertyValueString
)
342 delete[] m_value
.string
;
343 m_value
.string
= NULL
;
345 m_type
= copyFrom
.Type();
349 case wxPropertyValueInteger
:
350 (*this) = copyFrom
.IntegerValue();
353 case wxPropertyValueReal
:
354 (*this) = copyFrom
.RealValue();
357 case wxPropertyValueString
:
358 (*this) = wxString(copyFrom
.StringValue());
361 case wxPropertyValuebool
:
362 (*this) = copyFrom
.BoolValue();
366 case wxPropertyValueboolPtr
:
367 (*this) = copyFrom
.BoolValuePtr();
369 case wxPropertyValueRealPtr
:
370 (*this) = copyFrom
.RealValuePtr();
372 case wxPropertyValueIntegerPtr
:
373 (*this) = copyFrom
.IntegerValuePtr();
375 case wxPropertyValueStringPtr
:
377 wxChar
** s
= copyFrom
.StringValuePtr();
380 // what is this? are you trying to assign a bool or a string? VA can't figure it out..
381 #if defined(__VISAGECPP__) || defined( __VISUALC__ )
388 (*this) = (bool)(s
!= 0);
393 case wxPropertyValueList
:
395 m_value
.first
= NULL
;
398 wxPropertyValue
*expr
= copyFrom
.m_value
.first
;
401 wxPropertyValue
*expr2
= expr
->NewCopy();
407 case wxPropertyValueNull
:
408 wxFAIL_MSG( wxT("Should never get here!\n" ) );
413 // Return nth argument of a clause (starting from 1)
414 wxPropertyValue
*wxPropertyValue::Arg(wxPropertyValueType type
, int arg
) const
416 wxPropertyValue
*expr
= m_value
.first
;
417 for (int i
= 1; i
< arg
; i
++)
421 if (expr
&& (expr
->m_type
== type
))
427 // Return nth argument of a list expression (starting from zero)
428 wxPropertyValue
*wxPropertyValue::Nth(int arg
) const
430 if (m_type
!= wxPropertyValueList
)
433 wxPropertyValue
*expr
= m_value
.first
;
434 for (int i
= 0; i
< arg
; i
++)
445 // Returns the number of elements in a list expression
446 int wxPropertyValue::Number(void) const
448 if (m_type
!= wxPropertyValueList
)
452 wxPropertyValue
*expr
= m_value
.first
;
461 void wxPropertyValue::WritePropertyClause(wxString
& stream
) // Write this expression as a top-level clause
463 if (m_type
!= wxPropertyValueList
)
466 wxPropertyValue
*node
= m_value
.first
;
469 node
->WritePropertyType(stream
);
470 stream
.Append( wxT("(") );
476 stream
.Append( wxT(" ") );
477 node
->WritePropertyType(stream
);
480 stream
.Append( wxT(",\n" ) );
483 stream
.Append( wxT(").\n\n") );
487 void wxPropertyValue::WritePropertyType(wxString
& stream
) // Write as any other subexpression
492 case wxPropertyValueInteger
:
494 tmp
.Printf( wxT("%ld"), m_value
.integer
);
495 stream
.Append( tmp
);
498 case wxPropertyValueIntegerPtr
:
500 tmp
.Printf( wxT("%ld"), *m_value
.integerPtr
);
501 stream
.Append( tmp
);
504 case wxPropertyValuebool
:
507 stream
.Append( wxT("True") );
509 stream
.Append( wxT("False") );
512 case wxPropertyValueboolPtr
:
514 if (*m_value
.integerPtr
)
515 stream
.Append( wxT("True") );
517 stream
.Append( wxT("False") );
520 case wxPropertyValueReal
:
522 double d
= m_value
.real
;
523 tmp
.Printf( wxT("%.6g"), d
);
524 stream
.Append( tmp
);
527 case wxPropertyValueRealPtr
:
529 double d
= *m_value
.realPtr
;
530 tmp
.Printf( wxT("%.6g"), d
);
531 stream
.Append( tmp
);
534 case wxPropertyValueString
:
536 stream
.Append( m_value
.string
);
539 case wxPropertyValueStringPtr
:
541 wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );
544 int len = strlen(*(m_value.stringPtr));
545 for (i = 0; i < len; i++)
547 char ch = *(m_value.stringPtr)[i];
553 case wxPropertyValueList
:
556 stream
.Append( wxT("[]") );
559 wxPropertyValue
*expr
= m_value
.first
;
561 stream
.Append( wxT("[") );
564 expr
->WritePropertyType(stream
);
567 stream
.Append( wxT(", ") );
569 stream
.Append( wxT("]") );
573 case wxPropertyValueNull
: break;
577 wxString
wxPropertyValue::GetStringRepresentation(void)
580 WritePropertyType(str
);
584 void wxPropertyValue::operator=(const wxPropertyValue
& val
)
586 m_modifiedFlag
= TRUE
;
587 Copy((wxPropertyValue
&)val
);
590 // void wxPropertyValue::operator=(const char *val)
591 void wxPropertyValue::operator=(const wxString
& val1
)
593 const wxChar
*val
= (const wxChar
*)val1
;
595 m_modifiedFlag
= TRUE
;
597 wxPropertyValueType oldType
= m_type
;
598 if (oldType
== wxPropertyValueString
)
600 delete[] m_value
.string
;
601 m_value
.string
= NULL
;
604 if (m_type
== wxPropertyValueNull
)
605 m_type
= wxPropertyValueString
;
607 if (m_type
== wxPropertyValueString
)
610 m_value
.string
= copystring(val
);
612 m_value
.string
= NULL
;
614 else if (m_type
== wxPropertyValueStringPtr
)
616 wxFAIL_MSG( "Shouldn't try to assign a wxString reference to a char* pointer.");
618 *m_value
.stringPtr
= copystring(val
);
620 *m_value
.stringPtr
= NULL
;
629 void wxPropertyValue::operator=(const long val
)
631 wxPropertyValueType oldType
= m_type
;
632 if (oldType
== wxPropertyValueString
)
634 delete[] m_value
.string
;
635 m_value
.string
= NULL
;
638 m_modifiedFlag
= TRUE
;
639 if (m_type
== wxPropertyValueNull
)
640 m_type
= wxPropertyValueInteger
;
642 if (m_type
== wxPropertyValueInteger
)
643 m_value
.integer
= val
;
644 else if (m_type
== wxPropertyValueIntegerPtr
)
645 *m_value
.integerPtr
= val
;
646 else if (m_type
== wxPropertyValueReal
)
647 m_value
.real
= (float)val
;
648 else if (m_type
== wxPropertyValueRealPtr
)
649 *m_value
.realPtr
= (float)val
;
655 void wxPropertyValue::operator=(const bool val
)
657 wxPropertyValueType oldType
= m_type
;
658 if (oldType
== wxPropertyValueString
)
660 delete[] m_value
.string
;
661 m_value
.string
= NULL
;
664 m_modifiedFlag
= TRUE
;
665 if (m_type
== wxPropertyValueNull
)
666 m_type
= wxPropertyValuebool
;
668 if (m_type
== wxPropertyValuebool
)
669 m_value
.integer
= (long)val
;
670 else if (m_type
== wxPropertyValueboolPtr
)
671 *m_value
.boolPtr
= val
;
677 void wxPropertyValue::operator=(const float val
)
679 wxPropertyValueType oldType
= m_type
;
680 if (oldType
== wxPropertyValueString
)
682 delete[] m_value
.string
;
683 m_value
.string
= NULL
;
686 m_modifiedFlag
= TRUE
;
687 if (m_type
== wxPropertyValueNull
)
688 m_type
= wxPropertyValueReal
;
690 if (m_type
== wxPropertyValueInteger
)
691 m_value
.integer
= (long)val
;
692 else if (m_type
== wxPropertyValueIntegerPtr
)
693 *m_value
.integerPtr
= (long)val
;
694 else if (m_type
== wxPropertyValueReal
)
696 else if (m_type
== wxPropertyValueRealPtr
)
697 *m_value
.realPtr
= val
;
703 void wxPropertyValue::operator=(const wxChar
**val
)
705 wxPropertyValueType oldType
= m_type
;
706 if (oldType
== wxPropertyValueString
)
708 delete[] m_value
.string
;
709 m_value
.string
= NULL
;
712 m_modifiedFlag
= TRUE
;
713 m_type
= wxPropertyValueStringPtr
;
716 m_value
.stringPtr
= (wxChar
**)val
;
718 m_value
.stringPtr
= NULL
;
725 void wxPropertyValue::operator=(const long *val
)
727 m_modifiedFlag
= TRUE
;
728 m_type
= wxPropertyValueIntegerPtr
;
729 m_value
.integerPtr
= (long *)val
;
734 void wxPropertyValue::operator=(const bool *val
)
736 m_modifiedFlag
= TRUE
;
737 m_type
= wxPropertyValueboolPtr
;
738 m_value
.boolPtr
= (bool *)val
;
743 void wxPropertyValue::operator=(const float *val
)
745 m_modifiedFlag
= TRUE
;
746 m_type
= wxPropertyValueRealPtr
;
747 m_value
.realPtr
= (float *)val
;
752 long wxPropertyValue::IntegerValue(void) const
754 if (m_type
== wxPropertyValueInteger
)
755 return m_value
.integer
;
756 else if (m_type
== wxPropertyValueReal
)
757 return (long)m_value
.real
;
758 else if (m_type
== wxPropertyValueIntegerPtr
)
759 return *m_value
.integerPtr
;
760 else if (m_type
== wxPropertyValueRealPtr
)
761 return (long)(*m_value
.realPtr
);
765 long *wxPropertyValue::IntegerValuePtr(void) const
767 return m_value
.integerPtr
;
770 float wxPropertyValue::RealValue(void) const {
771 if (m_type
== wxPropertyValueReal
)
773 else if (m_type
== wxPropertyValueRealPtr
)
774 return *m_value
.realPtr
;
775 else if (m_type
== wxPropertyValueInteger
)
776 return (float)m_value
.integer
;
777 else if (m_type
== wxPropertyValueIntegerPtr
)
778 return (float)*(m_value
.integerPtr
);
782 float *wxPropertyValue::RealValuePtr(void) const
784 return m_value
.realPtr
;
787 bool wxPropertyValue::BoolValue(void) const {
788 if (m_type
== wxPropertyValueReal
)
789 return (m_value
.real
!= 0.0);
790 if (m_type
== wxPropertyValueRealPtr
)
791 return (*(m_value
.realPtr
) != 0.0);
792 else if (m_type
== wxPropertyValueInteger
)
793 return (m_value
.integer
!= 0);
794 else if (m_type
== wxPropertyValueIntegerPtr
)
795 return (*(m_value
.integerPtr
) != 0);
796 else if (m_type
== wxPropertyValuebool
)
797 return (m_value
.integer
!= 0);
798 else if (m_type
== wxPropertyValueboolPtr
)
799 return (*(m_value
.boolPtr
) != 0);
803 bool *wxPropertyValue::BoolValuePtr(void) const
805 return m_value
.boolPtr
;
808 wxChar
*wxPropertyValue::StringValue(void) const {
809 if (m_type
== wxPropertyValueString
)
810 return m_value
.string
;
811 else if (m_type
== wxPropertyValueStringPtr
)
812 return *(m_value
.stringPtr
);
816 wxChar
**wxPropertyValue::StringValuePtr(void) const
818 return m_value
.stringPtr
;
822 * A property (name plus value)
825 IMPLEMENT_DYNAMIC_CLASS(wxProperty
, wxObject
)
827 wxProperty::wxProperty(void)
829 m_propertyRole
= wxEmptyString
;
830 m_propertyValidator
= NULL
;
831 m_propertyWindow
= NULL
;
835 wxProperty::wxProperty(wxProperty
& copyFrom
)
837 m_value
= copyFrom
.GetValue();
838 m_name
= copyFrom
.GetName();
839 m_propertyRole
= copyFrom
.GetRole();
840 m_propertyValidator
= copyFrom
.GetValidator();
841 m_enabled
= copyFrom
.IsEnabled();
842 m_propertyWindow
= NULL
;
845 wxProperty::wxProperty(wxString nm
, wxString role
, wxPropertyValidator
*ed
):m_name(nm
), m_propertyRole(role
)
847 m_propertyValidator
= ed
;
848 m_propertyWindow
= NULL
;
852 wxProperty::wxProperty(wxString nm
, const wxPropertyValue
& val
, wxString role
, wxPropertyValidator
*ed
):
853 m_value(val
), m_name(nm
), m_propertyRole(role
)
855 m_propertyValidator
= ed
;
856 m_propertyWindow
= NULL
;
860 wxProperty::~wxProperty(void)
862 if (m_propertyValidator
)
863 delete m_propertyValidator
;
866 wxPropertyValue
& wxProperty::GetValue(void) const
868 return (wxPropertyValue
&) m_value
;
871 wxPropertyValidator
*wxProperty::GetValidator(void) const
873 return m_propertyValidator
;
876 wxString
& wxProperty::GetName(void) const
878 return (wxString
&) m_name
;
881 wxString
& wxProperty::GetRole(void) const
883 return (wxString
&) m_propertyRole
;
886 void wxProperty::SetValue(const wxPropertyValue
& val
)
891 void wxProperty::SetValidator(wxPropertyValidator
*ed
)
893 m_propertyValidator
= ed
;
896 void wxProperty::SetRole(wxString
& role
)
898 m_propertyRole
= role
;
901 void wxProperty::SetName(wxString
& nm
)
906 void wxProperty::operator=(const wxPropertyValue
& val
)
912 * Base property view class
915 IMPLEMENT_DYNAMIC_CLASS(wxPropertyView
, wxEvtHandler
)
917 wxPropertyView::wxPropertyView(long flags
)
919 m_buttonFlags
= flags
;
920 m_propertySheet
= NULL
;
921 m_currentValidator
= NULL
;
922 m_currentProperty
= NULL
;
925 wxPropertyView::~wxPropertyView(void)
929 void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry
*registry
)
931 m_validatorRegistryList
.Append(registry
);
934 wxPropertyValidator
*wxPropertyView::FindPropertyValidator(wxProperty
*property
)
936 if (property
->GetValidator())
937 return property
->GetValidator();
939 wxNode
*node
= m_validatorRegistryList
.First();
942 wxPropertyValidatorRegistry
*registry
= (wxPropertyValidatorRegistry
*)node
->Data();
943 wxPropertyValidator
*validator
= registry
->GetValidator(property
->GetRole());
950 if (!wxDefaultPropertyValidator)
951 wxDefaultPropertyValidator = new wxPropertyListValidator;
952 return wxDefaultPropertyValidator;
960 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet
, wxObject
)
962 wxPropertySheet::wxPropertySheet(const wxString
& name
)
963 :m_properties(wxKEY_STRING
),m_name(name
)
967 wxPropertySheet::~wxPropertySheet(void)
972 void wxPropertySheet::UpdateAllViews( wxPropertyView
*WXUNUSED(thisView
) )
977 void wxPropertySheet::AddProperty(wxProperty
*property
)
979 m_properties
.Append((const wxChar
*) property
->GetName(), property
);
982 // Get property by name
983 wxProperty
*wxPropertySheet::GetProperty(const wxString
& name
) const
985 wxNode
*node
= m_properties
.Find((const wxChar
*) name
);
989 return (wxProperty
*)node
->Data();
992 bool wxPropertySheet::SetProperty(const wxString
& name
, const wxPropertyValue
& value
)
994 wxProperty
* prop
= GetProperty(name
);
996 prop
->SetValue(value
);
1003 void wxPropertySheet::RemoveProperty(const wxString
& name
)
1005 wxNode
*node
= m_properties
.Find(name
);
1008 wxProperty
*prop
= (wxProperty
*)node
->Data();
1010 m_properties
.DeleteNode(node
);
1014 bool wxPropertySheet::HasProperty(const wxString
& name
) const
1016 return (GetProperty(name
)?TRUE
:FALSE
);
1019 // Clear all properties
1020 void wxPropertySheet::Clear(void)
1022 wxNode
*node
= m_properties
.First();
1025 wxProperty
*prop
= (wxProperty
*)node
->Data();
1026 wxNode
*next
= node
->Next();
1033 // Sets/clears the modified flag for each property value
1034 void wxPropertySheet::SetAllModified(bool flag
)
1036 wxNode
*node
= m_properties
.First();
1039 wxProperty
*prop
= (wxProperty
*)node
->Data();
1040 prop
->GetValue().SetModified(flag
);
1041 node
= node
->Next();
1046 * Property validator registry
1050 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry
, wxHashTable
)
1052 wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING
)
1056 wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
1061 void wxPropertyValidatorRegistry::RegisterValidator(const wxString
& typeName
, wxPropertyValidator
*validator
)
1063 Put((const wxChar
*) typeName
, validator
);
1066 wxPropertyValidator
*wxPropertyValidatorRegistry::GetValidator(const wxString
& typeName
)
1068 return (wxPropertyValidator
*)Get((const wxChar
*) typeName
);
1071 void wxPropertyValidatorRegistry::ClearRegistry(void)
1075 while ((node
= Next()) != NULL
)
1077 delete (wxPropertyValidator
*)node
->Data();
1082 * Property validator
1086 IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator
, wxEvtHandler
)
1088 wxPropertyValidator::wxPropertyValidator(long flags
)
1090 m_validatorFlags
= flags
;
1091 m_validatorProperty
= NULL
;
1094 wxPropertyValidator::~wxPropertyValidator(void)
1097 bool wxPropertyValidator::StringToFloat (wxChar
*s
, float *number
) {
1099 bool ok
= StringToDouble (s
, &num
);
1100 *number
= (float) num
;
1104 bool wxPropertyValidator::StringToDouble (wxChar
*s
, double *number
) {
1107 *number
= wxStrtod (s
, &value_ptr
);
1109 int len
= wxStrlen (value_ptr
);
1110 for (int i
= 0; i
< len
; i
++) {
1111 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1112 if (!ok
) return FALSE
;
1118 bool wxPropertyValidator::StringToInt (wxChar
*s
, int *number
) {
1120 bool ok
= StringToLong (s
, &num
);
1121 *number
= (int) num
;
1125 bool wxPropertyValidator::StringToLong (wxChar
*s
, long *number
) {
1128 *number
= wxStrtol (s
, &value_ptr
, 10);
1130 int len
= wxStrlen (value_ptr
);
1131 for (int i
= 0; i
< len
; i
++) {
1132 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1133 if (!ok
) return FALSE
;
1139 wxChar
*wxPropertyValidator::FloatToString (float number
) {
1140 static wxChar buf
[20];
1141 wxSprintf (buf
, wxT("%.6g"), number
);
1145 wxChar
*wxPropertyValidator::DoubleToString (double number
) {
1146 static wxChar buf
[20];
1147 wxSprintf (buf
, wxT("%.6g"), number
);
1151 wxChar
*wxPropertyValidator::IntToString (int number
) {
1152 return ::IntToString (number
);
1155 wxChar
*wxPropertyValidator::LongToString (long number
) {
1156 return ::LongToString (number
);