]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/xtiprop.h
Remove SetPageTitle and GetPageTitle and make GetCurrentTitle actually return the...
[wxWidgets.git] / include / wx / xtiprop.h
index abd3584eadd5be1b909dfc95f4c9c553216a59fd..23d901755f909c91256f00b9e199bddbfc414e8a 100644 (file)
 
 #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 +42,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 +55,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 +68,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 +76,7 @@ private:
 };
 
 template<typename coll_t> void WXDLLIMPEXP_BASE \
-    wxCollectionToVariantArray( const coll_t& coll, wxVariantBaseArray& result );
+    wxCollectionToVariantArray( const coll_t& coll, wxAnyList& result );
 
 class WXDLLIMPEXP_BASE wxPropertyCollectionAdder
 {
@@ -88,29 +84,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<Klass*>(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<Klass*>(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 +118,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<const Klass*>(object);          \
-        result = wxVariantBase( obj->gettermethod() );                     \
+        result = wxAny( obj->gettermethod() );                     \
     }                                                                   \
 };
 
@@ -136,13 +133,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<Klass*>(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 +152,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<const Klass*>(object);              \
         wxCollectionToVariantArray( obj->gettermethod(), result );         \
@@ -172,7 +170,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 +179,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 +188,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 +197,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 +248,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") ); 
     }
@@ -312,7 +310,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 +328,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 +372,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 +413,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 +431,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;
@@ -506,7 +457,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 +469,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 +481,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 +489,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 +498,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 )                                   \
@@ -574,13 +525,13 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap,
 #define wxEVENT_PROPERTY( name, eventType, eventClass )                               \
     static wxEventSourceTypeInfo _typeInfo##name( eventType, CLASSINFO( 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 ) );             \
     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
@@ -593,5 +544,8 @@ public:                                                 \
   void  Set##name( type const & p) { m_##name = p; }    \
   type const & Get##name() const  { return m_##name; }
 
+WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxAny, wxStringToAnyHashMap,
+    class WXDLLIMPEXP_BASE );
+
 #endif      // wxUSE_EXTENDED_RTTI
 #endif      // _XTIPROP_H_