2003-07-28 04:10:54 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2003-10-17 15:50:46 -04:00
|
|
|
// Name: wx/xti.h
|
2003-07-28 04:10:54 -04:00
|
|
|
// Purpose: runtime metadata information (extended class info)
|
|
|
|
// Author: Stefan Csomor
|
2011-01-04 03:31:53 -05:00
|
|
|
// Modified by: Francesco Montorsi
|
2003-07-28 04:10:54 -04:00
|
|
|
// Created: 27/07/03
|
|
|
|
// Copyright: (c) 1997 Julian Smart
|
|
|
|
// (c) 2003 Stefan Csomor
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-07-28 04:10:54 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_XTIH__
|
|
|
|
#define _WX_XTIH__
|
|
|
|
|
|
|
|
// We want to support properties, event sources and events sinks through
|
|
|
|
// explicit declarations, using templates and specialization to make the
|
2003-07-30 13:55:53 -04:00
|
|
|
// effort as painless as possible.
|
2003-07-28 04:10:54 -04:00
|
|
|
//
|
|
|
|
// This means we have the following domains :
|
|
|
|
//
|
|
|
|
// - Type Information for categorizing built in types as well as custom types
|
2011-01-04 03:31:53 -05:00
|
|
|
// this includes information about enums, their values and names
|
2011-01-07 12:22:59 -05:00
|
|
|
// - Type safe value storage : a kind of wxVariant, called right now wxAny
|
2011-01-04 03:31:53 -05:00
|
|
|
// which will be merged with wxVariant
|
2003-07-28 04:10:54 -04:00
|
|
|
// - Property Information and Property Accessors providing access to a class'
|
2011-01-04 03:31:53 -05:00
|
|
|
// values and exposed event delegates
|
2003-07-28 04:10:54 -04:00
|
|
|
// - Information about event handlers
|
|
|
|
// - extended Class Information for accessing all these
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
2004-04-15 18:51:57 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
#if wxUSE_EXTENDED_RTTI
|
2003-08-13 12:59:46 -04:00
|
|
|
|
2011-01-07 12:22:59 -05:00
|
|
|
class WXDLLIMPEXP_FWD_BASE wxAny;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxAnyList;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxObject;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxString;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxClassInfo;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxHashTable;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxObject;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxPluginLibrary;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxHashTable;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxHashTable_Node;
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxStringToAnyHashMap;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxPropertyInfoMap;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxPropertyAccessor;
|
2011-01-07 17:52:46 -05:00
|
|
|
class WXDLLIMPEXP_FWD_BASE wxObjectAllocatorAndCreator;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxObjectAllocator;
|
|
|
|
|
2011-01-07 12:22:59 -05:00
|
|
|
|
|
|
|
#define wx_dynamic_cast(t, x) dynamic_cast<t>(x)
|
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
#include "wx/xtitypes.h"
|
|
|
|
#include "wx/xtihandler.h"
|
2003-07-28 04:10:54 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxClassInfo
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2011-01-07 12:22:59 -05:00
|
|
|
class WXDLLIMPEXP_BASE wxObjectFunctor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~wxObjectFunctor();
|
|
|
|
|
|
|
|
// Invoke the actual event handler:
|
|
|
|
virtual void operator()(const wxObject *) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxPropertyInfo;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxHandlerInfo;
|
2011-01-04 03:31:53 -05:00
|
|
|
|
2003-07-28 04:10:54 -04:00
|
|
|
typedef wxObject *(*wxObjectConstructorFn)(void);
|
2011-01-07 12:22:59 -05:00
|
|
|
typedef wxPropertyInfo *(*wxPropertyInfoFn)(void);
|
|
|
|
typedef wxHandlerInfo *(*wxHandlerInfoFn)(void);
|
|
|
|
typedef void (*wxVariantToObjectConverter)( const wxAny &data, wxObjectFunctor* fn );
|
|
|
|
typedef wxObject* (*wxVariantToObjectPtrConverter) ( const wxAny& data);
|
|
|
|
typedef wxAny (*wxObjectToVariantConverter)( wxObject* );
|
|
|
|
|
|
|
|
WXDLLIMPEXP_BASE wxString wxAnyGetAsString( const wxAny& data);
|
|
|
|
WXDLLIMPEXP_BASE const wxObject* wxAnyGetAsObjectPtr( const wxAny& data);
|
2003-08-24 19:36:46 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
class WXDLLIMPEXP_BASE wxObjectWriter;
|
2011-01-07 12:22:59 -05:00
|
|
|
class WXDLLIMPEXP_BASE wxObjectWriterCallback;
|
2003-08-24 19:36:46 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
typedef bool (*wxObjectStreamingCallback) ( const wxObject *, wxObjectWriter *, \
|
2011-01-07 12:22:59 -05:00
|
|
|
wxObjectWriterCallback *, const wxStringToAnyHashMap & );
|
|
|
|
|
|
|
|
|
2003-07-28 04:10:54 -04:00
|
|
|
|
|
|
|
class WXDLLIMPEXP_BASE wxClassInfo
|
|
|
|
{
|
2011-01-04 03:31:53 -05:00
|
|
|
friend class WXDLLIMPEXP_BASE wxPropertyInfo;
|
2012-01-19 04:00:29 -05:00
|
|
|
friend class /* WXDLLIMPEXP_BASE */ wxHandlerInfo;
|
2011-01-07 12:22:59 -05:00
|
|
|
friend wxObject *wxCreateDynamicObject(const wxString& name);
|
2011-01-04 03:31:53 -05:00
|
|
|
|
2003-07-28 04:10:54 -04:00
|
|
|
public:
|
|
|
|
wxClassInfo(const wxClassInfo **_Parents,
|
2011-01-04 03:31:53 -05:00
|
|
|
const wxChar *_UnitName,
|
|
|
|
const wxChar *_ClassName,
|
|
|
|
int size,
|
|
|
|
wxObjectConstructorFn ctor,
|
2011-01-07 12:22:59 -05:00
|
|
|
wxPropertyInfoFn _Props,
|
|
|
|
wxHandlerInfoFn _Handlers,
|
2011-01-04 03:31:53 -05:00
|
|
|
wxObjectAllocatorAndCreator* _Constructor,
|
|
|
|
const wxChar ** _ConstructorProperties,
|
|
|
|
const int _ConstructorPropertiesCount,
|
2011-01-07 12:22:59 -05:00
|
|
|
wxVariantToObjectPtrConverter _PtrConverter1,
|
2011-01-04 03:31:53 -05:00
|
|
|
wxVariantToObjectConverter _Converter2,
|
|
|
|
wxObjectToVariantConverter _Converter3,
|
|
|
|
wxObjectStreamingCallback _streamingCallback = NULL) :
|
2003-08-24 08:55:22 -04:00
|
|
|
m_className(_ClassName),
|
|
|
|
m_objectSize(size),
|
|
|
|
m_objectConstructor(ctor),
|
|
|
|
m_next(sm_first),
|
2011-01-07 12:22:59 -05:00
|
|
|
m_firstPropertyFn(_Props),
|
|
|
|
m_firstHandlerFn(_Handlers),
|
|
|
|
m_firstProperty(NULL),
|
|
|
|
m_firstHandler(NULL),
|
|
|
|
m_firstInited(false),
|
2003-08-24 08:55:22 -04:00
|
|
|
m_parents(_Parents),
|
2003-08-25 19:29:55 -04:00
|
|
|
m_unitName(_UnitName),
|
2003-08-24 08:55:22 -04:00
|
|
|
m_constructor(_Constructor),
|
|
|
|
m_constructorProperties(_ConstructorProperties),
|
|
|
|
m_constructorPropertiesCount(_ConstructorPropertiesCount),
|
|
|
|
m_variantOfPtrToObjectConverter(_PtrConverter1),
|
|
|
|
m_variantToObjectConverter(_Converter2),
|
|
|
|
m_objectToVariantConverter(_Converter3),
|
|
|
|
m_streamingCallback(_streamingCallback)
|
2003-08-22 20:37:55 -04:00
|
|
|
{
|
|
|
|
sm_first = this;
|
2011-01-04 03:31:53 -05:00
|
|
|
Register();
|
2003-08-22 20:37:55 -04:00
|
|
|
}
|
|
|
|
|
2003-08-24 08:55:22 -04:00
|
|
|
wxClassInfo(const wxChar *_UnitName, const wxChar *_ClassName,
|
2003-08-25 19:29:55 -04:00
|
|
|
const wxClassInfo **_Parents) :
|
2003-08-24 08:55:22 -04:00
|
|
|
m_className(_ClassName),
|
|
|
|
m_objectSize(0),
|
|
|
|
m_objectConstructor(NULL),
|
|
|
|
m_next(sm_first),
|
2011-01-07 12:22:59 -05:00
|
|
|
m_firstPropertyFn(NULL),
|
|
|
|
m_firstHandlerFn(NULL),
|
2003-08-24 08:55:22 -04:00
|
|
|
m_firstProperty(NULL),
|
|
|
|
m_firstHandler(NULL),
|
2011-01-07 12:22:59 -05:00
|
|
|
m_firstInited(true),
|
2003-08-24 08:55:22 -04:00
|
|
|
m_parents(_Parents),
|
|
|
|
m_unitName(_UnitName),
|
|
|
|
m_constructor(NULL),
|
|
|
|
m_constructorProperties(NULL),
|
|
|
|
m_constructorPropertiesCount(0),
|
|
|
|
m_variantOfPtrToObjectConverter(NULL),
|
|
|
|
m_variantToObjectConverter(NULL),
|
|
|
|
m_objectToVariantConverter(NULL),
|
|
|
|
m_streamingCallback(NULL)
|
2003-08-22 20:37:55 -04:00
|
|
|
{
|
|
|
|
sm_first = this;
|
2011-01-04 03:31:53 -05:00
|
|
|
Register();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ctor compatible with old RTTI system
|
|
|
|
wxClassInfo(const wxChar *_ClassName,
|
|
|
|
const wxClassInfo *_Parent1,
|
|
|
|
const wxClassInfo *_Parent2,
|
|
|
|
int size,
|
|
|
|
wxObjectConstructorFn ctor) :
|
|
|
|
m_className(_ClassName),
|
|
|
|
m_objectSize(size),
|
|
|
|
m_objectConstructor(ctor),
|
|
|
|
m_next(sm_first),
|
2011-01-07 12:22:59 -05:00
|
|
|
m_firstPropertyFn(NULL),
|
|
|
|
m_firstHandlerFn(NULL),
|
2011-01-04 03:31:53 -05:00
|
|
|
m_firstProperty(NULL),
|
|
|
|
m_firstHandler(NULL),
|
2011-01-07 12:22:59 -05:00
|
|
|
m_firstInited(true),
|
2011-01-04 03:31:53 -05:00
|
|
|
m_parents(NULL),
|
|
|
|
m_unitName(NULL),
|
|
|
|
m_constructor(NULL),
|
|
|
|
m_constructorProperties(NULL),
|
|
|
|
m_constructorPropertiesCount(0),
|
|
|
|
m_variantOfPtrToObjectConverter(NULL),
|
|
|
|
m_variantToObjectConverter(NULL),
|
|
|
|
m_objectToVariantConverter(NULL),
|
|
|
|
m_streamingCallback(NULL)
|
|
|
|
{
|
|
|
|
sm_first = this;
|
|
|
|
m_parents[0] = _Parent1;
|
|
|
|
m_parents[1] = _Parent2;
|
|
|
|
m_parents[2] = NULL;
|
|
|
|
Register();
|
2003-08-22 20:37:55 -04:00
|
|
|
}
|
2003-08-11 06:01:02 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual ~wxClassInfo();
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
// allocates an instance of this class, this object does not have to be
|
|
|
|
// initialized or fully constructed as this call will be followed by a call to Create
|
|
|
|
virtual wxObject *AllocateObject() const
|
|
|
|
{ return m_objectConstructor ? (*m_objectConstructor)() : 0; }
|
2003-08-13 12:59:46 -04:00
|
|
|
|
|
|
|
// 'old naming' for AllocateObject staying here for backward compatibility
|
2011-01-04 03:31:53 -05:00
|
|
|
wxObject *CreateObject() const { return AllocateObject(); }
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-25 19:29:55 -04:00
|
|
|
// direct construction call for classes that cannot construct instances via alloc/create
|
2011-01-07 12:22:59 -05:00
|
|
|
wxObject *ConstructObject(int ParamCount, wxAny *Params) const;
|
2003-08-25 19:29:55 -04:00
|
|
|
|
2011-01-07 17:52:46 -05:00
|
|
|
bool NeedsDirectConstruction() const;
|
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
const wxChar *GetClassName() const
|
|
|
|
{ return m_className; }
|
2003-09-03 06:02:47 -04:00
|
|
|
const wxChar *GetBaseClassName1() const
|
|
|
|
{ return m_parents[0] ? m_parents[0]->GetClassName() : NULL; }
|
|
|
|
const wxChar *GetBaseClassName2() const
|
|
|
|
{ return (m_parents[0] && m_parents[1]) ? m_parents[1]->GetClassName() : NULL; }
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
const wxClassInfo *GetBaseClass1() const
|
|
|
|
{ return m_parents[0]; }
|
|
|
|
const wxClassInfo *GetBaseClass2() const
|
|
|
|
{ return m_parents[0] ? m_parents[1] : NULL; }
|
|
|
|
|
|
|
|
const wxChar *GetIncludeName() const
|
|
|
|
{ return m_unitName; }
|
|
|
|
const wxClassInfo **GetParents() const
|
|
|
|
{ return m_parents; }
|
|
|
|
int GetSize() const
|
|
|
|
{ return m_objectSize; }
|
|
|
|
bool IsDynamic() const
|
|
|
|
{ return (NULL != m_objectConstructor); }
|
|
|
|
|
|
|
|
wxObjectConstructorFn GetConstructor() const
|
|
|
|
{ return m_objectConstructor; }
|
|
|
|
const wxClassInfo *GetNext() const
|
|
|
|
{ return m_next; }
|
|
|
|
|
|
|
|
// statics:
|
|
|
|
|
|
|
|
static void CleanUp();
|
2011-01-07 12:22:59 -05:00
|
|
|
static wxClassInfo *FindClass(const wxString& className);
|
2011-01-04 03:31:53 -05:00
|
|
|
static const wxClassInfo *GetFirst()
|
|
|
|
{ return sm_first; }
|
|
|
|
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-22 20:37:55 -04:00
|
|
|
// Climb upwards through inheritance hierarchy.
|
|
|
|
// Dual inheritance is catered for.
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
bool IsKindOf(const wxClassInfo *info) const;
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-07 12:22:59 -05:00
|
|
|
wxDECLARE_CLASS_INFO_ITERATORS();
|
2007-04-15 07:43:37 -04:00
|
|
|
|
2003-08-24 08:55:22 -04:00
|
|
|
// if there is a callback registered with that class it will be called
|
|
|
|
// before this object will be written to disk, it can veto streaming out
|
|
|
|
// this object by returning false, if this class has not registered a
|
|
|
|
// callback, the search will go up the inheritance tree if no callback has
|
|
|
|
// been registered true will be returned by default
|
2011-01-07 12:22:59 -05:00
|
|
|
bool BeforeWriteObject( const wxObject *obj, wxObjectWriter *streamer,
|
|
|
|
wxObjectWriterCallback *writercallback, const wxStringToAnyHashMap &metadata) const;
|
2003-08-23 15:40:04 -04:00
|
|
|
|
|
|
|
// gets the streaming callback from this class or any superclass
|
2011-01-04 03:31:53 -05:00
|
|
|
wxObjectStreamingCallback GetStreamingCallback() const;
|
2003-08-14 14:51:07 -04:00
|
|
|
|
2003-08-04 04:39:41 -04:00
|
|
|
// returns the first property
|
2011-01-07 12:22:59 -05:00
|
|
|
wxPropertyInfo* GetFirstProperty() const
|
|
|
|
{ EnsureInfosInited(); return m_firstProperty; }
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-04 04:39:41 -04:00
|
|
|
// returns the first handler
|
2011-01-07 12:22:59 -05:00
|
|
|
wxHandlerInfo* GetFirstHandler() const
|
|
|
|
{ EnsureInfosInited(); return m_firstHandler; }
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-13 12:59:46 -04:00
|
|
|
// Call the Create upon an instance of the class, in the end the object is fully
|
|
|
|
// initialized
|
2011-01-07 12:22:59 -05:00
|
|
|
virtual bool Create (wxObject *object, int ParamCount, wxAny *Params) const;
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-04 04:39:41 -04:00
|
|
|
// get number of parameters for constructor
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual int GetCreateParamCount() const
|
|
|
|
{ return m_constructorPropertiesCount; }
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-13 12:59:46 -04:00
|
|
|
// get n-th constructor parameter
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual const wxChar* GetCreateParamName(int n) const
|
|
|
|
{ return m_constructorProperties[n]; }
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
// Runtime access to objects for simple properties (get/set) by property
|
|
|
|
// name and variant data
|
|
|
|
virtual void SetProperty (wxObject *object, const wxChar *propertyName,
|
2011-01-07 12:22:59 -05:00
|
|
|
const wxAny &value) const;
|
|
|
|
virtual wxAny GetProperty (wxObject *object, const wxChar *propertyName) const;
|
2003-08-13 12:59:46 -04:00
|
|
|
|
|
|
|
// Runtime access to objects for collection properties by property name
|
2011-01-07 12:22:59 -05:00
|
|
|
virtual wxAnyList GetPropertyCollection(wxObject *object,
|
2011-01-04 03:31:53 -05:00
|
|
|
const wxChar *propertyName) const;
|
|
|
|
virtual void AddToPropertyCollection(wxObject *object, const wxChar *propertyName,
|
2011-01-07 12:22:59 -05:00
|
|
|
const wxAny& value) const;
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
// we must be able to cast variants to wxObject pointers, templates seem
|
|
|
|
// not to be suitable
|
2011-01-07 12:22:59 -05:00
|
|
|
void CallOnAny( const wxAny &data, wxObjectFunctor* functor ) const;
|
|
|
|
|
|
|
|
wxObject* AnyToObjectPtr( const wxAny &data) const;
|
2003-08-05 12:50:30 -04:00
|
|
|
|
2011-01-07 12:22:59 -05:00
|
|
|
wxAny ObjectPtrToAny( wxObject *object ) const;
|
2003-07-30 13:55:53 -04:00
|
|
|
|
2003-08-04 04:39:41 -04:00
|
|
|
// find property by name
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual const wxPropertyInfo *FindPropertyInfo (const wxChar *PropertyName) const;
|
2003-07-28 16:16:51 -04:00
|
|
|
|
2003-08-04 04:39:41 -04:00
|
|
|
// find handler by name
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual const wxHandlerInfo *FindHandlerInfo (const wxChar *handlerName) const;
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-11 06:01:02 -04:00
|
|
|
// find property by name
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual wxPropertyInfo *FindPropertyInfoInThisClass (const wxChar *PropertyName) const;
|
2003-08-11 06:01:02 -04:00
|
|
|
|
|
|
|
// find handler by name
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *handlerName) 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;
|
2003-08-22 20:37:55 -04:00
|
|
|
|
2007-04-15 07:43:37 -04:00
|
|
|
private:
|
2003-07-28 04:10:54 -04:00
|
|
|
const wxChar *m_className;
|
|
|
|
int m_objectSize;
|
2011-01-04 03:31:53 -05:00
|
|
|
wxObjectConstructorFn m_objectConstructor;
|
2003-07-28 04:10:54 -04:00
|
|
|
|
|
|
|
// class info object live in a linked list:
|
|
|
|
// pointers to its head and the next element in it
|
|
|
|
|
|
|
|
static wxClassInfo *sm_first;
|
2011-01-04 03:31:53 -05:00
|
|
|
wxClassInfo *m_next;
|
2003-07-28 04:10:54 -04:00
|
|
|
|
|
|
|
static wxHashTable *sm_classTable;
|
|
|
|
|
2011-01-07 12:22:59 -05:00
|
|
|
wxPropertyInfoFn m_firstPropertyFn;
|
|
|
|
wxHandlerInfoFn m_firstHandlerFn;
|
|
|
|
|
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
protected:
|
2011-01-07 12:22:59 -05:00
|
|
|
void EnsureInfosInited() const
|
|
|
|
{
|
|
|
|
if ( !m_firstInited)
|
|
|
|
{
|
|
|
|
if ( m_firstPropertyFn != NULL)
|
|
|
|
m_firstProperty = (*m_firstPropertyFn)();
|
|
|
|
if ( m_firstHandlerFn != NULL)
|
|
|
|
m_firstHandler = (*m_firstHandlerFn)();
|
|
|
|
m_firstInited = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutable wxPropertyInfo* m_firstProperty;
|
|
|
|
mutable wxHandlerInfo* m_firstHandler;
|
2011-01-04 03:31:53 -05:00
|
|
|
|
2003-07-28 04:10:54 -04:00
|
|
|
private:
|
2012-01-19 04:00:29 -05:00
|
|
|
mutable bool m_firstInited;
|
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
const wxClassInfo** m_parents;
|
|
|
|
const wxChar* m_unitName;
|
|
|
|
|
|
|
|
wxObjectAllocatorAndCreator* m_constructor;
|
|
|
|
const wxChar ** m_constructorProperties;
|
|
|
|
const int m_constructorPropertiesCount;
|
2011-01-07 12:22:59 -05:00
|
|
|
wxVariantToObjectPtrConverter m_variantOfPtrToObjectConverter;
|
2011-01-04 03:31:53 -05:00
|
|
|
wxVariantToObjectConverter m_variantToObjectConverter;
|
|
|
|
wxObjectToVariantConverter m_objectToVariantConverter;
|
|
|
|
wxObjectStreamingCallback m_streamingCallback;
|
|
|
|
|
|
|
|
const wxPropertyAccessor *FindAccessor (const wxChar *propertyName) const;
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-06 06:44:48 -04:00
|
|
|
protected:
|
|
|
|
// registers the class
|
|
|
|
void Register();
|
|
|
|
void Unregister();
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxClassInfo);
|
2003-07-28 04:10:54 -04:00
|
|
|
};
|
|
|
|
|
2011-01-07 12:22:59 -05:00
|
|
|
WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2003-08-11 06:01:02 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2011-01-04 03:31:53 -05:00
|
|
|
// wxDynamicClassInfo
|
2003-08-11 06:01:02 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2011-01-04 03:31:53 -05:00
|
|
|
|
2003-08-11 06:01:02 -04:00
|
|
|
// this object leads to having a pure runtime-instantiation
|
|
|
|
|
2003-08-24 19:36:46 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxDynamicClassInfo : public wxClassInfo
|
2003-08-11 06:01:02 -04:00
|
|
|
{
|
2011-01-04 03:31:53 -05:00
|
|
|
friend class WXDLLIMPEXP_BASE wxDynamicObject;
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxDynamicClassInfo( const wxChar *_UnitName, const wxChar *_ClassName,
|
|
|
|
const wxClassInfo* superClass );
|
|
|
|
virtual ~wxDynamicClassInfo();
|
2003-08-11 06:01:02 -04:00
|
|
|
|
|
|
|
// constructs a wxDynamicObject with an instance
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual wxObject *AllocateObject() const;
|
2003-08-11 06:01:02 -04:00
|
|
|
|
|
|
|
// Call the Create method for a class
|
2011-01-07 12:22:59 -05:00
|
|
|
virtual bool Create (wxObject *object, int ParamCount, wxAny *Params) const;
|
2003-08-11 06:01:02 -04:00
|
|
|
|
|
|
|
// get number of parameters for constructor
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual int GetCreateParamCount() const;
|
2003-08-11 06:01:02 -04:00
|
|
|
|
|
|
|
// get i-th constructor parameter
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual const wxChar* GetCreateParamName(int i) const;
|
2003-08-11 06:01:02 -04:00
|
|
|
|
|
|
|
// Runtime access to objects by property name, and variant data
|
2011-01-04 03:31:53 -05:00
|
|
|
virtual void SetProperty (wxObject *object, const wxChar *PropertyName,
|
2011-01-07 12:22:59 -05:00
|
|
|
const wxAny &Value) const;
|
|
|
|
virtual wxAny GetProperty (wxObject *object, const wxChar *PropertyName) const;
|
2003-08-11 06:01:02 -04:00
|
|
|
|
2003-08-24 08:22:08 -04:00
|
|
|
// adds a property to this class at runtime
|
2011-01-04 03:31:53 -05:00
|
|
|
void AddProperty( const wxChar *propertyName, const wxTypeInfo* typeInfo );
|
2003-08-24 08:22:08 -04:00
|
|
|
|
|
|
|
// removes an existing runtime-property
|
2011-01-04 03:31:53 -05:00
|
|
|
void RemoveProperty( const wxChar *propertyName );
|
2003-08-24 08:22:08 -04:00
|
|
|
|
2003-08-24 19:36:46 -04:00
|
|
|
// renames an existing runtime-property
|
2011-01-04 03:31:53 -05:00
|
|
|
void RenameProperty( const wxChar *oldPropertyName, const wxChar *newPropertyName );
|
2003-08-24 19:36:46 -04:00
|
|
|
|
2003-08-24 08:22:08 -04:00
|
|
|
// as a handler to this class at runtime
|
2011-01-04 03:31:53 -05:00
|
|
|
void AddHandler( const wxChar *handlerName, wxObjectEventFunction address,
|
|
|
|
const wxClassInfo* eventClassInfo );
|
2003-08-24 08:22:08 -04:00
|
|
|
|
|
|
|
// removes an existing runtime-handler
|
2011-01-04 03:31:53 -05:00
|
|
|
void RemoveHandler( const wxChar *handlerName );
|
2003-08-24 19:36:46 -04:00
|
|
|
|
|
|
|
// renames an existing runtime-handler
|
2011-01-04 03:31:53 -05:00
|
|
|
void RenameHandler( const wxChar *oldHandlerName, const wxChar *newHandlerName );
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct wxDynamicClassInfoInternal;
|
|
|
|
wxDynamicClassInfoInternal* m_data;
|
|
|
|
};
|
|
|
|
|
2003-07-28 04:10:54 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2011-01-04 03:31:53 -05:00
|
|
|
// wxDECLARE class macros
|
2003-07-28 04:10:54 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
#define _DECLARE_DYNAMIC_CLASS(name) \
|
|
|
|
public: \
|
|
|
|
static wxClassInfo ms_classInfo; \
|
|
|
|
static const wxClassInfo* ms_classParents[]; \
|
|
|
|
static wxPropertyInfo* GetPropertiesStatic(); \
|
|
|
|
static wxHandlerInfo* GetHandlersStatic(); \
|
|
|
|
static wxClassInfo *GetClassInfoStatic() \
|
|
|
|
{ return &name::ms_classInfo; } \
|
|
|
|
virtual wxClassInfo *GetClassInfo() const \
|
|
|
|
{ return &name::ms_classInfo; }
|
|
|
|
|
|
|
|
#define wxDECLARE_DYNAMIC_CLASS(name) \
|
|
|
|
static wxObjectAllocatorAndCreator* ms_constructor; \
|
|
|
|
static const wxChar * ms_constructorProperties[]; \
|
|
|
|
static const int ms_constructorPropertiesCount; \
|
2003-08-05 17:25:58 -04:00
|
|
|
_DECLARE_DYNAMIC_CLASS(name)
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
#define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
|
2011-01-07 12:22:59 -05:00
|
|
|
wxDECLARE_NO_ASSIGN_CLASS(name); \
|
2011-01-04 03:31:53 -05:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(name)
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
#define wxDECLARE_DYNAMIC_CLASS_NO_COPY(name) \
|
2011-01-07 12:22:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(name); \
|
|
|
|
wxDECLARE_DYNAMIC_CLASS(name)
|
|
|
|
|
|
|
|
#define wxDECLARE_CLASS(name) \
|
2011-01-04 03:31:53 -05:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(name)
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
#define wxDECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
|
|
|
|
#define wxCLASSINFO(name) (&name::ms_classInfo)
|
2003-07-28 04:10:54 -04:00
|
|
|
|
2011-01-04 03:31:53 -05:00
|
|
|
#endif // wxUSE_EXTENDED_RTTI
|
2005-11-15 02:40:12 -05:00
|
|
|
#endif // _WX_XTIH__
|