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