Added support for wxLongLong and wxULongLong in wxVariant (closes #10166)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61070 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -337,6 +337,7 @@ All:
|
||||
- Added wxStd{Input,Output}Stream classes (Jonathan Liu).
|
||||
- Include port number in host header in wxHTTP (Marcin 'Malcom' Malich).
|
||||
- Added wxTempFile::Flush().
|
||||
- Added support for wxLongLong and wxULongLong in wxVariant.
|
||||
|
||||
All (GUI):
|
||||
|
||||
|
@@ -517,6 +517,12 @@ template<> inline wxVariant WXVARIANT( const wxArrayString& value )
|
||||
{ return wxVariant(value); }
|
||||
template<> inline wxVariant WXVARIANT( const wxString& value )
|
||||
{ return wxVariant(value); }
|
||||
#if wxUSE_LONGLONG
|
||||
template<> inline wxVariant WXVARIANT( const wxLongLong& value )
|
||||
{ return wxVariant(value); }
|
||||
template<> inline wxVariant WXVARIANT( const wxULongLong& value )
|
||||
{ return wxVariant(value); }
|
||||
#endif
|
||||
#if wxUSE_DATETIME
|
||||
template<> inline wxVariant WXVARIANT( const wxDateTime& value )
|
||||
{ return wxVariant(value); }
|
||||
@@ -656,8 +662,6 @@ WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname, wxEMPTY_PARAMETER_VALU
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxPoint, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxSize, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxArrayInt, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxLongLong, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(wxULongLong, WXDLLIMPEXP_PROPGRID)
|
||||
DECLARE_VARIANT_OBJECT_EXPORTED(wxFont, WXDLLIMPEXP_PROPGRID)
|
||||
template<> inline wxVariant WXVARIANT( const wxFont& value )
|
||||
{
|
||||
@@ -673,27 +677,6 @@ template<> inline wxVariant WXVARIANT( const wxColour& value )
|
||||
return variant;
|
||||
}
|
||||
|
||||
#if wxUSE_LONGLONG_NATIVE
|
||||
|
||||
template<> inline wxVariant WXVARIANT( const wxLongLong_t& value )
|
||||
{
|
||||
wxVariant variant;
|
||||
variant << wxLongLong(value);
|
||||
return variant;
|
||||
}
|
||||
|
||||
template<> inline wxVariant WXVARIANT( const wxULongLong_t& value )
|
||||
{
|
||||
wxVariant variant;
|
||||
variant << wxULongLong(value);
|
||||
return variant;
|
||||
}
|
||||
|
||||
WXDLLIMPEXP_PROPGRID wxLongLong_t& operator << ( wxLongLong_t &value, const wxVariant &variant );
|
||||
WXDLLIMPEXP_PROPGRID wxULongLong_t& operator << ( wxULongLong_t &value, const wxVariant &variant );
|
||||
|
||||
#endif // wxUSE_LONGLONG_NATIVE
|
||||
|
||||
// Define constants for common wxVariant type strings
|
||||
|
||||
#define wxPG_VARIANT_TYPE_STRING wxPGGlobalVars->m_strstring
|
||||
@@ -703,24 +686,8 @@ WXDLLIMPEXP_PROPGRID wxULongLong_t& operator << ( wxULongLong_t &value, const wx
|
||||
#define wxPG_VARIANT_TYPE_DOUBLE wxS("double")
|
||||
#define wxPG_VARIANT_TYPE_ARRSTRING wxS("arrstring")
|
||||
#define wxPG_VARIANT_TYPE_DATETIME wxS("datetime")
|
||||
|
||||
// Safely converts a wxVariant to (long) int. Supports converting from string
|
||||
// and boolean as well.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
long wxPGVariantToInt( const wxVariant& variant, long defVal = 1 );
|
||||
|
||||
// Safely converts a wxVariant to wxLongLong_t. Returns true on success.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult );
|
||||
|
||||
// Safely converts a wxVariant to wxULongLong_t. Returns true on success.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult );
|
||||
|
||||
// Safely converts a wxVariant to double. Supports converting from string and
|
||||
// wxLongLong as well.
|
||||
WXDLLIMPEXP_PROPGRID
|
||||
bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
|
||||
#define wxPG_VARIANT_TYPE_LONGLONG wxS("longlong")
|
||||
#define wxPG_VARIANT_TYPE_ULONGLONG wxS("ulonglong")
|
||||
|
||||
#endif // !SWIG
|
||||
|
||||
|
@@ -537,23 +537,17 @@ public:
|
||||
return value.GetArrayString();
|
||||
}
|
||||
|
||||
#if wxUSE_LONGLONG_NATIVE
|
||||
#ifdef wxLongLong_t
|
||||
wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK("wxLongLong",
|
||||
(long) GetPropertyValueAsLong(id))
|
||||
wxLongLong ll;
|
||||
ll << value;
|
||||
return ll.GetValue();
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
|
||||
return p->GetValue().GetLongLong().GetValue();
|
||||
}
|
||||
|
||||
wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
|
||||
{
|
||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK("wxULongLong",
|
||||
(unsigned long) GetPropertyValueAsULong(id))
|
||||
wxULongLong ull;
|
||||
ull << value;
|
||||
return ull.GetValue();
|
||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
|
||||
return p->GetValue().GetULongLong().GetValue();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1170,7 +1164,7 @@ public:
|
||||
SetPropVal( id, v );
|
||||
}
|
||||
|
||||
#if wxUSE_LONGLONG_NATIVE
|
||||
#ifdef wxLongLong_t
|
||||
/** Sets value (wxLongLong&) of a property.
|
||||
*/
|
||||
void SetPropertyValue( wxPGPropArg id, wxLongLong_t value )
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "wx/arrstr.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/cpp.h"
|
||||
#include "wx/longlong.h"
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
#include "wx/datetime.h"
|
||||
@@ -260,6 +261,23 @@ public:
|
||||
void operator= (wxObject* value);
|
||||
wxObject* GetWxObjectPtr() const;
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
// wxLongLong
|
||||
wxVariant(wxLongLong, const wxString& name = wxEmptyString);
|
||||
bool operator==(wxLongLong value) const;
|
||||
bool operator!=(wxLongLong value) const;
|
||||
void operator=(wxLongLong value);
|
||||
operator wxLongLong() const { return GetLongLong(); }
|
||||
wxLongLong GetLongLong() const;
|
||||
|
||||
// wxULongLong
|
||||
wxVariant(wxULongLong, const wxString& name = wxEmptyString);
|
||||
bool operator==(wxULongLong value) const;
|
||||
bool operator!=(wxULongLong value) const;
|
||||
void operator=(wxULongLong value);
|
||||
operator wxULongLong() const { return GetULongLong(); }
|
||||
wxULongLong GetULongLong() const;
|
||||
#endif
|
||||
|
||||
// ------------------------------
|
||||
// list operations
|
||||
@@ -307,6 +325,10 @@ public:
|
||||
#if wxUSE_DATETIME
|
||||
bool Convert(wxDateTime* value) const;
|
||||
#endif // wxUSE_DATETIME
|
||||
#if wxUSE_LONGLONG
|
||||
bool Convert(wxLongLong* value) const;
|
||||
bool Convert(wxULongLong* value) const;
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
// Attributes
|
||||
protected:
|
||||
|
@@ -141,6 +141,16 @@ public:
|
||||
*/
|
||||
wxVariant(double value, const wxString& name = wxEmptyString);
|
||||
|
||||
/**
|
||||
Constructs a variant from a wxLongLong.
|
||||
*/
|
||||
wxVariant(wxLongLong value, const wxString& name = wxEmptyString);
|
||||
|
||||
/**
|
||||
Constructs a variant from a wxULongLong.
|
||||
*/
|
||||
wxVariant(wxULongLong value, const wxString& name = wxEmptyString);
|
||||
|
||||
/**
|
||||
Constructs a variant from a list of variants
|
||||
*/
|
||||
@@ -250,6 +260,8 @@ public:
|
||||
bool Convert(double* value) const;
|
||||
bool Convert(wxString* value) const;
|
||||
bool Convert(wxChar* value) const;
|
||||
bool Convert(wxLongLong* value) const;
|
||||
bool Convert(wxULongLong* value) const;
|
||||
bool Convert(wxDateTime* value) const;
|
||||
//@}
|
||||
|
||||
@@ -290,6 +302,11 @@ public:
|
||||
*/
|
||||
long GetLong() const;
|
||||
|
||||
/**
|
||||
Returns the signed 64-bit integer value.
|
||||
*/
|
||||
wxLongLong GetLongLong() const;
|
||||
|
||||
/**
|
||||
Returns a constant reference to the variant name.
|
||||
*/
|
||||
@@ -310,7 +327,9 @@ public:
|
||||
- "double"
|
||||
- "list"
|
||||
- "long"
|
||||
- "longlong"
|
||||
- "string"
|
||||
- "ulonglong"
|
||||
- "arrstring"
|
||||
- "void*"
|
||||
|
||||
@@ -319,6 +338,11 @@ public:
|
||||
*/
|
||||
wxString GetType() const;
|
||||
|
||||
/**
|
||||
Returns the unsigned 64-bit integer value.
|
||||
*/
|
||||
wxULongLong GetULongLong() const;
|
||||
|
||||
/**
|
||||
Gets the void pointer value.
|
||||
|
||||
@@ -390,6 +414,8 @@ public:
|
||||
bool operator !=(long value) const;
|
||||
bool operator !=(bool value) const;
|
||||
bool operator !=(double value) const;
|
||||
bool operator !=(wxLongLong value) const;
|
||||
bool operator !=(wxULongLong value) const;
|
||||
bool operator !=(void* value) const;
|
||||
bool operator !=(wxObject* value) const;
|
||||
bool operator !=(const wxVariantList& value) const;
|
||||
@@ -410,6 +436,8 @@ public:
|
||||
void operator =(long value);
|
||||
void operator =(bool value);
|
||||
void operator =(double value);
|
||||
bool operator =(wxLongLong value) const;
|
||||
bool operator =(wxULongLong value) const;
|
||||
void operator =(void* value);
|
||||
void operator =(wxObject* value);
|
||||
void operator =(const wxVariantList& value);
|
||||
@@ -428,6 +456,8 @@ public:
|
||||
bool operator ==(long value) const;
|
||||
bool operator ==(bool value) const;
|
||||
bool operator ==(double value) const;
|
||||
bool operator ==(wxLongLong value) const;
|
||||
bool operator ==(wxULongLong value) const;
|
||||
bool operator ==(void* value) const;
|
||||
bool operator ==(wxObject* value) const;
|
||||
bool operator ==(const wxVariantList& value) const;
|
||||
@@ -437,10 +467,13 @@ public:
|
||||
|
||||
//@{
|
||||
/**
|
||||
Operator for implicit conversion to a long, using GetLong().
|
||||
Operators for implicit conversion, using appropriate getter member
|
||||
function.
|
||||
*/
|
||||
double operator double() const;
|
||||
long operator long() const;
|
||||
wxLongLong operator wxLongLong() const;
|
||||
wxULongLong operator wxULongLong() const;
|
||||
//@}
|
||||
|
||||
/**
|
||||
|
@@ -920,11 +920,11 @@ void FormMain::OnPropertyGridChange( wxPropertyGridEvent& event )
|
||||
SetSize ( m_pPropGridManager->GetPropertyValueAsInt(property), -1, -1, -1, wxSIZE_USE_EXISTING );
|
||||
else if ( name == wxT("Y") )
|
||||
// wxPGVariantToInt is safe long int value getter
|
||||
SetSize ( -1, wxPGVariantToInt(value), -1, -1, wxSIZE_USE_EXISTING );
|
||||
SetSize ( -1, value.GetLong(), -1, -1, wxSIZE_USE_EXISTING );
|
||||
else if ( name == wxT("Width") )
|
||||
SetSize ( -1, -1, m_pPropGridManager->GetPropertyValueAsInt(property), -1, wxSIZE_USE_EXISTING );
|
||||
else if ( name == wxT("Height") )
|
||||
SetSize ( -1, -1, -1, wxPGVariantToInt(value), wxSIZE_USE_EXISTING );
|
||||
SetSize ( -1, -1, -1, value.GetLong(), wxSIZE_USE_EXISTING );
|
||||
else if ( name == wxT("Label") )
|
||||
{
|
||||
SetTitle ( m_pPropGridManager->GetPropertyValueAsString(property) );
|
||||
|
@@ -220,7 +220,7 @@ wxVariant wxSizeProperty::ChildChanged( wxVariant& thisValue,
|
||||
wxVariant& childValue ) const
|
||||
{
|
||||
wxSize& size = wxSizeRefFromVariant(thisValue);
|
||||
int val = wxPGVariantToInt(childValue);
|
||||
int val = childValue.GetLong();
|
||||
switch ( childIndex )
|
||||
{
|
||||
case 0: size.x = val; break;
|
||||
@@ -261,7 +261,7 @@ wxVariant wxPointProperty::ChildChanged( wxVariant& thisValue,
|
||||
wxVariant& childValue ) const
|
||||
{
|
||||
wxPoint& point = wxPointRefFromVariant(thisValue);
|
||||
int val = wxPGVariantToInt(childValue);
|
||||
int val = childValue.GetLong();
|
||||
switch ( childIndex )
|
||||
{
|
||||
case 0: point.x = val; break;
|
||||
|
@@ -662,58 +662,6 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
|
||||
if ( pgman->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(-80000000000) )
|
||||
RT_FAILURE();
|
||||
|
||||
//
|
||||
// Flexible wx(U)LongLong << operator safety conformance tests
|
||||
wxPGProperty* prop;
|
||||
wxLongLong ll;
|
||||
wxULongLong ull;
|
||||
|
||||
prop = pgman->GetProperty(wxT("IntProperty"));
|
||||
prop->SetValue(128);
|
||||
ll << prop->GetValue();
|
||||
if ( ll != 128 )
|
||||
RT_FAILURE();
|
||||
|
||||
prop->SetValue(WXVARIANT(wxLL(68719476736)));
|
||||
ll << prop->GetValue();
|
||||
if ( ll.GetValue() != wxLL(68719476736) )
|
||||
RT_FAILURE();
|
||||
|
||||
#if wxUSE_LONGLONG_NATIVE
|
||||
wxLongLong_t ll_t;
|
||||
ll_t << prop->GetValue();
|
||||
if ( ll_t != wxLL(68719476736) )
|
||||
RT_FAILURE();
|
||||
#endif
|
||||
|
||||
prop->SetValue(256);
|
||||
ll << prop->GetValue();
|
||||
if ( ll != 256 )
|
||||
RT_FAILURE();
|
||||
|
||||
prop = pgman->GetProperty(wxT("UIntProperty"));
|
||||
prop->SetValue(128);
|
||||
ull << prop->GetValue();
|
||||
if ( ull != 128 )
|
||||
RT_FAILURE();
|
||||
|
||||
prop->SetValue(WXVARIANT(wxULL(68719476739)));
|
||||
ull << prop->GetValue();
|
||||
if ( ull.GetValue() != wxULL(68719476739) )
|
||||
RT_FAILURE();
|
||||
|
||||
#if wxUSE_LONGLONG_NATIVE
|
||||
wxULongLong_t ull_t;
|
||||
ull_t << prop->GetValue();
|
||||
if ( ull_t != wxLL(68719476739) )
|
||||
RT_FAILURE();
|
||||
#endif
|
||||
|
||||
prop->SetValue(256);
|
||||
ull << prop->GetValue();
|
||||
if ( ull != 256 )
|
||||
RT_FAILURE();
|
||||
|
||||
// Make sure children of composite parent get updated as well
|
||||
// Original string value: "Lamborghini Diablo SV; 5707; [300; 3.9; 8.6] 300000; Not Convertible"
|
||||
|
||||
|
@@ -1414,6 +1414,320 @@ wxArrayString wxVariant::GetArrayString() const
|
||||
return wxArrayString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxVariantDataLongLong
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
|
||||
class WXDLLIMPEXP_BASE wxVariantDataLongLong : public wxVariantData
|
||||
{
|
||||
public:
|
||||
wxVariantDataLongLong() { m_value = 0; }
|
||||
wxVariantDataLongLong(wxLongLong value) { m_value = value; }
|
||||
|
||||
wxLongLong GetValue() const { return m_value; }
|
||||
void SetValue(wxLongLong value) { m_value = value; }
|
||||
|
||||
virtual bool Eq(wxVariantData& data) const;
|
||||
|
||||
virtual bool Read(wxString& str);
|
||||
virtual bool Write(wxString& str) const;
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
virtual bool Read(wxSTD istream& str);
|
||||
virtual bool Write(wxSTD ostream& str) const;
|
||||
#endif
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool Read(wxInputStream& str);
|
||||
virtual bool Write(wxOutputStream &str) const;
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
wxVariantData* Clone() const
|
||||
{
|
||||
return new wxVariantDataLongLong(m_value);
|
||||
}
|
||||
|
||||
virtual wxString GetType() const { return wxS("longlong"); }
|
||||
|
||||
protected:
|
||||
wxLongLong m_value;
|
||||
};
|
||||
|
||||
bool wxVariantDataLongLong::Eq(wxVariantData& data) const
|
||||
{
|
||||
wxASSERT_MSG( (data.GetType() == wxS("longlong")),
|
||||
"wxVariantDataLongLong::Eq: argument mismatch" );
|
||||
|
||||
wxVariantDataLongLong& otherData = (wxVariantDataLongLong&) data;
|
||||
|
||||
return (otherData.m_value == m_value);
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
bool wxVariantDataLongLong::Write(wxSTD ostream& str) const
|
||||
{
|
||||
wxString s;
|
||||
Write(s);
|
||||
str << (const char*) s.mb_str();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool wxVariantDataLongLong::Write(wxString& str) const
|
||||
{
|
||||
str.Printf(wxS("%lld"), m_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
bool wxVariantDataLongLong::Read(wxSTD istream& WXUNUSED(str))
|
||||
{
|
||||
wxFAIL_MSG(wxS("Unimplemented"));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
bool wxVariantDataLongLong::Write(wxOutputStream& str) const
|
||||
{
|
||||
wxTextOutputStream s(str);
|
||||
s.Write32(m_value.GetLo());
|
||||
s.Write32(m_value.GetHi());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxVariantDataLongLong::Read(wxInputStream& str)
|
||||
{
|
||||
wxTextInputStream s(str);
|
||||
unsigned long lo = s.Read32();
|
||||
long hi = s.Read32();
|
||||
m_value = wxLongLong(hi, lo);
|
||||
return true;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
bool wxVariantDataLongLong::Read(wxString& str)
|
||||
{
|
||||
#ifdef wxLongLong_t
|
||||
wxLongLong_t value_t;
|
||||
if ( !str.ToLongLong(&value_t) )
|
||||
return false;
|
||||
m_value = value_t;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// wxVariant
|
||||
|
||||
wxVariant::wxVariant(wxLongLong val, const wxString& name)
|
||||
{
|
||||
m_refData = new wxVariantDataLongLong(val);
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
bool wxVariant::operator==(wxLongLong value) const
|
||||
{
|
||||
wxLongLong thisValue;
|
||||
if ( !Convert(&thisValue) )
|
||||
return false;
|
||||
else
|
||||
return (value == thisValue);
|
||||
}
|
||||
|
||||
bool wxVariant::operator!=(wxLongLong value) const
|
||||
{
|
||||
return (!((*this) == value));
|
||||
}
|
||||
|
||||
void wxVariant::operator=(wxLongLong value)
|
||||
{
|
||||
if ( GetType() == wxS("longlong") &&
|
||||
m_refData->GetRefCount() == 1 )
|
||||
{
|
||||
((wxVariantDataLongLong*)GetData())->SetValue(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnRef();
|
||||
m_refData = new wxVariantDataLongLong(value);
|
||||
}
|
||||
}
|
||||
|
||||
wxLongLong wxVariant::GetLongLong() const
|
||||
{
|
||||
wxLongLong value;
|
||||
if ( Convert(&value) )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG(wxT("Could not convert to a long long"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxVariantDataULongLong
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
|
||||
class WXDLLIMPEXP_BASE wxVariantDataULongLong : public wxVariantData
|
||||
{
|
||||
public:
|
||||
wxVariantDataULongLong() { m_value = 0; }
|
||||
wxVariantDataULongLong(wxULongLong value) { m_value = value; }
|
||||
|
||||
wxULongLong GetValue() const { return m_value; }
|
||||
void SetValue(wxULongLong value) { m_value = value; }
|
||||
|
||||
virtual bool Eq(wxVariantData& data) const;
|
||||
|
||||
virtual bool Read(wxString& str);
|
||||
virtual bool Write(wxString& str) const;
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
virtual bool Read(wxSTD istream& str);
|
||||
virtual bool Write(wxSTD ostream& str) const;
|
||||
#endif
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool Read(wxInputStream& str);
|
||||
virtual bool Write(wxOutputStream &str) const;
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
wxVariantData* Clone() const
|
||||
{
|
||||
return new wxVariantDataULongLong(m_value);
|
||||
}
|
||||
|
||||
virtual wxString GetType() const { return wxS("ulonglong"); }
|
||||
|
||||
protected:
|
||||
wxULongLong m_value;
|
||||
};
|
||||
|
||||
bool wxVariantDataULongLong::Eq(wxVariantData& data) const
|
||||
{
|
||||
wxASSERT_MSG( (data.GetType() == wxS("ulonglong")),
|
||||
"wxVariantDataULongLong::Eq: argument mismatch" );
|
||||
|
||||
wxVariantDataULongLong& otherData = (wxVariantDataULongLong&) data;
|
||||
|
||||
return (otherData.m_value == m_value);
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
bool wxVariantDataULongLong::Write(wxSTD ostream& str) const
|
||||
{
|
||||
wxString s;
|
||||
Write(s);
|
||||
str << (const char*) s.mb_str();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool wxVariantDataULongLong::Write(wxString& str) const
|
||||
{
|
||||
str.Printf(wxS("%llu"), m_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
bool wxVariantDataULongLong::Read(wxSTD istream& WXUNUSED(str))
|
||||
{
|
||||
wxFAIL_MSG(wxS("Unimplemented"));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
bool wxVariantDataULongLong::Write(wxOutputStream& str) const
|
||||
{
|
||||
wxTextOutputStream s(str);
|
||||
s.Write32(m_value.GetLo());
|
||||
s.Write32(m_value.GetHi());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxVariantDataULongLong::Read(wxInputStream& str)
|
||||
{
|
||||
wxTextInputStream s(str);
|
||||
unsigned long lo = s.Read32();
|
||||
long hi = s.Read32();
|
||||
m_value = wxULongLong(hi, lo);
|
||||
return true;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
bool wxVariantDataULongLong::Read(wxString& str)
|
||||
{
|
||||
#ifdef wxLongLong_t
|
||||
wxULongLong_t value_t;
|
||||
if ( !str.ToULongLong(&value_t) )
|
||||
return false;
|
||||
m_value = value_t;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// wxVariant
|
||||
|
||||
wxVariant::wxVariant(wxULongLong val, const wxString& name)
|
||||
{
|
||||
m_refData = new wxVariantDataULongLong(val);
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
bool wxVariant::operator==(wxULongLong value) const
|
||||
{
|
||||
wxULongLong thisValue;
|
||||
if ( !Convert(&thisValue) )
|
||||
return false;
|
||||
else
|
||||
return (value == thisValue);
|
||||
}
|
||||
|
||||
bool wxVariant::operator!=(wxULongLong value) const
|
||||
{
|
||||
return (!((*this) == value));
|
||||
}
|
||||
|
||||
void wxVariant::operator=(wxULongLong value)
|
||||
{
|
||||
if ( GetType() == wxS("ulonglong") &&
|
||||
m_refData->GetRefCount() == 1 )
|
||||
{
|
||||
((wxVariantDataULongLong*)GetData())->SetValue(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnRef();
|
||||
m_refData = new wxVariantDataULongLong(value);
|
||||
}
|
||||
}
|
||||
|
||||
wxULongLong wxVariant::GetULongLong() const
|
||||
{
|
||||
wxULongLong value;
|
||||
if ( Convert(&value) )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG(wxT("Could not convert to a long long"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxVariantDataList
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -1699,14 +2013,32 @@ size_t wxVariant::GetCount() const
|
||||
bool wxVariant::Convert(long* value) const
|
||||
{
|
||||
wxString type(GetType());
|
||||
if (type == wxT("double"))
|
||||
if (type == wxS("double"))
|
||||
*value = (long) (((wxVariantDoubleData*)GetData())->GetValue());
|
||||
else if (type == wxT("long"))
|
||||
else if (type == wxS("long"))
|
||||
*value = ((wxVariantDataLong*)GetData())->GetValue();
|
||||
else if (type == wxT("bool"))
|
||||
else if (type == wxS("bool"))
|
||||
*value = (long) (((wxVariantDataBool*)GetData())->GetValue());
|
||||
else if (type == wxT("string"))
|
||||
else if (type == wxS("string"))
|
||||
*value = wxAtol(((wxVariantDataString*)GetData())->GetValue());
|
||||
#if wxUSE_LONGLONG
|
||||
else if (type == wxS("longlong"))
|
||||
{
|
||||
wxLongLong v = ((wxVariantDataLongLong*)GetData())->GetValue();
|
||||
// Don't convert if return value would be vague
|
||||
if ( v < LONG_MIN || v > LONG_MAX )
|
||||
return false;
|
||||
*value = v.ToLong();
|
||||
}
|
||||
else if (type == wxS("ulonglong"))
|
||||
{
|
||||
wxULongLong v = ((wxVariantDataULongLong*)GetData())->GetValue();
|
||||
// Don't convert if return value would be vague
|
||||
if ( v.GetHi() )
|
||||
return false;
|
||||
*value = (long) v.ToULong();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -1750,6 +2082,16 @@ bool wxVariant::Convert(double* value) const
|
||||
*value = (double) (((wxVariantDataBool*)GetData())->GetValue());
|
||||
else if (type == wxT("string"))
|
||||
*value = (double) wxAtof(((wxVariantDataString*)GetData())->GetValue());
|
||||
#if wxUSE_LONGLONG
|
||||
else if (type == wxS("longlong"))
|
||||
{
|
||||
*value = ((wxVariantDataLongLong*)GetData())->GetValue().ToDouble();
|
||||
}
|
||||
else if (type == wxS("ulonglong"))
|
||||
{
|
||||
*value = ((wxVariantDataULongLong*)GetData())->GetValue().ToDouble();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -1795,6 +2137,91 @@ bool wxVariant::Convert(wxString* value) const
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxUSE_LONGLONG
|
||||
bool wxVariant::Convert(wxLongLong* value) const
|
||||
{
|
||||
wxString type(GetType());
|
||||
if (type == wxS("longlong"))
|
||||
*value = ((wxVariantDataLongLong*)GetData())->GetValue();
|
||||
else if (type == wxS("long"))
|
||||
*value = ((wxVariantDataLong*)GetData())->GetValue();
|
||||
else if (type == wxS("string"))
|
||||
{
|
||||
wxString s = ((wxVariantDataString*)GetData())->GetValue();
|
||||
#ifdef wxLongLong_t
|
||||
wxLongLong_t value_t;
|
||||
if ( !s.ToLongLong(&value_t) )
|
||||
return false;
|
||||
*value = value_t;
|
||||
#else
|
||||
long l_value;
|
||||
if ( !s.ToLong(&l_value) )
|
||||
return false;
|
||||
*value = l_value;
|
||||
#endif
|
||||
}
|
||||
else if (type == wxS("bool"))
|
||||
*value = (long) (((wxVariantDataBool*)GetData())->GetValue());
|
||||
else if (type == wxS("double"))
|
||||
{
|
||||
value->Assign(((wxVariantDoubleData*)GetData())->GetValue());
|
||||
}
|
||||
else if (type == wxS("ulonglong"))
|
||||
*value = ((wxVariantDataULongLong*)GetData())->GetValue();
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxVariant::Convert(wxULongLong* value) const
|
||||
{
|
||||
wxString type(GetType());
|
||||
if (type == wxS("ulonglong"))
|
||||
*value = ((wxVariantDataULongLong*)GetData())->GetValue();
|
||||
else if (type == wxS("long"))
|
||||
*value = ((wxVariantDataLong*)GetData())->GetValue();
|
||||
else if (type == wxS("string"))
|
||||
{
|
||||
wxString s = ((wxVariantDataString*)GetData())->GetValue();
|
||||
#ifdef wxLongLong_t
|
||||
wxULongLong_t value_t;
|
||||
if ( !s.ToULongLong(&value_t) )
|
||||
return false;
|
||||
*value = value_t;
|
||||
#else
|
||||
unsigned long l_value;
|
||||
if ( !s.ToULong(&l_value) )
|
||||
return false;
|
||||
*value = l_value;
|
||||
#endif
|
||||
}
|
||||
else if (type == wxS("bool"))
|
||||
*value = (long) (((wxVariantDataBool*)GetData())->GetValue());
|
||||
else if (type == wxS("double"))
|
||||
{
|
||||
double value_d = ((wxVariantDoubleData*)GetData())->GetValue();
|
||||
|
||||
if ( value_d < 0.0 )
|
||||
return false;
|
||||
|
||||
#ifdef wxLongLong_t
|
||||
*value = (wxULongLong_t) value_d;
|
||||
#else
|
||||
wxLongLong temp;
|
||||
temp.Assign(value_d);
|
||||
*value = temp;
|
||||
#endif
|
||||
}
|
||||
else if (type == wxS("longlong"))
|
||||
*value = ((wxVariantDataLongLong*)GetData())->GetValue();
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // wxUSE_LONGLONG
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
bool wxVariant::Convert(wxDateTime* value) const
|
||||
{
|
||||
|
@@ -720,7 +720,7 @@ wxVariant wxFontProperty::ChildChanged( wxVariant& thisValue,
|
||||
|
||||
if ( ind == 0 )
|
||||
{
|
||||
font.SetPointSize( wxPGVariantToInt(childValue) );
|
||||
font.SetPointSize( childValue.GetLong() );
|
||||
}
|
||||
else if ( ind == 1 )
|
||||
{
|
||||
@@ -1425,7 +1425,7 @@ bool wxSystemColourProperty::DoSetAttribute( const wxString& name, wxVariant& va
|
||||
{
|
||||
if ( name == wxPG_COLOUR_ALLOW_CUSTOM )
|
||||
{
|
||||
int ival = wxPGVariantToInt(value);
|
||||
int ival = value.GetLong();
|
||||
|
||||
if ( ival && (m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
|
||||
{
|
||||
|
@@ -1634,18 +1634,20 @@ long wxPGProperty::GetAttributeAsLong( const wxString& name, long defVal ) const
|
||||
{
|
||||
wxVariant variant = m_attributes.FindValue(name);
|
||||
|
||||
return wxPGVariantToInt(variant, defVal);
|
||||
if ( variant.IsNull() )
|
||||
return defVal;
|
||||
|
||||
return variant.GetLong();
|
||||
}
|
||||
|
||||
double wxPGProperty::GetAttributeAsDouble( const wxString& name, double defVal ) const
|
||||
{
|
||||
double retVal;
|
||||
wxVariant variant = m_attributes.FindValue(name);
|
||||
|
||||
if ( wxPGVariantToDouble(variant, &retVal) )
|
||||
return retVal;
|
||||
|
||||
if ( variant.IsNull() )
|
||||
return defVal;
|
||||
|
||||
return variant.GetDouble();
|
||||
}
|
||||
|
||||
wxVariant wxPGProperty::GetAttributesAsList() const
|
||||
|
@@ -56,173 +56,8 @@ const wxChar *wxPGTypeName_wxArrayString = wxT("arrstring");
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(wxPoint, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(wxSize, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(wxArrayInt, WXDLLIMPEXP_PROPGRID)
|
||||
|
||||
// For wxLongLong and wxULongLong have custom classname << variant
|
||||
// implementation for improved flexibility.
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(wxLongLong, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EQ(wxLongLong, WXDLLIMPEXP_PROPGRID)
|
||||
WXDLLIMPEXP_PROPGRID wxLongLong& operator << ( wxLongLong &value, const wxVariant &variant )
|
||||
{
|
||||
wxLongLong_t ll;
|
||||
if ( !wxPGVariantToLongLong(variant, &ll) )
|
||||
{
|
||||
wxFAIL_MSG("Cannot convert to wxLongLong");
|
||||
}
|
||||
value = ll;
|
||||
return value;
|
||||
}
|
||||
WXDLLIMPEXP_PROPGRID wxLongLong_t& operator << ( wxLongLong_t &value, const wxVariant &variant )
|
||||
{
|
||||
if ( !wxPGVariantToLongLong(variant, &value) )
|
||||
{
|
||||
wxFAIL_MSG("Cannot convert to wxLongLong");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(wxULongLong, WXDLLIMPEXP_PROPGRID)
|
||||
WX_PG_IMPLEMENT_VARIANT_DATA_EQ(wxULongLong, WXDLLIMPEXP_PROPGRID)
|
||||
WXDLLIMPEXP_PROPGRID wxULongLong& operator << ( wxULongLong &value, const wxVariant &variant )
|
||||
{
|
||||
wxULongLong_t ull;
|
||||
if ( !wxPGVariantToULongLong(variant, &ull) )
|
||||
{
|
||||
wxFAIL_MSG("Cannot convert to wxULongLong");
|
||||
}
|
||||
value = ull;
|
||||
return value;
|
||||
}
|
||||
WXDLLIMPEXP_PROPGRID wxULongLong_t& operator << ( wxULongLong_t &value, const wxVariant &variant )
|
||||
{
|
||||
if ( !wxPGVariantToULongLong(variant, &value) )
|
||||
{
|
||||
wxFAIL_MSG("Cannot convert to wxULongLong");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxFont, WXDLLIMPEXP_PROPGRID)
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxVariant helpers
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
long wxPGVariantToInt( const wxVariant& variant, long defVal )
|
||||
{
|
||||
if ( variant.IsNull() )
|
||||
return defVal;
|
||||
|
||||
if ( variant.GetType() == wxS("long") )
|
||||
return variant.GetLong();
|
||||
|
||||
if ( variant.GetType() == wxS("bool") )
|
||||
return variant.GetBool() ? 1 : 0;
|
||||
|
||||
if ( variant.GetType() == wxS("wxLongLong") )
|
||||
{
|
||||
wxLongLong ll;
|
||||
ll << variant;
|
||||
if ( ll >= LONG_MAX )
|
||||
return LONG_MAX;
|
||||
else if ( ll <= LONG_MIN )
|
||||
return LONG_MIN;
|
||||
return ll.ToLong();
|
||||
}
|
||||
|
||||
long l = defVal;
|
||||
|
||||
if ( variant.GetType() == wxPG_VARIANT_TYPE_STRING )
|
||||
variant.GetString().ToLong(&l, 0);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult )
|
||||
{
|
||||
if ( variant.IsNull() )
|
||||
return false;
|
||||
|
||||
wxString variantType = variant.GetType();
|
||||
|
||||
if ( variantType == wxPG_VARIANT_TYPE_LONG )
|
||||
{
|
||||
*pResult = variant.GetLong();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( variantType == wxLongLong_VariantType )
|
||||
{
|
||||
// NOTE: << operator uses this functions, so we can't use it here
|
||||
*pResult = wxLongLongRefFromVariant(variant).GetValue();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult )
|
||||
{
|
||||
if ( variant.IsNull() )
|
||||
return false;
|
||||
|
||||
wxString variantType = variant.GetType();
|
||||
|
||||
if ( variantType == wxPG_VARIANT_TYPE_LONG )
|
||||
{
|
||||
*pResult = (unsigned long)variant.GetLong();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( variantType == wxULongLong_VariantType )
|
||||
{
|
||||
// NOTE: << operator uses this functions, so we can't use it here
|
||||
*pResult = wxULongLongRefFromVariant(variant).GetValue();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
bool wxPGVariantToDouble( const wxVariant& variant, double* pResult )
|
||||
{
|
||||
if ( variant.IsNull() )
|
||||
return false;
|
||||
|
||||
wxString variantType = variant.GetType();
|
||||
|
||||
if ( variantType == wxPG_VARIANT_TYPE_DOUBLE )
|
||||
{
|
||||
*pResult = variant.GetDouble();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( variantType == wxPG_VARIANT_TYPE_LONG )
|
||||
{
|
||||
*pResult = (double)variant.GetLong();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( variantType == wxLongLong_VariantType )
|
||||
{
|
||||
wxLongLong ll;
|
||||
ll << variant;
|
||||
*pResult = ll.ToDouble();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( variantType == wxPG_VARIANT_TYPE_STRING )
|
||||
if ( variant.GetString().ToDouble(pResult) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPGPropArgCls
|
||||
// -----------------------------------------------------------------------
|
||||
|
@@ -134,7 +134,7 @@ bool wxStringProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
||||
if ( name == wxPG_STRING_PASSWORD )
|
||||
{
|
||||
m_flags &= ~(wxPG_PROP_PASSWORD);
|
||||
if ( wxPGVariantToInt(value) ) m_flags |= wxPG_PROP_PASSWORD;
|
||||
if ( value.GetLong() ) m_flags |= wxPG_PROP_PASSWORD;
|
||||
RecreateEditor();
|
||||
return false;
|
||||
}
|
||||
@@ -169,10 +169,9 @@ wxString wxIntProperty::ValueToString( wxVariant& value,
|
||||
{
|
||||
return wxString::Format(wxS("%li"),value.GetLong());
|
||||
}
|
||||
else if ( value.GetType() == wxLongLong_VariantType )
|
||||
else if ( value.GetType() == wxPG_VARIANT_TYPE_LONGLONG )
|
||||
{
|
||||
wxLongLong ll;
|
||||
ll << value;
|
||||
wxLongLong ll = value.GetLongLong();
|
||||
return ll.ToString();
|
||||
}
|
||||
|
||||
@@ -221,10 +220,9 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
||||
{
|
||||
bool doChangeValue = isPrevLong;
|
||||
|
||||
if ( !isPrevLong && variantType == wxLongLong_VariantType )
|
||||
if ( !isPrevLong && variantType == wxPG_VARIANT_TYPE_LONGLONG )
|
||||
{
|
||||
wxLongLong oldValue;
|
||||
oldValue << variant;
|
||||
wxLongLong oldValue = variant.GetLongLong();
|
||||
if ( oldValue.GetValue() != value64 )
|
||||
doChangeValue = true;
|
||||
}
|
||||
@@ -232,7 +230,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
||||
if ( doChangeValue )
|
||||
{
|
||||
wxLongLong ll(value64);
|
||||
variant << ll;
|
||||
variant = ll;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -274,14 +272,14 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va
|
||||
variant = property->GetAttribute(wxPGGlobalVars->m_strMin);
|
||||
if ( !variant.IsNull() )
|
||||
{
|
||||
wxPGVariantToLongLong(variant, &min);
|
||||
min = variant.GetLongLong().GetValue();
|
||||
minOk = true;
|
||||
}
|
||||
|
||||
variant = property->GetAttribute(wxPGGlobalVars->m_strMax);
|
||||
if ( !variant.IsNull() )
|
||||
{
|
||||
wxPGVariantToLongLong(variant, &max);
|
||||
max = variant.GetLongLong().GetValue();
|
||||
maxOk = true;
|
||||
}
|
||||
|
||||
@@ -319,12 +317,12 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const
|
||||
bool wxIntProperty::ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const
|
||||
{
|
||||
wxLongLong_t ll;
|
||||
if ( wxPGVariantToLongLong(value, &ll) )
|
||||
return DoValidation(this, ll, &validationInfo, wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
return true;
|
||||
wxLongLong_t ll = value.GetLongLong().GetValue();
|
||||
return DoValidation(this, ll, &validationInfo,
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
wxValidator* wxIntProperty::GetClassValidator()
|
||||
@@ -406,11 +404,11 @@ wxString wxUIntProperty::ValueToString( wxVariant& value,
|
||||
|
||||
if ( value.GetType() == wxPG_VARIANT_TYPE_LONG )
|
||||
{
|
||||
return wxString::Format(gs_uintTemplates32[index], (unsigned long)value.GetLong());
|
||||
return wxString::Format(gs_uintTemplates32[index],
|
||||
(unsigned long)value.GetLong());
|
||||
}
|
||||
|
||||
wxULongLong ull;
|
||||
ull << value;
|
||||
wxULongLong ull = value.GetULongLong();
|
||||
|
||||
return wxString::Format(gs_uintTemplates64[index], ull.GetValue());
|
||||
}
|
||||
@@ -439,18 +437,16 @@ bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, in
|
||||
{
|
||||
bool doChangeValue = isPrevLong;
|
||||
|
||||
if ( !isPrevLong && variantType == wxULongLong_VariantType )
|
||||
if ( !isPrevLong && variantType == wxPG_VARIANT_TYPE_ULONGLONG )
|
||||
{
|
||||
wxULongLong oldValue;
|
||||
oldValue << variant;
|
||||
wxULongLong oldValue = variant.GetULongLong();
|
||||
if ( oldValue.GetValue() != value64 )
|
||||
doChangeValue = true;
|
||||
}
|
||||
|
||||
if ( doChangeValue )
|
||||
{
|
||||
wxULongLong ull(value64);
|
||||
variant << ull;
|
||||
variant = wxULongLong(value64);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -481,9 +477,8 @@ bool wxUIntProperty::IntToValue( wxVariant& variant, int number, int WXUNUSED(ar
|
||||
bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const
|
||||
{
|
||||
// Check for min/max
|
||||
wxULongLong_t ll;
|
||||
if ( wxPGVariantToULongLong(value, &ll) )
|
||||
{
|
||||
wxULongLong_t ll = value.GetULongLong().GetValue();
|
||||
|
||||
wxULongLong_t min = 0;
|
||||
wxULongLong_t max = wxUINT64_MAX;
|
||||
wxVariant variant;
|
||||
@@ -491,7 +486,7 @@ bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& valida
|
||||
variant = GetAttribute(wxPGGlobalVars->m_strMin);
|
||||
if ( !variant.IsNull() )
|
||||
{
|
||||
wxPGVariantToULongLong(variant, &min);
|
||||
min = variant.GetULongLong().GetValue();
|
||||
if ( ll < min )
|
||||
{
|
||||
validationInfo.SetFailureMessage(
|
||||
@@ -503,7 +498,7 @@ bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& valida
|
||||
variant = GetAttribute(wxPGGlobalVars->m_strMax);
|
||||
if ( !variant.IsNull() )
|
||||
{
|
||||
wxPGVariantToULongLong(variant, &max);
|
||||
max = variant.GetULongLong().GetValue();
|
||||
if ( ll > max )
|
||||
{
|
||||
validationInfo.SetFailureMessage(
|
||||
@@ -512,7 +507,7 @@ bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& valida
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -655,7 +650,10 @@ bool wxFloatProperty::StringToValue( wxVariant& variant, const wxString& text, i
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value, wxPGValidationInfo* pValidationInfo, int mode )
|
||||
bool wxFloatProperty::DoValidation( const wxPGProperty* property,
|
||||
double& value,
|
||||
wxPGValidationInfo* pValidationInfo,
|
||||
int mode )
|
||||
{
|
||||
// Check for min/max
|
||||
double min = (double)wxINT64_MIN;
|
||||
@@ -667,14 +665,14 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value,
|
||||
variant = property->GetAttribute(wxPGGlobalVars->m_strMin);
|
||||
if ( !variant.IsNull() )
|
||||
{
|
||||
wxPGVariantToDouble(variant, &min);
|
||||
min = variant.GetDouble();
|
||||
minOk = true;
|
||||
}
|
||||
|
||||
variant = property->GetAttribute(wxPGGlobalVars->m_strMax);
|
||||
if ( !variant.IsNull() )
|
||||
{
|
||||
wxPGVariantToDouble(variant, &max);
|
||||
max = variant.GetDouble();
|
||||
maxOk = true;
|
||||
}
|
||||
|
||||
@@ -696,7 +694,7 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value,
|
||||
|
||||
if ( maxOk )
|
||||
{
|
||||
wxPGVariantToDouble(variant, &max);
|
||||
max = variant.GetDouble();
|
||||
if ( value > max )
|
||||
{
|
||||
if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE )
|
||||
@@ -713,12 +711,13 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxFloatProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const
|
||||
bool
|
||||
wxFloatProperty::ValidateValue( wxVariant& value,
|
||||
wxPGValidationInfo& validationInfo ) const
|
||||
{
|
||||
double fpv;
|
||||
if ( wxPGVariantToDouble(value, &fpv) )
|
||||
return DoValidation(this, fpv, &validationInfo, wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
return true;
|
||||
double fpv = value.GetDouble();
|
||||
return DoValidation(this, fpv, &validationInfo,
|
||||
wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
bool wxFloatProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
||||
@@ -849,8 +848,7 @@ bool wxBoolProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
||||
#if wxPG_INCLUDE_CHECKBOX
|
||||
if ( name == wxPG_BOOL_USE_CHECKBOX )
|
||||
{
|
||||
int ival = wxPGVariantToInt(value);
|
||||
if ( ival )
|
||||
if ( value.GetLong() )
|
||||
m_flags |= wxPG_PROP_USE_CHECKBOX;
|
||||
else
|
||||
m_flags &= ~(wxPG_PROP_USE_CHECKBOX);
|
||||
@@ -859,8 +857,7 @@ bool wxBoolProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
||||
#endif
|
||||
if ( name == wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING )
|
||||
{
|
||||
int ival = wxPGVariantToInt(value);
|
||||
if ( ival )
|
||||
if ( value.GetLong() )
|
||||
m_flags |= wxPG_PROP_USE_DCC;
|
||||
else
|
||||
m_flags &= ~(wxPG_PROP_USE_DCC);
|
||||
@@ -1799,7 +1796,7 @@ bool wxFileProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
||||
// stored in m_attributes.
|
||||
if ( name == wxPG_FILE_SHOW_FULL_PATH )
|
||||
{
|
||||
if ( wxPGVariantToInt(value) )
|
||||
if ( value.GetLong() )
|
||||
m_flags |= wxPG_PROP_SHOW_FULL_FILENAME;
|
||||
else
|
||||
m_flags &= ~(wxPG_PROP_SHOW_FULL_FILENAME);
|
||||
|
Reference in New Issue
Block a user