]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/xti.h
Rebake from clean wx tree.
[wxWidgets.git] / include / wx / xti.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/xti.h
3// Purpose: runtime metadata information (extended class info)
4// Author: Stefan Csomor
5// Modified by:
6// Created: 27/07/03
7// RCS-ID: $Id$
8// Copyright: (c) 1997 Julian Smart
9// (c) 2003 Stefan Csomor
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef _WX_XTIH__
14#define _WX_XTIH__
15
16// We want to support properties, event sources and events sinks through
17// explicit declarations, using templates and specialization to make the
18// effort as painless as possible.
19//
20// This means we have the following domains :
21//
22// - Type Information for categorizing built in types as well as custom types
23// this includes information about enums, their values and names
24// - Type safe value storage : a kind of wxVariant, called right now wxxVariant
25// which will be merged with wxVariant
26// - Property Information and Property Accessors providing access to a class'
27// values and exposed event delegates
28// - Information about event handlers
29// - extended Class Information for accessing all these
30
31// ----------------------------------------------------------------------------
32// headers
33// ----------------------------------------------------------------------------
34
35#include "wx/defs.h"
36#include "wx/memory.h"
37#include "wx/flags.h"
38#include "wx/string.h"
39#include "wx/arrstr.h"
40#include "wx/hashmap.h"
41#include "wx/log.h"
42#include "wx/intl.h"
43
44#include <typeinfo>
45
46// we will move this later to defs.h
47
48#if defined(__GNUC__) && !wxCHECK_GCC_VERSION( 3 , 4 )
49# define wxUSE_MEMBER_TEMPLATES 0
50#endif
51
52#if defined(_MSC_VER) && _MSC_VER <= 1200
53# define wxUSE_MEMBER_TEMPLATES 0
54# define wxUSE_FUNC_TEMPLATE_POINTER 0
55#endif
56
57#ifndef wxUSE_MEMBER_TEMPLATES
58# define wxUSE_MEMBER_TEMPLATES 1
59#endif
60
61#ifndef wxUSE_FUNC_TEMPLATE_POINTER
62# define wxUSE_FUNC_TEMPLATE_POINTER 1
63#endif
64
65#if wxUSE_MEMBER_TEMPLATES
66# define wxTEMPLATED_MEMBER_CALL( method , type ) method<type>()
67# define wxTEMPLATED_MEMBER_FIX( type )
68#else
69# define wxTEMPLATED_MEMBER_CALL( method , type ) method(NULL)
70# define wxTEMPLATED_MEMBER_FIX( type ) type* =NULL
71#endif
72
73#if defined(_MSC_VER) && _MSC_VER <= 1200
74# define wxTEMPLATED_FUNCTION_FIX( type ) , wxTEMPLATED_MEMBER_FIX(type)
75# define wxINFUNC_CLASS_TYPE_FIX( type ) typedef type type;
76#else
77# define wxTEMPLATED_FUNCTION_FIX( type )
78# define wxINFUNC_CLASS_TYPE_FIX( type )
79#endif
80
81#define EMPTY_MACROVALUE /**/
82
83class WXDLLIMPEXP_FWD_BASE wxObject;
84class WXDLLIMPEXP_FWD_BASE wxClassInfo;
85class WXDLLIMPEXP_FWD_BASE wxDynamicClassInfo;
86class WXDLLIMPEXP_FWD_BASE wxHashTable;
87class WXDLLIMPEXP_FWD_BASE wxHashTable_Node;
88class WXDLLIMPEXP_FWD_BASE wxObjectRefData;
89class WXDLLIMPEXP_FWD_BASE wxEvent;
90class WXDLLIMPEXP_FWD_BASE wxEvtHandler;
91
92typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
93
94#if wxUSE_FUNC_TEMPLATE_POINTER
95# define wxTO_STRING(type) wxToStringConverter<type>
96# define wxTO_STRING_IMP(type)
97# define wxFROM_STRING(type) wxFromStringConverter<type>
98# define wxFROM_STRING_IMP(type)
99#else
100# define wxTO_STRING(type) ToString##type
101# define wxTO_STRING_IMP(type) inline void ToString##type( const wxxVariant& data , wxString &result ) { wxToStringConverter<type>(data, result); }
102# define wxFROM_STRING(type) FromString##type
103# define wxFROM_STRING_IMP(type) inline void FromString##type( const wxString& data , wxxVariant &result ) { wxFromStringConverter<type>(data, result); }
104#endif
105
106// ----------------------------------------------------------------------------
107// Enum Support
108//
109// In the header files there would no change from pure c++ code, in the
110// implementation, an enum would have
111// to be enumerated eg :
112//
113// wxBEGIN_ENUM( wxFlavor )
114// wxENUM_MEMBER( Vanilla )
115// wxENUM_MEMBER( Chocolate )
116// wxENUM_MEMBER( Strawberry )
117// wxEND_ENUM( wxFlavor )
118// ----------------------------------------------------------------------------
119
120struct WXDLLIMPEXP_BASE wxEnumMemberData
121{
122 const wxChar* m_name;
123 int m_value;
124};
125
126class WXDLLIMPEXP_BASE wxEnumData
127{
128public :
129 wxEnumData( wxEnumMemberData* data ) ;
130
131 // returns true if the member has been found and sets the int value
132 // pointed to accordingly (if ptr != null )
133 // if not found returns false, value left unchanged
134 bool HasEnumMemberValue( const wxChar *name , int *value = NULL ) const ;
135
136 // returns the value of the member, if not found in debug mode an
137 // assert is issued, in release 0 is returned
138 int GetEnumMemberValue(const wxChar *name ) const ;
139
140 // returns the name of the enum member having the passed in value
141 // returns an emtpy string if not found
142 const wxChar *GetEnumMemberName(int value) const ;
143
144 // returns the number of members in this enum
145 int GetEnumCount() const { return m_count ; }
146
147 // returns the value of the nth member
148 int GetEnumMemberValueByIndex( int n ) const ;
149
150 // returns the value of the nth member
151 const wxChar *GetEnumMemberNameByIndex( int n ) const ;
152private :
153 wxEnumMemberData *m_members;
154 int m_count ;
155};
156
157#define wxBEGIN_ENUM( e ) \
158 wxEnumMemberData s_enumDataMembers##e[] = {
159
160#define wxENUM_MEMBER( v ) { wxT(#v), v } ,
161
162#define wxEND_ENUM( e ) { NULL , 0 } } ; \
163 wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
164 wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \
165 template<> void wxStringReadValue(const wxString& s , e &data ) \
166{ \
167 data = (e) s_enumData##e.GetEnumMemberValue(s) ; \
168} \
169 template<> void wxStringWriteValue(wxString &s , const e &data ) \
170{ \
171 s = s_enumData##e.GetEnumMemberName((int)data) ; \
172} \
173 void FromLong##e( long data , wxxVariant& result ) { result = wxxVariant((e)data) ;} \
174 void ToLong##e( const wxxVariant& data , long &result ) { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get , e) ;} \
175 wxTO_STRING_IMP( e ) \
176 wxFROM_STRING_IMP( e ) \
177 wxEnumTypeInfo s_typeInfo##e(wxT_ENUM , &s_enumData##e , &wxTO_STRING( e ) , &wxFROM_STRING( e ) , &ToLong##e , &FromLong##e , typeid(e).name() ) ;
178
179// ----------------------------------------------------------------------------
180// Set Support
181//
182// in the header :
183//
184// enum wxFlavor
185// {
186// Vanilla,
187// Chocolate,
188// Strawberry,
189// };
190//
191// typedef wxBitset<wxFlavor> wxCoupe ;
192//
193// in the implementation file :
194//
195// wxBEGIN_ENUM( wxFlavor )
196// wxENUM_MEMBER( Vanilla )
197// wxENUM_MEMBER( Chocolate )
198// wxENUM_MEMBER( Strawberry )
199// wxEND_ENUM( wxFlavor )
200//
201// wxIMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor )
202//
203// implementation note : no partial specialization for streaming, but a delegation to a
204// different class
205//
206// ----------------------------------------------------------------------------
207
208// in order to remove dependancy on string tokenizer
209void WXDLLIMPEXP_BASE wxSetStringToArray( const wxString &s , wxArrayString &array ) ;
210
211template<typename e>
212void wxSetFromString(const wxString &s , wxBitset<e> &data )
213{
214 wxEnumData* edata = wxGetEnumData((e) 0) ;
215 data.reset() ;
216
217 wxArrayString array ;
218 wxSetStringToArray( s , array ) ;
219 wxString flag;
220 for ( int i = 0 ; i < array.Count() ; ++i )
221 {
222 flag = array[i] ;
223 int ivalue ;
224 if ( edata->HasEnumMemberValue( flag , &ivalue ) )
225 {
226 data.set( (e) ivalue ) ;
227 }
228 }
229}
230
231template<typename e>
232void wxSetToString( wxString &s , const wxBitset<e> &data )
233{
234 wxEnumData* edata = wxGetEnumData((e) 0) ;
235 int count = edata->GetEnumCount() ;
236 int i ;
237 s.Clear() ;
238 for ( i = 0 ; i < count ; i++ )
239 {
240 e value = (e) edata->GetEnumMemberValueByIndex(i) ;
241 if ( data.test( value ) )
242 {
243 // this could also be done by the templated calls
244 if ( !s.empty() )
245 s +=wxT("|") ;
246 s += edata->GetEnumMemberNameByIndex(i) ;
247 }
248 }
249}
250
251#define wxIMPLEMENT_SET_STREAMING(SetName,e) \
252 template<> void wxStringReadValue(const wxString &s , wxBitset<e> &data ) \
253{ \
254 wxSetFromString( s , data ) ; \
255} \
256 template<> void wxStringWriteValue( wxString &s , const wxBitset<e> &data ) \
257{ \
258 wxSetToString( s , data ) ; \
259} \
260 void FromLong##SetName( long data , wxxVariant& result ) { result = wxxVariant(SetName((unsigned long)data)) ;} \
261 void ToLong##SetName( const wxxVariant& data , long &result ) { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get , SetName).to_ulong() ;} \
262 wxTO_STRING_IMP( SetName ) \
263 wxFROM_STRING_IMP( SetName ) \
264 wxEnumTypeInfo s_typeInfo##SetName(wxT_SET , &s_enumData##e , &wxTO_STRING( SetName ) , &wxFROM_STRING( SetName ) , &ToLong##SetName , &FromLong##SetName, typeid(SetName).name() ) ; \
265}
266
267template<typename e>
268void wxFlagsFromString(const wxString &s , e &data )
269{
270 wxEnumData* edata = wxGetEnumData((e*) 0) ;
271 data.m_data = 0 ;
272
273 wxArrayString array ;
274 wxSetStringToArray( s , array ) ;
275 wxString flag;
276 for ( size_t i = 0 ; i < array.Count() ; ++i )
277 {
278 flag = array[i] ;
279 int ivalue ;
280 if ( edata->HasEnumMemberValue( flag , &ivalue ) )
281 {
282 data.m_data |= ivalue ;
283 }
284 }
285}
286
287template<typename e>
288void wxFlagsToString( wxString &s , const e& data )
289{
290 wxEnumData* edata = wxGetEnumData((e*) 0) ;
291 int count = edata->GetEnumCount() ;
292 int i ;
293 s.Clear() ;
294 long dataValue = data.m_data ;
295 for ( i = 0 ; i < count ; i++ )
296 {
297 int value = edata->GetEnumMemberValueByIndex(i) ;
298 // make this to allow for multi-bit constants to work
299 if ( value && ( dataValue & value ) == value )
300 {
301 // clear the flags we just set
302 dataValue &= ~value ;
303 // this could also be done by the templated calls
304 if ( !s.empty() )
305 s +=wxT("|") ;
306 s += edata->GetEnumMemberNameByIndex(i) ;
307 }
308 }
309}
310
311#define wxBEGIN_FLAGS( e ) \
312 wxEnumMemberData s_enumDataMembers##e[] = {
313
314#define wxFLAGS_MEMBER( v ) { wxT(#v), v } ,
315
316#define wxEND_FLAGS( e ) { NULL , 0 } } ; \
317 wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
318 wxEnumData *wxGetEnumData(e*) { return &s_enumData##e ; } \
319 template<> void wxStringReadValue(const wxString &s , e &data ) \
320{ \
321 wxFlagsFromString<e>( s , data ) ; \
322} \
323 template<> void wxStringWriteValue( wxString &s , const e& data ) \
324{ \
325 wxFlagsToString<e>( s , data ) ; \
326} \
327 void FromLong##e( long data , wxxVariant& result ) { result = wxxVariant(e(data)) ;} \
328 void ToLong##e( const wxxVariant& data , long &result ) { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get , e).m_data ;} \
329 wxTO_STRING_IMP( e ) \
330 wxFROM_STRING_IMP( e ) \
331 wxEnumTypeInfo s_typeInfo##e(wxT_SET , &s_enumData##e , &wxTO_STRING( e ) , &wxFROM_STRING( e ) , &ToLong##e , &FromLong##e, typeid(e).name() ) ;
332// ----------------------------------------------------------------------------
333// Type Information
334// ----------------------------------------------------------------------------
335//
336//
337// All data exposed by the RTTI is characterized using the following classes.
338// The first characterization is done by wxTypeKind. All enums up to and including
339// wxT_CUSTOM represent so called simple types. These cannot be divided any further.
340// They can be converted to and from wxStrings, that's all.
341
342
343enum wxTypeKind
344{
345 wxT_VOID = 0, // unknown type
346 wxT_BOOL,
347 wxT_CHAR,
348 wxT_UCHAR,
349 wxT_INT,
350 wxT_UINT,
351 wxT_LONG,
352 wxT_ULONG,
353 wxT_FLOAT,
354 wxT_DOUBLE,
355 wxT_STRING, // must be wxString
356 wxT_SET, // must be wxBitset<> template
357 wxT_ENUM,
358 wxT_CUSTOM, // user defined type (e.g. wxPoint)
359
360 wxT_LAST_SIMPLE_TYPE_KIND = wxT_CUSTOM ,
361
362 wxT_OBJECT_PTR, // object reference
363 wxT_OBJECT , // embedded object
364 wxT_COLLECTION , // collection
365
366 wxT_DELEGATE , // for connecting against an event source
367
368 wxT_LAST_TYPE_KIND = wxT_DELEGATE // sentinel for bad data, asserts, debugging
369};
370
371class WXDLLIMPEXP_FWD_BASE wxxVariant ;
372class WXDLLIMPEXP_FWD_BASE wxTypeInfo ;
373
374WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxTypeInfo* , wxTypeInfoMap , class WXDLLIMPEXP_BASE ) ;
375
376class WXDLLIMPEXP_BASE wxTypeInfo
377{
378public :
379 typedef void (*converterToString_t)( const wxxVariant& data , wxString &result ) ;
380 typedef void (*converterFromString_t)( const wxString& data , wxxVariant &result ) ;
381
382 wxTypeInfo(wxTypeKind kind,
383 converterToString_t to = NULL, converterFromString_t from = NULL,
384 const wxString &name = wxEmptyString):
385 m_toString(to), m_fromString(from), m_kind(kind), m_name(name)
386 {
387 Register();
388 }
389#if wxUSE_UNICODE
390 wxTypeInfo(wxTypeKind kind,
391 converterToString_t to, converterFromString_t from,
392 const char *name):
393 m_toString(to), m_fromString(from), m_kind(kind), m_name(wxString::FromAscii(name))
394 {
395 Register();
396 }
397#endif
398
399 virtual ~wxTypeInfo()
400 {
401 Unregister() ;
402 }
403
404 // return the kind of this type (wxT_... constants)
405 wxTypeKind GetKind() const { return m_kind ; }
406
407 // returns the unique name of this type
408 const wxString& GetTypeName() const { return m_name ; }
409
410 // is this type a delegate type
411 bool IsDelegateType() const { return m_kind == wxT_DELEGATE ; }
412
413 // is this type a custom type
414 bool IsCustomType() const { return m_kind == wxT_CUSTOM ; }
415
416 // is this type an object type
417 bool IsObjectType() const { return m_kind == wxT_OBJECT || m_kind == wxT_OBJECT_PTR ; }
418
419 // can the content of this type be converted to and from strings ?
420 bool HasStringConverters() const { return m_toString != NULL && m_fromString != NULL ; }
421
422 // convert a wxxVariant holding data of this type into a string
423 void ConvertToString( const wxxVariant& data , wxString &result ) const
424
425 { if ( m_toString ) (*m_toString)( data , result ) ; else wxLogError( wxGetTranslation(wxT("String conversions not supported")) ) ; }
426
427 // convert a string into a wxxVariant holding the corresponding data in this type
428 void ConvertFromString( const wxString& data , wxxVariant &result ) const
429 { if( m_fromString ) (*m_fromString)( data , result ) ; else wxLogError( wxGetTranslation(wxT("String conversions not supported")) ) ; }
430
431#if wxUSE_UNICODE
432 static wxTypeInfo *FindType(const char *typeName) { return FindType( wxString::FromAscii(typeName) ) ; }
433#endif
434 static wxTypeInfo *FindType(const wxChar *typeName);
435 static wxTypeInfo *FindType(const wxString typeName)
436 {
437#if wxUSE_UNICODE
438 return FindType( typeName.wchar_str() );
439#else
440 return FindType( typeName.char_str() );
441#endif
442 }
443
444private :
445
446 void Register();
447 void Unregister();
448
449 converterToString_t m_toString ;
450 converterFromString_t m_fromString ;
451
452 static wxTypeInfoMap* ms_typeTable ;
453
454 wxTypeKind m_kind;
455 wxString m_name;
456};
457
458class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo
459{
460public :
461 wxBuiltInTypeInfo( wxTypeKind kind , converterToString_t to = NULL , converterFromString_t from = NULL , const wxString &name = wxEmptyString ) :
462 wxTypeInfo( kind , to , from , name )
463 { wxASSERT_MSG( GetKind() < wxT_SET , wxT("Illegal Kind for Base Type") ) ; }
464#if wxUSE_UNICODE
465 wxBuiltInTypeInfo( wxTypeKind kind , converterToString_t to , converterFromString_t from , const char *name ) :
466 wxTypeInfo( kind , to , from , name )
467 { wxASSERT_MSG( GetKind() < wxT_SET , wxT("Illegal Kind for Base Type") ) ; }
468#endif
469} ;
470
471class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo
472{
473public :
474 wxCustomTypeInfo( const wxString &name , converterToString_t to , converterFromString_t from ) :
475 wxTypeInfo( wxT_CUSTOM , to , from , name )
476 {}
477#if wxUSE_UNICODE
478 wxCustomTypeInfo( const char *name , converterToString_t to , converterFromString_t from ) :
479 wxTypeInfo( wxT_CUSTOM , to , from , name )
480 {}
481#endif
482} ;
483
484class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo
485{
486public :
487 typedef void (*converterToLong_t)( const wxxVariant& data , long &result ) ;
488 typedef void (*converterFromLong_t)( long data , wxxVariant &result ) ;
489
490 wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo , converterToString_t to , converterFromString_t from ,
491 converterToLong_t toLong , converterFromLong_t fromLong , const wxString &name ) :
492 wxTypeInfo( kind , to , from , name ) , m_toLong( toLong ) , m_fromLong( fromLong )
493 { wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_enumInfo = enumInfo ;}
494
495#if wxUSE_UNICODE
496 wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo , converterToString_t to , converterFromString_t from ,
497 converterToLong_t toLong , converterFromLong_t fromLong , const char * name ) :
498 wxTypeInfo( kind , to , from , name ) , m_toLong( toLong ) , m_fromLong( fromLong )
499 { wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_enumInfo = enumInfo ;}
500#endif
501 const wxEnumData* GetEnumData() const { return m_enumInfo ; }
502
503 // convert a wxxVariant holding data of this type into a long
504 void ConvertToLong( const wxxVariant& data , long &result ) const
505
506 { if( m_toLong ) (*m_toLong)( data , result ) ; else wxLogError( wxGetTranslation(wxT("Long Conversions not supported")) ) ; }
507
508 // convert a long into a wxxVariant holding the corresponding data in this type
509 void ConvertFromLong( long data , wxxVariant &result ) const
510 { if( m_fromLong ) (*m_fromLong)( data , result ) ; else wxLogError( wxGetTranslation(wxT("Long Conversions not supported")) ) ;}
511
512private :
513 converterToLong_t m_toLong ;
514 converterFromLong_t m_fromLong ;
515
516 wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET
517} ;
518
519class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo
520{
521public :
522 wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to = NULL , converterFromString_t from = NULL , const wxString &name = wxEmptyString) ;
523#if wxUSE_UNICODE
524 wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const char *name ) ;
525#endif
526 const wxClassInfo *GetClassInfo() const { return m_classInfo ; }
527private :
528 wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL
529} ;
530
531class WXDLLIMPEXP_BASE wxCollectionTypeInfo : public wxTypeInfo
532{
533public :
534 wxCollectionTypeInfo( const wxString &elementName , converterToString_t to , converterFromString_t from , const wxString &name) :
535 wxTypeInfo( wxT_COLLECTION , to , from , name )
536 { m_elementTypeName = elementName ; m_elementType = NULL ;}
537#if wxUSE_UNICODE
538 wxCollectionTypeInfo( const char *elementName , converterToString_t to , converterFromString_t from , const char *name ) :
539 wxTypeInfo( wxT_COLLECTION , to , from , name )
540 { m_elementTypeName = wxString::FromAscii( elementName ) ; m_elementType = NULL ;}
541#endif
542 const wxTypeInfo* GetElementType() const
543 {
544 if ( m_elementType == NULL )
545 m_elementType = wxTypeInfo::FindType( m_elementTypeName ) ;
546 return m_elementType ; }
547private :
548 mutable wxTypeInfo * m_elementType ;
549 wxString m_elementTypeName ;
550} ;
551
552// a delegate is an exposed event source
553
554class WXDLLIMPEXP_BASE wxDelegateTypeInfo : public wxTypeInfo
555{
556public :
557 wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to = NULL , converterFromString_t from = NULL ) ;
558 wxDelegateTypeInfo( int eventType , int lastEventType, wxClassInfo* eventClass , converterToString_t to = NULL , converterFromString_t from = NULL ) ;
559 int GetEventType() const { return m_eventType ; }
560 int GetLastEventType() const { return m_lastEventType ; }
561 const wxClassInfo* GetEventClass() const { return m_eventClass ; }
562private :
563 const wxClassInfo *m_eventClass; // (extended will merge into classinfo)
564 int m_eventType ;
565 int m_lastEventType ;
566} ;
567
568template<typename T> const wxTypeInfo* wxGetTypeInfo( T * ) { return wxTypeInfo::FindType(typeid(T).name()) ; }
569
570// this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
571
572#if wxUSE_FUNC_TEMPLATE_POINTER
573#define wxCUSTOM_TYPE_INFO( e , toString , fromString ) \
574 wxCustomTypeInfo s_typeInfo##e(typeid(e).name() , &toString , &fromString) ;
575#else
576#define wxCUSTOM_TYPE_INFO( e , toString , fromString ) \
577 void ToString##e( const wxxVariant& data , wxString &result ) { toString(data, result); } \
578 void FromString##e( const wxString& data , wxxVariant &result ) { fromString(data, result); } \
579 wxCustomTypeInfo s_typeInfo##e(typeid(e).name() , &ToString##e , &FromString##e) ;
580#endif
581
582#define wxCOLLECTION_TYPE_INFO( element , collection ) \
583 wxCollectionTypeInfo s_typeInfo##collection( typeid(element).name() , NULL , NULL , typeid(collection).name() ) ;
584
585// sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs, currently
586// we don't have to play tricks, but if we will have to according to the compiler, we will use that macro for that
587
588#define wxILLEGAL_TYPE_SPECIALIZATION( a )
589
590// ----------------------------------------------------------------------------
591// wxxVariant as typesafe data holder
592// ----------------------------------------------------------------------------
593
594class WXDLLIMPEXP_BASE wxxVariantData
595{
596public:
597 virtual ~wxxVariantData() {}
598
599 // return a heap allocated duplicate
600 virtual wxxVariantData* Clone() const = 0 ;
601
602 // returns the type info of the contentc
603 virtual const wxTypeInfo* GetTypeInfo() const = 0 ;
604} ;
605
606template<typename T> class wxxVariantDataT : public wxxVariantData
607{
608public:
609 wxxVariantDataT(const T& d) : m_data(d) {}
610 virtual ~wxxVariantDataT() {}
611
612 // get a ref to the stored data
613 T & Get() { return m_data; }
614
615 // get a const ref to the stored data
616 const T & Get() const { return m_data; }
617
618 // set the data
619 void Set(const T& d) { m_data = d; }
620
621 // return a heap allocated duplicate
622 virtual wxxVariantData* Clone() const { return new wxxVariantDataT<T>( Get() ) ; }
623
624 // returns the type info of the contentc
625 virtual const wxTypeInfo* GetTypeInfo() const { return wxGetTypeInfo( NULL ) ; }
626
627private:
628 T m_data;
629};
630
631class WXDLLIMPEXP_BASE wxxVariant
632{
633public :
634 wxxVariant() { m_data = NULL ; }
635 wxxVariant( wxxVariantData* data , const wxString& name = wxEmptyString ) : m_data(data) , m_name(name) {}
636 wxxVariant( const wxxVariant &d ) { if ( d.m_data ) m_data = d.m_data->Clone() ; else m_data = NULL ; m_name = d.m_name ; }
637
638 template<typename T> wxxVariant( const T& data , const wxString& name = wxEmptyString ) :
639 m_data(new wxxVariantDataT<T>(data) ), m_name(name) {}
640
641 ~wxxVariant() { delete m_data ; }
642
643 // get a ref to the stored data
644 template<typename T> T& Get(wxTEMPLATED_MEMBER_FIX(T))
645 {
646 wxxVariantDataT<T> *dataptr = dynamic_cast<wxxVariantDataT<T>*> (m_data) ;
647 wxASSERT_MSG( dataptr , wxString::Format(wxT("Cast to %s not possible"), typeid(T).name()) ) ;
648 return dataptr->Get() ;
649 }
650
651 // get a ref to the stored data
652 template<typename T> const T& Get(wxTEMPLATED_MEMBER_FIX(T)) const
653 {
654 const wxxVariantDataT<T> *dataptr = dynamic_cast<const wxxVariantDataT<T>*> (m_data) ;
655 wxASSERT_MSG( dataptr , wxString::Format(wxT("Cast to %s not possible"), typeid(T).name()) ) ;
656 return dataptr->Get() ;
657 }
658
659 bool IsEmpty() const { return m_data == NULL ; }
660
661 template<typename T> bool HasData(wxTEMPLATED_MEMBER_FIX(T)) const
662 {
663 const wxxVariantDataT<T> *dataptr = dynamic_cast<const wxxVariantDataT<T>*> (m_data) ;
664 return dataptr != NULL ;
665 }
666
667 // stores the data
668 template<typename T> void Set(const T& data) const
669 {
670 delete m_data ;
671 m_data = new wxxVariantDataT<T>(data) ;
672 }
673
674 wxxVariant& operator=(const wxxVariant &d)
675 {
676 delete m_data;
677 m_data = d.m_data ? d.m_data->Clone() : NULL ;
678 m_name = d.m_name ;
679 return *this ;
680 }
681
682 // gets the stored data casted to a wxObject* , returning NULL if cast is not possible
683 wxObject* GetAsObject() ;
684
685 // get the typeinfo of the stored object
686 const wxTypeInfo* GetTypeInfo() const { return m_data->GetTypeInfo() ; }
687
688 // returns this value as string
689 wxString GetAsString() const
690 {
691 wxString s ;
692 GetTypeInfo()->ConvertToString( *this , s ) ;
693 return s ;
694 }
695 const wxString& GetName() const { return m_name ; }
696private :
697 wxxVariantData* m_data ;
698 wxString m_name ;
699} ;
700
701#include "wx/dynarray.h"
702
703WX_DECLARE_OBJARRAY_WITH_DECL(wxxVariant, wxxVariantArray, class WXDLLIMPEXP_BASE);
704
705// templated streaming, every type must have their specialization for these methods
706
707template<typename T>
708void wxStringReadValue( const wxString &s , T &data );
709
710template<typename T>
711void wxStringWriteValue( wxString &s , const T &data);
712
713template<typename T>
714void wxToStringConverter( const wxxVariant &v, wxString &s wxTEMPLATED_FUNCTION_FIX(T)) { wxStringWriteValue( s , v.wxTEMPLATED_MEMBER_CALL(Get , T) ) ; }
715
716template<typename T>
717void wxFromStringConverter( const wxString &s, wxxVariant &v wxTEMPLATED_FUNCTION_FIX(T)) { T d ; wxStringReadValue( s , d ) ; v = wxxVariant(d) ; }
718
719// ----------------------------------------------------------------------------
720// Property Support
721//
722// wxPropertyInfo is used to inquire of the property by name. It doesn't
723// provide access to the property, only information about it. If you
724// want access, look at wxPropertyAccessor.
725// ----------------------------------------------------------------------------
726
727class WXDLLIMPEXP_BASE wxSetter
728{
729public:
730 wxSetter( const wxString name ) { m_name = name ; }
731 virtual ~wxSetter() {}
732 virtual void Set( wxObject *object, const wxxVariant &variantValue ) const = 0;
733 const wxString& GetName() const { return m_name ; }
734private:
735 wxString m_name;
736};
737
738class WXDLLIMPEXP_BASE wxGetter
739{
740public:
741 wxGetter( const wxString name ) { m_name = name ; }
742 virtual ~wxGetter() {}
743 virtual void Get( const wxObject *object , wxxVariant& result) const = 0;
744 const wxString& GetName() const { return m_name ; }
745private:
746 wxString m_name;
747};
748
749class WXDLLIMPEXP_BASE wxCollectionGetter
750{
751public :
752 wxCollectionGetter( const wxString name ) { m_name = name ; }
753 virtual ~wxCollectionGetter() {}
754 virtual void Get( const wxObject *object , wxxVariantArray& result) const = 0;
755 const wxString& GetName() const { return m_name ; }
756private :
757 wxString m_name ;
758} ;
759
760template<typename coll_t> void WXDLLIMPEXP_BASE wxCollectionToVariantArray( const coll_t& coll , wxxVariantArray& result ) ;
761
762class WXDLLIMPEXP_BASE wxAdder
763{
764public :
765 wxAdder( const wxString name ) { m_name = name ; }
766 virtual ~wxAdder() {}
767 virtual void Add( wxObject *object, const wxxVariant &variantValue ) const= 0;
768 const wxString& GetName() const { return m_name ; }
769private :
770 wxString m_name ;
771} ;
772
773
774#define wxSETTER( property, Klass, valueType, setterMethod ) \
775class wxSetter##property : public wxSetter \
776{ \
777public: \
778 wxINFUNC_CLASS_TYPE_FIX(Klass) \
779 wxSetter##property() : wxSetter( wxT(#setterMethod) ) {} \
780 virtual ~wxSetter##property() {} \
781 void Set( wxObject *object, const wxxVariant &variantValue ) const \
782{ \
783 Klass *obj = dynamic_cast<Klass*>(object) ; \
784 if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \
785 obj->setterMethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType)) ; \
786 else \
787 obj->setterMethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType*)) ; \
788} \
789} ;
790
791#define wxGETTER( property, Klass, valueType , gettermethod ) \
792class wxGetter##property : public wxGetter \
793{ \
794public : \
795 wxINFUNC_CLASS_TYPE_FIX(Klass) \
796 wxGetter##property() : wxGetter( wxT(#gettermethod) ) {} \
797 virtual ~wxGetter##property() {} \
798 void Get( const wxObject *object , wxxVariant &result) const \
799{ \
800 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
801 result = wxxVariant( obj->gettermethod() ) ; \
802} \
803} ;
804
805#define wxADDER( property, Klass, valueType , addermethod ) \
806class wxAdder##property : public wxAdder \
807{ \
808public: \
809 wxINFUNC_CLASS_TYPE_FIX(Klass) \
810 wxAdder##property() : wxAdder( wxT(#addermethod) ) {} \
811 virtual ~wxAdder##property() {} \
812 void Add( wxObject *object, const wxxVariant &variantValue ) const \
813{ \
814 Klass *obj = dynamic_cast<Klass*>(object) ; \
815 if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \
816 obj->addermethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType)) ; \
817 else \
818 obj->addermethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get , valueType*)) ; \
819} \
820} ;
821
822#define wxCOLLECTION_GETTER( property, Klass, valueType , gettermethod ) \
823class wxCollectionGetter##property : public wxCollectionGetter \
824{ \
825public : \
826 wxINFUNC_CLASS_TYPE_FIX(Klass) \
827 wxCollectionGetter##property() : wxCollectionGetter( wxT(#gettermethod) ) {} \
828 virtual ~wxCollectionGetter##property() {} \
829 void Get( const wxObject *object , wxxVariantArray &result) const \
830{ \
831 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
832 wxCollectionToVariantArray( obj->gettermethod() , result ) ; \
833} \
834} ;
835
836class WXDLLIMPEXP_BASE wxPropertyAccessor
837{
838public :
839 wxPropertyAccessor( wxSetter *setter , wxGetter *getter , wxAdder *adder , wxCollectionGetter *collectionGetter )
840 { m_setter = setter ; m_getter = getter ; m_adder = adder ; m_collectionGetter = collectionGetter ;}
841
842 virtual ~wxPropertyAccessor() {}
843
844 // Setting a simple property (non-collection)
845 virtual void SetProperty(wxObject *object, const wxxVariant &value) const
846 { if ( m_setter ) m_setter->Set( object , value ) ; else wxLogError( wxGetTranslation(wxT("SetProperty called w/o valid setter")) ) ;}
847
848 // Getting a simple property (non-collection)
849 virtual void GetProperty(const wxObject *object, wxxVariant &result) const
850 { if ( m_getter ) m_getter->Get( object , result ) ; else wxLogError( wxGetTranslation(wxT("GetProperty called w/o valid getter")) ) ;}
851
852 // Adding an element to a collection property
853 virtual void AddToPropertyCollection(wxObject *object, const wxxVariant &value) const
854 { if ( m_adder ) m_adder->Add( object , value ) ; else wxLogError( wxGetTranslation(wxT("AddToPropertyCollection called w/o valid adder")) ) ;}
855
856 // Getting a collection property
857 virtual void GetPropertyCollection( const wxObject *obj, wxxVariantArray &result) const
858 { if ( m_collectionGetter ) m_collectionGetter->Get( obj , result) ; else wxLogError( wxGetTranslation(wxT("GetPropertyCollection called w/o valid collection getter")) ) ;}
859
860 virtual bool HasSetter() const { return m_setter != NULL ; }
861 virtual bool HasCollectionGetter() const { return m_collectionGetter != NULL ; }
862 virtual bool HasGetter() const { return m_getter != NULL ; }
863 virtual bool HasAdder() const { return m_adder != NULL ; }
864
865 virtual const wxString& GetCollectionGetterName() const
866 { return m_collectionGetter->GetName() ; }
867 virtual const wxString& GetGetterName() const
868 { return m_getter->GetName() ; }
869 virtual const wxString& GetSetterName() const
870 { return m_setter->GetName() ; }
871 virtual const wxString& GetAdderName() const
872 { return m_adder->GetName() ; }
873
874protected :
875 wxSetter *m_setter ;
876 wxAdder *m_adder ;
877 wxGetter *m_getter ;
878 wxCollectionGetter* m_collectionGetter ;
879};
880
881class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor
882{
883public :
884 wxGenericPropertyAccessor( const wxString &propName ) ;
885 virtual ~wxGenericPropertyAccessor() ;
886
887 void RenameProperty( const wxString& WXUNUSED_UNLESS_DEBUG(oldName),
888 const wxString& newName )
889 {
890 wxASSERT( oldName == m_propertyName ) ; m_propertyName = newName ;
891 }
892 virtual bool HasSetter() const { return true ; }
893 virtual bool HasGetter() const { return true ; }
894 virtual bool HasAdder() const { return false ; }
895 virtual bool HasCollectionGetter() const { return false ; }
896
897 virtual const wxString& GetGetterName() const
898 { return m_getterName ; }
899 virtual const wxString& GetSetterName() const
900 { return m_setterName ; }
901
902 virtual void SetProperty(wxObject *object, const wxxVariant &value) const ;
903 virtual void GetProperty(const wxObject *object, wxxVariant &value) const ;
904
905 // Adding an element to a collection property
906 virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), const wxxVariant &WXUNUSED(value)) const
907 { wxLogError( wxGetTranslation(wxT("AddToPropertyCollection called on a generic accessor")) ) ;}
908
909 // Getting a collection property
910 virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), wxxVariantArray &WXUNUSED(result)) const
911 { wxLogError ( wxGetTranslation(wxT("GetPropertyCollection called on a generic accessor")) ) ;}
912private :
913 struct wxGenericPropertyAccessorInternal ;
914 wxGenericPropertyAccessorInternal* m_data ;
915 wxString m_propertyName ;
916 wxString m_setterName ;
917 wxString m_getterName ;
918} ;
919
920typedef long wxPropertyInfoFlags ;
921enum {
922 // will be removed in future releases
923 wxPROP_DEPRECATED = 0x00000001 ,
924 // object graph property, will be streamed with priority (after constructor properties)
925 wxPROP_OBJECT_GRAPH = 0x00000002 ,
926 // this will only be streamed out and in as enum/set, the internal representation is still a long
927 wxPROP_ENUM_STORE_LONG = 0x00000004 ,
928 // don't stream out this property, needed eg to avoid streaming out children that are always created by their parents
929 wxPROP_DONT_STREAM = 0x00000008 ,
930} ;
931
932class WXDLLIMPEXP_BASE wxPropertyInfo
933{
934 friend class WXDLLIMPEXP_FWD_BASE wxDynamicClassInfo ;
935public :
936 wxPropertyInfo(wxPropertyInfo* &iter,
937 wxClassInfo* itsClass,
938 const wxString& name,
939 const wxString& typeName,
940 wxPropertyAccessor *accessor,
941 wxxVariant dv,
942 wxPropertyInfoFlags flags = 0,
943 const wxString& helpString = wxEmptyString,
944 const wxString& groupString = wxEmptyString) :
945 m_itsClass(itsClass),
946 m_name(name),
947 m_typeInfo(NULL),
948 m_typeName(typeName) ,
949 m_collectionElementTypeInfo(NULL),
950 m_accessor(accessor),
951 m_defaultValue(dv),
952 m_flags(flags),
953 m_helpString(helpString),
954 m_groupString(groupString)
955 {
956 Insert(iter);
957 }
958
959#if wxUSE_UNICODE
960 wxPropertyInfo(wxPropertyInfo* &iter,
961 wxClassInfo* itsClass,
962 const wxString& name,
963 const char* typeName,
964 wxPropertyAccessor *accessor,
965 wxxVariant dv,
966 wxPropertyInfoFlags flags = 0,
967 const wxString& helpString = wxEmptyString,
968 const wxString& groupString = wxEmptyString) :
969 m_itsClass(itsClass),
970 m_name(name),
971 m_typeInfo(NULL),
972 m_typeName(wxString::FromAscii(typeName)) ,
973 m_collectionElementTypeInfo(NULL),
974 m_accessor(accessor),
975 m_defaultValue(dv),
976 m_flags(flags),
977 m_helpString(helpString),
978 m_groupString(groupString)
979 {
980 Insert(iter);
981 }
982#endif
983 wxPropertyInfo(wxPropertyInfo* &iter,
984 wxClassInfo* itsClass,
985 const wxString& name,
986 wxDelegateTypeInfo* type,
987 wxPropertyAccessor *accessor,
988 wxxVariant dv,
989 wxPropertyInfoFlags flags = 0,
990 const wxString& helpString = wxEmptyString,
991 const wxString& groupString = wxEmptyString) :
992 m_itsClass(itsClass),
993 m_name(name),
994 m_typeInfo(type),
995 m_collectionElementTypeInfo(NULL),
996 m_accessor(accessor),
997 m_defaultValue(dv),
998 m_flags(flags),
999 m_helpString(helpString),
1000 m_groupString(groupString)
1001 {
1002 Insert(iter);
1003 }
1004
1005 wxPropertyInfo(wxPropertyInfo* &iter,
1006 wxClassInfo* itsClass, const wxString& name,
1007 const wxString& collectionTypeName,
1008 const wxString& elementTypeName,
1009 wxPropertyAccessor *accessor,
1010 wxPropertyInfoFlags flags = 0,
1011 const wxString& helpString = wxEmptyString,
1012 const wxString& groupString = wxEmptyString) :
1013 m_itsClass(itsClass),
1014 m_name(name),
1015 m_typeInfo(NULL),
1016 m_typeName(collectionTypeName) ,
1017 m_collectionElementTypeInfo(NULL),
1018 m_collectionElementTypeName(elementTypeName),
1019 m_accessor(accessor) ,
1020 m_flags(flags),
1021 m_helpString(helpString),
1022 m_groupString(groupString)
1023 {
1024 Insert(iter);
1025 }
1026
1027#if wxUSE_UNICODE
1028 wxPropertyInfo(wxPropertyInfo* &iter,
1029 wxClassInfo* itsClass, const wxString& name,
1030 const char* collectionTypeName,
1031 const char* elementTypeName,
1032 wxPropertyAccessor *accessor,
1033 wxPropertyInfoFlags flags = 0,
1034 const wxString& helpString = wxEmptyString,
1035 const wxString& groupString = wxEmptyString) :
1036 m_itsClass(itsClass),
1037 m_name(name),
1038 m_typeInfo(NULL),
1039 m_typeName(wxString::FromAscii(collectionTypeName)) ,
1040 m_collectionElementTypeInfo(NULL),
1041 m_collectionElementTypeName(wxString::FromAscii(elementTypeName)),
1042 m_accessor(accessor) ,
1043 m_flags(flags),
1044 m_helpString(helpString),
1045 m_groupString(groupString)
1046 {
1047 Insert(iter);
1048 }
1049#endif
1050 ~wxPropertyInfo() ;
1051
1052 // return the class this property is declared in
1053 const wxClassInfo* GetDeclaringClass() const { return m_itsClass ; }
1054
1055 // return the name of this property
1056 const wxString& GetName() const { return m_name ; }
1057
1058 // returns the flags of this property
1059 wxPropertyInfoFlags GetFlags() const { return m_flags ;}
1060
1061 // returns the short help string of this property
1062 const wxString& GetHelpString() const { return m_helpString ; }
1063
1064 // returns the group string of this property
1065 const wxString& GetGroupString() const { return m_groupString ; }
1066
1067 // return the element type info of this property (for collections, otherwise NULL)
1068 const wxTypeInfo * GetCollectionElementTypeInfo() const
1069 {
1070 if ( m_collectionElementTypeInfo == NULL )
1071 m_collectionElementTypeInfo = wxTypeInfo::FindType(m_collectionElementTypeName) ;
1072 return m_collectionElementTypeInfo ;
1073 }
1074
1075 // return the type info of this property
1076 const wxTypeInfo * GetTypeInfo() const
1077 {
1078 if ( m_typeInfo == NULL )
1079 m_typeInfo = wxTypeInfo::FindType(m_typeName) ;
1080 return m_typeInfo ;
1081 }
1082
1083 // return the accessor for this property
1084 wxPropertyAccessor* GetAccessor() const { return m_accessor ; }
1085
1086 // returns NULL if this is the last property of this class
1087 wxPropertyInfo* GetNext() const { return m_next ; }
1088
1089 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
1090 wxxVariant GetDefaultValue() const { return m_defaultValue ; }
1091private :
1092 void Insert(wxPropertyInfo* &iter)
1093 {
1094 m_next = NULL ;
1095 if ( iter == NULL )
1096 iter = this ;
1097 else
1098 {
1099 wxPropertyInfo* i = iter ;
1100 while( i->m_next )
1101 i = i->m_next ;
1102
1103 i->m_next = this ;
1104 }
1105 }
1106
1107 wxClassInfo* m_itsClass ;
1108 wxString m_name ;
1109 mutable wxTypeInfo* m_typeInfo ;
1110 wxString m_typeName ;
1111 mutable wxTypeInfo* m_collectionElementTypeInfo ;
1112 wxString m_collectionElementTypeName ;
1113 wxPropertyAccessor* m_accessor ;
1114 wxxVariant m_defaultValue;
1115 wxPropertyInfoFlags m_flags ;
1116 wxString m_helpString ;
1117 wxString m_groupString ;
1118 // string representation of the default value
1119 // to be assigned by the designer to the property
1120 // when the component is dropped on the container.
1121 wxPropertyInfo* m_next ;
1122};
1123
1124WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo* , wxPropertyInfoMap , class WXDLLIMPEXP_BASE ) ;
1125
1126#define wxBEGIN_PROPERTIES_TABLE(theClass) \
1127 wxPropertyInfo *theClass::GetPropertiesStatic() \
1128{ \
1129 typedef theClass class_t; \
1130 static wxPropertyInfo* first = NULL ;
1131
1132#define wxEND_PROPERTIES_TABLE() \
1133 return first ; }
1134
1135#define wxHIDE_PROPERTY( pname ) \
1136 static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(void).name() ,NULL , wxxVariant() , wxPROP_DONT_STREAM , wxEmptyString , wxEmptyString ) ;
1137
1138#define wxPROPERTY( pname , type , setter , getter , defaultValue , flags , help , group) \
1139 wxSETTER( pname , class_t , type , setter ) \
1140 static wxSetter##pname _setter##pname ; \
1141 wxGETTER( pname , class_t , type , getter ) \
1142 static wxGetter##pname _getter##pname ; \
1143 static wxPropertyAccessor _accessor##pname( &_setter##pname , &_getter##pname , NULL , NULL ) ; \
1144 static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(type).name() ,&_accessor##pname , wxxVariant(defaultValue) , flags , group , help ) ;
1145
1146#define wxPROPERTY_FLAGS( pname , flags , type , setter , getter ,defaultValue , pflags , help , group) \
1147 wxSETTER( pname , class_t , type , setter ) \
1148 static wxSetter##pname _setter##pname ; \
1149 wxGETTER( pname , class_t , type , getter ) \
1150 static wxGetter##pname _getter##pname ; \
1151 static wxPropertyAccessor _accessor##pname( &_setter##pname , &_getter##pname , NULL , NULL ) ; \
1152 static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(flags).name() ,&_accessor##pname , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ;
1153
1154#define wxREADONLY_PROPERTY( pname , type , getter ,defaultValue , flags , help , group) \
1155 wxGETTER( pname , class_t , type , getter ) \
1156 static wxGetter##pname _getter##pname ; \
1157 static wxPropertyAccessor _accessor##pname( NULL , &_getter##pname , NULL , NULL ) ; \
1158 static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(type).name() ,&_accessor##pname , wxxVariant(defaultValue), flags , help , group ) ;
1159
1160#define wxREADONLY_PROPERTY_FLAGS( pname , flags , type , getter ,defaultValue , pflags , help , group) \
1161 wxGETTER( pname , class_t , type , getter ) \
1162 static wxGetter##pname _getter##pname ; \
1163 static wxPropertyAccessor _accessor##pname( NULL , &_getter##pname , NULL , NULL ) ; \
1164 static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(flags).name() ,&_accessor##pname , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ;
1165
1166#define wxPROPERTY_COLLECTION( pname , colltype , addelemtype , adder , getter , flags , help , group ) \
1167 wxADDER( pname , class_t , addelemtype , adder ) \
1168 static wxAdder##pname _adder##pname ; \
1169 wxCOLLECTION_GETTER( pname , class_t , colltype , getter ) \
1170 static wxCollectionGetter##pname _collectionGetter##pname ; \
1171 static wxPropertyAccessor _accessor##pname( NULL , NULL ,&_adder##pname , &_collectionGetter##pname ) ; \
1172 static wxPropertyInfo _propertyInfo##pname( first , class_t::GetClassInfoStatic() , wxT(#pname) , typeid(colltype).name() ,typeid(addelemtype).name() ,&_accessor##pname , flags , help , group ) ;
1173
1174#define wxREADONLY_PROPERTY_COLLECTION( pname , colltype , addelemtype , getter , flags , help , group) \
1175 wxCOLLECTION_GETTER( pname , class_t , colltype , getter ) \
1176 static wxCollectionGetter##pname _collectionGetter##pname ; \
1177 static wxPropertyAccessor _accessor##pname( NULL , NULL , NULL , &_collectionGetter##pname ) ; \
1178 static wxPropertyInfo _propertyInfo##pname( first ,class_t::GetClassInfoStatic() , wxT(#pname) , typeid(colltype).name() ,typeid(addelemtype).name() ,&_accessor##pname , flags , help , group ) ;
1179
1180
1181#define wxEVENT_PROPERTY( name , eventType , eventClass ) \
1182 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
1183 static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , wxT(#name) , &_typeInfo##name , NULL , wxxVariant() ) ; \
1184
1185#define wxEVENT_RANGE_PROPERTY( name , eventType , lastEventType , eventClass ) \
1186 static wxDelegateTypeInfo _typeInfo##name( eventType , lastEventType , CLASSINFO( eventClass ) ) ; \
1187 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , wxT(#name) , &_typeInfo##name , NULL , wxxVariant() ) ; \
1188
1189// ----------------------------------------------------------------------------
1190// Implementation Helper for Simple Properties
1191// ----------------------------------------------------------------------------
1192
1193#define wxIMPLEMENT_PROPERTY(name, type) \
1194private:\
1195 type m_##name; \
1196public: \
1197 void Set##name( type const & p) { m_##name = p; } \
1198 type const & Get##name() const { return m_##name; }
1199
1200// ----------------------------------------------------------------------------
1201// Handler Info
1202//
1203// this is describing an event sink
1204// ----------------------------------------------------------------------------
1205
1206class WXDLLIMPEXP_BASE wxHandlerInfo
1207{
1208 friend class WXDLLIMPEXP_FWD_BASE wxDynamicClassInfo ;
1209public :
1210 wxHandlerInfo(wxHandlerInfo* &iter,
1211 wxClassInfo* itsClass,
1212 const wxString& name,
1213 wxObjectEventFunction address,
1214 const wxClassInfo* eventClassInfo) :
1215 m_eventFunction(address),
1216 m_name(name),
1217 m_eventClassInfo(eventClassInfo) ,
1218 m_itsClass(itsClass)
1219 {
1220 m_next = NULL ;
1221 if ( iter == NULL )
1222 iter = this ;
1223 else
1224 {
1225 wxHandlerInfo* i = iter ;
1226 while( i->m_next )
1227 i = i->m_next ;
1228
1229 i->m_next = this ;
1230 }
1231 }
1232
1233 ~wxHandlerInfo() ;
1234
1235 // return the name of this handler
1236 const wxString& GetName() const { return m_name ; }
1237
1238 // return the class info of the event
1239 const wxClassInfo *GetEventClassInfo() const { return m_eventClassInfo ; }
1240
1241 // get the handler function pointer
1242 wxObjectEventFunction GetEventFunction() const { return m_eventFunction ; }
1243
1244 // returns NULL if this is the last handler of this class
1245 wxHandlerInfo* GetNext() const { return m_next ; }
1246
1247 // return the class this property is declared in
1248 const wxClassInfo* GetDeclaringClass() const { return m_itsClass ; }
1249
1250private :
1251 wxObjectEventFunction m_eventFunction ;
1252 wxString m_name;
1253 const wxClassInfo* m_eventClassInfo ;
1254 wxHandlerInfo* m_next ;
1255 wxClassInfo* m_itsClass ;
1256};
1257
1258#define wxHANDLER(name,eventClassType) \
1259 static wxHandlerInfo _handlerInfo##name( first , class_t::GetClassInfoStatic() , wxT(#name) , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
1260
1261#define wxBEGIN_HANDLERS_TABLE(theClass) \
1262 wxHandlerInfo *theClass::GetHandlersStatic() \
1263{ \
1264 typedef theClass class_t; \
1265 static wxHandlerInfo* first = NULL ;
1266
1267#define wxEND_HANDLERS_TABLE() \
1268 return first ; }
1269
1270// ----------------------------------------------------------------------------
1271// Constructor Bridges
1272//
1273// allow to set up constructors with params during runtime
1274// ----------------------------------------------------------------------------
1275
1276class WXDLLIMPEXP_BASE wxConstructorBridge
1277{
1278public :
1279 virtual ~wxConstructorBridge() {};
1280 virtual void Create(wxObject * &o, wxxVariant *args) = 0;
1281};
1282
1283// a direct constructor bridge calls the operator new for this class and
1284// passes all params to the constructor. needed for classes that cannot be
1285// instantiated using alloc-create semantics
1286class WXDLLIMPEXP_BASE wxDirectConstructorBrigde : public wxConstructorBridge
1287{
1288public :
1289 virtual void Create(wxObject * &o, wxxVariant *args) = 0;
1290} ;
1291
1292// Creator Bridges for all Numbers of Params
1293
1294// no params
1295
1296template<typename Class>
1297struct wxConstructorBridge_0 : public wxConstructorBridge
1298{
1299 void Create(wxObject * &o, wxxVariant *)
1300 {
1301 Class *obj = dynamic_cast<Class*>(o);
1302 obj->Create();
1303 }
1304};
1305
1306struct wxConstructorBridge_Dummy : public wxConstructorBridge
1307{
1308 void Create(wxObject *&, wxxVariant *)
1309 {
1310 }
1311} ;
1312
1313#define wxCONSTRUCTOR_0(klass) \
1314 wxConstructorBridge_0<klass> constructor##klass ; \
1315 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1316 const wxChar *klass::ms_constructorProperties[] = { NULL } ; \
1317 const int klass::ms_constructorPropertiesCount = 0 ;
1318
1319#define wxCONSTRUCTOR_DUMMY(klass) \
1320 wxConstructorBridge_Dummy constructor##klass ; \
1321 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1322 const wxChar *klass::ms_constructorProperties[] = { NULL } ; \
1323 const int klass::ms_constructorPropertiesCount = 0 ;
1324
1325// 1 param
1326
1327template<typename Class, typename T0>
1328struct wxConstructorBridge_1 : public wxConstructorBridge
1329{
1330 void Create(wxObject * &o, wxxVariant *args)
1331 {
1332 Class *obj = dynamic_cast<Class*>(o);
1333 obj->Create(
1334 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0)
1335 );
1336 }
1337};
1338
1339#define wxCONSTRUCTOR_1(klass,t0,v0) \
1340 wxConstructorBridge_1<klass,t0> constructor##klass ; \
1341 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1342 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) } ; \
1343 const int klass::ms_constructorPropertiesCount = 1 ;
1344
1345// 2 params
1346
1347template<typename Class,
1348typename T0, typename T1>
1349struct wxConstructorBridge_2 : public wxConstructorBridge
1350{
1351 void Create(wxObject * &o, wxxVariant *args)
1352 {
1353 Class *obj = dynamic_cast<Class*>(o);
1354 obj->Create(
1355 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1356 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1)
1357 );
1358 }
1359};
1360
1361#define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \
1362 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
1363 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1364 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) } ; \
1365 const int klass::ms_constructorPropertiesCount = 2;
1366
1367// direct constructor version
1368
1369template<typename Class,
1370typename T0, typename T1>
1371struct wxDirectConstructorBridge_2 : public wxDirectConstructorBrigde
1372{
1373 void Create(wxObject * &o, wxxVariant *args)
1374 {
1375 o = new Class(
1376 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1377 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1)
1378 );
1379 }
1380};
1381
1382#define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
1383 wxDirectConstructorBridge_2<klass,t0,t1> constructor##klass ; \
1384 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1385 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) } ; \
1386 const int klass::ms_constructorPropertiesCount = 2;
1387
1388
1389// 3 params
1390
1391template<typename Class,
1392typename T0, typename T1, typename T2>
1393struct wxConstructorBridge_3 : public wxConstructorBridge
1394{
1395 void Create(wxObject * &o, wxxVariant *args)
1396 {
1397 Class *obj = dynamic_cast<Class*>(o);
1398 obj->Create(
1399 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1400 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1401 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2)
1402 );
1403 }
1404};
1405
1406#define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
1407 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
1408 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1409 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) } ; \
1410 const int klass::ms_constructorPropertiesCount = 3 ;
1411
1412// direct constructor version
1413
1414template<typename Class,
1415typename T0, typename T1, typename T2>
1416struct wxDirectConstructorBridge_3 : public wxDirectConstructorBrigde
1417{
1418 void Create(wxObject * &o, wxxVariant *args)
1419 {
1420 o = new Class(
1421 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1422 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1423 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2)
1424 );
1425 }
1426};
1427
1428#define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
1429 wxDirectConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
1430 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1431 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) } ; \
1432 const int klass::ms_constructorPropertiesCount = 3;
1433
1434// 4 params
1435
1436template<typename Class,
1437typename T0, typename T1, typename T2, typename T3>
1438struct wxConstructorBridge_4 : public wxConstructorBridge
1439{
1440 void Create(wxObject * &o, wxxVariant *args)
1441 {
1442 Class *obj = dynamic_cast<Class*>(o);
1443 obj->Create(
1444 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1445 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1446 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) ,
1447 args[3].wxTEMPLATED_MEMBER_CALL(Get , T3)
1448 );
1449 }
1450};
1451
1452#define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
1453 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
1454 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1455 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) } ; \
1456 const int klass::ms_constructorPropertiesCount = 4 ;
1457
1458// 5 params
1459
1460template<typename Class,
1461typename T0, typename T1, typename T2, typename T3, typename T4>
1462struct wxConstructorBridge_5 : public wxConstructorBridge
1463{
1464 void Create(wxObject * &o, wxxVariant *args)
1465 {
1466 Class *obj = dynamic_cast<Class*>(o);
1467 obj->Create(
1468 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1469 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1470 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) ,
1471 args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) ,
1472 args[4].wxTEMPLATED_MEMBER_CALL(Get , T4)
1473 );
1474 }
1475};
1476
1477#define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
1478 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
1479 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1480 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) } ; \
1481 const int klass::ms_constructorPropertiesCount = 5;
1482
1483// 6 params
1484
1485template<typename Class,
1486typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
1487struct wxConstructorBridge_6 : public wxConstructorBridge
1488{
1489 void Create(wxObject * &o, wxxVariant *args)
1490 {
1491 Class *obj = dynamic_cast<Class*>(o);
1492 obj->Create(
1493 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1494 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1495 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) ,
1496 args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) ,
1497 args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) ,
1498 args[5].wxTEMPLATED_MEMBER_CALL(Get , T5)
1499 );
1500 }
1501};
1502
1503#define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
1504 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
1505 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1506 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) } ; \
1507 const int klass::ms_constructorPropertiesCount = 6;
1508
1509// direct constructor version
1510
1511template<typename Class,
1512typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
1513struct wxDirectConstructorBridge_6 : public wxDirectConstructorBrigde
1514{
1515 void Create(wxObject * &o, wxxVariant *args)
1516 {
1517 o = new Class(
1518 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1519 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1520 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) ,
1521 args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) ,
1522 args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) ,
1523 args[5].wxTEMPLATED_MEMBER_CALL(Get , T5)
1524 );
1525 }
1526};
1527
1528#define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
1529 wxDirectConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
1530 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1531 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) } ; \
1532 const int klass::ms_constructorPropertiesCount = 6;
1533
1534// 7 params
1535
1536template<typename Class,
1537typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1538struct wxConstructorBridge_7 : public wxConstructorBridge
1539{
1540 void Create(wxObject * &o, wxxVariant *args)
1541 {
1542 Class *obj = dynamic_cast<Class*>(o);
1543 obj->Create(
1544 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1545 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1546 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) ,
1547 args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) ,
1548 args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) ,
1549 args[5].wxTEMPLATED_MEMBER_CALL(Get , T5) ,
1550 args[6].wxTEMPLATED_MEMBER_CALL(Get , T6)
1551 );
1552 }
1553};
1554
1555#define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
1556 wxConstructorBridge_7<klass,t0,t1,t2,t3,t4,t5,t6> constructor##klass ; \
1557 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1558 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) , wxT(#v6) } ; \
1559 const int klass::ms_constructorPropertiesCount = 7;
1560
1561// 8 params
1562
1563template<typename Class,
1564typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
1565struct wxConstructorBridge_8 : public wxConstructorBridge
1566{
1567 void Create(wxObject * &o, wxxVariant *args)
1568 {
1569 Class *obj = dynamic_cast<Class*>(o);
1570 obj->Create(
1571 args[0].wxTEMPLATED_MEMBER_CALL(Get , T0) ,
1572 args[1].wxTEMPLATED_MEMBER_CALL(Get , T1) ,
1573 args[2].wxTEMPLATED_MEMBER_CALL(Get , T2) ,
1574 args[3].wxTEMPLATED_MEMBER_CALL(Get , T3) ,
1575 args[4].wxTEMPLATED_MEMBER_CALL(Get , T4) ,
1576 args[5].wxTEMPLATED_MEMBER_CALL(Get , T5) ,
1577 args[6].wxTEMPLATED_MEMBER_CALL(Get , T6) ,
1578 args[7].wxTEMPLATED_MEMBER_CALL(Get , T7)
1579 );
1580 }
1581};
1582
1583#define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
1584 wxConstructorBridge_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> constructor##klass ; \
1585 wxConstructorBridge* klass::ms_constructor = &constructor##klass ; \
1586 const wxChar *klass::ms_constructorProperties[] = { wxT(#v0) , wxT(#v1) , wxT(#v2) , wxT(#v3) , wxT(#v4) , wxT(#v5) , wxT(#v6) , wxT(#v7) } ; \
1587 const int klass::ms_constructorPropertiesCount = 8;
1588// ----------------------------------------------------------------------------
1589// wxClassInfo
1590// ----------------------------------------------------------------------------
1591
1592typedef wxObject *(*wxObjectConstructorFn)(void);
1593typedef wxObject* (*wxVariantToObjectConverter)( wxxVariant &data ) ;
1594typedef wxxVariant (*wxObjectToVariantConverter)( wxObject* ) ;
1595
1596class WXDLLIMPEXP_FWD_BASE wxWriter;
1597class WXDLLIMPEXP_FWD_BASE wxPersister;
1598
1599typedef bool (*wxObjectStreamingCallback) ( const wxObject *, wxWriter * , wxPersister * , wxxVariantArray & ) ;
1600
1601class WXDLLIMPEXP_BASE wxClassInfo
1602{
1603 friend class WXDLLIMPEXP_FWD_BASE wxPropertyInfo ;
1604 friend class WXDLLIMPEXP_FWD_BASE wxHandlerInfo ;
1605 friend wxObject *wxCreateDynamicObject(const wxString& name);
1606public:
1607 wxClassInfo(const wxClassInfo **_Parents,
1608 const wxChar *_UnitName,
1609 const wxChar *_ClassName,
1610 int size,
1611 wxObjectConstructorFn ctor ,
1612 wxPropertyInfo *_Props ,
1613 wxHandlerInfo *_Handlers ,
1614 wxConstructorBridge* _Constructor ,
1615 const wxChar ** _ConstructorProperties ,
1616 const int _ConstructorPropertiesCount ,
1617 wxVariantToObjectConverter _PtrConverter1 ,
1618 wxVariantToObjectConverter _Converter2 ,
1619 wxObjectToVariantConverter _Converter3 ,
1620 wxObjectStreamingCallback _streamingCallback = NULL
1621 ) :
1622
1623 m_className(_ClassName),
1624 m_objectSize(size),
1625 m_objectConstructor(ctor),
1626 m_next(sm_first),
1627 m_firstProperty(_Props),
1628 m_firstHandler(_Handlers),
1629 m_parents(_Parents),
1630 m_unitName(_UnitName),
1631 m_constructor(_Constructor),
1632 m_constructorProperties(_ConstructorProperties),
1633 m_constructorPropertiesCount(_ConstructorPropertiesCount),
1634 m_variantOfPtrToObjectConverter(_PtrConverter1),
1635 m_variantToObjectConverter(_Converter2),
1636 m_objectToVariantConverter(_Converter3),
1637 m_streamingCallback(_streamingCallback)
1638 {
1639 sm_first = this;
1640 Register() ;
1641 }
1642
1643 wxClassInfo(const wxChar *_UnitName, const wxChar *_ClassName,
1644 const wxClassInfo **_Parents) :
1645 m_className(_ClassName),
1646 m_objectSize(0),
1647 m_objectConstructor(NULL),
1648 m_next(sm_first),
1649 m_firstProperty(NULL),
1650 m_firstHandler(NULL),
1651 m_parents(_Parents),
1652 m_unitName(_UnitName),
1653 m_constructor(NULL),
1654 m_constructorProperties(NULL),
1655 m_constructorPropertiesCount(0),
1656 m_variantOfPtrToObjectConverter(NULL),
1657 m_variantToObjectConverter(NULL),
1658 m_objectToVariantConverter(NULL),
1659 m_streamingCallback(NULL)
1660 {
1661 sm_first = this;
1662 Register() ;
1663 }
1664
1665 virtual ~wxClassInfo() ;
1666
1667 // allocates an instance of this class, this object does not have to be initialized or fully constructed
1668 // as this call will be followed by a call to Create
1669 virtual wxObject *AllocateObject() const { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
1670
1671 // 'old naming' for AllocateObject staying here for backward compatibility
1672 wxObject *CreateObject() const { return AllocateObject() ; }
1673
1674 // direct construction call for classes that cannot construct instances via alloc/create
1675 wxObject *ConstructObject(int ParamCount, wxxVariant *Params) const
1676 {
1677 if ( ParamCount != m_constructorPropertiesCount )
1678 {
1679 wxLogError( wxGetTranslation(wxT("Illegal Parameter Count for ConstructObject Method")) ) ;
1680 return NULL ;
1681 }
1682 wxObject *object = NULL ;
1683 m_constructor->Create( object , Params ) ;
1684 return object ;
1685 }
1686
1687 bool NeedsDirectConstruction() const { return dynamic_cast<wxDirectConstructorBrigde*>( m_constructor) != NULL ; }
1688
1689 const wxChar *GetClassName() const { return m_className; }
1690 const wxChar *GetBaseClassName1() const
1691 { return m_parents[0] ? m_parents[0]->GetClassName() : NULL; }
1692 const wxChar *GetBaseClassName2() const
1693 { return (m_parents[0] && m_parents[1]) ? m_parents[1]->GetClassName() : NULL; }
1694 const wxChar *GetIncludeName() const { return m_unitName ; }
1695 const wxClassInfo **GetParents() const { return m_parents; }
1696 int GetSize() const { return m_objectSize; }
1697 bool IsDynamic() const { return (NULL != m_objectConstructor); }
1698
1699 wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
1700 static const wxClassInfo *GetFirst() { return sm_first; }
1701 const wxClassInfo *GetNext() const { return m_next; }
1702 static wxClassInfo *FindClass(const wxString& className);
1703
1704 // Climb upwards through inheritance hierarchy.
1705 // Dual inheritance is catered for.
1706
1707 bool IsKindOf(const wxClassInfo *info) const
1708 {
1709 if ( info != 0 )
1710 {
1711 if ( info == this )
1712 return true ;
1713
1714 for ( int i = 0 ; m_parents[i] ; ++ i )
1715 {
1716 if ( m_parents[i]->IsKindOf( info ) )
1717 return true ;
1718 }
1719 }
1720 return false ;
1721 }
1722
1723 DECLARE_CLASS_INFO_ITERATORS()
1724
1725 // if there is a callback registered with that class it will be called
1726 // before this object will be written to disk, it can veto streaming out
1727 // this object by returning false, if this class has not registered a
1728 // callback, the search will go up the inheritance tree if no callback has
1729 // been registered true will be returned by default
1730 bool BeforeWriteObject( const wxObject *obj, wxWriter *streamer , wxPersister *persister , wxxVariantArray &metadata) const ;
1731
1732 // gets the streaming callback from this class or any superclass
1733 wxObjectStreamingCallback GetStreamingCallback() const ;
1734
1735 static void CleanUp();
1736
1737 // returns the first property
1738 const wxPropertyInfo* GetFirstProperty() const { return m_firstProperty ; }
1739
1740 // returns the first handler
1741 const wxHandlerInfo* GetFirstHandler() const { return m_firstHandler ; }
1742
1743 // Call the Create upon an instance of the class, in the end the object is fully
1744 // initialized
1745 virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const
1746 {
1747 if ( ParamCount != m_constructorPropertiesCount )
1748 {
1749 wxLogError( wxGetTranslation(wxT("Illegal Parameter Count for Create Method")) ) ;
1750 return ;
1751 }
1752 m_constructor->Create( object , Params ) ;
1753 }
1754
1755 // get number of parameters for constructor
1756 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount; }
1757
1758 // get n-th constructor parameter
1759 virtual const wxChar* GetCreateParamName(int n) const { return m_constructorProperties[n] ; }
1760
1761 // Runtime access to objects for simple properties (get/set) by property name, and variant data
1762 virtual void SetProperty (wxObject *object, const wxChar *propertyName, const wxxVariant &value) const ;
1763 virtual wxxVariant GetProperty (wxObject *object, const wxChar *propertyName) const;
1764
1765 // Runtime access to objects for collection properties by property name
1766 virtual wxxVariantArray GetPropertyCollection(wxObject *object, const wxChar *propertyName) const ;
1767 virtual void AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const ;
1768
1769 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1770 wxObject* VariantToInstance( wxxVariant &data ) const
1771 {
1772 if ( data.GetTypeInfo()->GetKind() == wxT_OBJECT )
1773 return m_variantToObjectConverter( data ) ;
1774 else
1775 return m_variantOfPtrToObjectConverter( data ) ;
1776 }
1777
1778 wxxVariant InstanceToVariant( wxObject *object ) const { return m_objectToVariantConverter( object ) ; }
1779
1780 // find property by name
1781 virtual const wxPropertyInfo *FindPropertyInfo (const wxChar *PropertyName) const ;
1782
1783 // find handler by name
1784 virtual const wxHandlerInfo *FindHandlerInfo (const wxChar *PropertyName) const ;
1785
1786 // find property by name
1787 virtual wxPropertyInfo *FindPropertyInfoInThisClass (const wxChar *PropertyName) const ;
1788
1789 // find handler by name
1790 virtual wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *PropertyName) const ;
1791
1792 // puts all the properties of this class and its superclasses in the map, as long as there is not yet
1793 // an entry with the same name (overriding mechanism)
1794 void GetProperties( wxPropertyInfoMap &map ) const ;
1795private:
1796 const wxChar *m_className;
1797 int m_objectSize;
1798 wxObjectConstructorFn m_objectConstructor;
1799
1800 // class info object live in a linked list:
1801 // pointers to its head and the next element in it
1802
1803 static wxClassInfo *sm_first;
1804 wxClassInfo *m_next;
1805
1806 static wxHashTable *sm_classTable;
1807
1808protected :
1809 wxPropertyInfo * m_firstProperty ;
1810 wxHandlerInfo * m_firstHandler ;
1811private:
1812 const wxClassInfo** m_parents ;
1813 const wxChar* m_unitName;
1814
1815 wxConstructorBridge* m_constructor ;
1816 const wxChar ** m_constructorProperties ;
1817 const int m_constructorPropertiesCount ;
1818 wxVariantToObjectConverter m_variantOfPtrToObjectConverter ;
1819 wxVariantToObjectConverter m_variantToObjectConverter ;
1820 wxObjectToVariantConverter m_objectToVariantConverter ;
1821 wxObjectStreamingCallback m_streamingCallback ;
1822 const wxPropertyAccessor *FindAccessor (const wxChar *propertyName) const ;
1823
1824protected:
1825 // registers the class
1826 void Register();
1827 void Unregister();
1828
1829 wxDECLARE_NO_COPY_CLASS(wxClassInfo);
1830};
1831
1832
1833WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
1834
1835// ----------------------------------------------------------------------------
1836// wxDynamicObject
1837// ----------------------------------------------------------------------------
1838//
1839// this object leads to having a pure runtime-instantiation
1840
1841class WXDLLIMPEXP_BASE wxDynamicClassInfo : public wxClassInfo
1842{
1843 friend class WXDLLIMPEXP_FWD_BASE wxDynamicObject ;
1844public :
1845 wxDynamicClassInfo( const wxChar *_UnitName, const wxChar *_ClassName , const wxClassInfo* superClass ) ;
1846 virtual ~wxDynamicClassInfo() ;
1847
1848 // constructs a wxDynamicObject with an instance
1849 virtual wxObject *AllocateObject() const ;
1850
1851 // Call the Create method for a class
1852 virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const ;
1853
1854 // get number of parameters for constructor
1855 virtual int GetCreateParamCount() const ;
1856
1857 // get i-th constructor parameter
1858 virtual const wxChar* GetCreateParamName(int i) const ;
1859
1860 // Runtime access to objects by property name, and variant data
1861 virtual void SetProperty (wxObject *object, const wxChar *PropertyName, const wxxVariant &Value) const ;
1862 virtual wxxVariant GetProperty (wxObject *object, const wxChar *PropertyName) const ;
1863
1864 // adds a property to this class at runtime
1865 void AddProperty( const wxChar *propertyName , const wxTypeInfo* typeInfo ) ;
1866
1867 // removes an existing runtime-property
1868 void RemoveProperty( const wxChar *propertyName ) ;
1869
1870 // renames an existing runtime-property
1871 void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ;
1872
1873 // as a handler to this class at runtime
1874 void AddHandler( const wxChar *handlerName , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) ;
1875
1876 // removes an existing runtime-handler
1877 void RemoveHandler( const wxChar *handlerName ) ;
1878
1879 // renames an existing runtime-handler
1880 void RenameHandler( const wxChar *oldHandlerName , const wxChar *newHandlerName ) ;
1881private :
1882 struct wxDynamicClassInfoInternal ;
1883 wxDynamicClassInfoInternal* m_data ;
1884} ;
1885
1886// ----------------------------------------------------------------------------
1887// Dynamic class macros
1888// ----------------------------------------------------------------------------
1889
1890#define _DECLARE_DYNAMIC_CLASS(name) \
1891 public: \
1892 static wxClassInfo ms_classInfo; \
1893 static const wxClassInfo* ms_classParents[] ; \
1894 static wxPropertyInfo* GetPropertiesStatic() ; \
1895 static wxHandlerInfo* GetHandlersStatic() ; \
1896 static wxClassInfo *GetClassInfoStatic() \
1897{ return &name::ms_classInfo; } \
1898 virtual wxClassInfo *GetClassInfo() const \
1899{ return &name::ms_classInfo; }
1900
1901/*
1902#define _DECLARE_DYNAMIC_CLASS(name) \
1903 public: \
1904 static wxClassInfo ms_class##name; \
1905 static const wxClassInfo* ms_classParents##name[] ; \
1906 static wxPropertyInfo* GetPropertiesStatic() ; \
1907 static wxHandlerInfo* GetHandlersStatic() ; \
1908 static wxClassInfo *GetClassInfoStatic() \
1909{ return &name::ms_class##name; } \
1910 virtual wxClassInfo *GetClassInfo() const \
1911{ return &name::ms_class##name; }
1912*/
1913#define DECLARE_DYNAMIC_CLASS(name) \
1914 static wxConstructorBridge* ms_constructor ; \
1915 static const wxChar * ms_constructorProperties[] ; \
1916 static const int ms_constructorPropertiesCount ; \
1917 _DECLARE_DYNAMIC_CLASS(name)
1918
1919#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1920 DECLARE_NO_ASSIGN_CLASS(name) \
1921 DECLARE_DYNAMIC_CLASS(name)
1922
1923#define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1924 DECLARE_NO_COPY_CLASS(name) \
1925 DECLARE_DYNAMIC_CLASS(name)
1926
1927#define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1928#define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1929
1930// -----------------------------------
1931// for concrete classes
1932// -----------------------------------
1933
1934// Single inheritance with one base class
1935
1936#define _TYPEINFO_CLASSES(n , toString , fromString ) \
1937 wxClassTypeInfo s_typeInfo##n(wxT_OBJECT , &n::ms_classInfo , toString , fromString , typeid(n).name()) ; \
1938 wxClassTypeInfo s_typeInfoPtr##n(wxT_OBJECT_PTR , &n::ms_classInfo , toString , fromString , typeid(n*).name()) ;
1939
1940#define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit , callback) \
1941 wxObject* wxConstructorFor##name() \
1942{ return new name; } \
1943 const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \
1944 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \
1945 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1946 wxClassInfo name::ms_classInfo(name::ms_classParents , wxT(unit) , wxT(#name), \
1947 (int) sizeof(name), \
1948 (wxObjectConstructorFn) wxConstructorFor##name , \
1949 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::ms_constructor , name::ms_constructorProperties , \
1950 name::ms_constructorPropertiesCount , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name , callback);
1951
1952#define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit, callback ) \
1953 wxObject* wxConstructorFor##name() \
1954{ return new name; } \
1955 const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \
1956 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.wxTEMPLATED_MEMBER_CALL(Get , name) ; } \
1957 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \
1958 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1959 wxClassInfo name::ms_classInfo(name::ms_classParents , wxT(unit) , wxT(#name), \
1960 (int) sizeof(name), \
1961 (wxObjectConstructorFn) wxConstructorFor##name , \
1962 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::ms_constructor , name::ms_constructorProperties, \
1963 name::ms_constructorPropertiesCount , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name, callback);
1964
1965#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1966 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" , NULL ) \
1967 _TYPEINFO_CLASSES(name, NULL , NULL) \
1968 const wxPropertyInfo *name::GetPropertiesStatic() { return NULL ; } \
1969 const wxHandlerInfo *name::GetHandlersStatic() { return NULL ; } \
1970 wxCONSTRUCTOR_DUMMY( name )
1971
1972#define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1973 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" , NULL ) \
1974 _TYPEINFO_CLASSES(name, NULL , NULL) \
1975 wxPropertyInfo *name::GetPropertiesStatic() { return NULL ; } \
1976 wxHandlerInfo *name::GetHandlersStatic() { return NULL ; } \
1977 wxCONSTRUCTOR_DUMMY( name )
1978
1979#define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1980 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , NULL ) \
1981 _TYPEINFO_CLASSES(name, NULL , NULL)
1982
1983#define IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name , basename , unit , callback ) \
1984 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , &callback ) \
1985 _TYPEINFO_CLASSES(name, NULL , NULL)
1986
1987#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1988 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit , NULL ) \
1989 _TYPEINFO_CLASSES(name, NULL , NULL)
1990
1991#define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name , basename , unit , toString , fromString ) \
1992 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit , NULL ) \
1993 _TYPEINFO_CLASSES(name, toString , fromString)
1994
1995// this is for classes that do not derive from wxobject, there are no creators for these
1996
1997#define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1998 const wxClassInfo* name::ms_classParents[] = { NULL } ; \
1999 wxClassInfo name::ms_classInfo(name::ms_classParents , wxEmptyString , wxT(#name), \
2000 (int) sizeof(name), \
2001 (wxObjectConstructorFn) 0 , \
2002 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
2003 0 , 0 , 0 ); \
2004 _TYPEINFO_CLASSES(name, NULL , NULL)
2005
2006// this is for subclasses that still do not derive from wxobject
2007
2008#define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
2009 const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \
2010 wxClassInfo name::ms_classInfo(name::ms_classParents , wxEmptyString , wxT(#name), \
2011 (int) sizeof(name), \
2012 (wxObjectConstructorFn) 0 , \
2013 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
2014 0 , 0 , 0 ); \
2015 _TYPEINFO_CLASSES(name, NULL , NULL)
2016
2017
2018// Multiple inheritance with two base classes
2019
2020#define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit, callback) \
2021 wxObject* wxConstructorFor##name() \
2022{ return new name; } \
2023 const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,&basename2::ms_classInfo , NULL } ; \
2024 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \
2025 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
2026 wxClassInfo name::ms_classInfo(name::ms_classParents , wxT(unit) , wxT(#name), \
2027 (int) sizeof(name), \
2028 (wxObjectConstructorFn) wxConstructorFor##name , \
2029 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::ms_constructor , name::ms_constructorProperties , \
2030 name::ms_constructorPropertiesCount , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name , callback);
2031
2032#define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
2033 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "", NULL) \
2034 _TYPEINFO_CLASSES(name, NULL , NULL) \
2035 wxPropertyInfo *name::GetPropertiesStatic() { return NULL ; } \
2036 wxHandlerInfo *name::GetHandlersStatic() { return NULL ; } \
2037 wxCONSTRUCTOR_DUMMY( name )
2038
2039#define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
2040 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit, NULL) \
2041 _TYPEINFO_CLASSES(name, NULL , NULL)
2042
2043
2044// -----------------------------------
2045// for abstract classes
2046// -----------------------------------
2047
2048// Single inheritance with one base class
2049
2050#define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
2051 const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo ,NULL } ; \
2052 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \
2053 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.wxTEMPLATED_MEMBER_CALL(Get , name*) ; } \
2054 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
2055 wxClassInfo name::ms_classInfo(name::ms_classParents , wxEmptyString , wxT(#name), \
2056 (int) sizeof(name), \
2057 (wxObjectConstructorFn) 0 , \
2058 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
2059 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
2060 _TYPEINFO_CLASSES(name, NULL , NULL)
2061
2062#define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
2063 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
2064 wxHandlerInfo *name::GetHandlersStatic() { return NULL ; } \
2065 wxPropertyInfo *name::GetPropertiesStatic() { return NULL ; }
2066
2067// Multiple inheritance with two base classes
2068
2069#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
2070 wxClassInfo name::ms_classInfo(wxT(#name), wxT(#basename1), \
2071 wxT(#basename2), (int) sizeof(name), \
2072 (wxObjectConstructorFn) 0);
2073
2074#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
2075#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
2076
2077#define wxBEGIN_EVENT_TABLE( a , b ) BEGIN_EVENT_TABLE( a , b )
2078#define wxEND_EVENT_TABLE() END_EVENT_TABLE()
2079
2080// --------------------------------------------------------------------------
2081// Collection Support
2082// --------------------------------------------------------------------------
2083
2084template<typename iter , typename collection_t > void wxListCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value )
2085{
2086 iter current = coll.GetFirst() ;
2087 while (current)
2088 {
2089 value.Add( new wxxVariant(current->GetData()) ) ;
2090 current = current->GetNext();
2091 }
2092}
2093
2094template<typename collection_t> void wxArrayCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value )
2095{
2096 for( size_t i = 0 ; i < coll.GetCount() ; i++ )
2097 {
2098 value.Add( new wxxVariant(coll[i]) ) ;
2099 }
2100}
2101
2102
2103#endif // _WX_XTIH__