Eliminated C++ RTTI (typeid etc) use. Eliminated wxPGVariantData (default default value for new types is now Null variant). Re-created variantdata creator macros based on those found in variant.h. Using DECLARE/IMPLEMENT_VARIANT_OBJECT whenever possible.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55660 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -134,8 +134,8 @@ private:
|
|||||||
bool WXDLLIMPEXP_PROPGRID
|
bool WXDLLIMPEXP_PROPGRID
|
||||||
operator==(const wxColourPropertyValue&, const wxColourPropertyValue&);
|
operator==(const wxColourPropertyValue&, const wxColourPropertyValue&);
|
||||||
|
|
||||||
WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue,
|
DECLARE_VARIANT_OBJECT_EXPORTED(wxColourPropertyValue, WXDLLIMPEXP_PROPGRID)
|
||||||
wxColourPropertyValue, WXDLLIMPEXP_PROPGRID)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
|
@@ -813,18 +813,20 @@ wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000
|
|||||||
|
|
||||||
You can change the 'value type' of a property by simply assigning different
|
You can change the 'value type' of a property by simply assigning different
|
||||||
type of variant with SetValue. <b>It is mandatory to implement
|
type of variant with SetValue. <b>It is mandatory to implement
|
||||||
wxVariantData class for all data types used as property values.</b> Also,
|
wxVariantData class for all data types used as property values.</b>
|
||||||
it is further recommended to derive your class from wxPGVariantData, like
|
You can use macros declared in wxPropertyGrid headers. For instance:
|
||||||
this:
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
// In header file:
|
// In header file:
|
||||||
// (replace DECL with required data declaration, use
|
// (If you need to have export declaration, use version of macros
|
||||||
// wxEMPTY_PARAMETER_VALUE if none)
|
// with _EXPORTED postfix)
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantMyDataClass, MyDataClass, DECL)
|
WX_PG_DECLARE_VARIANT_DATA(MyDataClass)
|
||||||
|
|
||||||
// In sources file:
|
// In sources file:
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantMyDataClass, MyDataClass)
|
WX_PG_IMPLEMENT_VARIANT_DATA(MyDataClass)
|
||||||
|
|
||||||
|
// Or, if you don't have valid == operator:
|
||||||
|
WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(MyDataClass)
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@library{wxpropgrid}
|
@library{wxpropgrid}
|
||||||
|
@@ -57,19 +57,6 @@ public:
|
|||||||
// Replace with your own to affect all properties using default renderer.
|
// Replace with your own to affect all properties using default renderer.
|
||||||
wxPGCellRenderer* m_defaultRenderer;
|
wxPGCellRenderer* m_defaultRenderer;
|
||||||
|
|
||||||
// These are for fast variant type comparison
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_long;
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_string;
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_double;
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_bool;
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_arrstring;
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_wxobject;
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_list;
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_wxColour;
|
|
||||||
#if wxUSE_DATETIME
|
|
||||||
wxPGVariantDataClassInfo wxVariantClassInfo_datetime;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxPGChoices m_boolChoices;
|
wxPGChoices m_boolChoices;
|
||||||
|
|
||||||
wxVariant m_vEmptyString;
|
wxVariant m_vEmptyString;
|
||||||
@@ -79,6 +66,11 @@ public:
|
|||||||
wxVariant m_vFalse;
|
wxVariant m_vFalse;
|
||||||
|
|
||||||
// Cached constant strings
|
// Cached constant strings
|
||||||
|
wxPGCachedString m_strstring;
|
||||||
|
wxPGCachedString m_strlong;
|
||||||
|
wxPGCachedString m_strbool;
|
||||||
|
wxPGCachedString m_strlist;
|
||||||
|
|
||||||
wxPGCachedString m_strMin;
|
wxPGCachedString m_strMin;
|
||||||
wxPGCachedString m_strMax;
|
wxPGCachedString m_strMax;
|
||||||
wxPGCachedString m_strUnits;
|
wxPGCachedString m_strUnits;
|
||||||
@@ -101,13 +93,6 @@ public:
|
|||||||
|
|
||||||
extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass* wxPGGlobalVars;
|
extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass* wxPGGlobalVars;
|
||||||
|
|
||||||
#define wxPGIsVariantType(VARIANT, T) \
|
|
||||||
((VARIANT).GetData() && \
|
|
||||||
typeid(*(VARIANT).GetData()) == *wxPGGlobalVars->wxVariantClassInfo_##T)
|
|
||||||
|
|
||||||
#define wxPGIsVariantClassInfo(CLASSINFO, T) \
|
|
||||||
(*CLASSINFO == *wxPGGlobalVars->wxVariantClassInfo_##T)
|
|
||||||
|
|
||||||
#define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
|
#define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
|
||||||
#define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
|
#define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
|
||||||
#define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
|
#define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
|
||||||
@@ -116,8 +101,6 @@ extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass* wxPGGlobalVars;
|
|||||||
|
|
||||||
#define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
|
#define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
|
||||||
|
|
||||||
#define wxPGVariantAssign(A, B) A = B
|
|
||||||
|
|
||||||
#endif // !SWIG
|
#endif // !SWIG
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
@@ -453,93 +453,15 @@ WX_PG_DECLARE_EDITOR_WITH_DECL(ChoiceAndButton,WXDLLIMPEXP_PROPGRID)
|
|||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
|
|
||||||
/** @class wxPGVariantData
|
|
||||||
@ingroup classes
|
|
||||||
wxVariantData with additional functionality.
|
|
||||||
|
|
||||||
It is usually enough to use supplied to macros to automatically generate
|
|
||||||
variant data class. Like so:
|
|
||||||
|
|
||||||
@code
|
|
||||||
|
|
||||||
// In header
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataMyClass, // Name of the class
|
|
||||||
MyClass, // Name of the data type
|
|
||||||
wxEMPTY_PARAMETER_VALUE) // Declaration
|
|
||||||
|
|
||||||
// In source
|
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataMyClass, MyClass)
|
|
||||||
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
If your class is derived from wxObject, it is recommended that you use
|
|
||||||
wxObject-versions of the macros (WX_PG_DECLARE_WXOBJECT_VARIANT_DATA and
|
|
||||||
WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA).
|
|
||||||
|
|
||||||
*/
|
|
||||||
class WXDLLIMPEXP_PROPGRID wxPGVariantData : public wxVariantData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void* GetValuePtr() = 0;
|
|
||||||
virtual wxVariant GetDefaultValue() const = 0;
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// With wxWidgets 2.9 and later we demand native C++ RTTI support
|
|
||||||
#ifdef wxNO_RTTI
|
|
||||||
#error "You need to enable compiler RTTI support for wxPropertyGrid"
|
|
||||||
#endif
|
|
||||||
#define WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(A)
|
|
||||||
#define WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(A, B)
|
|
||||||
typedef const std::type_info* wxPGVariantDataClassInfo;
|
|
||||||
#define wxPGVariantDataGetClassInfo(A) (&typeid(*A))
|
|
||||||
#define wxPG_VARIANT_EQ(A, B) \
|
|
||||||
( ((A).GetData() && \
|
|
||||||
(B).GetData() && typeid(*(A).GetData()) == typeid(*(B).GetData()) && \
|
|
||||||
(A == B)) || !((A).GetData() && (B).GetData()) )
|
|
||||||
|
|
||||||
#ifndef wxDynamicCastVariantData
|
|
||||||
#define wxDynamicCastVariantData wxDynamicCast
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
inline void wxPGDoesNothing() {}
|
|
||||||
|
|
||||||
|
|
||||||
#define _WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, \
|
|
||||||
DATATYPE, \
|
|
||||||
AS_ARG, \
|
|
||||||
AS_ARG_CONST, \
|
|
||||||
CTOR_CODE, \
|
|
||||||
DEFAULT_VALUE, \
|
|
||||||
SET_CODE) \
|
|
||||||
WX_PG_DECLARE_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME) \
|
|
||||||
protected: \
|
|
||||||
DATATYPE m_value; \
|
|
||||||
public: \
|
|
||||||
CLASSNAME() { CTOR_CODE; } \
|
|
||||||
CLASSNAME(AS_ARG_CONST value) { CTOR_CODE; SET_CODE; m_value = value; } \
|
|
||||||
DATATYPE GetValue() const { return m_value; } \
|
|
||||||
AS_ARG_CONST GetValueRef() const { return m_value; } \
|
|
||||||
AS_ARG GetValueRef() { return m_value; } \
|
|
||||||
void SetValue(AS_ARG_CONST value) { SET_CODE; m_value = value; } \
|
|
||||||
virtual bool Eq(wxVariantData&) const { return false; } \
|
|
||||||
virtual wxString GetType() const { return wxS(#DATATYPE); } \
|
|
||||||
virtual wxVariantData* Clone() { return new CLASSNAME; } \
|
|
||||||
virtual bool Read(wxString &) { return false; } \
|
|
||||||
virtual bool Write(wxString &) const { return true; } \
|
|
||||||
virtual wxVariant GetDefaultValue() const { return DEFAULT_VALUE; }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macro WXVARIANT allows creation of wxVariant from any type supported by
|
// Macro WXVARIANT allows creation of wxVariant from any type supported by
|
||||||
// wxWidgets internally, and of all types created using
|
// wxWidgets internally, and of all types created using
|
||||||
// WX_PG_DECLARE_VARIANT_DATA.
|
// WX_PG_DECLARE_VARIANT_DATA.
|
||||||
template<class T>
|
template<class T>
|
||||||
wxVariant WXVARIANT( const T& value )
|
wxVariant WXVARIANT( const T& WXUNUSED(value) )
|
||||||
{
|
{
|
||||||
return wxVariant((void*)&value);
|
wxFAIL_MSG("Code should always call specializations of this template");
|
||||||
|
return wxVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> inline wxVariant WXVARIANT( const int& value )
|
template<> inline wxVariant WXVARIANT( const int& value )
|
||||||
@@ -559,127 +481,135 @@ template<> inline wxVariant WXVARIANT( const wxDateTime& value )
|
|||||||
{ return wxVariant(value); }
|
{ return wxVariant(value); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME) \
|
|
||||||
extern int CLASSNAME##_d_;
|
|
||||||
#define _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
|
|
||||||
int CLASSNAME##_d_;
|
|
||||||
|
|
||||||
#define _WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, \
|
//
|
||||||
DATATYPE, \
|
// These are modified versions of DECLARE/WX_PG_IMPLEMENT_VARIANT_DATA
|
||||||
AS_ARG, \
|
// macros found in variant.h. Difference are as follows:
|
||||||
AS_CONST_ARG, \
|
// * These support non-wxObject data
|
||||||
NULLVAL, \
|
// * These implement classname##RefFromVariant function which returns
|
||||||
BASECLASS) \
|
// reference to data within.
|
||||||
_WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER(CLASSNAME) \
|
// * const char* classname##_VariantType which equals classname.
|
||||||
WX_PG_IMPLEMENT_DYNAMIC_CLASS_VARIANTDATA(CLASSNAME, BASECLASS) \
|
// * WXVARIANT
|
||||||
AS_ARG operator <<( AS_ARG value, const wxVariant &variant ) \
|
//
|
||||||
|
#define WX_PG_DECLARE_VARIANT_DATA(classname) \
|
||||||
|
WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
|
||||||
|
|
||||||
|
#define WX_PG_DECLARE_VARIANT_DATA_EXPORTED(classname,expdecl) \
|
||||||
|
expdecl classname& operator << ( classname &object, const wxVariant &variant ); \
|
||||||
|
expdecl wxVariant& operator << ( wxVariant &variant, const classname &object ); \
|
||||||
|
expdecl const classname& classname##RefFromVariant( const wxVariant& variant ); \
|
||||||
|
expdecl classname& classname##RefFromVariant( wxVariant& variant ); \
|
||||||
|
template<> inline wxVariant WXVARIANT( const classname& value ) \
|
||||||
{ \
|
{ \
|
||||||
CLASSNAME *data = wxDynamicCastVariantData( variant.GetData(), CLASSNAME ); \
|
wxVariant variant; \
|
||||||
wxASSERT( data ); \
|
variant << value; \
|
||||||
value = data->GetValue(); \
|
|
||||||
return value; \
|
|
||||||
} \
|
|
||||||
wxVariant& operator <<( wxVariant &variant, AS_CONST_ARG value ) \
|
|
||||||
{ \
|
|
||||||
CLASSNAME *data = new CLASSNAME( value ); \
|
|
||||||
variant.SetData( data ); \
|
|
||||||
return variant; \
|
return variant; \
|
||||||
} \
|
} \
|
||||||
AS_ARG DATATYPE##FromVariant( const wxVariant& v ) \
|
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) \
|
||||||
|
const char* classname##_VariantType = #classname; \
|
||||||
|
class classname##VariantData: public wxVariantData \
|
||||||
{ \
|
{ \
|
||||||
CLASSNAME *data = wxDynamicCastVariantData( v.GetData(), CLASSNAME ); \
|
public:\
|
||||||
if ( !data ) \
|
classname##VariantData() {} \
|
||||||
return NULLVAL; \
|
classname##VariantData( const classname &value ) { m_value = value; } \
|
||||||
return data->GetValueRef(); \
|
\
|
||||||
|
classname &GetValue() { 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; \
|
||||||
|
};\
|
||||||
|
\
|
||||||
|
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 );\
|
||||||
|
variant.SetData( data );\
|
||||||
|
return variant;\
|
||||||
} \
|
} \
|
||||||
wxVariant DATATYPE##ToVariant( AS_CONST_ARG value ) \
|
expdecl classname& classname##RefFromVariant( wxVariant& variant ) \
|
||||||
{ \
|
{ \
|
||||||
wxVariant variant( new CLASSNAME( value ) ); \
|
wxASSERT( variant.GetType() == #classname );\
|
||||||
return variant; \
|
classname##VariantData *data = (classname##VariantData*) variant.GetData();\
|
||||||
|
return data->GetValueRef();\
|
||||||
|
} \
|
||||||
|
expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \
|
||||||
|
{ \
|
||||||
|
wxASSERT( variant.GetType() == #classname );\
|
||||||
|
classname##VariantData *data = (classname##VariantData*) variant.GetData();\
|
||||||
|
return data->GetValueRef();\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE) \
|
// implements a wxVariantData-derived class using for the Eq() method the
|
||||||
class CLASSNAME : public wxPGVariantData \
|
// operator== which must have been provided by "classname"
|
||||||
{ \
|
#define WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname,expdecl) \
|
||||||
_WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_NO_EQ(classname,wxEMPTY_PARAMETER_VALUE expdecl) \
|
||||||
const DATATYPE&, wxPGDoesNothing(), \
|
\
|
||||||
wxVariant(new CLASSNAME(DATATYPE())), \
|
bool classname##VariantData::Eq(wxVariantData& data) const \
|
||||||
wxPGDoesNothing()) \
|
{\
|
||||||
public: \
|
wxASSERT( GetType() == data.GetType() );\
|
||||||
virtual void* GetValuePtr() { return (void*)&m_value; } \
|
\
|
||||||
}; \
|
classname##VariantData & otherData = (classname##VariantData &) data;\
|
||||||
_WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, \
|
\
|
||||||
DATATYPE, \
|
return otherData.m_value == m_value;\
|
||||||
DATATYPE&, \
|
}
|
||||||
const DATATYPE&, \
|
|
||||||
(DATATYPE&)*((DATATYPE*)NULL), \
|
|
||||||
wxPGVariantData)
|
|
||||||
|
|
||||||
#define WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(CLASSNAME, DATATYPE) \
|
#define WX_PG_IMPLEMENT_VARIANT_DATA(classname) \
|
||||||
class CLASSNAME : public wxPGVariantData \
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(classname, wxEMPTY_PARAMETER_VALUE)
|
||||||
{ \
|
|
||||||
_WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE, DATATYPE&, \
|
|
||||||
const DATATYPE&, wxPGDoesNothing(), \
|
|
||||||
wxVariant(new CLASSNAME(DATATYPE())), \
|
|
||||||
wxPGDoesNothing()) \
|
|
||||||
public: \
|
|
||||||
virtual void* GetValuePtr() { return (void*)&m_value; } \
|
|
||||||
virtual wxClassInfo* GetValueClassInfo() \
|
|
||||||
{ return m_value.GetClassInfo(); } \
|
|
||||||
}; \
|
|
||||||
_WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE&, \
|
|
||||||
const DATATYPE&, \
|
|
||||||
(DATATYPE&)*((DATATYPE*)NULL), \
|
|
||||||
wxPGVariantData)
|
|
||||||
|
|
||||||
|
// 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) \
|
||||||
|
\
|
||||||
|
bool classname##VariantData::Eq(wxVariantData& WXUNUSED(data)) const \
|
||||||
|
{\
|
||||||
|
return false; \
|
||||||
|
}
|
||||||
|
|
||||||
#define WX_PG_DECLARE_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
|
#define WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(classname) \
|
||||||
DECL DATATYPE& operator <<( DATATYPE& value, const wxVariant &variant ); \
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(classname, wxEMPTY_PARAMETER_VALUE)
|
||||||
DECL wxVariant& operator <<( wxVariant &variant, const DATATYPE& value ); \
|
|
||||||
DECL DATATYPE& DATATYPE##FromVariant( const wxVariant& variant ); \
|
|
||||||
DECL wxVariant DATATYPE##ToVariant( const DATATYPE& value ); \
|
|
||||||
template<> inline wxVariant WXVARIANT( const DATATYPE& value ) \
|
|
||||||
{ return DATATYPE##ToVariant(value); } \
|
|
||||||
DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
|
|
||||||
|
|
||||||
#define WX_PG_DECLARE_WXOBJECT_VARIANT_DATA WX_PG_DECLARE_VARIANT_DATA
|
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 )
|
||||||
|
{
|
||||||
|
wxVariant variant;
|
||||||
|
variant << value;
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
|
||||||
#define WX_PG_DECLARE_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DECL) \
|
|
||||||
DECL DATATYPE* operator <<( DATATYPE* value, const wxVariant &variant ); \
|
|
||||||
DECL wxVariant& operator <<( wxVariant &variant, DATATYPE* value ); \
|
|
||||||
DECL DATATYPE* DATATYPE##FromVariant( const wxVariant& variant ); \
|
|
||||||
DECL wxVariant DATATYPE##ToVariant( DATATYPE* value ); \
|
|
||||||
DECL _WX_PG_VARIANT_DATA_CLASSINFO_CONTAINER_DECL(CLASSNAME);
|
|
||||||
|
|
||||||
|
|
||||||
#define WX_PG_IMPLEMENT_PTR_VARIANT_DATA(CLASSNAME, DATATYPE, DEFAULT) \
|
|
||||||
class CLASSNAME : public wxPGVariantData \
|
|
||||||
{ \
|
|
||||||
_WX_PG_IMPLEMENT_VARIANT_DATA_CLASS(CLASSNAME, DATATYPE*, DATATYPE*, \
|
|
||||||
DATATYPE*, m_value = NULL, \
|
|
||||||
DEFAULT, \
|
|
||||||
if (m_value) Py_DECREF(m_value); \
|
|
||||||
if (!value) value = Py_None; \
|
|
||||||
Py_INCREF(value) ) \
|
|
||||||
~CLASSNAME() { if (m_value) Py_DECREF(m_value); } \
|
|
||||||
public: \
|
|
||||||
virtual void* GetValuePtr() { return (void*)m_value; } \
|
|
||||||
}; \
|
|
||||||
_WX_PG_IMPLEMENT_VARIANT_DATA(CLASSNAME, DATATYPE, DATATYPE*, DATATYPE*, \
|
|
||||||
NULL, wxPGVariantData)
|
|
||||||
|
|
||||||
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataPoint, wxPoint, WXDLLIMPEXP_PROPGRID)
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataSize, wxSize, WXDLLIMPEXP_PROPGRID)
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataArrayInt,
|
|
||||||
wxArrayInt, WXDLLIMPEXP_PROPGRID)
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataLongLong,
|
|
||||||
wxLongLong, WXDLLIMPEXP_PROPGRID)
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataULongLong,
|
|
||||||
wxULongLong, WXDLLIMPEXP_PROPGRID)
|
|
||||||
|
|
||||||
WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataFont,
|
|
||||||
wxFont, WXDLLIMPEXP_PROPGRID)
|
|
||||||
template<> inline wxVariant WXVARIANT( const wxColour& value )
|
template<> inline wxVariant WXVARIANT( const wxColour& value )
|
||||||
{
|
{
|
||||||
wxVariant variant;
|
wxVariant variant;
|
||||||
@@ -687,8 +617,15 @@ template<> inline wxVariant WXVARIANT( const wxColour& value )
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WX_PG_VARIANT_GETVALUEREF(P, T) \
|
// Define constants for common wxVariant type strings
|
||||||
(*((T*)((wxPGVariantData*)(P.GetData()))->GetValuePtr()))
|
|
||||||
|
#define wxPG_VARIANT_TYPE_STRING wxPGGlobalVars->m_strstring
|
||||||
|
#define wxPG_VARIANT_TYPE_LONG wxPGGlobalVars->m_strlong
|
||||||
|
#define wxPG_VARIANT_TYPE_BOOL wxPGGlobalVars->m_strbool
|
||||||
|
#define wxPG_VARIANT_TYPE_LIST wxPGGlobalVars->m_strlist
|
||||||
|
#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
|
// Safely converts a wxVariant to (long) int. Supports converting from string
|
||||||
// and boolean as well.
|
// and boolean as well.
|
||||||
@@ -714,28 +651,6 @@ bool wxPGVariantToDouble( const wxVariant& variant, double* pResult );
|
|||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
|
|
||||||
WXDLLIMPEXP_PROPGRID
|
|
||||||
wxObject*
|
|
||||||
wxPG_VariantToWxObject( const wxVariant& variant, wxClassInfo* classInfo );
|
|
||||||
|
|
||||||
//
|
|
||||||
// Redefine wxGetVariantCast to also take propertygrid variantdata
|
|
||||||
// classes into account.
|
|
||||||
//
|
|
||||||
#undef wxGetVariantCast
|
|
||||||
#define wxGetVariantCast(var,classname) \
|
|
||||||
(classname*)wxPG_VariantToWxObject(var,&classname::ms_classInfo)
|
|
||||||
|
|
||||||
// TODO: After a while, remove this.
|
|
||||||
#define WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) \
|
|
||||||
(CLASSNAME*)wxPG_VariantToWxObject(VARIANT,&CLASSNAME::ms_classInfo)
|
|
||||||
|
|
||||||
#endif // !SWIG
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef SWIG
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tokenizer macros.
|
// Tokenizer macros.
|
||||||
// NOTE: I have made two versions - worse ones (performance and consistency
|
// NOTE: I have made two versions - worse ones (performance and consistency
|
||||||
|
@@ -116,10 +116,10 @@ typedef const wxPGPropArgCls& wxPGPropArg;
|
|||||||
|
|
||||||
WXDLLIMPEXP_PROPGRID
|
WXDLLIMPEXP_PROPGRID
|
||||||
void wxPGTypeOperationFailed( const wxPGProperty* p,
|
void wxPGTypeOperationFailed( const wxPGProperty* p,
|
||||||
const wxChar* typestr,
|
const wxString& typestr,
|
||||||
const wxChar* op );
|
const wxString& op );
|
||||||
WXDLLIMPEXP_PROPGRID
|
WXDLLIMPEXP_PROPGRID
|
||||||
void wxPGGetFailed( const wxPGProperty* p, const wxChar* typestr );
|
void wxPGGetFailed( const wxPGProperty* p, const wxString& typestr );
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -550,74 +550,80 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
bool GetPropertyValueAsBool( wxPGPropArg id ) const;
|
bool GetPropertyValueAsBool( wxPGPropArg id ) const;
|
||||||
double GetPropertyValueAsDouble( wxPGPropArg id ) const;
|
double GetPropertyValueAsDouble( wxPGPropArg id ) const;
|
||||||
wxObject* GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const;
|
|
||||||
void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
|
void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
|
||||||
|
|
||||||
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
|
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
|
||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
||||||
if ( p->m_value.GetType() != TYPENAME ) \
|
wxString typeName(wxS(TYPENAME)); \
|
||||||
|
wxVariant value = p->GetValue(); \
|
||||||
|
if ( value.GetType() != typeName ) \
|
||||||
{ \
|
{ \
|
||||||
wxPGGetFailed(p, TYPENAME); \
|
wxPGGetFailed(p, typeName); \
|
||||||
return DEFVAL; \
|
return DEFVAL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
|
#define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
|
||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
|
||||||
if ( p->m_value.GetType() != TYPENAME ) \
|
wxVariant value = p->GetValue(); \
|
||||||
|
if ( value.GetType() != wxS(TYPENAME) ) \
|
||||||
return DEFVAL; \
|
return DEFVAL; \
|
||||||
|
|
||||||
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
|
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("arrstring"),
|
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring",
|
||||||
wxArrayString())
|
wxArrayString())
|
||||||
return p->m_value.GetArrayString();
|
return value.GetArrayString();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPoint GetPropertyValueAsPoint( wxPGPropArg id ) const
|
wxPoint GetPropertyValueAsPoint( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxPoint"), wxPoint())
|
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxPoint", wxPoint())
|
||||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxPoint);
|
wxPoint pt;
|
||||||
|
pt << value;
|
||||||
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize GetPropertyValueAsSize( wxPGPropArg id ) const
|
wxSize GetPropertyValueAsSize( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxSize"), wxSize())
|
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxSize", wxSize())
|
||||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxSize);
|
wxSize sz;
|
||||||
|
sz << value;
|
||||||
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
|
wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxLongLong"),
|
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK("wxLongLong",
|
||||||
(long) GetPropertyValueAsLong(id))
|
(long) GetPropertyValueAsLong(id))
|
||||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxLongLong).GetValue();
|
wxLongLong ll;
|
||||||
|
ll << value;
|
||||||
|
return ll.GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
|
wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(wxT("wxULongLong"),
|
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK("wxULongLong",
|
||||||
(unsigned long) GetPropertyValueAsULong(id))
|
(unsigned long) GetPropertyValueAsULong(id))
|
||||||
return WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxULongLong).GetValue();
|
wxULongLong ull;
|
||||||
|
ull << value;
|
||||||
|
return ull.GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
|
wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(wxT("wxArrayInt"),
|
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt",
|
||||||
wxArrayInt())
|
wxArrayInt())
|
||||||
wxArrayInt arr = WX_PG_VARIANT_GETVALUEREF(p->GetValue(), wxArrayInt);
|
wxArrayInt arr;
|
||||||
|
arr << value;
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
|
wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxDateTime())
|
wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime",
|
||||||
|
wxDateTime())
|
||||||
if ( wxStrcmp(p->m_value.GetType(), wxT("datetime")) != 0 )
|
return value.GetDateTime();
|
||||||
{
|
|
||||||
wxPGGetFailed(p, wxT("datetime"));
|
|
||||||
return wxDateTime();
|
|
||||||
}
|
|
||||||
return p->m_value.GetDateTime();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -406,18 +406,22 @@ struct wxPGChoiceInfo
|
|||||||
they are only really needed if you need to use wxRTTI with your
|
they are only really needed if you need to use wxRTTI with your
|
||||||
property class.
|
property class.
|
||||||
|
|
||||||
You can change the 'value type' of a property by simply assigning different type
|
You can change the 'value type' of a property by simply assigning different
|
||||||
of variant with SetValue. <b>It is mandatory to implement wxVariantData class
|
type of variant with SetValue. <b>It is mandatory to implement
|
||||||
for all data types used as property values.</b> Also, it is further recommended
|
wxVariantData class for all data types used as property values.</b>
|
||||||
to derive your class from wxPGVariantData, like this:
|
You can use macros declared in wxPropertyGrid headers. For instance:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
// In header file:
|
// In header file:
|
||||||
// (replace DECL with required data declaration, wxEMPTY_PARAMETER_VALUE if none)
|
// (If you need to have export declaration, use version of macros
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantMyDataClass, MyDataClass, DECL)
|
// with _EXPORTED postfix)
|
||||||
|
WX_PG_DECLARE_VARIANT_DATA(MyDataClass)
|
||||||
|
|
||||||
// In sources file:
|
// In sources file:
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantMyDataClass, MyDataClass)
|
WX_PG_IMPLEMENT_VARIANT_DATA(MyDataClass)
|
||||||
|
|
||||||
|
// Or, if you don't have valid == operator:
|
||||||
|
WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(MyDataClass)
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@library{wxpropgrid}
|
@library{wxpropgrid}
|
||||||
|
@@ -350,8 +350,7 @@ public:
|
|||||||
return p->GetValidator();
|
return p->GetValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns value as wxVariant. To get wxObject pointer from it,
|
/** Returns value as wxVariant.
|
||||||
you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
|
|
||||||
|
|
||||||
If property value is unspecified, Null variant is returned.
|
If property value is unspecified, Null variant is returned.
|
||||||
*/
|
*/
|
||||||
@@ -370,7 +369,6 @@ public:
|
|||||||
int GetPropertyValueAsInt( wxPGPropArg id ) const { return (int)GetPropertyValueAsLong(id); }
|
int GetPropertyValueAsInt( wxPGPropArg id ) const { return (int)GetPropertyValueAsLong(id); }
|
||||||
bool GetPropertyValueAsBool( wxPGPropArg id ) const;
|
bool GetPropertyValueAsBool( wxPGPropArg id ) const;
|
||||||
double GetPropertyValueAsDouble( wxPGPropArg id ) const;
|
double GetPropertyValueAsDouble( wxPGPropArg id ) const;
|
||||||
wxObject* GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const;
|
|
||||||
void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
|
void* GetPropertyValueAsVoidPtr( wxPGPropArg id ) const;
|
||||||
|
|
||||||
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
|
wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
|
||||||
|
@@ -459,7 +459,7 @@ void wxAdvImageFileProperty::OnCustomPaint( wxDC& dc,
|
|||||||
|
|
||||||
// See propgridsample.h for wxVector3f class
|
// See propgridsample.h for wxVector3f class
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxVector3fVariantData, wxVector3f)
|
WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(wxVector3f)
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxVectorProperty,wxPGProperty,
|
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxVectorProperty,wxPGProperty,
|
||||||
wxVector3f,const wxVector3f&,TextCtrl)
|
wxVector3f,const wxVector3f&,TextCtrl)
|
||||||
@@ -470,7 +470,7 @@ wxVectorProperty::wxVectorProperty( const wxString& label,
|
|||||||
const wxVector3f& value )
|
const wxVector3f& value )
|
||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
SetValue( wxVector3fToVariant(value) );
|
SetValue( WXVARIANT(value) );
|
||||||
AddChild( new wxFloatProperty(wxT("X"),wxPG_LABEL,value.x) );
|
AddChild( new wxFloatProperty(wxT("X"),wxPG_LABEL,value.x) );
|
||||||
AddChild( new wxFloatProperty(wxT("Y"),wxPG_LABEL,value.y) );
|
AddChild( new wxFloatProperty(wxT("Y"),wxPG_LABEL,value.y) );
|
||||||
AddChild( new wxFloatProperty(wxT("Z"),wxPG_LABEL,value.z) );
|
AddChild( new wxFloatProperty(wxT("Z"),wxPG_LABEL,value.z) );
|
||||||
@@ -481,7 +481,7 @@ wxVectorProperty::~wxVectorProperty() { }
|
|||||||
void wxVectorProperty::RefreshChildren()
|
void wxVectorProperty::RefreshChildren()
|
||||||
{
|
{
|
||||||
if ( !GetChildCount() ) return;
|
if ( !GetChildCount() ) return;
|
||||||
wxVector3f& vector = wxVector3fFromVariant(m_value);
|
const wxVector3f& vector = wxVector3fRefFromVariant(m_value);
|
||||||
Item(0)->SetValue( vector.x );
|
Item(0)->SetValue( vector.x );
|
||||||
Item(1)->SetValue( vector.y );
|
Item(1)->SetValue( vector.y );
|
||||||
Item(2)->SetValue( vector.z );
|
Item(2)->SetValue( vector.z );
|
||||||
@@ -489,13 +489,15 @@ void wxVectorProperty::RefreshChildren()
|
|||||||
|
|
||||||
void wxVectorProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
void wxVectorProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
||||||
{
|
{
|
||||||
wxVector3f& vector = wxVector3fFromVariant(thisValue);
|
wxVector3f vector;
|
||||||
|
vector << thisValue;
|
||||||
switch ( childIndex )
|
switch ( childIndex )
|
||||||
{
|
{
|
||||||
case 0: vector.x = childValue.GetDouble(); break;
|
case 0: vector.x = childValue.GetDouble(); break;
|
||||||
case 1: vector.y = childValue.GetDouble(); break;
|
case 1: vector.y = childValue.GetDouble(); break;
|
||||||
case 2: vector.z = childValue.GetDouble(); break;
|
case 2: vector.z = childValue.GetDouble(); break;
|
||||||
}
|
}
|
||||||
|
thisValue << vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -505,7 +507,7 @@ void wxVectorProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVar
|
|||||||
|
|
||||||
// See propgridsample.h for wxTriangle class
|
// See propgridsample.h for wxTriangle class
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxTriangleVariantData, wxTriangle)
|
WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(wxTriangle)
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxTriangleProperty,wxPGProperty,
|
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxTriangleProperty,wxPGProperty,
|
||||||
wxTriangle,const wxTriangle&,TextCtrl)
|
wxTriangle,const wxTriangle&,TextCtrl)
|
||||||
@@ -516,7 +518,7 @@ wxTriangleProperty::wxTriangleProperty( const wxString& label,
|
|||||||
const wxTriangle& value)
|
const wxTriangle& value)
|
||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
SetValue( wxTriangleToVariant(value) );
|
SetValue( WXVARIANT(value) );
|
||||||
AddChild( new wxVectorProperty(wxT("A"),wxPG_LABEL,value.a) );
|
AddChild( new wxVectorProperty(wxT("A"),wxPG_LABEL,value.a) );
|
||||||
AddChild( new wxVectorProperty(wxT("B"),wxPG_LABEL,value.b) );
|
AddChild( new wxVectorProperty(wxT("B"),wxPG_LABEL,value.b) );
|
||||||
AddChild( new wxVectorProperty(wxT("C"),wxPG_LABEL,value.c) );
|
AddChild( new wxVectorProperty(wxT("C"),wxPG_LABEL,value.c) );
|
||||||
@@ -527,22 +529,24 @@ wxTriangleProperty::~wxTriangleProperty() { }
|
|||||||
void wxTriangleProperty::RefreshChildren()
|
void wxTriangleProperty::RefreshChildren()
|
||||||
{
|
{
|
||||||
if ( !GetChildCount() ) return;
|
if ( !GetChildCount() ) return;
|
||||||
wxTriangle& triangle = wxTriangleFromVariant(m_value);
|
const wxTriangle& triangle = wxTriangleRefFromVariant(m_value);
|
||||||
Item(0)->SetValue( wxVector3fToVariant(triangle.a) );
|
Item(0)->SetValue( WXVARIANT(triangle.a) );
|
||||||
Item(1)->SetValue( wxVector3fToVariant(triangle.b) );
|
Item(1)->SetValue( WXVARIANT(triangle.b) );
|
||||||
Item(2)->SetValue( wxVector3fToVariant(triangle.c) );
|
Item(2)->SetValue( WXVARIANT(triangle.c) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTriangleProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
void wxTriangleProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
||||||
{
|
{
|
||||||
wxTriangle& triangle = wxTriangleFromVariant(thisValue);
|
wxTriangle triangle;
|
||||||
wxVector3f& vector = wxVector3fFromVariant(childValue);
|
triangle << thisValue;
|
||||||
|
const wxVector3f& vector = wxVector3fRefFromVariant(childValue);
|
||||||
switch ( childIndex )
|
switch ( childIndex )
|
||||||
{
|
{
|
||||||
case 0: triangle.a = vector; break;
|
case 0: triangle.a = vector; break;
|
||||||
case 1: triangle.b = vector; break;
|
case 1: triangle.b = vector; break;
|
||||||
case 2: triangle.c = vector; break;
|
case 2: triangle.c = vector; break;
|
||||||
}
|
}
|
||||||
|
thisValue << triangle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -922,34 +926,36 @@ void FormMain::OnPropertyGridChange( wxPropertyGridEvent& event )
|
|||||||
else
|
else
|
||||||
if ( name == wxT("Font") )
|
if ( name == wxT("Font") )
|
||||||
{
|
{
|
||||||
wxFont& font = *wxDynamicCast(m_pPropGridManager->GetPropertyValueAsWxObjectPtr(property), wxFont);
|
wxFont font;
|
||||||
wxASSERT( &font && font.Ok() );
|
font << value;
|
||||||
|
wxASSERT( font.Ok() );
|
||||||
|
|
||||||
m_pPropGridManager->SetFont( font );
|
m_pPropGridManager->SetFont( font );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if ( name == wxT("Margin Colour") )
|
if ( name == wxT("Margin Colour") )
|
||||||
{
|
{
|
||||||
wxColourPropertyValue& cpv = *wxGetVariantCast(value,wxColourPropertyValue);
|
wxColourPropertyValue cpv;
|
||||||
m_pPropGridManager->GetGrid()->SetMarginColour ( cpv.m_colour );
|
cpv << value;
|
||||||
|
m_pPropGridManager->GetGrid()->SetMarginColour( cpv.m_colour );
|
||||||
}
|
}
|
||||||
else if ( name == wxT("Cell Colour") )
|
else if ( name == wxT("Cell Colour") )
|
||||||
{
|
{
|
||||||
wxColourPropertyValue* cpv = wxGetVariantCast(value,wxColourPropertyValue);
|
wxColourPropertyValue cpv;
|
||||||
wxASSERT( cpv );
|
cpv << value;
|
||||||
m_pPropGridManager->GetGrid()->SetCellBackgroundColour( cpv->m_colour );
|
m_pPropGridManager->GetGrid()->SetCellBackgroundColour( cpv.m_colour );
|
||||||
}
|
}
|
||||||
else if ( name == wxT("Line Colour") )
|
else if ( name == wxT("Line Colour") )
|
||||||
{
|
{
|
||||||
wxColourPropertyValue* cpv = wxGetVariantCast(value,wxColourPropertyValue);
|
wxColourPropertyValue cpv;
|
||||||
wxASSERT( cpv );
|
cpv << value;
|
||||||
m_pPropGridManager->GetGrid()->SetLineColour( cpv->m_colour );
|
m_pPropGridManager->GetGrid()->SetLineColour( cpv.m_colour );
|
||||||
}
|
}
|
||||||
else if ( name == wxT("Cell Text Colour") )
|
else if ( name == wxT("Cell Text Colour") )
|
||||||
{
|
{
|
||||||
wxColourPropertyValue* cpv = wxGetVariantCast(value,wxColourPropertyValue);
|
wxColourPropertyValue cpv;
|
||||||
wxASSERT( cpv );
|
cpv << value;
|
||||||
m_pPropGridManager->GetGrid()->SetCellTextColour( cpv->m_colour );
|
m_pPropGridManager->GetGrid()->SetCellTextColour( cpv.m_colour );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ inline bool operator == (const wxVector3f& a, const wxVector3f& b)
|
|||||||
return (a.x == b.x && a.y == b.y && a.z == b.z);
|
return (a.x == b.x && a.y == b.y && a.z == b.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxVector3fVariantData, wxVector3f, wxEMPTY_PARAMETER_VALUE)
|
WX_PG_DECLARE_VARIANT_DATA(wxVector3f)
|
||||||
|
|
||||||
class wxVectorProperty : public wxPGProperty
|
class wxVectorProperty : public wxPGProperty
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ inline bool operator == (const wxTriangle& a, const wxTriangle& b)
|
|||||||
return (a.a == b.a && a.b == b.b && a.c == b.c);
|
return (a.a == b.a && a.b == b.b && a.c == b.c);
|
||||||
}
|
}
|
||||||
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxTriangleVariantData, wxTriangle, wxEMPTY_PARAMETER_VALUE)
|
WX_PG_DECLARE_VARIANT_DATA(wxTriangle)
|
||||||
|
|
||||||
class wxTriangleProperty : public wxPGProperty
|
class wxTriangleProperty : public wxPGProperty
|
||||||
{
|
{
|
||||||
|
@@ -48,7 +48,7 @@ bool operator == (const wxFontData&, const wxFontData&)
|
|||||||
|
|
||||||
#include <wx/fontdlg.h>
|
#include <wx/fontdlg.h>
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(wxPGVariantDataFontData, wxFontData)
|
IMPLEMENT_VARIANT_OBJECT_SHALLOWCMP(wxFontData)
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxFontDataProperty,wxFontProperty,
|
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxFontDataProperty,wxFontProperty,
|
||||||
wxFontData,const wxFontData&,TextCtrlAndButton)
|
wxFontData,const wxFontData&,TextCtrlAndButton)
|
||||||
@@ -56,51 +56,68 @@ WX_PG_IMPLEMENT_PROPERTY_CLASS(wxFontDataProperty,wxFontProperty,
|
|||||||
wxFontDataProperty::wxFontDataProperty( const wxString& label, const wxString& name,
|
wxFontDataProperty::wxFontDataProperty( const wxString& label, const wxString& name,
|
||||||
const wxFontData& value ) : wxFontProperty(label,name,value.GetInitialFont())
|
const wxFontData& value ) : wxFontProperty(label,name,value.GetInitialFont())
|
||||||
{
|
{
|
||||||
// Set initial value - should be done in a simpler way like this
|
wxFontData fontData(value);
|
||||||
// (instead of calling SetValue) in derived (wxObject) properties.
|
|
||||||
m_value_wxFontData << value;
|
|
||||||
|
|
||||||
wxFontData& fontData = wxFontDataFromVariant(m_value_wxFontData);
|
|
||||||
|
|
||||||
// Fix value.
|
// Fix value.
|
||||||
fontData.SetChosenFont(value.GetInitialFont());
|
fontData.SetChosenFont(value.GetInitialFont());
|
||||||
if ( !fontData.GetColour().Ok() )
|
if ( !fontData.GetColour().Ok() )
|
||||||
fontData.SetColour(*wxBLACK);
|
fontData.SetColour(*wxBLACK);
|
||||||
|
|
||||||
// Add extra children.
|
// Set initial value - should be done in a simpler way like this
|
||||||
AddChild( new wxColourProperty(_("Colour"),wxPG_LABEL,
|
// (instead of calling SetValue) in derived (wxObject) properties.
|
||||||
fontData.GetColour() ) );
|
m_value_wxFontData << value;
|
||||||
|
|
||||||
|
// Add extra children.
|
||||||
|
AddChild( new wxColourProperty(_("Colour"), wxPG_LABEL,
|
||||||
|
fontData.GetColour() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontDataProperty::~wxFontDataProperty () { }
|
wxFontDataProperty::~wxFontDataProperty () { }
|
||||||
|
|
||||||
void wxFontDataProperty::OnSetValue()
|
void wxFontDataProperty::OnSetValue()
|
||||||
{
|
{
|
||||||
if ( !(&wxFontDataFromVariant(m_value)) )
|
if ( m_value.GetType() != "wxFontData" )
|
||||||
{
|
{
|
||||||
wxFont* pFont = &wxFontFromVariant(m_value);
|
if ( m_value.GetType() == "wxFont" )
|
||||||
if ( pFont )
|
|
||||||
{
|
{
|
||||||
|
wxFont font;
|
||||||
|
font << m_value;
|
||||||
wxFontData fontData;
|
wxFontData fontData;
|
||||||
fontData.SetChosenFont(*pFont);
|
fontData.SetChosenFont(font);
|
||||||
m_value = WXVARIANT(fontData);
|
if ( !m_value_wxFontData.IsNull() )
|
||||||
|
{
|
||||||
|
wxFontData oldFontData;
|
||||||
|
oldFontData << m_value_wxFontData;
|
||||||
|
fontData.SetColour(oldFontData.GetColour());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fontData.SetColour(*wxBLACK);
|
||||||
|
}
|
||||||
|
wxVariant variant;
|
||||||
|
variant << fontData;
|
||||||
|
m_value_wxFontData = variant;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxFAIL_MSG(wxT("Value to wxFontDataProperty must be eithe wxFontData or wxFont"));
|
wxFAIL_MSG(wxT("Value to wxFontDataProperty must be eithe wxFontData or wxFont"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set m_value to wxFont so that wxFontProperty methods will work
|
||||||
|
// correctly.
|
||||||
|
m_value_wxFontData = m_value;
|
||||||
|
|
||||||
// Set m_value to wxFont so that wxFontProperty methods will work
|
wxFontData fontData;
|
||||||
// correctly.
|
fontData << m_value_wxFontData;
|
||||||
m_value_wxFontData = m_value;
|
|
||||||
wxFontData& fontData = wxFontDataFromVariant(m_value_wxFontData);
|
|
||||||
|
|
||||||
wxFont font = fontData.GetChosenFont();
|
wxFont font = fontData.GetChosenFont();
|
||||||
if ( !font.Ok() )
|
if ( !font.Ok() )
|
||||||
font = wxFont(10,wxSWISS,wxNORMAL,wxNORMAL);
|
font = wxFont(10,wxSWISS,wxNORMAL,wxNORMAL);
|
||||||
m_value = WXVARIANT(font);
|
|
||||||
|
m_value = WXVARIANT(font);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVariant wxFontDataProperty::DoGetValue() const
|
wxVariant wxFontDataProperty::DoGetValue() const
|
||||||
@@ -117,7 +134,8 @@ bool wxFontDataProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
// Update value from last minute changes
|
// Update value from last minute changes
|
||||||
PrepareValueForDialogEditing(propgrid);
|
PrepareValueForDialogEditing(propgrid);
|
||||||
|
|
||||||
wxFontData& fontData = wxFontDataFromVariant(m_value_wxFontData);
|
wxFontData fontData;
|
||||||
|
fontData << m_value_wxFontData;
|
||||||
|
|
||||||
fontData.SetInitialFont(fontData.GetChosenFont());
|
fontData.SetInitialFont(fontData.GetChosenFont());
|
||||||
|
|
||||||
@@ -125,7 +143,9 @@ bool wxFontDataProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
|
|
||||||
if ( dlg.ShowModal() == wxID_OK )
|
if ( dlg.ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
SetValueInEvent( wxFontDataToVariant(dlg.GetFontData()) );
|
wxVariant variant;
|
||||||
|
variant << dlg.GetFontData();
|
||||||
|
SetValueInEvent( variant );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,16 +155,17 @@ bool wxFontDataProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
void wxFontDataProperty::RefreshChildren()
|
void wxFontDataProperty::RefreshChildren()
|
||||||
{
|
{
|
||||||
wxFontProperty::RefreshChildren();
|
wxFontProperty::RefreshChildren();
|
||||||
if ( GetChildCount() < 6 ) // Number is count of inherit prop's children + 1.
|
if ( GetChildCount() < 6 ) // Number is count of wxFontProperty's children + 1.
|
||||||
return;
|
return;
|
||||||
wxFontData& fontData = wxFontDataFromVariant(m_value_wxFontData);
|
wxFontData fontData; fontData << m_value_wxFontData;
|
||||||
wxVariant variant; variant << fontData.GetColour();
|
wxVariant variant; variant << fontData.GetColour();
|
||||||
Item(6)->SetValue( variant );
|
Item(6)->SetValue( variant );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontDataProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
void wxFontDataProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
||||||
{
|
{
|
||||||
wxFontData& fontData = wxFontDataFromVariant(thisValue);
|
wxFontData fontData;
|
||||||
|
fontData << thisValue;
|
||||||
wxColour col;
|
wxColour col;
|
||||||
wxVariant variant;
|
wxVariant variant;
|
||||||
|
|
||||||
@@ -155,11 +176,15 @@ void wxFontDataProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxV
|
|||||||
fontData.SetColour( col );
|
fontData.SetColour( col );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Transfer between subset to superset.
|
// Transfer from subset to superset.
|
||||||
variant = WXVARIANT(fontData.GetChosenFont());
|
wxFont font = fontData.GetChosenFont();
|
||||||
|
variant = WXVARIANT(font);
|
||||||
wxFontProperty::ChildChanged( variant, childIndex, childValue );
|
wxFontProperty::ChildChanged( variant, childIndex, childValue );
|
||||||
fontData.SetChosenFont(wxFontFromVariant(variant));
|
font << variant;
|
||||||
|
fontData.SetChosenFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thisValue << fontData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -182,14 +207,14 @@ wxSizeProperty::~wxSizeProperty() { }
|
|||||||
void wxSizeProperty::RefreshChildren()
|
void wxSizeProperty::RefreshChildren()
|
||||||
{
|
{
|
||||||
if ( !GetChildCount() ) return;
|
if ( !GetChildCount() ) return;
|
||||||
const wxSize& size = wxSizeFromVariant(m_value);
|
const wxSize& size = wxSizeRefFromVariant(m_value);
|
||||||
Item(0)->SetValue( (long)size.x );
|
Item(0)->SetValue( (long)size.x );
|
||||||
Item(1)->SetValue( (long)size.y );
|
Item(1)->SetValue( (long)size.y );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSizeProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
void wxSizeProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
||||||
{
|
{
|
||||||
wxSize& size = wxSizeFromVariant(thisValue);
|
wxSize& size = wxSizeRefFromVariant(thisValue);
|
||||||
int val = wxPGVariantToInt(childValue);
|
int val = wxPGVariantToInt(childValue);
|
||||||
switch ( childIndex )
|
switch ( childIndex )
|
||||||
{
|
{
|
||||||
@@ -218,14 +243,14 @@ wxPointProperty::~wxPointProperty() { }
|
|||||||
void wxPointProperty::RefreshChildren()
|
void wxPointProperty::RefreshChildren()
|
||||||
{
|
{
|
||||||
if ( !GetChildCount() ) return;
|
if ( !GetChildCount() ) return;
|
||||||
const wxPoint& point = wxPointFromVariant(m_value);
|
const wxPoint& point = wxPointRefFromVariant(m_value);
|
||||||
Item(0)->SetValue( (long)point.x );
|
Item(0)->SetValue( (long)point.x );
|
||||||
Item(1)->SetValue( (long)point.y );
|
Item(1)->SetValue( (long)point.y );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPointProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
void wxPointProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
|
||||||
{
|
{
|
||||||
wxPoint& point = wxPointFromVariant(thisValue);
|
wxPoint& point = wxPointRefFromVariant(thisValue);
|
||||||
int val = wxPGVariantToInt(childValue);
|
int val = wxPGVariantToInt(childValue);
|
||||||
switch ( childIndex )
|
switch ( childIndex )
|
||||||
{
|
{
|
||||||
@@ -452,7 +477,7 @@ bool operator == (const wxArrayDouble& a, const wxArrayDouble& b)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataArrayDouble, wxArrayDouble)
|
WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(wxArrayDouble)
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxArrayDoubleProperty,
|
WX_PG_IMPLEMENT_PROPERTY_CLASS(wxArrayDoubleProperty,
|
||||||
wxPGProperty,
|
wxPGProperty,
|
||||||
@@ -478,7 +503,7 @@ wxArrayDoubleProperty::wxArrayDoubleProperty (const wxString& label,
|
|||||||
|
|
||||||
m_delimiter = use_delimiter;
|
m_delimiter = use_delimiter;
|
||||||
|
|
||||||
SetValue( wxArrayDoubleToVariant(array) );
|
SetValue( WXVARIANT(array) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayDoubleProperty::~wxArrayDoubleProperty () { }
|
wxArrayDoubleProperty::~wxArrayDoubleProperty () { }
|
||||||
@@ -509,7 +534,7 @@ void wxArrayDoubleProperty::GenerateValueAsString( wxString& target, int prec, b
|
|||||||
|
|
||||||
target.Empty();
|
target.Empty();
|
||||||
|
|
||||||
const wxArrayDouble& value = wxArrayDoubleFromVariant(m_value);
|
const wxArrayDouble& value = wxArrayDoubleRefFromVariant(m_value);
|
||||||
|
|
||||||
for ( i=0; i<value.GetCount(); i++ )
|
for ( i=0; i<value.GetCount(); i++ )
|
||||||
{
|
{
|
||||||
@@ -529,7 +554,7 @@ bool wxArrayDoubleProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
{
|
{
|
||||||
if ( propgrid->IsMainButtonEvent(event) )
|
if ( propgrid->IsMainButtonEvent(event) )
|
||||||
{
|
{
|
||||||
wxArrayDouble& value = wxArrayDoubleFromVariant(m_value);
|
wxArrayDouble& value = wxArrayDoubleRefFromVariant(m_value);
|
||||||
|
|
||||||
// Update the value in case of last minute changes
|
// Update the value in case of last minute changes
|
||||||
PrepareValueForDialogEditing(propgrid);
|
PrepareValueForDialogEditing(propgrid);
|
||||||
@@ -544,7 +569,7 @@ bool wxArrayDoubleProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
int res = dlg.ShowModal();
|
int res = dlg.ShowModal();
|
||||||
if ( res == wxID_OK && dlg.IsModified() )
|
if ( res == wxID_OK && dlg.IsModified() )
|
||||||
{
|
{
|
||||||
SetValueInEvent( wxArrayDoubleToVariant(dlg.GetArray()) );
|
SetValueInEvent( WXVARIANT(dlg.GetArray()) );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -591,9 +616,9 @@ bool wxArrayDoubleProperty::StringToValue( wxVariant& variant, const wxString& t
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !(wxArrayDoubleFromVariant(m_value) == new_array) )
|
if ( !(wxArrayDoubleRefFromVariant(m_value) == new_array) )
|
||||||
{
|
{
|
||||||
variant = wxArrayDoubleToVariant(new_array);
|
variant = WXVARIANT(new_array);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
#define _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
|
#define _WX_SAMPLES_PROPGRID_SAMPLEPROPS_H_
|
||||||
|
|
||||||
|
|
||||||
WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataFontData, wxFontData, wxEMPTY_PARAMETER_VALUE)
|
DECLARE_VARIANT_OBJECT(wxFontData)
|
||||||
|
|
||||||
|
|
||||||
class wxFontDataProperty : public wxFontProperty
|
class wxFontDataProperty : public wxFontProperty
|
||||||
@@ -61,7 +61,7 @@ protected:
|
|||||||
// I stands for internal
|
// I stands for internal
|
||||||
void SetValueI( const wxSize& value )
|
void SetValueI( const wxSize& value )
|
||||||
{
|
{
|
||||||
m_value = wxSizeToVariant(value);
|
m_value = WXVARIANT(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ protected:
|
|||||||
// I stands for internal
|
// I stands for internal
|
||||||
void SetValueI( const wxPoint& value )
|
void SetValueI( const wxPoint& value )
|
||||||
{
|
{
|
||||||
m_value = wxPointToVariant(value);
|
m_value = WXVARIANT(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(wxDirsProperty, clas
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
WX_PG_DECLARE_VARIANT_DATA(wxPGVariantDataArrayDouble, wxArrayDouble, wxEMPTY_PARAMETER_VALUE)
|
WX_PG_DECLARE_VARIANT_DATA(wxArrayDouble)
|
||||||
|
|
||||||
class wxArrayDoubleProperty : public wxPGProperty
|
class wxArrayDoubleProperty : public wxPGProperty
|
||||||
{
|
{
|
||||||
|
@@ -446,7 +446,7 @@ wxFontProperty::wxFontProperty( const wxString& label, const wxString& name,
|
|||||||
const wxFont& value )
|
const wxFont& value )
|
||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
SetValue( wxFontToVariant(value) );
|
SetValue(WXVARIANT(value));
|
||||||
|
|
||||||
// Initialize font family choices list
|
// Initialize font family choices list
|
||||||
if ( !wxPGGlobalVars->m_fontFamilyChoices )
|
if ( !wxPGGlobalVars->m_fontFamilyChoices )
|
||||||
@@ -467,7 +467,8 @@ wxFontProperty::wxFontProperty( const wxString& label, const wxString& name,
|
|||||||
|
|
||||||
wxString emptyString(wxEmptyString);
|
wxString emptyString(wxEmptyString);
|
||||||
|
|
||||||
wxFont& font = wxFontFromVariant(m_value);
|
wxFont font;
|
||||||
|
font << m_value;
|
||||||
|
|
||||||
AddChild( new wxIntProperty( _("Point Size"), wxS("Point Size"),(long)font.GetPointSize() ) );
|
AddChild( new wxIntProperty( _("Point Size"), wxS("Point Size"),(long)font.GetPointSize() ) );
|
||||||
|
|
||||||
@@ -502,16 +503,14 @@ wxFontProperty::~wxFontProperty() { }
|
|||||||
|
|
||||||
void wxFontProperty::OnSetValue()
|
void wxFontProperty::OnSetValue()
|
||||||
{
|
{
|
||||||
wxFont& font = wxFontFromVariant(m_value);
|
wxFont font;
|
||||||
wxASSERT(&font);
|
font << m_value;
|
||||||
|
|
||||||
wxFont font2;
|
|
||||||
if ( !font.Ok() )
|
if ( !font.Ok() )
|
||||||
font2 = wxFont(10,wxSWISS,wxNORMAL,wxNORMAL);
|
{
|
||||||
else
|
font = wxFont(10,wxSWISS,wxNORMAL,wxNORMAL);
|
||||||
font2 = font;
|
m_value << font;
|
||||||
|
}
|
||||||
m_value = wxFontToVariant(font2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFontProperty::GetValueAsString( int argFlags ) const
|
wxString wxFontProperty::GetValueAsString( int argFlags ) const
|
||||||
@@ -528,7 +527,9 @@ bool wxFontProperty::OnEvent( wxPropertyGrid* propgrid, wxWindow* WXUNUSED(prima
|
|||||||
PrepareValueForDialogEditing(propgrid);
|
PrepareValueForDialogEditing(propgrid);
|
||||||
|
|
||||||
wxFontData data;
|
wxFontData data;
|
||||||
data.SetInitialFont( wxFontFromVariant(m_value) );
|
wxFont font;
|
||||||
|
font << m_value;
|
||||||
|
data.SetInitialFont( font );
|
||||||
data.SetColour(*wxBLACK);
|
data.SetColour(*wxBLACK);
|
||||||
|
|
||||||
wxFontDialog dlg(propgrid, data);
|
wxFontDialog dlg(propgrid, data);
|
||||||
@@ -536,7 +537,8 @@ bool wxFontProperty::OnEvent( wxPropertyGrid* propgrid, wxWindow* WXUNUSED(prima
|
|||||||
{
|
{
|
||||||
propgrid->EditorsValueWasModified();
|
propgrid->EditorsValueWasModified();
|
||||||
|
|
||||||
wxVariant variant = wxFontToVariant(dlg.GetFontData().GetChosenFont());
|
wxVariant variant;
|
||||||
|
variant << dlg.GetFontData().GetChosenFont();
|
||||||
SetValueInEvent( variant );
|
SetValueInEvent( variant );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -547,7 +549,8 @@ bool wxFontProperty::OnEvent( wxPropertyGrid* propgrid, wxWindow* WXUNUSED(prima
|
|||||||
void wxFontProperty::RefreshChildren()
|
void wxFontProperty::RefreshChildren()
|
||||||
{
|
{
|
||||||
if ( !GetChildCount() ) return;
|
if ( !GetChildCount() ) return;
|
||||||
const wxFont& font = wxFontFromVariant(m_value);
|
wxFont font;
|
||||||
|
font << m_value;
|
||||||
Item(0)->SetValue( (long)font.GetPointSize() );
|
Item(0)->SetValue( (long)font.GetPointSize() );
|
||||||
Item(1)->SetValue( (long)font.GetFamily() );
|
Item(1)->SetValue( (long)font.GetFamily() );
|
||||||
Item(2)->SetValueFromString( font.GetFaceName(), wxPG_FULL_VALUE );
|
Item(2)->SetValueFromString( font.GetFaceName(), wxPG_FULL_VALUE );
|
||||||
@@ -558,7 +561,8 @@ void wxFontProperty::RefreshChildren()
|
|||||||
|
|
||||||
void wxFontProperty::ChildChanged( wxVariant& thisValue, int ind, wxVariant& childValue ) const
|
void wxFontProperty::ChildChanged( wxVariant& thisValue, int ind, wxVariant& childValue ) const
|
||||||
{
|
{
|
||||||
wxFont& font = wxFontFromVariant(thisValue);
|
wxFont font;
|
||||||
|
font << thisValue;
|
||||||
|
|
||||||
if ( ind == 0 )
|
if ( ind == 0 )
|
||||||
{
|
{
|
||||||
@@ -604,6 +608,8 @@ void wxFontProperty::ChildChanged( wxVariant& thisValue, int ind, wxVariant& chi
|
|||||||
{
|
{
|
||||||
font.SetUnderlined( childValue.GetBool() );
|
font.SetUnderlined( childValue.GetBool() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thisValue << font;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -718,7 +724,7 @@ static long gs_cp_es_syscolour_values[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue, wxColourPropertyValue)
|
IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxColourPropertyValue, WXDLLIMPEXP_PROPGRID)
|
||||||
|
|
||||||
|
|
||||||
// Class body is in advprops.h
|
// Class body is in advprops.h
|
||||||
@@ -738,7 +744,7 @@ void wxSystemColourProperty::Init( int type, const wxColour& colour )
|
|||||||
|
|
||||||
m_flags |= wxPG_PROP_STATIC_CHOICES; // Colour selection cannot be changed.
|
m_flags |= wxPG_PROP_STATIC_CHOICES; // Colour selection cannot be changed.
|
||||||
|
|
||||||
m_value = wxColourPropertyValueToVariant(cpv);
|
m_value << cpv;
|
||||||
|
|
||||||
OnSetValue();
|
OnSetValue();
|
||||||
}
|
}
|
||||||
@@ -797,20 +803,29 @@ wxColourPropertyValue wxSystemColourProperty::GetVal( const wxVariant* pVariant
|
|||||||
if ( pVariant->IsNull() )
|
if ( pVariant->IsNull() )
|
||||||
return wxColourPropertyValue(wxPG_COLOUR_UNSPECIFIED, wxColour());
|
return wxColourPropertyValue(wxPG_COLOUR_UNSPECIFIED, wxColour());
|
||||||
|
|
||||||
wxColourPropertyValue* v1 = &wxColourPropertyValueFromVariant(*pVariant);
|
if ( pVariant->GetType() == wxS("wxColourPropertyValue") )
|
||||||
if ( v1 )
|
{
|
||||||
return *v1;
|
wxColourPropertyValue v;
|
||||||
|
v << *pVariant;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
wxColour* pCol = wxGetVariantCast(*pVariant, wxColour);
|
|
||||||
wxColour col;
|
wxColour col;
|
||||||
bool variantProcessed = true;
|
bool variantProcessed = true;
|
||||||
|
|
||||||
if ( pCol )
|
if ( pVariant->GetType() == wxS("wxColour*") )
|
||||||
{
|
{
|
||||||
|
wxColour* pCol = wxStaticCast(pVariant->GetWxObjectPtr(), wxColour);
|
||||||
col = *pCol;
|
col = *pCol;
|
||||||
}
|
}
|
||||||
else if ( pVariant->GetType() == wxT("wxArrayInt") )
|
else if ( pVariant->GetType() == wxS("wxColour") )
|
||||||
{
|
{
|
||||||
|
col << *pVariant;
|
||||||
|
}
|
||||||
|
else if ( pVariant->GetType() == wxArrayInt_VariantType )
|
||||||
|
{
|
||||||
|
// This code is mostly needed for wxPython bindings, which
|
||||||
|
// may offer tuple of integers as colour value.
|
||||||
wxArrayInt arr;
|
wxArrayInt arr;
|
||||||
arr << *pVariant;
|
arr << *pVariant;
|
||||||
|
|
||||||
@@ -832,10 +847,6 @@ wxColourPropertyValue wxSystemColourProperty::GetVal( const wxVariant* pVariant
|
|||||||
variantProcessed = false;
|
variantProcessed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( pVariant->GetType() == wxT("wxColour") )
|
|
||||||
{
|
|
||||||
col << *pVariant;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
variantProcessed = false;
|
variantProcessed = false;
|
||||||
@@ -855,7 +866,9 @@ wxColourPropertyValue wxSystemColourProperty::GetVal( const wxVariant* pVariant
|
|||||||
|
|
||||||
wxVariant wxSystemColourProperty::DoTranslateVal( wxColourPropertyValue& v ) const
|
wxVariant wxSystemColourProperty::DoTranslateVal( wxColourPropertyValue& v ) const
|
||||||
{
|
{
|
||||||
return wxColourPropertyValueToVariant(v);
|
wxVariant variant;
|
||||||
|
variant << v;
|
||||||
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxSystemColourProperty::ColToInd( const wxColour& colour ) const
|
int wxSystemColourProperty::ColToInd( const wxColour& colour ) const
|
||||||
@@ -889,10 +902,9 @@ static inline wxColour wxColourFromPGLong( long col )
|
|||||||
void wxSystemColourProperty::OnSetValue()
|
void wxSystemColourProperty::OnSetValue()
|
||||||
{
|
{
|
||||||
// Convert from generic wxobject ptr to wxPGVariantDataColour
|
// Convert from generic wxobject ptr to wxPGVariantDataColour
|
||||||
if ( wxPGIsVariantType(m_value, wxobject) )
|
if ( m_value.GetType() == wxS("wxColour*") )
|
||||||
{
|
{
|
||||||
wxASSERT( m_value.IsValueKindOf(CLASSINFO(wxColour)) );
|
wxColour* pCol = wxStaticCast(m_value.GetWxObjectPtr(), wxColour);
|
||||||
wxColour* pCol = (wxColour*) m_value.GetWxObjectPtr();
|
|
||||||
m_value << *pCol;
|
m_value << *pCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,39 +924,46 @@ void wxSystemColourProperty::OnSetValue()
|
|||||||
m_value = TranslateVal(val);
|
m_value = TranslateVal(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColourPropertyValue* pCpv = &wxColourPropertyValueFromVariant(m_value);
|
|
||||||
wxColour col;
|
|
||||||
if ( pCpv )
|
|
||||||
col = pCpv->m_colour;
|
|
||||||
else
|
|
||||||
col << m_value;
|
|
||||||
|
|
||||||
if ( !col.Ok() )
|
|
||||||
{
|
|
||||||
SetValueToUnspecified();
|
|
||||||
SetIndex(wxNOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ind;
|
int ind;
|
||||||
|
|
||||||
if ( pCpv )
|
if ( m_value.GetType() == wxS("wxColourPropertyValue") )
|
||||||
{
|
{
|
||||||
if ( pCpv->m_type < wxPG_COLOUR_WEB_BASE )
|
wxColourPropertyValue cpv;
|
||||||
|
cpv << m_value;
|
||||||
|
wxColour col = cpv.m_colour;
|
||||||
|
|
||||||
|
if ( !col.Ok() )
|
||||||
|
{
|
||||||
|
SetValueToUnspecified();
|
||||||
|
SetIndex(wxNOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( cpv.m_type < wxPG_COLOUR_WEB_BASE )
|
||||||
{
|
{
|
||||||
if ( m_choices.HasValues() )
|
if ( m_choices.HasValues() )
|
||||||
ind = GetIndexForValue(pCpv->m_type);
|
ind = GetIndexForValue(cpv.m_type);
|
||||||
else
|
else
|
||||||
ind = ColToInd(col);
|
ind = ColToInd(col);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pCpv->m_type = wxPG_COLOUR_CUSTOM;
|
cpv.m_type = wxPG_COLOUR_CUSTOM;
|
||||||
ind = GetCustomColourIndex();
|
ind = GetCustomColourIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
wxColour col;
|
||||||
|
col << m_value;
|
||||||
|
|
||||||
|
if ( !col.Ok() )
|
||||||
|
{
|
||||||
|
SetValueToUnspecified();
|
||||||
|
SetIndex(wxNOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ind = ColToInd(col);
|
ind = ColToInd(col);
|
||||||
|
|
||||||
if ( ind == wxNOT_FOUND )
|
if ( ind == wxNOT_FOUND )
|
||||||
@@ -1006,7 +1025,7 @@ int wxSystemColourProperty::GetCustomColourIndex() const
|
|||||||
|
|
||||||
bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const
|
bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const
|
||||||
{
|
{
|
||||||
wxASSERT( m_value.GetType() != wxT("string") );
|
wxASSERT( m_value.GetType() != wxPG_VARIANT_TYPE_STRING );
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
wxPropertyGrid* propgrid = GetGrid();
|
wxPropertyGrid* propgrid = GetGrid();
|
||||||
@@ -1668,7 +1687,7 @@ void wxMultiChoiceProperty::GenerateValueAsString()
|
|||||||
{
|
{
|
||||||
wxArrayString strings;
|
wxArrayString strings;
|
||||||
|
|
||||||
if ( wxPGIsVariantType(m_value, arrstring) )
|
if ( m_value.GetType() == wxPG_VARIANT_TYPE_ARRSTRING )
|
||||||
strings = m_value.GetArrayString();
|
strings = m_value.GetArrayString();
|
||||||
|
|
||||||
wxString& tempStr = m_display;
|
wxString& tempStr = m_display;
|
||||||
@@ -1691,7 +1710,7 @@ void wxMultiChoiceProperty::GenerateValueAsString()
|
|||||||
|
|
||||||
wxArrayInt wxMultiChoiceProperty::GetValueAsIndices() const
|
wxArrayInt wxMultiChoiceProperty::GetValueAsIndices() const
|
||||||
{
|
{
|
||||||
const wxArrayInt& valueArr = wxArrayIntFromVariant(GetValue());
|
const wxArrayInt& valueArr = wxArrayIntRefFromVariant(GetValue());
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
// Translate values to string indices.
|
// Translate values to string indices.
|
||||||
|
@@ -898,7 +898,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
// List variants are reserved a special purpose
|
// List variants are reserved a special purpose
|
||||||
// as intermediate containers for child values
|
// as intermediate containers for child values
|
||||||
// of properties with children.
|
// of properties with children.
|
||||||
if ( wxPGIsVariantType(value, list) )
|
if ( value.GetType() == wxPG_VARIANT_TYPE_LIST )
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// However, situation is different for composed string properties
|
// However, situation is different for composed string properties
|
||||||
@@ -919,7 +919,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
|
|
||||||
if ( pList && !pList->IsNull() )
|
if ( pList && !pList->IsNull() )
|
||||||
{
|
{
|
||||||
wxASSERT( wxPGIsVariantType(*pList, list) );
|
wxASSERT( pList->GetType() == wxPG_VARIANT_TYPE_LIST );
|
||||||
wxASSERT( GetChildCount() );
|
wxASSERT( GetChildCount() );
|
||||||
wxASSERT( !IsCategory() );
|
wxASSERT( !IsCategory() );
|
||||||
|
|
||||||
@@ -938,7 +938,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
if ( child )
|
if ( child )
|
||||||
{
|
{
|
||||||
//wxLogDebug(wxT("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName().c_str(),childValue.GetType().c_str());
|
//wxLogDebug(wxT("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName().c_str(),childValue.GetType().c_str());
|
||||||
if ( wxPGIsVariantType(childValue, list) )
|
if ( childValue.GetType() == wxPG_VARIANT_TYPE_LIST )
|
||||||
{
|
{
|
||||||
if ( child->HasFlag(wxPG_PROP_AGGREGATE) && !(flags & wxPG_SETVAL_AGGREGATED) )
|
if ( child->HasFlag(wxPG_PROP_AGGREGATE) && !(flags & wxPG_SETVAL_AGGREGATED) )
|
||||||
{
|
{
|
||||||
@@ -951,7 +951,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
child->SetValue(oldVal, &childValue, flags|wxPG_SETVAL_FROM_PARENT);
|
child->SetValue(oldVal, &childValue, flags|wxPG_SETVAL_FROM_PARENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !wxPG_VARIANT_EQ(child->GetValue(), childValue) )
|
else if ( child->GetValue() != childValue )
|
||||||
{
|
{
|
||||||
// For aggregate properties, we will trust RefreshChildren()
|
// For aggregate properties, we will trust RefreshChildren()
|
||||||
// to update child values.
|
// to update child values.
|
||||||
@@ -967,7 +967,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
|
|||||||
|
|
||||||
if ( !value.IsNull() )
|
if ( !value.IsNull() )
|
||||||
{
|
{
|
||||||
wxPGVariantAssign(m_value, value);
|
m_value = value;
|
||||||
OnSetValue();
|
OnSetValue();
|
||||||
|
|
||||||
if ( !(flags & wxPG_SETVAL_FROM_PARENT) )
|
if ( !(flags & wxPG_SETVAL_FROM_PARENT) )
|
||||||
@@ -1053,34 +1053,34 @@ wxVariant wxPGProperty::GetDefaultValue() const
|
|||||||
|
|
||||||
if ( !value.IsNull() )
|
if ( !value.IsNull() )
|
||||||
{
|
{
|
||||||
wxPGVariantDataClassInfo classInfo = wxPGVariantDataGetClassInfo(value.GetData());
|
wxString valueType(value.GetType());
|
||||||
if ( wxPGIsVariantClassInfo(classInfo, long) )
|
|
||||||
|
if ( valueType == wxPG_VARIANT_TYPE_LONG )
|
||||||
return wxPGVariant_Zero;
|
return wxPGVariant_Zero;
|
||||||
if ( wxPGIsVariantClassInfo(classInfo, string) )
|
if ( valueType == wxPG_VARIANT_TYPE_STRING )
|
||||||
return wxPGVariant_EmptyString;
|
return wxPGVariant_EmptyString;
|
||||||
if ( wxPGIsVariantClassInfo(classInfo, bool) )
|
if ( valueType == wxPG_VARIANT_TYPE_BOOL )
|
||||||
return wxPGVariant_False;
|
return wxPGVariant_False;
|
||||||
if ( wxPGIsVariantClassInfo(classInfo, double) )
|
if ( valueType == wxPG_VARIANT_TYPE_DOUBLE )
|
||||||
return wxVariant(0.0);
|
return wxVariant(0.0);
|
||||||
|
if ( valueType == wxPG_VARIANT_TYPE_ARRSTRING )
|
||||||
wxPGVariantData* pgvdata = wxDynamicCastVariantData(m_value.GetData(), wxPGVariantData);
|
|
||||||
if ( pgvdata )
|
|
||||||
return pgvdata->GetDefaultValue();
|
|
||||||
|
|
||||||
if ( wxPGIsVariantClassInfo(classInfo, arrstring) )
|
|
||||||
return wxVariant(wxArrayString());
|
return wxVariant(wxArrayString());
|
||||||
if ( wxPGIsVariantClassInfo(classInfo, wxColour) )
|
if ( valueType == wxS("wxLongLong") )
|
||||||
return WXVARIANT(*wxRED);
|
return WXVARIANT(wxLongLong(0));
|
||||||
|
if ( valueType == wxS("wxULongLong") )
|
||||||
|
return WXVARIANT(wxULongLong(0));
|
||||||
|
if ( valueType == wxS("wxColour") )
|
||||||
|
return WXVARIANT(*wxBLACK);
|
||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
if ( wxPGIsVariantClassInfo(classInfo, datetime) )
|
if ( valueType == wxPG_VARIANT_TYPE_DATETIME )
|
||||||
return wxVariant(wxDateTime::Now());
|
return wxVariant(wxDateTime::Now());
|
||||||
#endif
|
#endif
|
||||||
|
if ( valueType == wxS("wxFont") )
|
||||||
wxFAIL_MSG(
|
return WXVARIANT(*wxNORMAL_FONT);
|
||||||
wxString::Format(wxT("Inorder for value to have default value, it must be added to")
|
if ( valueType == wxS("wxPoint") )
|
||||||
wxT("wxPGProperty::GetDefaultValue or it's variantdata must inherit")
|
return WXVARIANT(wxPoint(0, 0));
|
||||||
wxT("from wxPGVariantData (unrecognized type was '%s')"),m_value.GetType().c_str())
|
if ( valueType == wxS("wxSize") )
|
||||||
);
|
return WXVARIANT(wxSize(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxVariant();
|
return wxVariant();
|
||||||
@@ -1672,7 +1672,7 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const
|
|||||||
{
|
{
|
||||||
//wxLogDebug(wxT(" %s(n=%i), %s"),childValue.GetName().c_str(),n,childValue.GetType().c_str());
|
//wxLogDebug(wxT(" %s(n=%i), %s"),childValue.GetName().c_str(),n,childValue.GetType().c_str());
|
||||||
|
|
||||||
if ( wxPGIsVariantType(childValue, list) )
|
if ( childValue.GetType() == wxPG_VARIANT_TYPE_LIST )
|
||||||
{
|
{
|
||||||
wxVariant cv2(child->GetValue());
|
wxVariant cv2(child->GetValue());
|
||||||
child->AdaptListToValue(childValue, &cv2);
|
child->AdaptListToValue(childValue, &cv2);
|
||||||
@@ -1916,7 +1916,7 @@ bool wxPGProperty::AreAllChildrenSpecified( wxVariant* pendingList ) const
|
|||||||
{
|
{
|
||||||
const wxVariant* childList = NULL;
|
const wxVariant* childList = NULL;
|
||||||
|
|
||||||
if ( listValue && wxPGIsVariantType(*listValue, list) )
|
if ( listValue && listValue->GetType() == wxPG_VARIANT_TYPE_LIST )
|
||||||
childList = listValue;
|
childList = listValue;
|
||||||
|
|
||||||
if ( !child->AreAllChildrenSpecified((wxVariant*)childList) )
|
if ( !child->AreAllChildrenSpecified((wxVariant*)childList) )
|
||||||
|
@@ -199,37 +199,6 @@ wxPGGlobalVarsClass::wxPGGlobalVarsClass()
|
|||||||
|
|
||||||
wxVariant v;
|
wxVariant v;
|
||||||
|
|
||||||
v = (long)0;
|
|
||||||
wxVariantClassInfo_long = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
|
|
||||||
v = wxString();
|
|
||||||
wxVariantClassInfo_string = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
|
|
||||||
v = (double)0.0;
|
|
||||||
wxVariantClassInfo_double = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
|
|
||||||
v = (bool)false;
|
|
||||||
wxVariantClassInfo_bool = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
|
|
||||||
v = wxArrayString();
|
|
||||||
wxVariantClassInfo_arrstring = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
|
|
||||||
wxColour col;
|
|
||||||
wxVariant v2((wxObject*)&col);
|
|
||||||
wxVariantClassInfo_wxobject = wxPGVariantDataGetClassInfo(v2.GetData());
|
|
||||||
|
|
||||||
wxVariantList list;
|
|
||||||
v = wxVariant(list);
|
|
||||||
wxVariantClassInfo_list = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
|
|
||||||
v << *wxRED;
|
|
||||||
wxVariantClassInfo_wxColour = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
|
|
||||||
#if wxUSE_DATETIME
|
|
||||||
v = wxVariant(wxDateTime::Now());
|
|
||||||
wxVariantClassInfo_datetime = wxPGVariantDataGetClassInfo(v.GetData());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Prepare some shared variants
|
// Prepare some shared variants
|
||||||
m_vEmptyString = wxString();
|
m_vEmptyString = wxString();
|
||||||
m_vZero = (long) 0;
|
m_vZero = (long) 0;
|
||||||
@@ -238,6 +207,10 @@ wxPGGlobalVarsClass::wxPGGlobalVarsClass()
|
|||||||
m_vFalse = false;
|
m_vFalse = false;
|
||||||
|
|
||||||
// Prepare cached string constants
|
// Prepare cached string constants
|
||||||
|
m_strstring = wxS("string");
|
||||||
|
m_strlong = wxS("long");
|
||||||
|
m_strbool = wxS("bool");
|
||||||
|
m_strlist = wxS("list");
|
||||||
m_strMin = wxS("Min");
|
m_strMin = wxS("Min");
|
||||||
m_strMax = wxS("Max");
|
m_strMax = wxS("Max");
|
||||||
m_strUnits = wxS("Units");
|
m_strUnits = wxS("Units");
|
||||||
@@ -2826,7 +2799,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
|
|||||||
|
|
||||||
m_validationInfo.m_failureBehavior = m_permanentValidationFailureBehavior;
|
m_validationInfo.m_failureBehavior = m_permanentValidationFailureBehavior;
|
||||||
|
|
||||||
if ( !wxPGIsVariantType(pendingValue, list) )
|
if ( pendingValue.GetType() == wxPG_VARIANT_TYPE_LIST )
|
||||||
{
|
{
|
||||||
if ( !p->ValidateValue(pendingValue, m_validationInfo) )
|
if ( !p->ValidateValue(pendingValue, m_validationInfo) )
|
||||||
return false;
|
return false;
|
||||||
@@ -2873,7 +2846,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
|
|||||||
wxVariant value;
|
wxVariant value;
|
||||||
wxPGProperty* evtChangingProperty = changedProperty;
|
wxPGProperty* evtChangingProperty = changedProperty;
|
||||||
|
|
||||||
if ( !wxPGIsVariantType(*pPendingValue, list) )
|
if ( pPendingValue->GetType() != wxPG_VARIANT_TYPE_LIST )
|
||||||
{
|
{
|
||||||
value = *pPendingValue;
|
value = *pPendingValue;
|
||||||
}
|
}
|
||||||
@@ -2928,7 +2901,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue
|
|||||||
|
|
||||||
// If changedProperty is not property which value was edited,
|
// If changedProperty is not property which value was edited,
|
||||||
// then call wxPGProperty::ValidateValue() for that as well.
|
// then call wxPGProperty::ValidateValue() for that as well.
|
||||||
if ( p != changedProperty && !wxPGIsVariantType(value, list) )
|
if ( p != changedProperty && value.GetType() != wxPG_VARIANT_TYPE_LIST )
|
||||||
{
|
{
|
||||||
if ( !changedProperty->ValidateValue(value, m_validationInfo) )
|
if ( !changedProperty->ValidateValue(value, m_validationInfo) )
|
||||||
return false;
|
return false;
|
||||||
|
@@ -65,30 +65,13 @@ const wxChar *wxPGTypeName_wxArrayString = wxT("arrstring");
|
|||||||
// VariantDatas
|
// VariantDatas
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataPoint, wxPoint)
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(wxPoint, WXDLLIMPEXP_PROPGRID)
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataSize, wxSize)
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(wxSize, WXDLLIMPEXP_PROPGRID)
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataArrayInt, wxArrayInt)
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED_DUMMY_EQ(wxArrayInt, WXDLLIMPEXP_PROPGRID)
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataLongLong, wxLongLong)
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(wxLongLong, WXDLLIMPEXP_PROPGRID)
|
||||||
WX_PG_IMPLEMENT_VARIANT_DATA(wxPGVariantDataULongLong, wxULongLong)
|
WX_PG_IMPLEMENT_VARIANT_DATA_EXPORTED(wxULongLong, WXDLLIMPEXP_PROPGRID)
|
||||||
|
|
||||||
WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(wxPGVariantDataFont, wxFont)
|
IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxFont, WXDLLIMPEXP_PROPGRID)
|
||||||
|
|
||||||
wxObject* wxPG_VariantToWxObject( const wxVariant& variant, wxClassInfo* classInfo )
|
|
||||||
{
|
|
||||||
if ( !variant.IsValueKindOf(classInfo) )
|
|
||||||
return (wxObject*) NULL;
|
|
||||||
|
|
||||||
wxVariantData* vdata = variant.GetData();
|
|
||||||
|
|
||||||
wxPGVariantData* pgvdata = wxDynamicCastVariantData(vdata, wxPGVariantData);
|
|
||||||
if ( pgvdata )
|
|
||||||
return (wxObject*) pgvdata->GetValuePtr();
|
|
||||||
|
|
||||||
if ( wxPGIsVariantClassInfo(wxPGVariantDataGetClassInfo(vdata), wxobject) )
|
|
||||||
return variant.GetWxObjectPtr();
|
|
||||||
|
|
||||||
return (wxObject*) NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxVariant helpers
|
// wxVariant helpers
|
||||||
@@ -99,15 +82,16 @@ long wxPGVariantToInt( const wxVariant& variant, long defVal )
|
|||||||
if ( variant.IsNull() )
|
if ( variant.IsNull() )
|
||||||
return defVal;
|
return defVal;
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, long) )
|
if ( variant.GetType() == wxS("long") )
|
||||||
return variant.GetLong();
|
return variant.GetLong();
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, bool) )
|
if ( variant.GetType() == wxS("bool") )
|
||||||
return variant.GetBool() ? 1 : 0;
|
return variant.GetBool() ? 1 : 0;
|
||||||
|
|
||||||
if ( typeid(*variant.GetData()) == typeid(wxPGVariantDataLongLong) )
|
if ( variant.GetType() == wxS("wxLongLong") )
|
||||||
{
|
{
|
||||||
wxLongLong ll = ((const wxPGVariantDataLongLong&)variant).GetValue();
|
wxLongLong ll;
|
||||||
|
ll << variant;
|
||||||
if ( ll >= LONG_MAX )
|
if ( ll >= LONG_MAX )
|
||||||
return LONG_MAX;
|
return LONG_MAX;
|
||||||
else if ( ll <= LONG_MIN )
|
else if ( ll <= LONG_MIN )
|
||||||
@@ -117,7 +101,7 @@ long wxPGVariantToInt( const wxVariant& variant, long defVal )
|
|||||||
|
|
||||||
long l = defVal;
|
long l = defVal;
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, string) )
|
if ( variant.GetType() == wxPG_VARIANT_TYPE_STRING )
|
||||||
variant.GetString().ToLong(&l, 0);
|
variant.GetString().ToLong(&l, 0);
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
@@ -130,15 +114,19 @@ bool wxPGVariantToLongLong( const wxVariant& variant, wxLongLong_t* pResult )
|
|||||||
if ( variant.IsNull() )
|
if ( variant.IsNull() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, long) )
|
wxString variantType = variant.GetType();
|
||||||
|
|
||||||
|
if ( variantType == wxPG_VARIANT_TYPE_LONG )
|
||||||
{
|
{
|
||||||
*pResult = variant.GetLong();
|
*pResult = variant.GetLong();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeid(*variant.GetData()) == typeid(wxPGVariantDataLongLong) )
|
if ( variantType == wxLongLong_VariantType )
|
||||||
{
|
{
|
||||||
*pResult = ((const wxPGVariantDataLongLong&)variant).GetValue().GetValue();
|
wxLongLong ll;
|
||||||
|
ll << variant;
|
||||||
|
*pResult = ll.GetValue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,15 +140,19 @@ bool wxPGVariantToULongLong( const wxVariant& variant, wxULongLong_t* pResult )
|
|||||||
if ( variant.IsNull() )
|
if ( variant.IsNull() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, long) )
|
wxString variantType = variant.GetType();
|
||||||
|
|
||||||
|
if ( variantType == wxPG_VARIANT_TYPE_LONG )
|
||||||
{
|
{
|
||||||
*pResult = (unsigned long)variant.GetLong();
|
*pResult = (unsigned long)variant.GetLong();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeid(*variant.GetData()) == typeid(wxPGVariantDataULongLong) )
|
if ( variantType == wxULongLong_VariantType )
|
||||||
{
|
{
|
||||||
*pResult = ((const wxPGVariantDataULongLong&)variant).GetValue().GetValue();
|
wxULongLong ull;
|
||||||
|
ull << variant;
|
||||||
|
*pResult = ull.GetValue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,26 +166,29 @@ bool wxPGVariantToDouble( const wxVariant& variant, double* pResult )
|
|||||||
if ( variant.IsNull() )
|
if ( variant.IsNull() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, double) )
|
wxString variantType = variant.GetType();
|
||||||
|
|
||||||
|
if ( variantType == wxPG_VARIANT_TYPE_DOUBLE )
|
||||||
{
|
{
|
||||||
*pResult = variant.GetDouble();
|
*pResult = variant.GetDouble();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, long) )
|
if ( variantType == wxPG_VARIANT_TYPE_LONG )
|
||||||
{
|
{
|
||||||
*pResult = (double)variant.GetLong();
|
*pResult = (double)variant.GetLong();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeid(*variant.GetData()) == typeid(wxPGVariantDataLongLong) )
|
if ( variantType == wxLongLong_VariantType )
|
||||||
{
|
{
|
||||||
wxLongLong ll = ((const wxPGVariantDataLongLong&)variant).GetValue();
|
wxLongLong ll;
|
||||||
|
ll << variant;
|
||||||
*pResult = ll.ToDouble();
|
*pResult = ll.ToDouble();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( wxPGIsVariantType(variant, string) )
|
if ( variantType == wxPG_VARIANT_TYPE_STRING )
|
||||||
if ( variant.GetString().ToDouble(pResult) )
|
if ( variant.GetString().ToDouble(pResult) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -487,19 +482,20 @@ void wxPropertyGridInterface::SetPropertyValueUnspecified( wxPGPropArg id )
|
|||||||
// wxPropertyGridInterface property value setting and getting
|
// wxPropertyGridInterface property value setting and getting
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxPGGetFailed( const wxPGProperty* p, const wxChar* typestr )
|
void wxPGGetFailed( const wxPGProperty* p, const wxString& typestr )
|
||||||
{
|
{
|
||||||
wxPGTypeOperationFailed(p,typestr,wxT("Get"));
|
wxPGTypeOperationFailed(p, typestr, wxS("Get"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxPGTypeOperationFailed( const wxPGProperty* p, const wxChar* typestr,
|
void wxPGTypeOperationFailed( const wxPGProperty* p,
|
||||||
const wxChar* op )
|
const wxString& typestr,
|
||||||
|
const wxString& op )
|
||||||
{
|
{
|
||||||
wxASSERT( p != NULL );
|
wxASSERT( p != NULL );
|
||||||
wxLogError( _("Type operation \"%s\" failed: Property labeled \"%s\" is of type \"%s\", NOT \"%s\"."),
|
wxLogError( _("Type operation \"%s\" failed: Property labeled \"%s\" is of type \"%s\", NOT \"%s\"."),
|
||||||
op,p->GetLabel().c_str(),p->GetValue().GetType().c_str(),typestr );
|
op.c_str(), p->GetLabel().c_str(), p->GetValue().GetType().c_str(), typestr.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -834,29 +830,6 @@ IMPLEMENT_GET_VALUE(long,long,Long,0)
|
|||||||
IMPLEMENT_GET_VALUE(double,double,Double,0.0)
|
IMPLEMENT_GET_VALUE(double,double,Double,0.0)
|
||||||
IMPLEMENT_GET_VALUE(void,void*,VoidPtr,NULL)
|
IMPLEMENT_GET_VALUE(void,void*,VoidPtr,NULL)
|
||||||
|
|
||||||
// wxObject is different than others.
|
|
||||||
wxObject* wxPropertyGridInterface::GetPropertyValueAsWxObjectPtr( wxPGPropArg id ) const
|
|
||||||
{
|
|
||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL((wxObject*)NULL)
|
|
||||||
|
|
||||||
wxVariant value = p->GetValue();
|
|
||||||
wxVariantData* vdata = value.GetData();
|
|
||||||
|
|
||||||
if ( !vdata->GetValueClassInfo() )
|
|
||||||
return (wxObject*) NULL;
|
|
||||||
|
|
||||||
wxPGVariantData* pgvdata = wxDynamicCastVariantData(vdata, wxPGVariantData);
|
|
||||||
if ( pgvdata )
|
|
||||||
return (wxObject*) pgvdata->GetValuePtr();
|
|
||||||
|
|
||||||
if ( wxPGIsVariantClassInfo(wxPGVariantDataGetClassInfo(vdata), wxobject) )
|
|
||||||
return (wxObject*) value.GetWxObjectPtr();
|
|
||||||
|
|
||||||
return (wxObject*) NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool wxPropertyGridInterface::IsPropertyExpanded( wxPGPropArg id ) const
|
bool wxPropertyGridInterface::IsPropertyExpanded( wxPGPropArg id ) const
|
||||||
{
|
{
|
||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
|
||||||
|
@@ -1449,7 +1449,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
|
|||||||
wxPGProperty* foundProp = BaseGetPropertyByName(propName);
|
wxPGProperty* foundProp = BaseGetPropertyByName(propName);
|
||||||
if ( foundProp )
|
if ( foundProp )
|
||||||
{
|
{
|
||||||
wxASSERT( wxPGIsVariantType(*current, list) );
|
wxASSERT( current->GetType() == wxPG_VARIANT_TYPE_LIST );
|
||||||
|
|
||||||
wxVariantList& list2 = current->GetList();
|
wxVariantList& list2 = current->GetList();
|
||||||
wxVariantList::const_iterator node2;
|
wxVariantList::const_iterator node2;
|
||||||
|
@@ -150,21 +150,25 @@ wxIntProperty::wxIntProperty( const wxString& label, const wxString& name,
|
|||||||
wxIntProperty::wxIntProperty( const wxString& label, const wxString& name,
|
wxIntProperty::wxIntProperty( const wxString& label, const wxString& name,
|
||||||
const wxLongLong& value ) : wxPGProperty(label,name)
|
const wxLongLong& value ) : wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
SetValue(wxLongLongToVariant(value));
|
SetValue(WXVARIANT(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIntProperty::~wxIntProperty() { }
|
wxIntProperty::~wxIntProperty() { }
|
||||||
|
|
||||||
wxString wxIntProperty::GetValueAsString( int ) const
|
wxString wxIntProperty::GetValueAsString( int ) const
|
||||||
{
|
{
|
||||||
if ( wxPGIsVariantType(m_value, long) )
|
if ( m_value.GetType() == wxPG_VARIANT_TYPE_LONG )
|
||||||
|
{
|
||||||
return wxString::Format(wxS("%li"),m_value.GetLong());
|
return wxString::Format(wxS("%li"),m_value.GetLong());
|
||||||
|
}
|
||||||
|
else if ( m_value.GetType() == wxLongLong_VariantType )
|
||||||
|
{
|
||||||
|
wxLongLong ll;
|
||||||
|
ll << m_value;
|
||||||
|
return ll.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
wxLongLong* ll = &wxLongLongFromVariant(m_value);
|
return wxEmptyString;
|
||||||
if ( ll )
|
|
||||||
return ll->ToString();
|
|
||||||
|
|
||||||
return wxEmptyString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int argFlags ) const
|
bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int argFlags ) const
|
||||||
@@ -198,7 +202,8 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
|||||||
|
|
||||||
wxString useText = text.substr(firstNonZeroPos, text.length() - firstNonZeroPos);
|
wxString useText = text.substr(firstNonZeroPos, text.length() - firstNonZeroPos);
|
||||||
|
|
||||||
bool isPrevLong = wxPGIsVariantType(variant, long);
|
wxString variantType = variant.GetType();
|
||||||
|
bool isPrevLong = variantType == wxPG_VARIANT_TYPE_LONG;
|
||||||
|
|
||||||
wxLongLong_t value64 = 0;
|
wxLongLong_t value64 = 0;
|
||||||
|
|
||||||
@@ -206,10 +211,20 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
|||||||
( value64 >= INT_MAX || value64 <= INT_MIN )
|
( value64 >= INT_MAX || value64 <= INT_MIN )
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
wxLongLong* _m_value64 = &wxLongLongFromVariant(m_value);
|
bool doChangeValue = isPrevLong;
|
||||||
if ( isPrevLong || !_m_value64 || _m_value64->GetValue() != value64 )
|
|
||||||
|
if ( !isPrevLong && variantType == wxLongLong_VariantType )
|
||||||
{
|
{
|
||||||
variant = wxLongLongToVariant(value64);
|
wxLongLong oldValue;
|
||||||
|
oldValue << variant;
|
||||||
|
if ( oldValue.GetValue() != value64 )
|
||||||
|
doChangeValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( doChangeValue )
|
||||||
|
{
|
||||||
|
wxLongLong ll(value64);
|
||||||
|
variant << ll;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +246,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int
|
|||||||
|
|
||||||
bool wxIntProperty::IntToValue( wxVariant& variant, int value, int WXUNUSED(argFlags) ) const
|
bool wxIntProperty::IntToValue( wxVariant& variant, int value, int WXUNUSED(argFlags) ) const
|
||||||
{
|
{
|
||||||
if ( !wxPGIsVariantType(variant, long) || variant.GetLong() != value )
|
if ( variant.GetType() != wxPG_VARIANT_TYPE_LONG || variant.GetLong() != value )
|
||||||
{
|
{
|
||||||
variant = (long)value;
|
variant = (long)value;
|
||||||
return true;
|
return true;
|
||||||
@@ -365,7 +380,7 @@ wxUIntProperty::wxUIntProperty( const wxString& label, const wxString& name,
|
|||||||
const wxULongLong& value ) : wxPGProperty(label,name)
|
const wxULongLong& value ) : wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
SetValue(wxULongLongToVariant(value));
|
SetValue(WXVARIANT(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUIntProperty::~wxUIntProperty() { }
|
wxUIntProperty::~wxUIntProperty() { }
|
||||||
@@ -376,16 +391,21 @@ wxString wxUIntProperty::GetValueAsString( int ) const
|
|||||||
if ( index >= wxPG_UINT_TEMPLATE_MAX )
|
if ( index >= wxPG_UINT_TEMPLATE_MAX )
|
||||||
index = wxPG_BASE_DEC;
|
index = wxPG_BASE_DEC;
|
||||||
|
|
||||||
if ( wxPGIsVariantType(m_value, long) )
|
if ( m_value.GetType() == wxPG_VARIANT_TYPE_LONG )
|
||||||
return wxString::Format(gs_uintTemplates32[index],(unsigned long)m_value.GetLong());
|
{
|
||||||
else
|
return wxString::Format(gs_uintTemplates32[index], (unsigned long)m_value.GetLong());
|
||||||
return wxString::Format(gs_uintTemplates64[index],wxULongLongFromVariant(m_value).GetValue());
|
}
|
||||||
|
|
||||||
|
wxULongLong ull;
|
||||||
|
ull << m_value;
|
||||||
|
|
||||||
|
return wxString::Format(gs_uintTemplates64[index], ull.GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, int WXUNUSED(argFlags) ) const
|
bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, int WXUNUSED(argFlags) ) const
|
||||||
{
|
{
|
||||||
//long unsigned value32 = 0;
|
wxString variantType = variant.GetType();
|
||||||
bool isPrevLong = wxPGIsVariantType(variant, long);
|
bool isPrevLong = variantType == wxPG_VARIANT_TYPE_LONG;
|
||||||
|
|
||||||
if ( text.length() == 0 )
|
if ( text.length() == 0 )
|
||||||
{
|
{
|
||||||
@@ -404,10 +424,20 @@ bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, in
|
|||||||
{
|
{
|
||||||
if ( value64 >= LONG_MAX )
|
if ( value64 >= LONG_MAX )
|
||||||
{
|
{
|
||||||
wxULongLong* _m_value64 = &wxULongLongFromVariant(m_value);
|
bool doChangeValue = isPrevLong;
|
||||||
if ( isPrevLong || !_m_value64 || _m_value64->GetValue() != value64 )
|
|
||||||
|
if ( !isPrevLong && variantType == wxULongLong_VariantType )
|
||||||
{
|
{
|
||||||
variant = wxULongLongToVariant(value64);
|
wxULongLong oldValue;
|
||||||
|
oldValue << variant;
|
||||||
|
if ( oldValue.GetValue() != value64 )
|
||||||
|
doChangeValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( doChangeValue )
|
||||||
|
{
|
||||||
|
wxULongLong ull(value64);
|
||||||
|
variant << ull;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -857,9 +887,11 @@ int wxBaseEnumProperty::GetIndexForValue( int value ) const
|
|||||||
|
|
||||||
void wxBaseEnumProperty::OnSetValue()
|
void wxBaseEnumProperty::OnSetValue()
|
||||||
{
|
{
|
||||||
if ( wxPGIsVariantType(m_value, long) )
|
wxString variantType = m_value.GetType();
|
||||||
|
|
||||||
|
if ( variantType == wxPG_VARIANT_TYPE_LONG )
|
||||||
ValueFromInt_( m_value, m_value.GetLong(), wxPG_FULL_VALUE );
|
ValueFromInt_( m_value, m_value.GetLong(), wxPG_FULL_VALUE );
|
||||||
else if ( wxPGIsVariantType(m_value, string) )
|
else if ( variantType == wxPG_VARIANT_TYPE_STRING )
|
||||||
ValueFromString_( m_value, m_value.GetString(), 0 );
|
ValueFromString_( m_value, m_value.GetString(), 0 );
|
||||||
else
|
else
|
||||||
wxASSERT( false );
|
wxASSERT( false );
|
||||||
@@ -876,7 +908,7 @@ bool wxBaseEnumProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& WX
|
|||||||
// Make sure string value is in the list,
|
// Make sure string value is in the list,
|
||||||
// unless property has string as preferred value type
|
// unless property has string as preferred value type
|
||||||
// To reduce code size, use conversion here as well
|
// To reduce code size, use conversion here as well
|
||||||
if ( wxPGIsVariantType(value, string) &&
|
if ( value.GetType() == wxPG_VARIANT_TYPE_STRING &&
|
||||||
!this->IsKindOf(CLASSINFO(wxEditEnumProperty)) )
|
!this->IsKindOf(CLASSINFO(wxEditEnumProperty)) )
|
||||||
return ValueFromString_( value, value.GetString(), wxPG_PROPERTY_SPECIFIC );
|
return ValueFromString_( value, value.GetString(), wxPG_PROPERTY_SPECIFIC );
|
||||||
|
|
||||||
@@ -885,7 +917,7 @@ bool wxBaseEnumProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& WX
|
|||||||
|
|
||||||
wxString wxBaseEnumProperty::GetValueAsString( int ) const
|
wxString wxBaseEnumProperty::GetValueAsString( int ) const
|
||||||
{
|
{
|
||||||
if ( wxPGIsVariantType(m_value, string) )
|
if ( m_value.GetType() == wxPG_VARIANT_TYPE_STRING )
|
||||||
return m_value.GetString();
|
return m_value.GetString();
|
||||||
|
|
||||||
if ( m_index >= 0 )
|
if ( m_index >= 0 )
|
||||||
@@ -938,7 +970,7 @@ bool wxBaseEnumProperty::ValueFromString_( wxVariant& value, const wxString& tex
|
|||||||
// If text not any of the choices, store as text instead
|
// If text not any of the choices, store as text instead
|
||||||
// (but only if we are wxEditEnumProperty)
|
// (but only if we are wxEditEnumProperty)
|
||||||
if ( useIndex == -1 &&
|
if ( useIndex == -1 &&
|
||||||
(!wxPGIsVariantType(m_value, string) || (m_value.GetString() != text)) &&
|
(value.GetType() != wxPG_VARIANT_TYPE_STRING || (m_value.GetString() != text)) &&
|
||||||
isEdit )
|
isEdit )
|
||||||
{
|
{
|
||||||
asText = true;
|
asText = true;
|
||||||
|
Reference in New Issue
Block a user