xti additions / changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23125 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2003-08-23 00:37:55 +00:00
parent b192f49963
commit ae820c693a
3 changed files with 737 additions and 512 deletions

117
include/wx/flags.h Normal file
View File

@@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/flags.h
// Purpose: a bitset suited for replacing the current style flags
// Author: Stefan Csomor
// Modified by:
// Created: 27/07/03
// RCS-ID: $Id$
// Copyright: (c) 2003 Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SETH__
#define _WX_SETH__
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "flags.h"
#endif
// wxFlags should be applied to an enum, then this can be used like
// bitwise operators but keeps the type safety and information, the
// enums must be in a sequence , their value determines the bit position
// that they represent
template <class T> class wxFlags
{
friend class wxEnumData ;
public:
wxFlags(long val) { m_data = val ; }
wxFlags() { m_data = 0; }
wxFlags(const wxFlags &src) { m_data = src.m_data; }
wxFlags(const T el) { m_data |= 1 << el; }
operator long() const { return m_data ; }
wxFlags &operator =(const wxFlags &rhs)
{
m_data = rhs.m_data;
return *this;
}
wxFlags &operator +=(const wxFlags &rhs) // union
{
m_data |= rhs.m_data;
return *this;
}
wxFlags &operator -=(const wxFlags &rhs) // difference
{
m_data ^= rhs.m_data;
return *this;
}
wxFlags &operator *=(const wxFlags &rhs) // intersection
{
m_data &= rhs.m_data;
return *this;
}
wxFlags operator +(const wxFlags &rhs) const // union
{
wxFlags<T> s;
s.m_data = m_data | rhs.m_data;
return s;
}
wxFlags operator -(const wxFlags &rhs) const // difference
{
wxFlags<T> s;
s.m_data = m_data ^ rhs.m_data;
return s;
}
wxFlags operator *(const wxFlags &rhs) const // intersection
{
wxFlags<T> s;
s.m_data = m_data & rhs.m_data;
return s;
}
wxFlags& Set(const T el) //Add element
{
m_data |= 1 << el;
return *this;
}
wxFlags& Clear(const T el) //remove element
{
m_data &= ~(1 << el);
return *this;
}
bool Contains(const T el) const
{
return (m_data & (1 << el)) ? true : false;
}
wxFlags &Clear()
{
m_data = 0;
return *this;
}
bool Empty() const
{
return m_data == 0;
}
bool operator ==(const wxFlags &rhs) const
{
return m_data == rhs.m_data;
}
bool operator !=(const wxFlags &rhs) const
{
return !operator==(rhs);
}
private :
int m_data;
};
#endif

View File

