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