X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e1d3601acaecd1c69c453b60610ba98f619bd383..8e77fd8bca165aab9709649d79a7cbc6a172d4e1:/include/wx/xtiprop.h?ds=inline diff --git a/include/wx/xtiprop.h b/include/wx/xtiprop.h index abd3584ead..a79364c9e7 100644 --- a/include/wx/xtiprop.h +++ b/include/wx/xtiprop.h @@ -17,18 +17,16 @@ #if wxUSE_EXTENDED_RTTI -#include "wx/string.h" -#include "wx/variant.h" -#include "wx/intl.h" -#include "wx/log.h" -#include "wx/xtitypes.h" +#include "wx/xti.h" +#include "wx/any.h" +/* class WXDLLIMPEXP_BASE wxObject; class WXDLLIMPEXP_BASE wxClassInfo; class WXDLLIMPEXP_BASE wxDynamicClassInfo; +*/ class WXDLLIMPEXP_BASE wxHashTable; class WXDLLIMPEXP_BASE wxHashTable_Node; -class WXDLLIMPEXP_BASE wxObjectRefData; class WXDLLIMPEXP_BASE wxEvent; class WXDLLIMPEXP_BASE wxEvtHandler; @@ -46,7 +44,7 @@ public: wxPropertySetter( const wxString name ) { m_name = name; } virtual ~wxPropertySetter() {} - virtual void Set( wxObject *object, const wxVariantBase &variantValue ) const = 0; + virtual void Set( wxObject *object, const wxAny &variantValue ) const = 0; const wxString& GetName() const { return m_name; } private: @@ -59,7 +57,7 @@ public: wxPropertyGetter( const wxString name ) { m_name = name; } virtual ~wxPropertyGetter() {} - virtual void Get( const wxObject *object, wxVariantBase& result) const = 0; + virtual void Get( const wxObject *object, wxAny& result) const = 0; const wxString& GetName() const { return m_name; } private: @@ -72,7 +70,7 @@ public: wxPropertyCollectionGetter( const wxString name ) { m_name = name; } virtual ~wxPropertyCollectionGetter() {} - virtual void Get( const wxObject *object, wxVariantBaseArray& result) const = 0; + virtual void Get( const wxObject *object, wxAnyList& result) const = 0; const wxString& GetName() const { return m_name; } private: @@ -80,7 +78,7 @@ private: }; template void WXDLLIMPEXP_BASE \ - wxCollectionToVariantArray( const coll_t& coll, wxVariantBaseArray& result ); + wxCollectionToVariantArray( const coll_t& coll, wxAnyList& result ); class WXDLLIMPEXP_BASE wxPropertyCollectionAdder { @@ -88,29 +86,30 @@ public: wxPropertyCollectionAdder( const wxString name ) { m_name = name; } virtual ~wxPropertyCollectionAdder() {} - virtual void Add( wxObject *object, const wxVariantBase &variantValue ) const= 0; + virtual void Add( wxObject *object, const wxAny &variantValue ) const= 0; const wxString& GetName() const { return m_name; } private: wxString m_name; }; -#define wxPROPERTY_SETTER( property, Klass, valueType, setterMethod ) \ -class wxPropertySetter##property : public wxPropertySetter \ +#define wxPROPERTY_SETTER( property, Klass, valueType, setterMethod ) \ +class wxPropertySetter##property : public wxPropertySetter \ { \ public: \ wxINFUNC_CLASS_TYPE_FIX(Klass) \ wxPropertySetter##property() : wxPropertySetter( wxT(#setterMethod) ) {} \ - virtual ~wxPropertySetter##property() {} \ + virtual ~wxPropertySetter##property() {} \ \ - void Set( wxObject *object, const wxVariantBase &variantValue ) const \ + void Set( wxObject *object, const wxAny &variantValue ) const \ { \ - Klass *obj = dynamic_cast(object); \ - if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \ - obj->setterMethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType)); \ - else \ - obj->setterMethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType*)); \ - } \ + Klass *obj = dynamic_cast(object); \ + valueType tempobj; \ + if ( variantValue.GetAs(&tempobj) ) \ + obj->setterMethod(tempobj); \ + else \ + obj->setterMethod(*wxANY_AS(variantValue, valueType*)); \ + } \ }; #define wxPROPERTY_GETTER( property, Klass, valueType, gettermethod ) \ @@ -121,10 +120,10 @@ public: \ wxPropertyGetter##property() : wxPropertyGetter( wxT(#gettermethod) ) {} \ virtual ~wxPropertyGetter##property() {} \ \ - void Get( const wxObject *object, wxVariantBase &result) const \ + void Get( const wxObject *object, wxAny &result) const \ { \ const Klass *obj = dynamic_cast(object); \ - result = wxVariantBase( obj->gettermethod() ); \ + result = wxAny( obj->gettermethod() ); \ } \ }; @@ -136,13 +135,14 @@ public: \ wxPropertyCollectionAdder##property() : wxPropertyCollectionAdder( wxT(#addermethod) ) {} \ virtual ~wxPropertyCollectionAdder##property() {} \ \ - void Add( wxObject *object, const wxVariantBase &variantValue ) const \ + void Add( wxObject *object, const wxAny &variantValue ) const \ { \ Klass *obj = dynamic_cast(object); \ - if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \ - obj->addermethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType)); \ + valueType tempobj; \ + if ( variantValue.GetAs(&tempobj) ) \ + obj->addermethod(tempobj); \ else \ - obj->addermethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType*)); \ + obj->addermethod(*wxANY_AS(variantValue, valueType*)); \ } \ }; @@ -154,7 +154,7 @@ public: \ wxPropertyCollectionGetter##property() : wxPropertyCollectionGetter( wxT(#gettermethod) ) {} \ virtual ~wxPropertyCollectionGetter##property() {} \ \ - void Get( const wxObject *object, wxVariantBaseArray &result) const \ + void Get( const wxObject *object, wxAnyList &result) const \ { \ const Klass *obj = dynamic_cast(object); \ wxCollectionToVariantArray( obj->gettermethod(), result ); \ @@ -172,7 +172,7 @@ public: virtual ~wxPropertyAccessor() {} // Setting a simple property (non-collection) - virtual void SetProperty(wxObject *object, const wxVariantBase &value) const + virtual void SetProperty(wxObject *object, const wxAny &value) const { if ( m_setter ) m_setter->Set( object, value ); @@ -181,7 +181,7 @@ public: } // Getting a simple property (non-collection) - virtual void GetProperty(const wxObject *object, wxVariantBase &result) const + virtual void GetProperty(const wxObject *object, wxAny &result) const { if ( m_getter ) m_getter->Get( object, result ); @@ -190,7 +190,7 @@ public: } // Adding an element to a collection property - virtual void AddToPropertyCollection(wxObject *object, const wxVariantBase &value) const + virtual void AddToPropertyCollection(wxObject *object, const wxAny &value) const { if ( m_adder ) m_adder->Add( object, value ); @@ -199,7 +199,7 @@ public: } // Getting a collection property - virtual void GetPropertyCollection( const wxObject *obj, wxVariantBaseArray &result) const + virtual void GetPropertyCollection( const wxObject *obj, wxAnyList &result) const { if ( m_collectionGetter ) m_collectionGetter->Get( obj, result); @@ -250,19 +250,19 @@ public: virtual const wxString& GetSetterName() const { return m_setterName; } - virtual void SetProperty(wxObject *object, const wxVariantBase &value) const; - virtual void GetProperty(const wxObject *object, wxVariantBase &value) const; + virtual void SetProperty(wxObject *object, const wxAny &value) const; + virtual void GetProperty(const wxObject *object, wxAny &value) const; // Adding an element to a collection property virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), - const wxVariantBase &WXUNUSED(value)) const + const wxAny &WXUNUSED(value)) const { wxLogError( _("AddToPropertyCollection called on a generic accessor") ); } // Getting a collection property virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), - wxVariantBaseArray &WXUNUSED(result)) const + wxAnyList &WXUNUSED(result)) const { wxLogError ( _("GetPropertyCollection called on a generic accessor") ); } @@ -304,7 +304,7 @@ enum class WXDLLIMPEXP_BASE wxPropertyInfo { - friend class WXDLLIMPEXP_BASE wxDynamicClassInfo; + friend class /* WXDLLIMPEXP_BASE */ wxDynamicClassInfo; public: wxPropertyInfo(wxPropertyInfo* &iter, @@ -312,7 +312,7 @@ public: const wxString& name, const wxString& typeName, wxPropertyAccessor *accessor, - wxVariantBase dv, + wxAny dv, wxPropertyInfoFlags flags = 0, const wxString& helpString = wxEmptyString, const wxString& groupString = wxEmptyString) : @@ -330,36 +330,12 @@ public: Insert(iter); } -#if wxUSE_UNICODE - wxPropertyInfo(wxPropertyInfo* &iter, - wxClassInfo* itsClass, - const wxString& name, - const char* typeName, - wxPropertyAccessor *accessor, - wxVariantBase dv, - wxPropertyInfoFlags flags = 0, - const wxString& helpString = wxEmptyString, - const wxString& groupString = wxEmptyString) : - m_itsClass(itsClass), - m_name(name), - m_typeInfo(NULL), - m_typeName(wxString::FromAscii(typeName)), - m_collectionElementTypeInfo(NULL), - m_accessor(accessor), - m_defaultValue(dv), - m_flags(flags), - m_helpString(helpString), - m_groupString(groupString) - { - Insert(iter); - } -#endif wxPropertyInfo(wxPropertyInfo* &iter, wxClassInfo* itsClass, const wxString& name, wxEventSourceTypeInfo* type, wxPropertyAccessor *accessor, - wxVariantBase dv, + wxAny dv, wxPropertyInfoFlags flags = 0, const wxString& helpString = wxEmptyString, const wxString& groupString = wxEmptyString) : @@ -398,29 +374,6 @@ public: Insert(iter); } -#if wxUSE_UNICODE - wxPropertyInfo(wxPropertyInfo* &iter, - wxClassInfo* itsClass, const wxString& name, - const char* collectionTypeName, - const char* elementTypeName, - wxPropertyAccessor *accessor, - wxPropertyInfoFlags flags = 0, - const wxString& helpString = wxEmptyString, - const wxString& groupString = wxEmptyString) : - m_itsClass(itsClass), - m_name(name), - m_typeInfo(NULL), - m_typeName(wxString::FromAscii(collectionTypeName)), - m_collectionElementTypeInfo(NULL), - m_collectionElementTypeName(wxString::FromAscii(elementTypeName)), - m_accessor(accessor), - m_flags(flags), - m_helpString(helpString), - m_groupString(groupString) - { - Insert(iter); - } -#endif ~wxPropertyInfo() { Remove(); } @@ -462,7 +415,7 @@ public: wxPropertyInfo* GetNext() const { return m_next; } // returns the default value of this property, its kind may be wxT_VOID if it is not valid - wxVariantBase GetDefaultValue() const { return m_defaultValue; } + wxAny GetDefaultValue() const { return m_defaultValue; } private: @@ -480,7 +433,7 @@ private: mutable wxTypeInfo* m_collectionElementTypeInfo; wxString m_collectionElementTypeName; wxPropertyAccessor* m_accessor; - wxVariantBase m_defaultValue; + wxAny m_defaultValue; wxPropertyInfoFlags m_flags; wxString m_helpString; wxString m_groupString; @@ -492,9 +445,20 @@ private: // when the component is dropped on the container. }; -WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, +// stl is giving problems when forwarding declarations, therefore we define it as a subclass + +WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMapBase, class WXDLLIMPEXP_BASE ); +class WXDLLIMPEXP_BASE wxPropertyInfoMap : public wxPropertyInfoMapBase { +}; + +WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxAny, wxStringToAnyHashMapBase, + class WXDLLIMPEXP_BASE ); + +class WXDLLIMPEXP_FWD_BASE wxStringToAnyHashMap : public wxStringToAnyHashMapBase { +}; + #define wxBEGIN_PROPERTIES_TABLE(theClass) \ wxPropertyInfo *theClass::GetPropertiesStatic() \ { \ @@ -506,7 +470,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, #define wxHIDE_PROPERTY( pname ) \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(void).name(), NULL, wxVariantBase(), wxPROP_DONT_STREAM, \ + wxT(#pname), typeid(void).name(), NULL, wxAny(), wxPROP_DONT_STREAM, \ wxEmptyString, wxEmptyString ); #define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \ @@ -518,7 +482,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(type).name(), &_accessor##pname, \ - wxVariantBase(defaultValue), flags, group, help ); + wxAny(defaultValue), flags, group, help ); #define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \ pflags, help, group) \ @@ -530,7 +494,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(flags).name(), &_accessor##pname, \ - wxVariantBase(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); + wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); #define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \ wxPROPERTY_GETTER( pname, class_t, type, getter ) \ @@ -538,7 +502,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(type).name(),&_accessor##pname, \ - wxVariantBase(defaultValue), flags, help, group ); + wxAny(defaultValue), flags, help, group ); #define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \ pflags, help, group) \ @@ -547,7 +511,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(flags).name(),&_accessor##pname, \ - wxVariantBase(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); + wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); #define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \ flags, help, group ) \ @@ -572,15 +536,15 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, &_accessor##pname, flags, help, group ); #define wxEVENT_PROPERTY( name, eventType, eventClass ) \ - static wxEventSourceTypeInfo _typeInfo##name( eventType, CLASSINFO( eventClass ) ); \ + static wxEventSourceTypeInfo _typeInfo##name( eventType, wxCLASSINFO( eventClass ) ); \ static wxPropertyInfo _propertyInfo##name( first,class_t::GetClassInfoStatic(), \ - wxT(#name), &_typeInfo##name, NULL, wxVariantBase() ); + wxT(#name), &_typeInfo##name, NULL, wxAny() ); #define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) \ static wxEventSourceTypeInfo _typeInfo##name( eventType, lastEventType, \ - CLASSINFO( eventClass ) ); \ + wxCLASSINFO( eventClass ) ); \ static wxPropertyInfo _propertyInfo##name( first, class_t::GetClassInfoStatic(), \ - wxT(#name), &_typeInfo##name, NULL, wxVariantBase() ); + wxT(#name), &_typeInfo##name, NULL, wxAny() ); // ---------------------------------------------------------------------------- // Implementation Helper for Simple Properties