// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma hdrstop
#endif
+#if wxUSE_PROPSHEET
+
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
wxPropertyValue::wxPropertyValue(const wxPropertyValue& copyFrom)
{
+ m_value.string = (wxChar*) NULL;
m_modifiedFlag = FALSE;
Copy((wxPropertyValue& )copyFrom);
}
wxNode *node = the_list->First();
while (node)
{
- char *s = (char *)node->Data();
+ wxChar *s = (wxChar *)node->Data();
Append(new wxPropertyValue(s));
node = node->Next();
}
void wxPropertyValue::Copy(wxPropertyValue& copyFrom)
{
+ if (m_type == wxPropertyValueString)
+ {
+ delete[] m_value.string ;
+ m_value.string = NULL;
+ }
m_type = copyFrom.Type();
switch (m_type)
expr->WritePropertyType(stream);
expr = expr->m_next;
if (expr)
- stream.Append( wxT(", ") );
+ stream.Append( wxT(", ") );
}
stream.Append( wxT("]") );
}
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;
}
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
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;
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;
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;
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;
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
{}
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) {
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) {
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, wxT("%.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, wxT("%.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