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;
@@ -117,7 +118,9 @@ private :
{ \ { \
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* & ) \
{ \ { \
@@ -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,17 +203,23 @@ 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>
@@ -662,11 +727,11 @@ 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 ;
@@ -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,6 +827,8 @@ 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() \
{ \ { \
@@ -747,33 +840,41 @@ 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 ) ; \
@@ -788,7 +889,7 @@ private :
#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 ;
}; };
@@ -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,6 +1413,8 @@ 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; }
@@ -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) ;
} ; } ;