X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f4bc1aa27cb33f679d7e9c1518a7855bbc1fa471..dd021ce2bd29a7e1d19b80995cd700828d5367c3:/include/wx/propgrid/propgriddefs.h diff --git a/include/wx/propgrid/propgriddefs.h b/include/wx/propgrid/propgriddefs.h index 97cde0852a..0cafff6934 100644 --- a/include/wx/propgrid/propgriddefs.h +++ b/include/wx/propgrid/propgriddefs.h @@ -513,7 +513,9 @@ extern expdecl const char* classname##_VariantType; #define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \ WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE) -#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ(classname,expdecl) \ +// Add getter (ie. classname << variant) separately to allow +// custom implementations. +#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,expdecl) \ const char* classname##_VariantType = #classname; \ class classname##VariantData: public wxVariantData \ { \ @@ -522,16 +524,14 @@ public:\ classname##VariantData( const classname &value ) { m_value = value; } \ \ classname &GetValue() { return m_value; } \ +\ + const classname &GetValue() const { return m_value; } \ \ virtual bool Eq(wxVariantData& data) const; \ \ virtual wxString GetType() const; \ \ virtual wxVariantData* Clone() const { return new classname##VariantData(m_value); } \ -\ - classname& GetValueRef() { return m_value; } \ -\ - const classname& GetValueRef() const { return m_value; } \ \ protected:\ classname m_value; \ @@ -542,15 +542,6 @@ wxString classname##VariantData::GetType() const\ return wxS(#classname);\ }\ \ -expdecl classname& operator << ( classname &value, const wxVariant &variant )\ -{\ - wxASSERT( variant.GetType() == #classname );\ - \ - classname##VariantData *data = (classname##VariantData*) variant.GetData();\ - value = data->GetValue();\ - return value;\ -}\ -\ expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\ {\ classname##VariantData *data = new classname##VariantData( value );\ @@ -561,20 +552,26 @@ expdecl classname& classname##RefFromVariant( wxVariant& variant ) \ { \ wxASSERT( variant.GetType() == #classname );\ classname##VariantData *data = (classname##VariantData*) variant.GetData();\ - return data->GetValueRef();\ + return data->GetValue();\ } \ expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \ { \ wxASSERT( variant.GetType() == #classname );\ classname##VariantData *data = (classname##VariantData*) variant.GetData();\ - return data->GetValueRef();\ + return data->GetValue();\ } -// implements a wxVariantData-derived class using for the Eq() method the -// operator== which must have been provided by "classname" -#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname,expdecl) \ -WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl) \ -\ +#define WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname, expdecl) \ +expdecl classname& operator << ( classname &value, const wxVariant &variant )\ +{\ + wxASSERT( variant.GetType() == #classname );\ + \ + classname##VariantData *data = (classname##VariantData*) variant.GetData();\ + value = data->GetValue();\ + return value;\ +} + +#define WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname, expdecl) \ bool classname##VariantData::Eq(wxVariantData& data) const \ {\ wxASSERT( GetType() == data.GetType() );\ @@ -584,12 +581,20 @@ bool classname##VariantData::Eq(wxVariantData& data) const \ return otherData.m_value == m_value;\ } +// implements a wxVariantData-derived class using for the Eq() method the +// operator== which must have been provided by "classname" +#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname,expdecl) \ +WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \ +WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \ +WX_PG_IMPLEMENT_VARIANT_DATA_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl) + #define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \ WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE) // with Eq() implementation that always returns false #define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname,expdecl) \ -WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl) \ +WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ_NO_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \ +WX_PG_IMPLEMENT_VARIANT_DATA_GETTER(classname,wxEMPTY_PARAMETER_VALUE expdecl) \ \ bool classname##VariantData::Eq(wxVariantData& WXUNUSED(data)) const \ {\ @@ -619,6 +624,27 @@ 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