@@ -38,9 +38,10 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/memory.h" #include "wx/memory.h"
#include "wx/set.h" #include "wx/flags.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/arrstr.h" #include "wx/arrstr.h"
#include "wx/hashmap.h"
class WXDLLIMPEXP_BASE wxObject; class WXDLLIMPEXP_BASE wxObject;
class WXDLLIMPEXP_BASE wxClassInfo; class WXDLLIMPEXP_BASE wxClassInfo;
@@ -110,23 +111,25 @@ private :
wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \ wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \ wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \
template<> void wxStringReadValue(const wxString& s , e &data ) \ template<> void wxStringReadValue(const wxString& s , e &data ) \
{ \ { \
data = (e) s_enumData##e.GetEnumMemberValue(s) ; \ data = (e) s_enumData##e.GetEnumMemberValue(s) ; \
} \ } \
template<> void wxStringWriteValue(wxString &s , const e &data ) \ template<> void wxStringWriteValue(wxString &s , const e &data ) \
{ \ { \
s = s_enumData##e.GetEnumMemberName((int)data) ; \ s = s_enumData##e.GetEnumMemberName((int)data) ; \
} \ } \
template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e , &wxToStringConverter<e> , &wxFromStringConverter<e>) ; return &s_typeInfo ; } \ void FromLong##e( long data , wxxVariant& result ) { result = wxxVariant((e)data) ;} \
void ToLong##e( const wxxVariant& data , long &result ) { result = (long) data.Get<e>() ;} \
template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e , &wxToStringConverter<e> , &wxFromStringConverter<e> , &ToLong##e , &FromLong##e , #e) ; return &s_typeInfo ; } \
template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \
template<> void wxStringReadValue(const wxString& , e* & ) \ template<> void wxStringReadValue(const wxString& , e* & ) \
{ \ { \
assert(0) ; \ assert(0) ; \
} \ } \
template<> void wxStringWriteValue(wxString &s , e* const & ) \ template<> void wxStringWriteValue(wxString &s , e* const & ) \
{ \ { \
assert(0) ; \ assert(0) ; \
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Set Support // Set Support
@@ -140,7 +143,7 @@ private :
// Strawberry, // Strawberry,
// }; // };
// //
// typedef wxSet<wxFlavor> wxCoupe ; // typedef wxFlags<wxFlavor> wxCoupe ;
// //
// in the implementation file : // in the implementation file :
// //
@@ -161,7 +164,7 @@ private :
void wxSetStringToArray( const wxString &s , wxArrayString &array ) ; void wxSetStringToArray( const wxString &s , wxArrayString &array ) ;
template<typename e> template<typename e>
void wxSetFromString(const wxString &s , wxSet<e> &data ) void wxSetFromString(const wxString &s , wxFlags<e> &data )
{ {
wxEnumData* edata = wxGetEnumData((e) 0) ; wxEnumData* edata = wxGetEnumData((e) 0) ;
data.Clear() ; data.Clear() ;
@@ -181,7 +184,7 @@ void wxSetFromString(const wxString &s , wxSet<e> &data )
} }
template<typename e> template<typename e>
void wxSetToString( wxString &s , const wxSet<e> &data ) void wxSetToString( wxString &s , const wxFlags<e> &data )
{ {
wxEnumData* edata = wxGetEnumData((e) 0) ; wxEnumData* edata = wxGetEnumData((e) 0) ;
int count = edata->GetEnumCount() ; int count = edata->GetEnumCount() ;
@@ -200,18 +203,24 @@ void wxSetToString( wxString &s , const wxSet<e> &data )
} }
} }
// if the wxSet specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro // if the wxFlags specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro
// template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; } // template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; }
#define WX_IMPLEMENT_SET_STREAMING(SetName,e) \ #define WX_IMPLEMENT_SET_STREAMING(SetName,e) \
template<> void wxStringReadValue(const wxString &s , wxSet<e> &data ) \ template<> void wxStringReadValue(const wxString &s , wxFlags<e> &data ) \
{ \ { \
wxSetFromString( s , data ) ; \ wxSetFromString( s , data ) ; \
} \ } \
template<> void wxStringWriteValue( wxString &s , const wxSet<e> &data ) \ template<> void wxStringWriteValue( wxString &s , const wxFlags<e> &data ) \
{ \ { \
wxSetToString( s , data ) ; \ wxSetToString( s , data ) ; \
} } \
void FromLong##SetName( long data , wxxVariant& result ) { result = wxxVariant(SetName(data)) ;} \
void ToLong##SetName( const wxxVariant& data , long &result ) { result = (long) data.Get<SetName>() ;} \
template<> const wxTypeInfo* wxGetTypeInfo( SetName * ) \
{ \
static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e , &wxToStringConverter<SetName> , &wxFromStringConverter<SetName> , &ToLong##SetName , &FromLong##SetName, #SetName ) ; return &s_typeInfo ; \
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -238,7 +247,7 @@ enum wxTypeKind
wxT_FLOAT, wxT_FLOAT,
wxT_DOUBLE, wxT_DOUBLE,
wxT_STRING, // must be wxString wxT_STRING, // must be wxString
wxT_SET, // must be wxSet<> template wxT_SET, // must be wxFlags<> template
wxT_ENUM, wxT_ENUM,
wxT_CUSTOM, // user defined type (e.g. wxPoint) wxT_CUSTOM, // user defined type (e.g. wxPoint)
@@ -254,64 +263,118 @@ enum wxTypeKind
}; };
class wxxVariant ; class wxxVariant ;
class wxTypeInfo ;
WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxTypeInfo* , wxTypeInfoMap ) ;
class WXDLLIMPEXP_BASE wxTypeInfo class WXDLLIMPEXP_BASE wxTypeInfo
{ {
public : public :
wxTypeInfo() : m_kind( wxT_VOID) , m_toString(NULL) , m_fromString(NULL) {} typedef void (*converterToString_t)( const wxxVariant& data , wxString &result ) ;
virtual ~wxTypeInfo() {} typedef void (*converterFromString_t)( const wxString& data , wxxVariant &result ) ;
wxTypeInfo(wxTypeKind kind , converterToString_t to = NULL , converterFromString_t from= NULL, const wxString &name = wxEmptyString ) :
m_kind( kind) , m_toString(to) , m_fromString(from) , m_name(name)
{
Register() ;
}
virtual ~wxTypeInfo()
{
Unregister() ;
}
// return the kind of this type (wxT_... constants)
wxTypeKind GetKind() const { return m_kind ; } wxTypeKind GetKind() const { return m_kind ; }
// returns the unique name of this type
const wxString& GetTypeName() const { return m_name ; }
// is this type a delegate type
bool IsDelegateType() const { return m_kind == wxT_DELEGATE ; } bool IsDelegateType() const { return m_kind == wxT_DELEGATE ; }
// is this type a custom type
bool IsCustomType() const { return m_kind == wxT_CUSTOM ; } bool IsCustomType() const { return m_kind == wxT_CUSTOM ; }
// is this type an object type
bool IsObjectType() const { return m_kind == wxT_OBJECT || m_kind == wxT_OBJECT_PTR ; } bool IsObjectType() const { return m_kind == wxT_OBJECT || m_kind == wxT_OBJECT_PTR ; }
// can the content of this type be converted to and from strings ?
bool HasStringConverters() const { return m_toString != NULL && m_fromString != NULL ; } bool HasStringConverters() const { return m_toString != NULL && m_fromString != NULL ; }
// convert a wxxVariant holding data of this type into a string
void ConvertToString( const wxxVariant& data , wxString &result ) const void ConvertToString( const wxxVariant& data , wxString &result ) const
{ wxASSERT_MSG( m_toString , wxT("String conversions not supported") ) ; (*m_toString)( data , result ) ; } { wxASSERT_MSG( m_toString , wxT("String conversions not supported") ) ; (*m_toString)( data , result ) ; }
// convert a string into a wxxVariant holding the corresponding data in this type
void ConvertFromString( const wxString& data , wxxVariant &result ) const void ConvertFromString( const wxString& data , wxxVariant &result ) const
{ wxASSERT_MSG( m_fromString , wxT("String conversions not supported") ) ; (*m_fromString)( data , result ) ; } { wxASSERT_MSG( m_fromString , wxT("String conversions not supported") ) ; (*m_fromString)( data , result ) ; }
protected : static wxTypeInfo *FindType(const wxChar *typeName);
typedef void (*converterToString_t)( const wxxVariant& data , wxString &result ) ;
typedef void (*converterFromString_t)( const wxString& data , wxxVariant &result ) ; private :
void Register();
void Unregister();
converterToString_t m_toString ; converterToString_t m_toString ;
converterFromString_t m_fromString ; converterFromString_t m_fromString ;
static wxTypeInfoMap* sm_typeTable ;
wxTypeKind m_kind ; wxTypeKind m_kind ;
wxString m_name ;
}; };
class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo
{ {
public : public :
wxBuiltInTypeInfo( wxTypeKind kind , converterToString_t to = NULL , converterFromString_t from= NULL ) wxBuiltInTypeInfo( wxTypeKind kind , converterToString_t to = NULL , converterFromString_t from = NULL , const wxString &name = wxEmptyString ) :
{ wxASSERT_MSG( kind < wxT_SET , wxT("Illegal Kind for Base Type") ) ; m_kind = kind ; m_toString = to ; m_fromString = from ;} wxTypeInfo( kind , to , from , name )
{ wxASSERT_MSG( GetKind() < wxT_SET , wxT("Illegal Kind for Base Type") ) ; }
} ; } ;
class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo
{ {
public : public :
wxCustomTypeInfo( const wxChar *typeName , converterToString_t to= NULL , converterFromString_t from= NULL ) wxCustomTypeInfo( const wxString &name , converterToString_t to , converterFromString_t from ) :
{ m_kind = wxT_CUSTOM ; m_typeName = typeName ;m_toString = to ; m_fromString = from ;} wxTypeInfo( wxT_CUSTOM , to , from , name )
const wxChar *GetTypeName() const { return m_typeName ; } {}
private :
const wxChar *m_typeName; // Kind == wxT_CUSTOM
} ; } ;
class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo
{ {
public : public :
wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo , converterToString_t to = NULL , converterFromString_t from= NULL ) typedef void (*converterToLong_t)( const wxxVariant& data , long &result ) ;
{ wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_kind = kind ; m_enumInfo = enumInfo ;m_toString = to ; m_fromString = from ;} typedef void (*converterFromLong_t)( long data , wxxVariant &result ) ;
wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo , converterToString_t to , converterFromString_t from ,
converterToLong_t toLong , converterFromLong_t fromLong , const wxString &name ) :
wxTypeInfo( kind , to , from , name ) , m_toLong( toLong ) , m_fromLong( fromLong )
{ wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_enumInfo = enumInfo ;}
const wxEnumData* GetEnumData() const { return m_enumInfo ; } const wxEnumData* GetEnumData() const { return m_enumInfo ; }
// convert a wxxVariant holding data of this type into a long
void ConvertToLong( const wxxVariant& data , long &result ) const
{ wxASSERT_MSG( m_toLong , wxT("Long conversions not supported") ) ; (*m_toLong)( data , result ) ; }
// convert a long into a wxxVariant holding the corresponding data in this type
void ConvertFromLong( long data , wxxVariant &result ) const
{ wxASSERT_MSG( m_fromLong , wxT("Long conversions not supported") ) ; (*m_fromLong)( data , result ) ; }
private : private :
converterToLong_t m_toLong ;
converterFromLong_t m_fromLong ;
wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET
} ; } ;
class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo
{ {
public : public :
wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to = NULL , converterFromString_t from = NULL ) wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to = NULL , converterFromString_t from = NULL ) ;
{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_kind = kind ; m_classInfo = classInfo ;}
const wxClassInfo *GetClassInfo() const { return m_classInfo ; } const wxClassInfo *GetClassInfo() const { return m_classInfo ; }
private : private :
wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL
@@ -320,8 +383,9 @@ private :
class WXDLLIMPEXP_BASE wxCollectionTypeInfo : public wxTypeInfo class WXDLLIMPEXP_BASE wxCollectionTypeInfo : public wxTypeInfo
{ {
public : public :
wxCollectionTypeInfo( wxTypeInfo *elementType , converterToString_t to = NULL , converterFromString_t from = NULL ) wxCollectionTypeInfo( wxTypeInfo *elementType , converterToString_t to , converterFromString_t from , const wxString &name) :
{ m_kind = wxT_COLLECTION , m_elementType = elementType ; m_toString = to ; m_fromString = from ;} wxTypeInfo( wxT_COLLECTION , to , from , name )
{ m_elementType = elementType ;}
const wxTypeInfo* GetElementType() const { return m_elementType ; } const wxTypeInfo* GetElementType() const { return m_elementType ; }
private : private :
@@ -333,9 +397,7 @@ private :
class WXDLLIMPEXP_BASE wxDelegateTypeInfo : public wxTypeInfo class WXDLLIMPEXP_BASE wxDelegateTypeInfo : public wxTypeInfo
{ {
public : public :
wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to = NULL , converterFromString_t from = NULL ) wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to = NULL , converterFromString_t from = NULL ) ;
{ m_kind = wxT_DELEGATE ; m_eventClass = eventClass ; m_eventType = eventType ;m_toString = to ; m_fromString = from ;}
const wxClassInfo *GetEventClass() const { assert( m_kind == wxT_DELEGATE ) ; return m_eventClass ; }
int GetEventType() const { return m_eventType ; } int GetEventType() const { return m_eventType ; }
private : private :
const wxClassInfo *m_eventClass; // (extended will merge into classinfo) const wxClassInfo *m_eventClass; // (extended will merge into classinfo)
@@ -344,17 +406,20 @@ private :
template<typename T> const wxTypeInfo* wxGetTypeInfo( T * ) ; template<typename T> const wxTypeInfo* wxGetTypeInfo( T * ) ;
template<typename T> const wxTypeInfo* wxGetTypeInfo( wxSet<T> * )
{
static wxEnumTypeInfo s_typeInfo(wxT_SET , wxGetEnumData((T) 0) ) ; return &s_typeInfo ;
}
// this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
#define WX_CUSTOM_TYPE_INFO( e ) \ #define WX_CUSTOM_TYPE_INFO( e ) \
template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \
template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e, &wxToStringConverter<e> , &wxFromStringConverter<e>) ; return &s_typeInfo ; } template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e, &wxToStringConverter<e> , &wxFromStringConverter<e>) ; return &s_typeInfo ; }
#define WX_COLLECTION_TYPE_INFO( element , collection ) \
template<> const wxTypeInfo* wxGetTypeInfo( collection * ) \
{ \
static wxCollectionTypeInfo s_typeInfo( (wxTypeInfo*) wxGetTypeInfo( (element *) NULL) , NULL , NULL , #collection ) ; \
return &s_typeInfo ; \
} \
// templated streaming, every type must have their specialization for these methods // templated streaming, every type must have their specialization for these methods
template<typename T> template<typename T>
@@ -372,10 +437,10 @@ void wxFromStringConverter( const wxString &s, wxxVariant &v) { T d ; wxStringRe
// sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs // sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
#define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \ #define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \
template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \ template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \
static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \ static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \
template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\ template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\
template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; } template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxxVariant as typesafe data holder // wxxVariant as typesafe data holder
@@ -541,58 +606,58 @@ private :
#define WX_SETTER( property, Klass, valueType, setterMethod ) \ #define WX_SETTER( property, Klass, valueType, setterMethod ) \
class wxSetter##property : public wxSetter \ class wxSetter##property : public wxSetter \
{ \ { \
public: \ public: \
wxSetter##property() : wxSetter( #setterMethod ) {} \ wxSetter##property() : wxSetter( #setterMethod ) {} \
void Set( wxObject *object, const wxxVariant &variantValue ) const \ void Set( wxObject *object, const wxxVariant &variantValue ) const \
{ \ { \
Klass *obj = dynamic_cast<Klass*>(object) ; \ Klass *obj = dynamic_cast<Klass*>(object) ; \
if ( variantValue.HasData<valueType>() ) \ if ( variantValue.HasData<valueType>() ) \
obj->setterMethod(variantValue.Get<valueType>()) ; \ obj->setterMethod(variantValue.Get<valueType>()) ; \
else \ else \
obj->setterMethod(*variantValue.Get<valueType*>()) ; \ obj->setterMethod(*variantValue.Get<valueType*>()) ; \
} \ } \
} ; } ;
#define WX_GETTER( property, Klass, valueType , gettermethod ) \ #define WX_GETTER( property, Klass, valueType , gettermethod ) \
class wxGetter##property : public wxGetter \ class wxGetter##property : public wxGetter \
{ \ { \
public : \ public : \
wxGetter##property() : wxGetter( #gettermethod ) {} \ wxGetter##property() : wxGetter( #gettermethod ) {} \
void Get( const wxObject *object , wxxVariant &result) const \ void Get( const wxObject *object , wxxVariant &result) const \
{ \ { \
const Klass *obj = dynamic_cast<const Klass*>(object) ; \ const Klass *obj = dynamic_cast<const Klass*>(object) ; \
result = wxxVariant( obj->gettermethod() ) ; \ result = wxxVariant( obj->gettermethod() ) ; \
} \ } \
} ; } ;
#define WX_ADDER( property, Klass, valueType , addermethod ) \ #define WX_ADDER( property, Klass, valueType , addermethod ) \
class wxAdder##property : public wxAdder \ class wxAdder##property : public wxAdder \
{ \ { \
public: \ public: \
wxAdder##property() : wxAdder( #addermethod ) {} \ wxAdder##property() : wxAdder( #addermethod ) {} \
void Add( wxObject *object, const wxxVariant &variantValue ) const \ void Add( wxObject *object, const wxxVariant &variantValue ) const \
{ \ { \
Klass *obj = dynamic_cast<Klass*>(object) ; \ Klass *obj = dynamic_cast<Klass*>(object) ; \
if ( variantValue.HasData<valueType>() ) \ if ( variantValue.HasData<valueType>() ) \
obj->addermethod(variantValue.Get<valueType>()) ; \ obj->addermethod(variantValue.Get<valueType>()) ; \
else \ else \
obj->addermethod(*variantValue.Get<valueType*>()) ; \ obj->addermethod(*variantValue.Get<valueType*>()) ; \
} \ } \
} ; } ;
#define WX_COLLECTION_GETTER( property, Klass, valueType , gettermethod ) \ #define WX_COLLECTION_GETTER( property, Klass, valueType , gettermethod ) \
class wxCollectionGetter##property : public wxCollectionGetter \ class wxCollectionGetter##property : public wxCollectionGetter \
{ \ { \
public : \ public : \
wxCollectionGetter##property() : wxCollectionGetter( #gettermethod ) {} \ wxCollectionGetter##property() : wxCollectionGetter( #gettermethod ) {} \
void Get( const wxObject *object , wxxVariantArray &result) const \ void Get( const wxObject *object , wxxVariantArray &result) const \
{ \ { \
const Klass *obj = dynamic_cast<const Klass*>(object) ; \ const Klass *obj = dynamic_cast<const Klass*>(object) ; \
wxCollectionToVariantArray( obj->gettermethod() , result ) ; \ wxCollectionToVariantArray( obj->gettermethod() , result ) ; \
} \ } \
} ; } ;
class WXDLLIMPEXP_BASE wxPropertyAccessor class WXDLLIMPEXP_BASE wxPropertyAccessor
{ {
@@ -642,9 +707,9 @@ protected :
wxCollectionGetter* m_collectionGetter ; wxCollectionGetter* m_collectionGetter ;
}; };
class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor
{ {
public : public :
wxGenericPropertyAccessor( const wxString &propName ) ; wxGenericPropertyAccessor( const wxString &propName ) ;
~wxGenericPropertyAccessor() ; ~wxGenericPropertyAccessor() ;
@@ -662,13 +727,13 @@ protected :
virtual void GetProperty(const wxObject *object, wxxVariant &value) const ; virtual void GetProperty(const wxObject *object, wxxVariant &value) const ;
// Adding an element to a collection property // Adding an element to a collection property
virtual void AddToPropertyCollection(wxObject *object, const wxxVariant &value) const virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), const wxxVariant &WXUNUSED(value)) const
{ wxASSERT_MSG(0,wxT("AddToPropertyCollection called on a generic accessor") ) ;} { wxASSERT_MSG(0,wxT("AddToPropertyCollection called on a generic accessor") ) ;}
// Getting a collection property // Getting a collection property
virtual void GetPropertyCollection( const wxObject *obj, wxxVariantArray &result) const virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), wxxVariantArray &WXUNUSED(result)) const
{ wxASSERT_MSG(0,wxT("GetPropertyCollection called on a generic accessor") ) ;} { wxASSERT_MSG(0,wxT("GetPropertyCollection called on a generic accessor") ) ;}
private : private :
struct wxGenericPropertyAccessorInternal ; struct wxGenericPropertyAccessorInternal ;
wxGenericPropertyAccessorInternal* m_data ; wxGenericPropertyAccessorInternal* m_data ;
wxString m_propertyName ; wxString m_propertyName ;
@@ -676,23 +741,45 @@ protected :
wxString m_getterName ; wxString m_getterName ;
} ; } ;
typedef long wxPropertyInfoFlags ;
enum {
// will be removed in future releases
wxPROP_DEPRECATED = 0x00000001 ,
// object graph property, will be streamed with priority (after constructor properties)
wxPROP_OBJECT_GRAPH = 0x00000002 ,
// this will only be streamed out and in as enum/set, the internal representation is still a long
wxPROP_ENUM_STORE_LONG = 0x00000004 ,
} ;
class WXDLLIMPEXP_BASE wxPropertyInfo class WXDLLIMPEXP_BASE wxPropertyInfo
{ {
public : public :
wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* typeInfo , wxPropertyAccessor *accessor , wxxVariant dv ) : wxPropertyInfo( wxPropertyInfo* &iter , const wxClassInfo* itsClass , const wxString& name , const wxTypeInfo* typeInfo , wxPropertyAccessor *accessor , wxxVariant dv , wxPropertyInfoFlags flags = 0 , const wxString& helpString=wxEmptyString, const wxString& groupString=wxEmptyString ) :
m_name( name ) , m_typeInfo( typeInfo ) , m_accessor( accessor ) , m_defaultValue( dv ) , m_collectionElementTypeInfo(NULL) m_name( name ) , m_itsClass( itsClass ) , m_typeInfo( typeInfo ) , m_accessor( accessor ) , m_defaultValue( dv ) , m_collectionElementTypeInfo(NULL) , m_helpString (helpString ) , m_groupString( groupString ) , m_flags(flags)
{ {
Insert(iter) ; Insert(iter) ;
} }
wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* collTypeInfo , const wxTypeInfo* elemTypeInfo , wxPropertyAccessor *accessor ) : wxPropertyInfo( wxPropertyInfo* &iter , const wxClassInfo* itsClass , const wxString& name , const wxTypeInfo* collTypeInfo , const wxTypeInfo* elemTypeInfo , wxPropertyAccessor *accessor , wxPropertyInfoFlags flags = 0 , const wxString& helpString=wxEmptyString, const wxString& groupString=wxEmptyString ) :
m_name( name ) , m_typeInfo( collTypeInfo ) , m_accessor( accessor ) , m_collectionElementTypeInfo(elemTypeInfo) m_name( name ) , m_itsClass( itsClass ) , m_typeInfo( collTypeInfo ) , m_accessor( accessor ) , m_collectionElementTypeInfo(elemTypeInfo) , m_helpString (helpString ) , m_groupString( groupString ) , m_flags(flags)
{ {
Insert(iter) ; Insert(iter) ;
} }
// return the class this property is declared in
const wxClassInfo* GetDeclaringClass() const { return m_itsClass ; }
// return the name of this property // return the name of this property
const wxChar * GetName() const { return m_name ; } const wxString& GetName() const { return m_name ; }
// returns the flags of this property
wxPropertyInfoFlags GetFlags() const { return m_flags ;}
// returns the short help string of this property
const wxString& GetHelpString() const { return m_helpString ; }
// returns the group string of this property
const wxString& GetGroupString() const { return m_groupString ; }
// return the element type info of this property (for collections, otherwise NULL) // return the element type info of this property (for collections, otherwise NULL)
const wxTypeInfo * GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo ; } const wxTypeInfo * GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo ; }
@@ -724,8 +811,12 @@ private :
} }
} }
const wxChar * m_name; wxString m_name;
const wxChar * m_typeName ; wxString m_typeName ;
wxString m_groupString ;
wxString m_helpString ;
const wxClassInfo* m_itsClass ;
wxPropertyInfoFlags m_flags ;
const wxTypeInfo* m_typeInfo ; const wxTypeInfo* m_typeInfo ;
const wxTypeInfo* m_collectionElementTypeInfo ; const wxTypeInfo* m_collectionElementTypeInfo ;
wxPropertyAccessor* m_accessor ; wxPropertyAccessor* m_accessor ;
@@ -736,9 +827,11 @@ private :
wxPropertyInfo* m_next ; wxPropertyInfo* m_next ;
}; };
WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxPropertyInfo* , wxPropertyInfoMap ) ;
#define WX_BEGIN_PROPERTIES_TABLE(theClass) \ #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
wxPropertyInfo *theClass::GetPropertiesStatic() \ wxPropertyInfo *theClass::GetPropertiesStatic() \
{ \ { \
typedef theClass class_t; \ typedef theClass class_t; \
static wxPropertyInfo* first = NULL ; static wxPropertyInfo* first = NULL ;
@@ -747,48 +840,56 @@ private :
#define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \ #define WX_PROPERTY( name , type , setter , getter ,defaultValue , flags , help , group) \
WX_SETTER( name , class_t , type , setter ) \ WX_SETTER( name , class_t , type , setter ) \
static wxSetter##name _setter##name ; \ static wxSetter##name _setter##name ; \
WX_GETTER( name , class_t , type , getter ) \ WX_GETTER( name , class_t , type , getter ) \
static wxGetter##name _getter##name ; \ static wxGetter##name _getter##name ; \
static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \ static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) , flags , group , help ) ;
#define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \ #define WX_PROPERTY_FLAGS( name , flags , type , setter , getter ,defaultValue , pflags , help , group) \
WX_SETTER( name , class_t , type , setter ) \
static wxSetter##name _setter##name ; \
WX_GETTER( name , class_t , type , getter ) \
static wxGetter##name _getter##name ; \
static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (flags*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ;
#define WX_READONLY_PROPERTY( name , type , getter ,defaultValue , flags , help , group) \
WX_GETTER( name , class_t , type , getter ) \ WX_GETTER( name , class_t , type , getter ) \
static wxGetter##name _getter##name ; \ static wxGetter##name _getter##name ; \
static wxPropertyAccessor _accessor##name( NULL , &_getter##name , NULL , NULL ) ; \ static wxPropertyAccessor _accessor##name( NULL , &_getter##name , NULL , NULL ) ; \
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), flags , help , group ) ;
#define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \ #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter , flags , help , group ) \
WX_ADDER( name , class_t , addelemtype , adder ) \ WX_ADDER( name , class_t , addelemtype , adder ) \
static wxAdder##name _adder##name ; \ static wxAdder##name _adder##name ; \
WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \ WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
static wxCollectionGetter##name _collectionGetter##name ; \ static wxCollectionGetter##name _collectionGetter##name ; \
static wxPropertyAccessor _accessor##name( NULL , NULL ,&_adder##name , &_collectionGetter##name ) ; \ static wxPropertyAccessor _accessor##name( NULL , NULL ,&_adder##name , &_collectionGetter##name ) ; \
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
#define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \ #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter , flags , help , group) \
WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \ WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
static wxCollectionGetter##name _collectionGetter##name ; \ static wxCollectionGetter##name _collectionGetter##name ; \
static wxPropertyAccessor _accessor##name( NULL , NULL , NULL , &_collectionGetter##name ) ; \ static wxPropertyAccessor _accessor##name( NULL , NULL , NULL , &_collectionGetter##name ) ; \
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
/* /*
#define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \ #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \ static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
#define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \ #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &getter , #getter ) ; \ static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &getter , #getter ) ; \
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
*/ */
#define WX_DELEGATE( name , eventType , eventClass ) \ #define WX_DELEGATE( name , eventType , eventClass ) \
static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \ static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
static wxPropertyInfo _propertyInfo##name( first , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \ static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Handler Info // Handler Info
@@ -799,7 +900,7 @@ private :
class wxHandlerInfo class wxHandlerInfo
{ {
public : public :
wxHandlerInfo( wxHandlerInfo* &iter , const wxChar *name , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) : wxHandlerInfo( wxHandlerInfo* &iter , const wxString& name , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) :
m_name( name ) , m_eventClassInfo( eventClassInfo ) , m_eventFunction( address ) m_name( name ) , m_eventClassInfo( eventClassInfo ) , m_eventFunction( address )
{ {
m_next = NULL ; m_next = NULL ;
@@ -815,8 +916,8 @@ public :
} }
} }
// get the name of the handler method // return the name of this handler
const wxChar * GetName() const { return m_name ; } const wxString& GetName() const { return m_name ; }
// return the class info of the event // return the class info of the event
const wxClassInfo * GetEventClassInfo() const { return m_eventClassInfo ; } const wxClassInfo * GetEventClassInfo() const { return m_eventClassInfo ; }
@@ -828,7 +929,7 @@ public :
wxHandlerInfo* GetNext() const { return m_next ; } wxHandlerInfo* GetNext() const { return m_next ; }
private : private :
wxObjectEventFunction m_eventFunction ; wxObjectEventFunction m_eventFunction ;
const wxChar * m_name; wxString m_name;
const wxClassInfo* m_eventClassInfo ; const wxClassInfo* m_eventClassInfo ;
wxHandlerInfo* m_next ; wxHandlerInfo* m_next ;
}; };
@@ -838,7 +939,7 @@ private :
#define WX_BEGIN_HANDLERS_TABLE(theClass) \ #define WX_BEGIN_HANDLERS_TABLE(theClass) \
wxHandlerInfo *theClass::GetHandlersStatic() \ wxHandlerInfo *theClass::GetHandlersStatic() \
{ \ { \
typedef theClass class_t; \ typedef theClass class_t; \
static wxHandlerInfo* first = NULL ; static wxHandlerInfo* first = NULL ;
@@ -913,7 +1014,7 @@ struct wxConstructorBridge_1 : public wxConstructorBridge
// 2 params // 2 params
template<typename Class, template<typename Class,
typename T0, typename T1> typename T0, typename T1>
struct wxConstructorBridge_2 : public wxConstructorBridge struct wxConstructorBridge_2 : public wxConstructorBridge
{ {
void Create(wxObject *o, wxxVariant *args) void Create(wxObject *o, wxxVariant *args)
@@ -935,7 +1036,7 @@ struct wxConstructorBridge_2 : public wxConstructorBridge
// 3 params // 3 params
template<typename Class, template<typename Class,
typename T0, typename T1, typename T2> typename T0, typename T1, typename T2>
struct wxConstructorBridge_3 : public wxConstructorBridge struct wxConstructorBridge_3 : public wxConstructorBridge
{ {
void Create(wxObject *o, wxxVariant *args) void Create(wxObject *o, wxxVariant *args)
@@ -958,7 +1059,7 @@ struct wxConstructorBridge_3 : public wxConstructorBridge
// 4 params // 4 params
template<typename Class, template<typename Class,
typename T0, typename T1, typename T2, typename T3> typename T0, typename T1, typename T2, typename T3>
struct wxConstructorBridge_4 : public wxConstructorBridge struct wxConstructorBridge_4 : public wxConstructorBridge
{ {
void Create(wxObject *o, wxxVariant *args) void Create(wxObject *o, wxxVariant *args)
@@ -982,7 +1083,7 @@ struct wxConstructorBridge_4 : public wxConstructorBridge
// 5 params // 5 params
template<typename Class, template<typename Class,
typename T0, typename T1, typename T2, typename T3, typename T4> typename T0, typename T1, typename T2, typename T3, typename T4>
struct wxConstructorBridge_5 : public wxConstructorBridge struct wxConstructorBridge_5 : public wxConstructorBridge
{ {
void Create(wxObject *o, wxxVariant *args) void Create(wxObject *o, wxxVariant *args)
@@ -1007,7 +1108,7 @@ struct wxConstructorBridge_5 : public wxConstructorBridge
// 6 params // 6 params
template<typename Class, template<typename Class,
typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
struct wxConstructorBridge_6 : public wxConstructorBridge struct wxConstructorBridge_6 : public wxConstructorBridge
{ {
void Create(wxObject *o, wxxVariant *args) void Create(wxObject *o, wxxVariant *args)
@@ -1033,7 +1134,7 @@ struct wxConstructorBridge_6 : public wxConstructorBridge
// 7 params // 7 params
template<typename Class, template<typename Class,
typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
struct wxConstructorBridge_7 : public wxConstructorBridge struct wxConstructorBridge_7 : public wxConstructorBridge
{ {
void Create(wxObject *o, wxxVariant *args) void Create(wxObject *o, wxxVariant *args)
@@ -1060,7 +1161,7 @@ struct wxConstructorBridge_7 : public wxConstructorBridge
// 8 params // 8 params
template<typename Class, template<typename Class,
typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
struct wxConstructorBridge_8 : public wxConstructorBridge struct wxConstructorBridge_8 : public wxConstructorBridge
{ {
void Create(wxObject *o, wxxVariant *args) void Create(wxObject *o, wxxVariant *args)
@@ -1220,6 +1321,10 @@ public:
// find handler by name // find handler by name
virtual const wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *PropertyName) const ; virtual const wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *PropertyName) const ;
// puts all the properties of this class and its superclasses in the map, as long as there is not yet
// an entry with the same name (overriding mechanism)
void GetProperties( wxPropertyInfoMap &map ) const ;
public: public:
const wxChar *m_className; const wxChar *m_className;
int m_objectSize; int m_objectSize;
@@ -1308,13 +1413,15 @@ public :
static const wxClassInfo* sm_classParents##name[] ; \ static const wxClassInfo* sm_classParents##name[] ; \
static wxPropertyInfo* GetPropertiesStatic() ; \ static wxPropertyInfo* GetPropertiesStatic() ; \
static wxHandlerInfo* GetHandlersStatic() ; \ static wxHandlerInfo* GetHandlersStatic() ; \
static wxClassInfo *GetClassInfoStatic() \
{ return &name::sm_class##name; } \
virtual wxClassInfo *GetClassInfo() const \ virtual wxClassInfo *GetClassInfo() const \
{ return &name::sm_class##name; } { return &name::sm_class##name; }
#define DECLARE_DYNAMIC_CLASS(name) \ #define DECLARE_DYNAMIC_CLASS(name) \
static wxConstructorBridge* sm_constructor##name ; \ static wxConstructorBridge* sm_constructor##name ; \
static const wxChar * sm_constructorProperties##name[] ; \ static const wxChar * sm_constructorProperties##name[] ; \
static const int sm_constructorPropertiesCount##name ; \ static const int sm_constructorPropertiesCount##name ; \
_DECLARE_DYNAMIC_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
@@ -1332,14 +1439,14 @@ static const int sm_constructorPropertiesCount##name ; \
// for concrete classes // for concrete classes
// ----------------------------------- // -----------------------------------
// Single inheritance with one base class // Single inheritance with one base class
#define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \ #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \
wxObject* wxConstructorFor##name() \ wxObject* wxConstructorFor##name() \
{ return new name; } \ { return new name; } \
const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \ const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \ wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
(int) sizeof(name), \ (int) sizeof(name), \
(wxObjectConstructorFn) wxConstructorFor##name , \ (wxObjectConstructorFn) wxConstructorFor##name , \
@@ -1357,11 +1464,11 @@ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVaria
#define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \ #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \
wxObject* wxConstructorFor##name() \ wxObject* wxConstructorFor##name() \
{ return new name; } \ { return new name; } \
const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \ const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \ wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \ wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
(int) sizeof(name), \ (int) sizeof(name), \
(wxObjectConstructorFn) wxConstructorFor##name , \ (wxObjectConstructorFn) wxConstructorFor##name , \
@@ -1378,22 +1485,22 @@ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVaria
template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \ #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
_IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \
const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
WX_CONSTRUCTOR_DUMMY( name ) WX_CONSTRUCTOR_DUMMY( name )
#define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \ #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
_IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \ _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \
wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
WX_CONSTRUCTOR_DUMMY( name ) WX_CONSTRUCTOR_DUMMY( name )
#define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \ #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
_IMPLEMENT_DYNAMIC_CLASS( name , basename , unit ) _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit )
#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \ #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
_IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit ) _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
// this is for classes that do not derive from wxobject, there are no creators for these // this is for classes that do not derive from wxobject, there are no creators for these
@@ -1430,11 +1537,11 @@ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
// Multiple inheritance with two base classes // Multiple inheritance with two base classes
#define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \ #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
wxObject* wxConstructorFor##name() \ wxObject* wxConstructorFor##name() \
{ return new name; } \ { return new name; } \
const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \ const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
@@ -1452,10 +1559,10 @@ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
#define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \ #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
_IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \ _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
WX_CONSTRUCTOR_DUMMY( name ) WX_CONSTRUCTOR_DUMMY( name )
#define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \ #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
_IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit) _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
@@ -1464,13 +1571,13 @@ WX_CONSTRUCTOR_DUMMY( name )
// for abstract classes // for abstract classes
// ----------------------------------- // -----------------------------------
// Single inheritance with one base class // Single inheritance with one base class
#define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \ #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \ const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \ wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
(int) sizeof(name), \ (int) sizeof(name), \
(wxObjectConstructorFn) 0 , \ (wxObjectConstructorFn) 0 , \
@@ -1485,11 +1592,11 @@ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVaria
template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
#define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \ #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
_IMPLEMENT_ABSTRACT_CLASS( name , basename ) \ _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
// Multiple inheritance with two base classes // Multiple inheritance with two base classes
#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \ wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
@@ -1515,7 +1622,7 @@ template<typename collection_t> void wxListCollectionToVariantArray( const colle
template<typename collection_t> void wxArrayCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value ) template<typename collection_t> void wxArrayCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value )
{ {
for( int i = 0 ; i < coll.GetCount() ; i++ ) for( size_t i = 0 ; i < coll.GetCount() ; i++ )
{ {
value.Add( new wxxVariant(coll[i]) ) ; value.Add( new wxxVariant(coll[i]) ) ;
} }

View File

@@ -142,6 +142,7 @@ private :
struct wxWriterInternalPropertiesData ; struct wxWriterInternalPropertiesData ;
void WriteAllProperties( const wxObject * obj , const wxClassInfo* ci , wxPersister *persister, wxWriterInternalPropertiesData * data ) ; void WriteAllProperties( const wxObject * obj , const wxClassInfo* ci , wxPersister *persister, wxWriterInternalPropertiesData * data ) ;
void WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , const wxPropertyInfo* pi , wxPersister *persister , wxWriterInternalPropertiesData *data ) ;
void WriteObject(const wxObject *object, const wxClassInfo *classInfo , wxPersister *persister , bool isEmbedded, wxxVariantArray &metadata ) ; void WriteObject(const wxObject *object, const wxClassInfo *classInfo , wxPersister *persister , bool isEmbedded, wxxVariantArray &metadata ) ;
void FindConnectEntry(const wxWindow * evSource,const wxDelegateTypeInfo* dti, const wxObject* &sink , const wxHandlerInfo *&handler) ; void FindConnectEntry(const wxWindow * evSource,const wxDelegateTypeInfo* dti, const wxObject* &sink , const wxHandlerInfo *&handler) ;
} ; } ;