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