X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9626e0bfc6ae68c9068cdca7a9a43c8e820c5eb9..58b1642453c5858a4dd29425b065e9215cb8ec79:/src/generic/prop.cpp diff --git a/src/generic/prop.cpp b/src/generic/prop.cpp index 058a0d5026..25fc02ce07 100644 --- a/src/generic/prop.cpp +++ b/src/generic/prop.cpp @@ -24,26 +24,14 @@ #include "wx/wx.h" #endif +#include "wx/debug.h" +#include "wx/prop.h" + #include #include #include #include -#if wxUSE_IOSTREAMH -#if defined(__WXMSW__) && !defined(__GNUWIN32__) -#include -#else -#include -#endif -#else -#include -#endif - -#include "wx/window.h" -#include "wx/utils.h" -#include "wx/list.h" -#include "wx/debug.h" -#include "wx/prop.h" IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue, wxObject) @@ -254,7 +242,7 @@ void wxPropertyValue::Insert(wxPropertyValue *expr) void wxPropertyValue::Delete(wxPropertyValue *node) { wxPropertyValue *expr = GetFirst(); - + wxPropertyValue *previous = NULL; while (expr && (expr != node)) { @@ -266,7 +254,7 @@ void wxPropertyValue::Delete(wxPropertyValue *node) { if (previous) previous->m_next = expr->m_next; - + // If node was the first in the list, // make the list point to the NEXT one. if (GetFirst() == expr) @@ -339,10 +327,8 @@ wxPropertyValue *wxPropertyValue::NewCopy(void) const case wxPropertyValueStringPtr: return new wxPropertyValue(m_value.stringPtr); - case wxPropertyValueNull: -#ifdef __X__ - cerr << "Should never get here!\n"; -#endif + case wxPropertyValueNull: + wxFAIL_MSG( wxT("Should never get here!\n" ) ); break; } return NULL; @@ -361,11 +347,11 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) case wxPropertyValueReal: (*this) = copyFrom.RealValue(); return ; - + case wxPropertyValueString: (*this) = wxString(copyFrom.StringValue()); return ; - + case wxPropertyValuebool: (*this) = copyFrom.BoolValue(); return ; @@ -383,10 +369,21 @@ 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__) || defined( __VISUALC__ ) (*this) = s; +#else + (*this) = s != 0; +#endif +#endif // if 0 + + (*this) = (bool)(s != 0); + return ; } - + case wxPropertyValueList: { m_value.first = NULL; @@ -401,10 +398,8 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) } return; } - case wxPropertyValueNull: -#ifdef __X__ - cerr << "Should never get here!\n"; -#endif + case wxPropertyValueNull: + wxFAIL_MSG( wxT("Should never get here!\n" ) ); break; } } @@ -457,7 +452,7 @@ int wxPropertyValue::Number(void) const return i; } -void wxPropertyValue::WritePropertyClause(ostream& stream) // Write this expression as a top-level clause +void wxPropertyValue::WritePropertyClause(wxString& stream) // Write this expression as a top-level clause { if (m_type != wxPropertyValueList) return; @@ -466,91 +461,78 @@ void wxPropertyValue::WritePropertyClause(ostream& stream) // Write this expres if (node) { node->WritePropertyType(stream); - stream << "("; + stream.Append( wxT("(") ); node = node->m_next; bool first = TRUE; while (node) { if (!first) - stream << " "; + stream.Append( wxT(" ") ); node->WritePropertyType(stream); node = node->m_next; - if (node) stream << ",\n"; + if (node) + stream.Append( wxT(",\n" ) ); first = FALSE; } - stream << ").\n\n"; + stream.Append( wxT(").\n\n") ); } } -void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any other subexpression +void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any other subexpression { + wxString tmp; switch (m_type) { case wxPropertyValueInteger: { - stream << m_value.integer; + tmp.Printf( wxT("%ld"), m_value.integer ); + stream.Append( tmp ); break; } case wxPropertyValueIntegerPtr: { - stream << *m_value.integerPtr; + tmp.Printf( wxT("%ld"), *m_value.integerPtr ); + stream.Append( tmp ); break; } case wxPropertyValuebool: { if (m_value.integer) - stream << "True"; + stream.Append( wxT("True") ); else - stream << "False"; + stream.Append( wxT("False") ); break; } case wxPropertyValueboolPtr: { if (*m_value.integerPtr) - stream << "True"; + stream.Append( wxT("True") ); else - stream << "False"; + stream.Append( wxT("False") ); break; } case wxPropertyValueReal: { - float f = m_value.real; - wxSprintf(wxBuffer, _T("%.6g"), (double)f); - stream << wxBuffer; + double d = m_value.real; + tmp.Printf( wxT("%.6g"), d ); + stream.Append( tmp ); break; } case wxPropertyValueRealPtr: { - float f = *m_value.realPtr; -/* Now the parser can cope with this. - // Prevent printing in 'e' notation. Any better way? - if (fabs(f) < 0.00001) - f = 0.0; -*/ - wxSprintf(wxBuffer, _T("%.6g"), f); - stream << wxBuffer; + double d = *m_value.realPtr; + tmp.Printf( wxT("%.6g"), d ); + stream.Append( tmp ); break; } case wxPropertyValueString: { -// stream << "\""; - int i; - const wxWX2MBbuf strbuf = wxConv_libc.cWX2MB(m_value.string); - int len = strlen(strbuf); - for (i = 0; i < len; i++) - { - char ch = strbuf[i]; -// if (ch == '"' || ch == '\\') -// stream << "\\"; - stream << ch; - } - -// stream << "\""; + stream.Append( m_value.string ); break; } 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)); @@ -565,19 +547,20 @@ void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any othe case wxPropertyValueList: { if (!m_value.first) - stream << "[]"; + stream.Append( wxT("[]") ); else { wxPropertyValue *expr = m_value.first; - stream << "["; + stream.Append( wxT("[") ); while (expr) { expr->WritePropertyType(stream); expr = expr->m_next; - if (expr) stream << ", "; + if (expr) + stream.Append( wxT(", ") ); } - stream << "]"; + stream.Append( wxT("]") ); } break; } @@ -587,16 +570,9 @@ void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any othe wxString wxPropertyValue::GetStringRepresentation(void) { - char buf[500]; - buf[0] = 0; - - ostrstream str((char *)buf, (int)500, ios::out); + wxString str; WritePropertyType(str); - str << '\0'; - str.flush(); - - wxString theString(buf); - return theString; + return str; } void wxPropertyValue::operator=(const wxPropertyValue& val) @@ -630,7 +606,7 @@ void wxPropertyValue::operator=(const wxString& val1) else *m_value.stringPtr = NULL; } - + m_clientData = NULL; m_next = NULL; m_last = NULL; @@ -804,7 +780,7 @@ wxChar **wxPropertyValue::StringValuePtr(void) const /* * A property (name plus value) */ - + IMPLEMENT_DYNAMIC_CLASS(wxProperty, wxObject) wxProperty::wxProperty(void) @@ -894,7 +870,7 @@ void wxProperty::operator=(const wxPropertyValue& val) /* * Base property view class */ - + IMPLEMENT_DYNAMIC_CLASS(wxPropertyView, wxEvtHandler) wxPropertyView::wxPropertyView(long flags) @@ -918,7 +894,7 @@ wxPropertyValidator *wxPropertyView::FindPropertyValidator(wxProperty *property) { if (property->GetValidator()) return property->GetValidator(); - + wxNode *node = m_validatorRegistryList.First(); while (node) { @@ -952,16 +928,6 @@ wxPropertySheet::~wxPropertySheet(void) Clear(); } -bool wxPropertySheet::Save( ostream& WXUNUSED(str) ) -{ - return FALSE; -} - -bool wxPropertySheet::Load( ostream& WXUNUSED(str) ) -{ - return FALSE; -} - void wxPropertySheet::UpdateAllViews( wxPropertyView *WXUNUSED(thisView) ) { } @@ -1005,8 +971,8 @@ void wxPropertySheet::RemoveProperty(const wxString& name) } bool wxPropertySheet::HasProperty(const wxString& name) const -{ - return (GetProperty(name)?TRUE:FALSE); +{ + return (GetProperty(name)?TRUE:FALSE); } // Clear all properties @@ -1032,7 +998,7 @@ void wxPropertySheet::SetAllModified(bool flag) wxProperty *prop = (wxProperty *)node->Data(); prop->GetValue().SetModified(flag); node = node->Next(); - } + } } /* @@ -1065,7 +1031,7 @@ void wxPropertyValidatorRegistry::ClearRegistry(void) { BeginFind(); wxNode *node; - while ((node = Next())) + while ((node = Next()) != NULL) { delete (wxPropertyValidator *)node->Data(); } @@ -1131,13 +1097,13 @@ bool wxPropertyValidator::StringToLong (wxChar *s, long *number) { wxChar *wxPropertyValidator::FloatToString (float number) { static wxChar buf[20]; - wxSprintf (buf, _T("%.6g"), number); + wxSprintf (buf, wxT("%.6g"), number); return buf; } wxChar *wxPropertyValidator::DoubleToString (double number) { static wxChar buf[20]; - wxSprintf (buf, _T("%.6g"), number); + wxSprintf (buf, wxT("%.6g"), number); return buf; }