// Author: Jaakko Salli
// Modified by:
// Created: 2008-08-31
-// RCS-ID: $Id:
+// RCS-ID: $Id$
// Copyright: (c) Jaakko Salli
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#if wxUSE_PROPGRID
#include "wx/dynarray.h"
+#include "wx/vector.h"
#include "wx/hashmap.h"
#include "wx/variant.h"
#include "wx/longlong.h"
class wxPGOwnerDrawnComboBox;
class wxPGCustomComboControl;
class wxPGEditorDialogAdapter;
-struct wxPGValidationInfo;
+class wxPGValidationInfo;
// -----------------------------------------------------------------------
#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 \
{ \
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; \
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 );\
{ \
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() );\
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 \
{\
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