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
)
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
->GetFirst();
165 wxPropertyValue
*expr
= (wxPropertyValue
*)node
->GetData();
167 node
= node
->GetNext();
173 wxPropertyValue::wxPropertyValue(wxStringList
*the_list
)
175 m_modifiedFlag
= FALSE
;
176 m_type
= wxPropertyValueList
;
179 m_value
.first
= NULL
;
181 wxStringList::Node
*node
= the_list
->GetFirst();
184 wxChar
*s
= node
->GetData();
185 Append(new wxPropertyValue(s
));
186 node
= node
->GetNext();
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
)
840 m_value
= copyFrom
.GetValue();
841 m_name
= copyFrom
.GetName();
842 m_propertyRole
= copyFrom
.GetRole();
843 m_propertyValidator
= copyFrom
.GetValidator();
844 m_enabled
= copyFrom
.IsEnabled();
845 m_propertyWindow
= NULL
;
848 wxProperty::wxProperty(wxString nm
, wxString role
, wxPropertyValidator
*ed
):m_name(nm
), m_propertyRole(role
)
850 m_propertyValidator
= ed
;
851 m_propertyWindow
= NULL
;
855 wxProperty::wxProperty(wxString nm
, const wxPropertyValue
& val
, wxString role
, wxPropertyValidator
*ed
):
856 m_value(val
), m_name(nm
), m_propertyRole(role
)
858 m_propertyValidator
= ed
;
859 m_propertyWindow
= NULL
;
863 wxProperty::~wxProperty(void)
865 if (m_propertyValidator
)
866 delete m_propertyValidator
;
869 wxPropertyValue
& wxProperty::GetValue(void) const
871 return (wxPropertyValue
&) m_value
;
874 wxPropertyValidator
*wxProperty::GetValidator(void) const
876 return m_propertyValidator
;
879 wxString
& wxProperty::GetName(void) const
881 return (wxString
&) m_name
;
884 wxString
& wxProperty::GetRole(void) const
886 return (wxString
&) m_propertyRole
;
889 void wxProperty::SetValue(const wxPropertyValue
& val
)
894 void wxProperty::SetValidator(wxPropertyValidator
*ed
)
896 m_propertyValidator
= ed
;
899 void wxProperty::SetRole(wxString
& role
)
901 m_propertyRole
= role
;
904 void wxProperty::SetName(wxString
& nm
)
909 void wxProperty::operator=(const wxPropertyValue
& val
)
915 * Base property view class
918 IMPLEMENT_DYNAMIC_CLASS(wxPropertyView
, wxEvtHandler
)
920 wxPropertyView::wxPropertyView(long flags
)
922 m_buttonFlags
= flags
;
923 m_propertySheet
= NULL
;
924 m_currentValidator
= NULL
;
925 m_currentProperty
= NULL
;
928 wxPropertyView::~wxPropertyView(void)
932 void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry
*registry
)
934 m_validatorRegistryList
.Append(registry
);
937 wxPropertyValidator
*wxPropertyView::FindPropertyValidator(wxProperty
*property
)
939 if (property
->GetValidator())
940 return property
->GetValidator();
942 wxNode
*node
= m_validatorRegistryList
.GetFirst();
945 wxPropertyValidatorRegistry
*registry
= (wxPropertyValidatorRegistry
*)node
->GetData();
946 wxPropertyValidator
*validator
= registry
->GetValidator(property
->GetRole());
949 node
= node
->GetNext();
953 if (!wxDefaultPropertyValidator)
954 wxDefaultPropertyValidator = new wxPropertyListValidator;
955 return wxDefaultPropertyValidator;
963 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet
, wxObject
)
965 wxPropertySheet::wxPropertySheet(const wxString
& name
)
966 :m_properties(wxKEY_STRING
),m_name(name
)
970 wxPropertySheet::~wxPropertySheet(void)
975 void wxPropertySheet::UpdateAllViews( wxPropertyView
*WXUNUSED(thisView
) )
980 void wxPropertySheet::AddProperty(wxProperty
*property
)
982 m_properties
.Append((const wxChar
*) property
->GetName(), property
);
985 // Get property by name
986 wxProperty
*wxPropertySheet::GetProperty(const wxString
& name
) const
988 wxNode
*node
= m_properties
.Find((const wxChar
*) name
);
992 return (wxProperty
*)node
->GetData();
995 bool wxPropertySheet::SetProperty(const wxString
& name
, const wxPropertyValue
& value
)
997 wxProperty
* prop
= GetProperty(name
);
999 prop
->SetValue(value
);
1006 void wxPropertySheet::RemoveProperty(const wxString
& name
)
1008 wxNode
*node
= m_properties
.Find(name
);
1011 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1013 m_properties
.DeleteNode(node
);
1017 bool wxPropertySheet::HasProperty(const wxString
& name
) const
1019 return (GetProperty(name
)?TRUE
:FALSE
);
1022 // Clear all properties
1023 void wxPropertySheet::Clear(void)
1025 wxNode
*node
= m_properties
.GetFirst();
1028 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1029 wxNode
*next
= node
->GetNext();
1036 // Sets/clears the modified flag for each property value
1037 void wxPropertySheet::SetAllModified(bool flag
)
1039 wxNode
*node
= m_properties
.GetFirst();
1042 wxProperty
*prop
= (wxProperty
*)node
->GetData();
1043 prop
->GetValue().SetModified(flag
);
1044 node
= node
->GetNext();
1049 * Property validator registry
1053 IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry
, wxHashTable
)
1055 wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING
)
1059 wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void)
1064 void wxPropertyValidatorRegistry::RegisterValidator(const wxString
& typeName
, wxPropertyValidator
*validator
)
1066 Put((const wxChar
*) typeName
, validator
);
1069 wxPropertyValidator
*wxPropertyValidatorRegistry::GetValidator(const wxString
& typeName
)
1071 return (wxPropertyValidator
*)Get((const wxChar
*) typeName
);
1074 void wxPropertyValidatorRegistry::ClearRegistry(void)
1078 while ((node
= Next()) != NULL
)
1080 delete (wxPropertyValidator
*)node
->GetData();
1085 * Property validator
1089 IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator
, wxEvtHandler
)
1091 wxPropertyValidator::wxPropertyValidator(long flags
)
1093 m_validatorFlags
= flags
;
1094 m_validatorProperty
= NULL
;
1097 wxPropertyValidator::~wxPropertyValidator(void)
1100 bool wxPropertyValidator::StringToFloat (wxChar
*s
, float *number
) {
1102 bool ok
= StringToDouble (s
, &num
);
1103 *number
= (float) num
;
1107 bool wxPropertyValidator::StringToDouble (wxChar
*s
, double *number
) {
1110 *number
= wxStrtod (s
, &value_ptr
);
1112 int len
= wxStrlen (value_ptr
);
1113 for (int i
= 0; i
< len
; i
++) {
1114 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1115 if (!ok
) return FALSE
;
1121 bool wxPropertyValidator::StringToInt (wxChar
*s
, int *number
) {
1123 bool ok
= StringToLong (s
, &num
);
1124 *number
= (int) num
;
1128 bool wxPropertyValidator::StringToLong (wxChar
*s
, long *number
) {
1131 *number
= wxStrtol (s
, &value_ptr
, 10);
1133 int len
= wxStrlen (value_ptr
);
1134 for (int i
= 0; i
< len
; i
++) {
1135 ok
= (wxIsspace (value_ptr
[i
]) != 0);
1136 if (!ok
) return FALSE
;
1142 wxChar
*wxPropertyValidator::FloatToString (float number
) {
1143 static wxChar buf
[20];
1144 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1148 wxChar
*wxPropertyValidator::DoubleToString (double number
) {
1149 static wxChar buf
[20];
1150 wxSnprintf (buf
, 20, wxT("%.6g"), number
);
1154 wxChar
*wxPropertyValidator::IntToString (int number
) {
1155 return ::IntToString (number
);
1158 wxChar
*wxPropertyValidator::LongToString (long number
) {
1159 return ::LongToString (number
);
1162 #endif // wxUSE_PROPSHEET