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"
38 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue
, wxObject
)
40 wxPropertyValue::wxPropertyValue(void)
42 m_type
= wxPropertyValueNull
;
47 m_modifiedFlag
= FALSE
;
50 wxPropertyValue::wxPropertyValue(const wxPropertyValue
& copyFrom
)
52 m_value
.string
= (wxChar
*) NULL
;
53 m_modifiedFlag
= FALSE
;
54 Copy((wxPropertyValue
& )copyFrom
);
57 wxPropertyValue::wxPropertyValue(const wxChar
*val
)
59 m_modifiedFlag
= FALSE
;
60 m_type
= wxPropertyValueString
;
62 m_value
.string
= copystring(val
);
68 wxPropertyValue::wxPropertyValue(const wxString
& val
)
70 m_modifiedFlag
= FALSE
;
71 m_type
= wxPropertyValueString
;
73 m_value
.string
= copystring((const wxChar
*)val
);
79 wxPropertyValue::wxPropertyValue(long the_integer
)
81 m_modifiedFlag
= FALSE
;
82 m_type
= wxPropertyValueInteger
;
83 m_value
.integer
= the_integer
;
88 wxPropertyValue::wxPropertyValue(bool val
)
90 m_modifiedFlag
= FALSE
;
91 m_type
= wxPropertyValuebool
;
92 m_value
.integer
= val
;
97 wxPropertyValue::wxPropertyValue(float the_real
)
99 m_modifiedFlag
= FALSE
;
100 m_type
= wxPropertyValueReal
;
101 m_value
.real
= the_real
;
106 wxPropertyValue::wxPropertyValue(double the_real
)
108 m_modifiedFlag
= FALSE
;
109 m_type
= wxPropertyValueReal
;
110 m_value
.real
= (float)the_real
;
115 // Pointer versions: we have a pointer to the real C++ value.
116 wxPropertyValue::wxPropertyValue(wxChar
**val
)
118 m_modifiedFlag
= FALSE
;
119 m_type
= wxPropertyValueStringPtr
;
121 m_value
.stringPtr
= val
;
127 wxPropertyValue::wxPropertyValue(long *val
)
129 m_modifiedFlag
= FALSE
;
130 m_type
= wxPropertyValueIntegerPtr
;
131 m_value
.integerPtr
= val
;
136 wxPropertyValue::wxPropertyValue(bool *val
)
138 m_modifiedFlag
= FALSE
;
139 m_type
= wxPropertyValueboolPtr
;
140 m_value
.boolPtr
= val
;
145 wxPropertyValue::wxPropertyValue(float *val
)
147 m_modifiedFlag
= FALSE
;
148 m_type
= wxPropertyValueRealPtr
;
149 m_value
.realPtr
= val
;
154 wxPropertyValue::wxPropertyValue(wxList
*the_list
)
156 m_modifiedFlag
= FALSE
;
157 m_type
= wxPropertyValueList
;
160 m_value
.first
= NULL
;
162 wxNode
*node
= the_list
->First();
165 wxPropertyValue
*expr
= (wxPropertyValue
*)node
->Data();
173 wxPropertyValue::wxPropertyValue(wxStringList
*the_list
)
175 m_modifiedFlag
= FALSE
;
176 m_type
= wxPropertyValueList
;
179 m_value
.first
= NULL
;
181 wxNode
*node
= the_list
->First();
184 wxChar
*s
= (wxChar
*)node
->Data();
185 Append(new wxPropertyValue(s
));
191 wxPropertyValue::~wxPropertyValue(void)
195 case wxPropertyValueInteger
:
196 case wxPropertyValuebool
:
197 case wxPropertyValueReal
:
201 case wxPropertyValueString
:
203 delete[] m_value
.string
;
206 case wxPropertyValueList
:
208 wxPropertyValue
*expr
= m_value
.first
;
211 wxPropertyValue
*expr1
= expr
->m_next
;
219 case wxPropertyValueNull
: break;
223 void wxPropertyValue::Append(wxPropertyValue
*expr
)
225 m_modifiedFlag
= TRUE
;
227 m_value
.first
= expr
;
230 m_last
->m_next
= expr
;
234 void wxPropertyValue::Insert(wxPropertyValue
*expr
)
236 m_modifiedFlag
= TRUE
;
237 expr
->m_next
= m_value
.first
;
238 m_value
.first
= expr
;
245 void wxPropertyValue::Delete(wxPropertyValue
*node
)
247 wxPropertyValue
*expr
= GetFirst();
249 wxPropertyValue
*previous
= NULL
;
250 while (expr
&& (expr
!= node
))
253 expr
= expr
->GetNext();
259 previous
->m_next
= expr
->m_next
;
261 // If node was the first in the list,
262 // make the list point to the NEXT one.
263 if (GetFirst() == expr
)
265 m_value
.first
= expr
->m_next
;
268 // If node was the last in the list,
269 // make the list 'last' pointer point to the PREVIOUS one.
270 if (GetLast() == expr
)
277 m_modifiedFlag
= TRUE
;
283 void wxPropertyValue::ClearList(void)
285 wxPropertyValue
*val
= GetFirst();
287 m_modifiedFlag
= TRUE
;
291 wxPropertyValue
*next
= val
->GetNext();
295 m_value
.first
= NULL
;
299 wxPropertyValue
*wxPropertyValue::NewCopy(void) const
303 case wxPropertyValueInteger
:
304 return new wxPropertyValue(m_value
.integer
);
305 case wxPropertyValuebool
:
306 return new wxPropertyValue((bool) (m_value
.integer
!= 0));
307 case wxPropertyValueReal
:
308 return new wxPropertyValue(m_value
.real
);
309 case wxPropertyValueString
:
310 return new wxPropertyValue(m_value
.string
);
311 case wxPropertyValueList
:
313 wxPropertyValue
*expr
= m_value
.first
;
314 wxPropertyValue
*new_list
= new wxPropertyValue
;
315 new_list
->SetType(wxPropertyValueList
);
318 wxPropertyValue
*expr2
= expr
->NewCopy();
319 new_list
->Append(expr2
);
324 case wxPropertyValueIntegerPtr
:
325 return new wxPropertyValue(m_value
.integerPtr
);
326 case wxPropertyValueRealPtr
:
327 return new wxPropertyValue(m_value
.realPtr
);
328 case wxPropertyValueboolPtr
:
329 return new wxPropertyValue(m_value
.boolPtr
);
330 case wxPropertyValueStringPtr
:
331 return new wxPropertyValue(m_value
.stringPtr
);
333 case wxPropertyValueNull
:
334 wxFAIL_MSG( wxT("Should never get here!\n" ) );
340 void wxPropertyValue::Copy(wxPropertyValue
& copyFrom
)
342 if (m_type
== wxPropertyValueString
)
344 delete[] m_value
.string
;
345 m_value
.string
= NULL
;
347 m_type
= copyFrom
.Type();
351 case wxPropertyValueInteger
:
352 (*this) = copyFrom
.IntegerValue();
355 case wxPropertyValueReal
:
356 (*this) = copyFrom
.RealValue();
359 case wxPropertyValueString
:
360 (*this) = wxString(copyFrom
.StringValue());
363 case wxPropertyValuebool
:
364 (*this) = copyFrom
.BoolValue();
368 case wxPropertyValueboolPtr
:
369 (*this) = copyFrom
.BoolValuePtr();
371 case wxPropertyValueRealPtr
:
372 (*this) = copyFrom
.RealValuePtr();
374 case wxPropertyValueIntegerPtr
:
375 (*this) = copyFrom
.IntegerValuePtr();
377 case wxPropertyValueStringPtr
:
379 wxChar
** s
= copyFrom
.StringValuePtr();
382 // what is this? are you trying to assign a bool or a string? VA can't figure it out..
383 #if defined(__VISAGECPP__) || defined( __VISUALC__ )
390 (*this) = (bool)(s
!= 0);
395 case wxPropertyValueList
:
397 m_value
.first
= NULL
;
400 wxPropertyValue
*expr
= copyFrom
.m_value
.first
;
403 wxPropertyValue
*expr2
= expr
->NewCopy();
409 case wxPropertyValueNull
:
410 wxFAIL_MSG( wxT("Should never get here!\n" ) );
415 // Return nth argument of a clause (starting from 1)
416 wxPropertyValue
*wxPropertyValue::Arg(wxPropertyValueType type
, int arg
) const
418 wxPropertyValue
*expr
= m_value
.first
;
419 for (int i
= 1; i
< arg
; i
++)
423 if (expr
&& (expr
->m_type
== type
))
429 // Return nth argument of a list expression (starting from zero)
430 wxPropertyValue
*wxPropertyValue::Nth(int arg
) const
432 if (m_type
!= wxPropertyValueList
)
435 wxPropertyValue
*expr
= m_value
.first
;
436 for (int i
= 0; i
< arg
; i
++)
447 // Returns the number of elements in a list expression
448 int wxPropertyValue::Number(void) const
450 if (m_type
!= wxPropertyValueList
)
454 wxPropertyValue
*expr
= m_value
.first
;
463 void wxPropertyValue::WritePropertyClause(wxString
& stream
) // Write this expression as a top-level clause
465 if (m_type
!= wxPropertyValueList
)
468 wxPropertyValue
*node
= m_value
.first
;
471 node
->WritePropertyType(stream
);
472 stream
.Append( wxT("(") );
478 stream
.Append( wxT(" ") );
479 node
->WritePropertyType(stream
);
482 stream
.Append( wxT(",\n" ) );
485 stream
.Append( wxT(").\n\n") );
489 void wxPropertyValue::WritePropertyType(wxString
& stream
) // Write as any other subexpression
494 case wxPropertyValueInteger
:
496 tmp
.Printf( wxT("%ld"), m_value
.integer
);
497 stream
.Append( tmp
);
500 case wxPropertyValueIntegerPtr
:
502 tmp
.Printf( wxT("%ld"), *m_value
.integerPtr
);
503 stream
.Append( tmp
);
506 case wxPropertyValuebool
:
509 stream
.Append( wxT("True") );
511 stream
.Append( wxT("False") );
514 case wxPropertyValueboolPtr
:
516 if (*m_value
.integerPtr
)
517 stream
.Append( wxT("True") );
519 stream
.Append( wxT("False") );
522 case wxPropertyValueReal
:
524 double d
= m_value
.real
;
525 tmp
.Printf( wxT("%.6g"), d
);
526 stream
.Append( tmp
);
529 case wxPropertyValueRealPtr
:
531 double d
= *m_value
.realPtr
;
532 tmp
.Printf( wxT("%.6g"), d
);
533 stream
.Append( tmp
);
536 case wxPropertyValueString
:
538 stream
.Append( m_value
.string
);
541 case wxPropertyValueStringPtr
:
543 wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );
546 int len = strlen(*(m_value.stringPtr));
547 for (i = 0; i < len; i++)
549 char ch = *(m_value.stringPtr)[i];
555 case wxPropertyValueList
:
558 stream
.Append( wxT("[]") );
561 wxPropertyValue
*expr
= m_value
.first
;
563 stream
.Append( wxT("[") );
566 expr
->WritePropertyType(stream
);
569 stream
.Append( wxT(", ") );
571 stream
.Append( wxT("]") );
575 case wxPropertyValueNull
: break;
579 wxString
wxPropertyValue::GetStringRepresentation(void)
582 WritePropertyType(str
);
586 void wxPropertyValue::operator=(const wxPropertyValue
& val
)
588 m_modifiedFlag
= TRUE
;
589 Copy((wxPropertyValue
&)val
);
592 // void wxPropertyValue::operator=(const char *val)
593 void wxPropertyValue::operator=(const wxString
& val1
)
595 const wxChar
*val
= (const wxChar
*)val1
;
597 m_modifiedFlag
= TRUE
;
599 wxPropertyValueType oldType
= m_type
;
600 if (oldType
== wxPropertyValueString
)
602 delete[] m_value
.string
;
603 m_value
.string
= NULL
;
606 if (m_type
== wxPropertyValueNull
)
607 m_type
= wxPropertyValueString
;
609 if (m_type
== wxPropertyValueString
)
612 m_value
.string
= copystring(val
);
614 m_value
.string
= NULL
;
616 else if (m_type
== wxPropertyValueStringPtr
)
618 wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") );
620 *m_value
.stringPtr
= copystring(val
);
622 *m_value
.stringPtr
= NULL
;
631 void wxPropertyValue::operator=(const long val
)
633 wxPropertyValueType oldType
= m_type
;
634 if (oldType
== wxPropertyValueString
)
636 delete[] m_value
.string
;
637 m_value
.string
= NULL
;
640 m_modifiedFlag
= TRUE
;
641 if (m_type
== wxPropertyValueNull
)
642 m_type
= wxPropertyValueInteger
;
644 if (m_type
== wxPropertyValueInteger
)
645 m_value
.integer
= val
;
646 else if (m_type
== wxPropertyValueIntegerPtr
)
647 *m_value
.integerPtr
= val
;
648 else if (m_type
== wxPropertyValueReal
)
649 m_value
.real
= (float)val
;
650 else if (m_type
== wxPropertyValueRealPtr
)
651 *m_value
.realPtr
= (float)val
;
657 void wxPropertyValue::operator=(const bool val
)
659 wxPropertyValueType oldType
= m_type
;
660 if (oldType
== wxPropertyValueString
)
662 delete[] m_value
.string
;
663 m_value
.string
= NULL
;
666 m_modifiedFlag
= TRUE
;
667 if (m_type
== wxPropertyValueNull
)
668 m_type
= wxPropertyValuebool
;
670 if (m_type
== wxPropertyValuebool
)
671 m_value
.integer
= (long)val
;
672 else if (m_type
== wxPropertyValueboolPtr
)
673 *m_value
.boolPtr
= val
;
679 void wxPropertyValue::operator=(const float val
)
681 wxPropertyValueType oldType
= m_type
;
682 if (oldType
== wxPropertyValueString
)
684 delete[] m_value
.string
;
685 m_value
.string
= NULL
;
688 m_modifiedFlag
= TRUE
;
689 if (m_type
== wxPropertyValueNull
)
690 m_type
= wxPropertyValueReal
;
692 if (m_type
== wxPropertyValueInteger
)
693 m_value
.integer
= (long)val
;
694 else if (m_type
== wxPropertyValueIntegerPtr
)
695 *m_value
.integerPtr
= (long)val
;
696 else if (m_type
== wxPropertyValueReal
)
698 else if (m_type
== wxPropertyValueRealPtr
)
699 *m_value
.realPtr
= val
;
705 void wxPropertyValue::operator=(const wxChar
**val
)
707 wxPropertyValueType oldType
= m_type
;
708 if (oldType
== wxPropertyValueString
)
710 delete[] m_value
.string
;
711 m_value
.string
= NULL
;
714 m_modifiedFlag
= TRUE
;
715 m_type
= wxPropertyValueStringPtr
;
718 m_value
.stringPtr
= (wxChar
**)val
;
720 m_value
.stringPtr
= NULL
;
727 void wxPropertyValue::operator=(const long *val
)
729 m_modifiedFlag
= TRUE
;
730 m_type
= wxPropertyValueIntegerPtr
;
731 m_value
.integerPtr
= (long *)val
;
736 void wxPropertyValue::operator=(const bool *val
)
738 m_modifiedFlag
= TRUE
;
739 m_type
= wxPropertyValueboolPtr
;
740 m_value
.boolPtr
= (bool *)val
;
745 void wxPropertyValue::operator=(const float *val
)
747 m_modifiedFlag
= TRUE
;
748 m_type
= wxPropertyValueRealPtr
;
749 m_value
.realPtr
= (float *)val
;
754 long wxPropertyValue::IntegerValue(void) const
756 if (m_type
== wxPropertyValueInteger
)
757 return m_value
.integer
;
758 else if (m_type
== wxPropertyValueReal
)
759 return (long)m_value
.real
;
760 else if (m_type
== wxPropertyValueIntegerPtr
)
761 return *m_value
.integerPtr
;
762 else if (m_type
== wxPropertyValueRealPtr
)
763 return (long)(*m_value
.realPtr
);
767 long *wxPropertyValue::IntegerValuePtr(void) const
769 return m_value
.integerPtr
;
772 float wxPropertyValue::RealValue(void) const {
773 if (m_type
== wxPropertyValueReal
)
775 else if (m_type
== wxPropertyValueRealPtr
)
776 return *m_value
.realPtr
;
777 else if (m_type
== wxPropertyValueInteger
)
778 return (float)m_value
.integer
;
779 else if (m_type
== wxPropertyValueIntegerPtr
)
780 return (float)*(m_value
.integerPtr
);
784 float *wxPropertyValue::RealValuePtr(void) const
786 return m_value
.realPtr
;
789 bool wxPropertyValue::BoolValue(void) const {
790 if (m_type
== wxPropertyValueReal
)
791 return (m_value
.real
!= 0.0);
792 if (m_type
== wxPropertyValueRealPtr
)
793 return (*(m_value
.realPtr
) != 0.0);
794 else if (m_type
== wxPropertyValueInteger
)
795 return (m_value
.integer
!= 0);
796 else if (m_type
== wxPropertyValueIntegerPtr
)
797 return (*(m_value
.integerPtr
) != 0);
798 else if (m_type
== wxPropertyValuebool
)
799 return (m_value
.integer
!= 0);
800 else if (m_type
== wxPropertyValueboolPtr
)
801 return (*(m_value
.boolPtr
) != 0);
805 bool *wxPropertyValue::BoolValuePtr(void) const
807 return m_value
.boolPtr
;
810 wxChar
*wxPropertyValue::StringValue(void) const {
811 if (m_type
== wxPropertyValueString
)
812 return m_value
.string
;
813 else if (m_type
== wxPropertyValueStringPtr
)
814 return *(m_value
.stringPtr
);
818 wxChar
**wxPropertyValue::StringValuePtr(void) const
820 return m_value
.stringPtr
;
824 * A property (name plus value)
827 IMPLEMENT_DYNAMIC_CLASS(wxProperty
, wxObject
)
829 wxProperty::wxProperty(void)
831 m_propertyRole
= wxEmptyString
;
832 m_propertyValidator
= NULL
;
833 m_propertyWindow
= NULL
;
837 wxProperty::wxProperty(wxProperty
& copyFrom
)
839 m_value
= copyFrom
.GetValue();
840 m_name
= copyFrom
.GetName();
841 m_propertyRole
= copyFrom
.GetRole();
842 m_propertyValidator
= copyFrom
.GetValidator();
843 m_enabled
= copyFrom
.IsEnabled();
844 m_propertyWindow
= NULL
;
847 wxProperty::wxProperty(wxString nm
, wxString role
, wxPropertyValidator
*ed
):m_name(nm
), m_propertyRole(role
)
849 m_propertyValidator
= ed
;
850 m_propertyWindow
= NULL
;
854 wxProperty::wxProperty(wxString nm
, const wxPropertyValue
& val
, wxString role
, wxPropertyValidator
*ed
):
855 m_value(val
), m_name(nm
), m_propertyRole(role
)
857 m_propertyValidator
= ed
;
858 m_propertyWindow
= NULL
;
862 wxProperty::~wxProperty(void)
864 if (m_propertyValidator
)
865 delete m_propertyValidator
;
868 wxPropertyValue
& wxProperty::GetValue(void) const
870 return (wxPropertyValue
&) m_value
;
873 wxPropertyValidator
*wxProperty::GetValidator(void) const
875 return m_propertyValidator
;
878 wxString
& wxProperty::GetName(void) const
880 return (wxString
&) m_name
;
883 wxString
& wxProperty::GetRole(void) const
885 return (wxString
&) m_propertyRole
;
888 void wxProperty::SetValue(const wxPropertyValue
& val
)
893 void wxProperty::SetValidator(wxPropertyValidator
*ed
)
895 m_propertyValidator
= ed
;
898 void wxProperty::SetRole(wxString
& role
)
900 m_propertyRole
= role
;
903 void wxProperty::SetName(wxString
& nm
)
908 void wxProperty::operator=(const wxPropertyValue
& val
)
914 * Base property view class
917 IMPLEMENT_DYNAMIC_CLASS(wxPropertyView
, wxEvtHandler
)
919 wxPropertyView::wxPropertyView(long flags
)
921 m_buttonFlags
= flags
;
922 m_propertySheet
= NULL
;
923 m_currentValidator
= NULL
;
924 m_currentProperty
= NULL
;
927 wxPropertyView::~wxPropertyView(void)
931 void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry
*registry
)
933 m_validatorRegistryList
.Append(registry
);
936 wxPropertyValidator
*wxPropertyView::FindPropertyValidator(wxProperty
*property
)
938 if (property
->GetValidator())
939 return property
->GetValidator();
941 wxNode
*node
= m_validatorRegistryList
.First();
944 wxPropertyValidatorRegistry
*registry
= (wxPropertyValidatorRegistry
*)node
->Data();
945 wxPropertyValidator
*validator
= registry
->GetValidator(property
->GetRole());
952 if (!wxDefaultPropertyValidator)
953 wxDefaultPropertyValidator = new wxPropertyListValidator;
954 return wxDefaultPropertyValidator;
962 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet
, wxObject
)
964 wxPropertySheet::wxPropertySheet(const wxString
& name
)
965 :m_properties(wxKEY_STRING
),m_name(name
)
969 wxPropertySheet::~wxPropertySheet(void)
974 void wxPropertySheet::UpdateAllViews( wxPropertyView
*WXUNUSED(thisView
) )
979 void wxPropertySheet::AddProperty(wxProperty
*property
)
981 m_properties
.Append((const wxChar
*) property
->GetName(), property
);
984 // Get property by name
985 wxProperty
*wxPropertySheet::GetProperty(const wxString
& name
) const
987 wxNode
*node
= m_properties
.Find((const wxChar
*) name
);
991 return (wxProperty
*)node
->Data();
994 bool wxPropertySheet::SetProperty(const wxString
& name
, const wxPropertyValue
& value
)
996 wxProperty
* prop
= GetProperty(name
);
998 prop
->SetValue(value
);
1005 void wxPropertySheet::RemoveProperty(const wxString
& name
)
1007 wxNode
*node
= m_properties
.Find(name
);
1010 wxProperty
*prop
= (wxProperty
*)node
->Data();
1012 m_properties
.DeleteNode(node
);
1016 bool wxPropertySheet::HasProperty(const wxString
& name
) const
1018 return (GetProperty(name
)?TRUE
:FALSE
);
1021 // Clear all properties
1022 void wxPropertySheet::Clear(void)
1024 wxNode
*node
= m_properties
.First();
1027 wxProperty
*prop
= (wxProperty
*)node
->Data();
1028 wxNode
*next
= node
->Next();
1035 // Sets/clears the modified flag for each property value
1036 void wxPropertySheet::SetAllModified(bool flag
)
1038 wxNode
*node
= m_properties
.First();
1041 wxProperty
*prop
= (wxProperty
*)node
->Data();
1042 prop
->GetValue().SetModified(flag
);
1043 node
= node
->Next();
1048 * Property validator registry
1052 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry
, wxHashTable
)
1054 wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING
)
1058 wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
1063 void wxPropertyValidatorRegistry::RegisterValidator(const wxString
& typeName
, wxPropertyValidator
*validator
)
1065 Put((const wxChar
*) typeName
, validator
);
1068 wxPropertyValidator
*wxPropertyValidatorRegistry::GetValidator(const wxString
& typeName
)
1070 return (wxPropertyValidator
*)Get((const wxChar
*) typeName
);
1073 void wxPropertyValidatorRegistry::ClearRegistry(void)
1077 while ((node
= Next()) != NULL
)
1079 delete (wxPropertyValidator
*)node
->Data();
1084 * Property validator
1088 IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator
, wxEvtHandler
)
1090 wxPropertyValidator::wxPropertyValidator(long flags
)
1092 m_validatorFlags
= flags
;
1093 m_validatorProperty
= NULL
;
1096 wxPropertyValidator::~wxPropertyValidator(void)
1099 bool wxPropertyValidator::StringToFloat (wxChar
*s
, float *number
) {
1101 bool ok
= StringToDouble (s
, &num
);
1102 *number
= (float) num
;
1106 bool wxPropertyValidator::StringToDouble (wxChar
*s
, double *number
) {
1109 *number
= wxStrtod (s
, &value_ptr
);
1111 int len
= wxStrlen (value_ptr
);
1112 for (int i
= 0; i
< len
; i
++) {
1113 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1114 if (!ok
) return FALSE
;
1120 bool wxPropertyValidator::StringToInt (wxChar
*s
, int *number
) {
1122 bool ok
= StringToLong (s
, &num
);
1123 *number
= (int) num
;
1127 bool wxPropertyValidator::StringToLong (wxChar
*s
, long *number
) {
1130 *number
= wxStrtol (s
, &value_ptr
, 10);
1132 int len
= wxStrlen (value_ptr
);
1133 for (int i
= 0; i
< len
; i
++) {
1134 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1135 if (!ok
) return FALSE
;
1141 wxChar
*wxPropertyValidator::FloatToString (float number
) {
1142 static wxChar buf
[20];
1143 wxSprintf (buf
, wxT("%.6g"), number
);
1147 wxChar
*wxPropertyValidator::DoubleToString (double number
) {
1148 static wxChar buf
[20];
1149 wxSprintf (buf
, wxT("%.6g"), number
);
1153 wxChar
*wxPropertyValidator::IntToString (int number
) {
1154 return ::IntToString (number
);
1157 wxChar
*wxPropertyValidator::LongToString (long number
) {
1158 return ::LongToString (number
);
1161 #endif // wxUSE_PROPSHEET