X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3a2490c684620904e063cf0a8ff1867c31818e18..758bce950ba9236d0a9edc4c880c3ec73b5173f3:/src/generic/prop.cpp diff --git a/src/generic/prop.cpp b/src/generic/prop.cpp index 178d82bc97..028427d935 100644 --- a/src/generic/prop.cpp +++ b/src/generic/prop.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -20,8 +20,9 @@ #pragma hdrstop #endif +#if wxUSE_PROPSHEET + #ifndef WX_PRECOMP -#include "wx/wx.h" #endif #include "wx/debug.h" @@ -47,6 +48,7 @@ wxPropertyValue::wxPropertyValue(void) wxPropertyValue::wxPropertyValue(const wxPropertyValue& copyFrom) { + m_value.string = (wxChar*) NULL; m_modifiedFlag = FALSE; Copy((wxPropertyValue& )copyFrom); } @@ -178,7 +180,7 @@ wxPropertyValue::wxPropertyValue(wxStringList *the_list) wxNode *node = the_list->First(); while (node) { - char *s = (char *)node->Data(); + wxChar *s = (wxChar *)node->Data(); Append(new wxPropertyValue(s)); node = node->Next(); } @@ -328,7 +330,7 @@ wxPropertyValue *wxPropertyValue::NewCopy(void) const return new wxPropertyValue(m_value.stringPtr); case wxPropertyValueNull: - wxFAIL_MSG( _T("Should never get here!\n" ) ); + wxFAIL_MSG( wxT("Should never get here!\n" ) ); break; } return NULL; @@ -336,6 +338,11 @@ wxPropertyValue *wxPropertyValue::NewCopy(void) const void wxPropertyValue::Copy(wxPropertyValue& copyFrom) { + if (m_type == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } m_type = copyFrom.Type(); switch (m_type) @@ -369,12 +376,18 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) case wxPropertyValueStringPtr: { wxChar** s = copyFrom.StringValuePtr(); + +#if 0 // what is this? are you trying to assign a bool or a string? VA can't figure it out.. -#if defined(__VISAGECPP__) +#if defined(__VISAGECPP__) || defined( __VISUALC__ ) (*this) = s; #else (*this) = s != 0; #endif +#endif // if 0 + + (*this) = (bool)(s != 0); + return ; } @@ -393,7 +406,7 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) return; } case wxPropertyValueNull: - wxFAIL_MSG( _T("Should never get here!\n" ) ); + wxFAIL_MSG( wxT("Should never get here!\n" ) ); break; } } @@ -455,20 +468,20 @@ void wxPropertyValue::WritePropertyClause(wxString& stream) // Write this expre if (node) { node->WritePropertyType(stream); - stream.Append( _T("(") ); + stream.Append( wxT("(") ); node = node->m_next; bool first = TRUE; while (node) { if (!first) - stream.Append( _T(" ") ); + stream.Append( wxT(" ") ); node->WritePropertyType(stream); node = node->m_next; if (node) - stream.Append( _T(",\n" ) ); + stream.Append( wxT(",\n" ) ); first = FALSE; } - stream.Append( _T(").\n\n") ); + stream.Append( wxT(").\n\n") ); } } @@ -479,43 +492,43 @@ void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any oth { case wxPropertyValueInteger: { - tmp.Printf( _T("%ld"), m_value.integer ); + tmp.Printf( wxT("%ld"), m_value.integer ); stream.Append( tmp ); break; } case wxPropertyValueIntegerPtr: { - tmp.Printf( _T("%ld"), *m_value.integerPtr ); + tmp.Printf( wxT("%ld"), *m_value.integerPtr ); stream.Append( tmp ); break; } case wxPropertyValuebool: { if (m_value.integer) - stream.Append( _T("True") ); + stream.Append( wxT("True") ); else - stream.Append( _T("False") ); + stream.Append( wxT("False") ); break; } case wxPropertyValueboolPtr: { if (*m_value.integerPtr) - stream.Append( _T("True") ); + stream.Append( wxT("True") ); else - stream.Append( _T("False") ); + stream.Append( wxT("False") ); break; } case wxPropertyValueReal: { double d = m_value.real; - tmp.Printf( _T("%.6g"), d ); + tmp.Printf( wxT("%.6g"), d ); stream.Append( tmp ); break; } case wxPropertyValueRealPtr: { double d = *m_value.realPtr; - tmp.Printf( _T("%.6g"), d ); + tmp.Printf( wxT("%.6g"), d ); stream.Append( tmp ); break; } @@ -526,7 +539,7 @@ void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any oth } case wxPropertyValueStringPtr: { - wxFAIL_MSG( _T("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") ); + wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") ); /* int i; int len = strlen(*(m_value.stringPtr)); @@ -541,20 +554,20 @@ void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any oth case wxPropertyValueList: { if (!m_value.first) - stream.Append( _T("[]") ); + stream.Append( wxT("[]") ); else { wxPropertyValue *expr = m_value.first; - stream.Append( _T("[") ); + stream.Append( wxT("[") ); while (expr) { expr->WritePropertyType(stream); expr = expr->m_next; if (expr) - stream.Append( _T(", ") ); + stream.Append( wxT(", ") ); } - stream.Append( _T("]") ); + stream.Append( wxT("]") ); } break; } @@ -581,6 +594,14 @@ void wxPropertyValue::operator=(const wxString& val1) const wxChar *val = (const wxChar *)val1; m_modifiedFlag = TRUE; + + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + if (m_type == wxPropertyValueNull) m_type = wxPropertyValueString; @@ -593,8 +614,7 @@ void wxPropertyValue::operator=(const wxString& val1) } else if (m_type == wxPropertyValueStringPtr) { - if (*m_value.stringPtr) - delete[] *m_value.stringPtr; + wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") ); if (val) *m_value.stringPtr = copystring(val); else @@ -609,6 +629,13 @@ void wxPropertyValue::operator=(const wxString& val1) void wxPropertyValue::operator=(const long val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; if (m_type == wxPropertyValueNull) m_type = wxPropertyValueInteger; @@ -628,6 +655,13 @@ void wxPropertyValue::operator=(const long val) void wxPropertyValue::operator=(const bool val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; if (m_type == wxPropertyValueNull) m_type = wxPropertyValuebool; @@ -643,6 +677,13 @@ void wxPropertyValue::operator=(const bool val) void wxPropertyValue::operator=(const float val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; if (m_type == wxPropertyValueNull) m_type = wxPropertyValueReal; @@ -662,6 +703,13 @@ void wxPropertyValue::operator=(const float val) void wxPropertyValue::operator=(const wxChar **val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; m_type = wxPropertyValueStringPtr; @@ -959,14 +1007,14 @@ void wxPropertySheet::RemoveProperty(const wxString& name) if(node) { wxProperty *prop = (wxProperty *)node->Data(); - delete prop; + delete prop; m_properties.DeleteNode(node); } -} +} bool wxPropertySheet::HasProperty(const wxString& name) const { - return (GetProperty(name)?TRUE:FALSE); + return (GetProperty(name)?TRUE:FALSE); } // Clear all properties @@ -1048,10 +1096,10 @@ wxPropertyValidator::~wxPropertyValidator(void) {} bool wxPropertyValidator::StringToFloat (wxChar *s, float *number) { - double num; - bool ok = StringToDouble (s, &num); - *number = (float) num; - return ok; + double num; + bool ok = StringToDouble (s, &num); + *number = (float) num; + return ok; } bool wxPropertyValidator::StringToDouble (wxChar *s, double *number) { @@ -1059,20 +1107,20 @@ bool wxPropertyValidator::StringToDouble (wxChar *s, double *number) { wxChar *value_ptr; *number = wxStrtod (s, &value_ptr); if (value_ptr) { - int len = wxStrlen (value_ptr); - for (int i = 0; i < len; i++) { - ok = (wxIsspace (value_ptr[i]) != 0); - if (!ok) return FALSE; - } + int len = wxStrlen (value_ptr); + for (int i = 0; i < len; i++) { + ok = (wxIsspace (value_ptr[i]) != 0); + if (!ok) return FALSE; + } } return ok; } bool wxPropertyValidator::StringToInt (wxChar *s, int *number) { - long num; - bool ok = StringToLong (s, &num); - *number = (int) num; - return ok; + long num; + bool ok = StringToLong (s, &num); + *number = (int) num; + return ok; } bool wxPropertyValidator::StringToLong (wxChar *s, long *number) { @@ -1080,31 +1128,33 @@ bool wxPropertyValidator::StringToLong (wxChar *s, long *number) { wxChar *value_ptr; *number = wxStrtol (s, &value_ptr, 10); if (value_ptr) { - int len = wxStrlen (value_ptr); - for (int i = 0; i < len; i++) { - ok = (wxIsspace (value_ptr[i]) != 0); - if (!ok) return FALSE; - } + int len = wxStrlen (value_ptr); + for (int i = 0; i < len; i++) { + ok = (wxIsspace (value_ptr[i]) != 0); + if (!ok) return FALSE; + } } return ok; } wxChar *wxPropertyValidator::FloatToString (float number) { - static wxChar buf[20]; - wxSprintf (buf, _T("%.6g"), number); - return buf; + static wxChar buf[20]; + wxSprintf (buf, wxT("%.6g"), number); + return buf; } wxChar *wxPropertyValidator::DoubleToString (double number) { - static wxChar buf[20]; - wxSprintf (buf, _T("%.6g"), number); - return buf; + static wxChar buf[20]; + wxSprintf (buf, wxT("%.6g"), number); + return buf; } wxChar *wxPropertyValidator::IntToString (int number) { - return ::IntToString (number); + return ::IntToString (number); } wxChar *wxPropertyValidator::LongToString (long number) { - return ::LongToString (number); + return ::LongToString (number); } + +#endif // wxUSE_PROPSHEET