]>
Commit | Line | Data |
---|---|---|
a095505c SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/xti.h | |
3 | // Purpose: runtime metadata information (extended class info) | |
4 | // Author: Stefan Csomor | |
4393b50c | 5 | // Modified by: |
a095505c SC |
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 | ||
12028905 | 16 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
a095505c SC |
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 | |
4393b50c | 22 | // effort as painless as possible. |
a095505c SC |
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 | |
4393b50c | 29 | // which will be merged with wxVariant |
a095505c SC |
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/set.h" | |
42 | #include "wx/string.h" | |
aeec2045 | 43 | #include "wx/arrstr.h" |
a095505c | 44 | |
438edbc0 SC |
45 | // some compilers have troubles getting the correct wxPropertyAccessorT constructor |
46 | // set this to 1 to make things work for these, too | |
47 | ||
31478355 | 48 | #ifndef WX_XTI_TEMPLATE_FIX |
438edbc0 | 49 | #define WX_XTI_TEMPLATE_FIX 0 |
31478355 | 50 | #endif |
438edbc0 SC |
51 | |
52 | #if WX_XTI_TEMPLATE_FIX | |
53 | #define WX_XTI_PARAM_FIX(a,b) a,b | |
54 | #else | |
55 | #define WX_XTI_PARAM_FIX(a,b) | |
56 | #endif | |
57 | ||
a095505c SC |
58 | class WXDLLIMPEXP_BASE wxObject; |
59 | class WXDLLIMPEXP_BASE wxClassInfo; | |
60 | class WXDLLIMPEXP_BASE wxHashTable; | |
61 | class WXDLLIMPEXP_BASE wxObjectRefData; | |
62 | class WXDLLIMPEXP_BASE wxEvent; | |
63 | ||
64 | typedef void (wxObject::*wxObjectEventFunction)(wxEvent&); | |
65 | ||
66 | // ---------------------------------------------------------------------------- | |
67 | // Enum Support | |
68 | // | |
4393b50c | 69 | // In the header files there would no change from pure c++ code, in the |
a095505c SC |
70 | // implementation, an enum would have |
71 | // to be enumerated eg : | |
72 | // | |
73 | // WX_BEGIN_ENUM( wxFlavor ) | |
74 | // WX_ENUM_MEMBER( Vanilla ) | |
75 | // WX_ENUM_MEMBER( Chocolate ) | |
76 | // WX_ENUM_MEMBER( Strawberry ) | |
77 | // WX_END_ENUM( wxFlavor ) | |
78 | // ---------------------------------------------------------------------------- | |
79 | ||
80 | struct WXDLLIMPEXP_BASE wxEnumMemberData | |
81 | { | |
517fb871 VS |
82 | const wxChar* m_name; |
83 | int m_value; | |
a095505c SC |
84 | }; |
85 | ||
86 | class WXDLLIMPEXP_BASE wxEnumData | |
87 | { | |
88 | public : | |
517fb871 | 89 | wxEnumData( wxEnumMemberData* data ) ; |
a095505c | 90 | |
517fb871 VS |
91 | // returns true if the member has been found and sets the int value |
92 | // pointed to accordingly (if ptr != null ) | |
93 | // if not found returns false, value left unchanged | |
94 | bool HasEnumMemberValue( const wxChar *name , int *value = NULL ) ; | |
4393b50c | 95 | |
517fb871 VS |
96 | // returns the value of the member, if not found in debug mode an |
97 | // assert is issued, in release 0 is returned | |
98 | int GetEnumMemberValue(const wxChar *name ); | |
4393b50c | 99 | |
517fb871 VS |
100 | // returns the name of the enum member having the passed in value |
101 | // returns an emtpy string if not found | |
a095505c | 102 | const wxChar *GetEnumMemberName(int value); |
4393b50c | 103 | |
517fb871 VS |
104 | // returns the number of members in this enum |
105 | int GetEnumCount() { return m_count ; } | |
4393b50c | 106 | |
517fb871 VS |
107 | // returns the value of the nth member |
108 | int GetEnumMemberValueByIndex( int n ) ; | |
4393b50c | 109 | |
517fb871 VS |
110 | // returns the value of the nth member |
111 | const wxChar *GetEnumMemberNameByIndex( int n ) ; | |
a095505c SC |
112 | private : |
113 | wxEnumMemberData *m_members; | |
517fb871 | 114 | int m_count ; |
a095505c SC |
115 | }; |
116 | ||
117 | #define WX_BEGIN_ENUM( e ) \ | |
517fb871 | 118 | wxEnumMemberData s_enumDataMembers##e[] = { |
a095505c SC |
119 | |
120 | #define WX_ENUM_MEMBER( v ) { #v, v } , | |
121 | ||
122 | #define WX_END_ENUM( e ) { NULL , 0 } } ; \ | |
517fb871 VS |
123 | wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \ |
124 | wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \ | |
125 | template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e) ; return &s_typeInfo ; } \ | |
126 | template<> void wxStringReadValue(const wxString& s , e &data ) \ | |
127 | { \ | |
128 | data = (e) s_enumData##e.GetEnumMemberValue(s) ; \ | |
129 | } \ | |
130 | template<> void wxStringWriteValue(wxString &s , const e &data ) \ | |
131 | { \ | |
132 | s = s_enumData##e.GetEnumMemberName((int)data) ; \ | |
f0b7eadf SC |
133 | } \ |
134 | template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \ | |
135 | template<> void wxStringReadValue(const wxString& , e* & ) \ | |
136 | { \ | |
137 | assert(0) ; \ | |
138 | } \ | |
139 | template<> void wxStringWriteValue(wxString &s , e* const & ) \ | |
140 | { \ | |
141 | assert(0) ; \ | |
517fb871 | 142 | } |
a095505c SC |
143 | |
144 | // ---------------------------------------------------------------------------- | |
145 | // Set Support | |
4393b50c | 146 | // |
a095505c | 147 | // in the header : |
4393b50c | 148 | // |
a095505c | 149 | // enum wxFlavor |
4393b50c | 150 | // { |
517fb871 VS |
151 | // Vanilla, |
152 | // Chocolate, | |
153 | // Strawberry, | |
a095505c | 154 | // }; |
4393b50c | 155 | // |
a095505c | 156 | // typedef wxSet<wxFlavor> wxCoupe ; |
4393b50c | 157 | // |
a095505c | 158 | // in the implementation file : |
4393b50c | 159 | // |
a095505c | 160 | // WX_BEGIN_ENUM( wxFlavor ) |
517fb871 VS |
161 | // WX_ENUM_MEMBER( Vanilla ) |
162 | // WX_ENUM_MEMBER( Chocolate ) | |
163 | // WX_ENUM_MEMBER( Strawberry ) | |
a095505c | 164 | // WX_END_ENUM( wxFlavor ) |
a095505c | 165 | // |
4393b50c SC |
166 | // WX_IMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor ) |
167 | // | |
168 | // implementation note : no partial specialization for streaming, but a delegation to a | |
a095505c SC |
169 | // different class |
170 | // | |
171 | // ---------------------------------------------------------------------------- | |
172 | ||
173 | // in order to remove dependancy on string tokenizer | |
174 | void wxSetStringToArray( const wxString &s , wxArrayString &array ) ; | |
175 | ||
176 | template<typename e> | |
4393b50c | 177 | void wxSetFromString(const wxString &s , wxSet<e> &data ) |
a095505c | 178 | { |
517fb871 VS |
179 | wxEnumData* edata = wxGetEnumData((e) 0) ; |
180 | data.Clear() ; | |
a095505c | 181 | |
517fb871 VS |
182 | wxArrayString array ; |
183 | wxSetStringToArray( s , array ) ; | |
a095505c SC |
184 | wxString flag; |
185 | for ( int i = 0 ; i < array.Count() ; ++i ) | |
186 | { | |
187 | flag = array[i] ; | |
517fb871 VS |
188 | int ivalue ; |
189 | if ( edata->HasEnumMemberValue( flag , &ivalue ) ) | |
190 | { | |
191 | data.Set( (e) ivalue ) ; | |
192 | } | |
a095505c SC |
193 | } |
194 | } | |
195 | ||
196 | template<typename e> | |
197 | void wxSetToString( wxString &s , const wxSet<e> &data ) | |
198 | { | |
517fb871 VS |
199 | wxEnumData* edata = wxGetEnumData((e) 0) ; |
200 | int count = edata->GetEnumCount() ; | |
201 | int i ; | |
202 | s.Clear() ; | |
203 | for ( i = 0 ; i < count ; i++ ) | |
204 | { | |
205 | e value = (e) edata->GetEnumMemberValueByIndex(i) ; | |
206 | if ( data.Contains( value ) ) | |
207 | { | |
208 | // this could also be done by the templated calls | |
209 | if ( !s.IsEmpty() ) | |
210 | s +="|" ; | |
211 | s += edata->GetEnumMemberNameByIndex(i) ; | |
212 | } | |
213 | } | |
a095505c SC |
214 | } |
215 | ||
216 | // if the wxSet specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro | |
517fb871 | 217 | // template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; } |
a095505c SC |
218 | |
219 | #define WX_IMPLEMENT_SET_STREAMING(SetName,e) \ | |
517fb871 VS |
220 | template<> void wxStringReadValue(const wxString &s , wxSet<e> &data ) \ |
221 | { \ | |
222 | wxSetFromString( s , data ) ; \ | |
223 | } \ | |
224 | template<> void wxStringWriteValue( wxString &s , const wxSet<e> &data ) \ | |
225 | { \ | |
226 | wxSetToString( s , data ) ; \ | |
227 | } \ | |
a095505c SC |
228 | |
229 | ||
230 | // ---------------------------------------------------------------------------- | |
231 | // Type Information | |
232 | // ---------------------------------------------------------------------------- | |
ab6e4913 SC |
233 | // |
234 | // | |
235 | // All data exposed by the RTTI is characterized using the following classes. | |
236 | // The first characterization is done by wxTypeKind. All enums up to and including | |
237 | // wxT_CUSTOM represent so called simple types. These cannot be divided any further. | |
238 | // They can be converted to and from wxStrings, that's all. | |
239 | ||
a095505c SC |
240 | |
241 | enum wxTypeKind | |
242 | { | |
243 | wxT_VOID = 0, // unknown type | |
244 | wxT_BOOL, | |
245 | wxT_CHAR, | |
246 | wxT_UCHAR, | |
247 | wxT_INT, | |
248 | wxT_UINT, | |
249 | wxT_LONG, | |
250 | wxT_ULONG, | |
251 | wxT_FLOAT, | |
252 | wxT_DOUBLE, | |
253 | wxT_STRING, // must be wxString | |
254 | wxT_SET, // must be wxSet<> template | |
255 | wxT_ENUM, | |
a095505c | 256 | wxT_CUSTOM, // user defined type (e.g. wxPoint) |
ab6e4913 SC |
257 | |
258 | wxT_LAST_SIMPLE_TYPE_KIND = wxT_CUSTOM , | |
259 | ||
260 | wxT_OBJECT_PTR, // object reference | |
261 | wxT_OBJECT , // embedded object | |
262 | wxT_COLLECTION , // collection | |
263 | ||
517fb871 | 264 | wxT_DELEGATE , // for connecting against an event source |
ab6e4913 SC |
265 | |
266 | wxT_LAST_TYPE_KIND = wxT_DELEGATE // sentinel for bad data, asserts, debugging | |
a095505c SC |
267 | }; |
268 | ||
269 | class WXDLLIMPEXP_BASE wxTypeInfo | |
270 | { | |
271 | public : | |
fa08490f SC |
272 | wxTypeInfo() : m_kind( wxT_VOID) {} |
273 | virtual ~wxTypeInfo() {} | |
274 | wxTypeKind GetKind() const { return m_kind ; } | |
275 | bool IsDelegateType() const { return m_kind == wxT_DELEGATE ; } | |
276 | bool IsCustomType() const { return m_kind == wxT_CUSTOM ; } | |
277 | bool IsObjectType() const { return m_kind == wxT_OBJECT || m_kind == wxT_OBJECT_PTR ; } | |
a095505c | 278 | protected : |
fa08490f | 279 | wxTypeKind m_kind ; |
a095505c SC |
280 | }; |
281 | ||
282 | class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo | |
283 | { | |
284 | public : | |
517fb871 | 285 | wxBuiltInTypeInfo( wxTypeKind kind ) { wxASSERT_MSG( kind < wxT_SET , wxT("Illegal Kind for Base Type") ) ; m_kind = kind ;} |
a095505c SC |
286 | } ; |
287 | ||
288 | class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo | |
289 | { | |
290 | public : | |
517fb871 VS |
291 | wxCustomTypeInfo( const wxChar *typeName ) |
292 | { m_kind = wxT_CUSTOM ; m_typeName = typeName ;} | |
293 | const wxChar *GetTypeName() const { return m_typeName ; } | |
a095505c | 294 | private : |
517fb871 | 295 | const wxChar *m_typeName; // Kind == wxT_CUSTOM |
a095505c SC |
296 | } ; |
297 | ||
298 | class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo | |
299 | { | |
300 | public : | |
517fb871 VS |
301 | wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo ) |
302 | { wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_kind = kind ; m_enumInfo = enumInfo ;} | |
303 | const wxEnumData* GetEnumData() const { return m_enumInfo ; } | |
a095505c | 304 | private : |
517fb871 | 305 | wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET |
a095505c SC |
306 | } ; |
307 | ||
308 | class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo | |
309 | { | |
310 | public : | |
fa08490f SC |
311 | wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo ) |
312 | { wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_kind = kind ; m_classInfo = classInfo ;} | |
313 | const wxClassInfo *GetClassInfo() const { return m_classInfo ; } | |
a095505c | 314 | private : |
517fb871 | 315 | wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL |
a095505c SC |
316 | } ; |
317 | ||
ab6e4913 SC |
318 | class WXDLLIMPEXP_BASE wxCollectionTypeInfo : public wxTypeInfo |
319 | { | |
320 | public : | |
321 | wxCollectionTypeInfo( wxTypeInfo *elementType ) | |
322 | { m_kind = wxT_COLLECTION , m_elementType = elementType ; } | |
323 | ||
324 | const wxTypeInfo* GetElementType() const { return m_elementType ; } | |
325 | private : | |
326 | wxTypeInfo * m_elementType ; | |
327 | } ; | |
328 | ||
4393b50c | 329 | // a delegate is an exposed event source |
a095505c SC |
330 | |
331 | class WXDLLIMPEXP_BASE wxDelegateTypeInfo : public wxTypeInfo | |
332 | { | |
333 | public : | |
517fb871 VS |
334 | wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass ) |
335 | { m_kind = wxT_DELEGATE ; m_eventClass = eventClass ; m_eventType = eventType ;} | |
336 | const wxClassInfo *GetEventClass() const { assert( m_kind == wxT_DELEGATE ) ; return m_eventClass ; } | |
337 | int GetEventType() const { return m_eventType ; } | |
a095505c | 338 | private : |
517fb871 VS |
339 | const wxClassInfo *m_eventClass; // (extended will merge into classinfo) |
340 | int m_eventType ; | |
a095505c SC |
341 | } ; |
342 | ||
343 | template<typename T> const wxTypeInfo* wxGetTypeInfo( T * ) ; | |
344 | ||
4393b50c | 345 | template<typename T> const wxTypeInfo* wxGetTypeInfo( wxSet<T> * ) |
a095505c | 346 | { |
517fb871 | 347 | static wxEnumTypeInfo s_typeInfo(wxT_SET , wxGetEnumData((T) 0) ) ; return &s_typeInfo ; |
a095505c SC |
348 | } |
349 | ||
350 | // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type | |
351 | ||
352 | #define WX_CUSTOM_TYPE_INFO( e ) \ | |
f0b7eadf SC |
353 | template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \ |
354 | template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e) ; return &s_typeInfo ; } | |
a095505c | 355 | |
a095505c SC |
356 | // templated streaming, every type must have their specialization for these methods |
357 | ||
358 | template<typename T> | |
f0b7eadf | 359 | void wxStringReadValue( const wxString &s , T &data ); |
a095505c SC |
360 | |
361 | template<typename T> | |
f0b7eadf | 362 | void wxStringWriteValue( wxString &s , const T &data); |
a095505c | 363 | |
aa8d7c2f | 364 | // sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs |
a095505c | 365 | |
aa8d7c2f SC |
366 | #define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \ |
367 | template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \ | |
368 | static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \ | |
369 | template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\ | |
370 | template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; } | |
a095505c SC |
371 | |
372 | // ---------------------------------------------------------------------------- | |
373 | // wxxVariant as typesafe data holder | |
374 | // ---------------------------------------------------------------------------- | |
375 | ||
376 | class WXDLLIMPEXP_BASE wxxVariantData | |
377 | { | |
378 | public: | |
517fb871 | 379 | virtual ~wxxVariantData() {} |
a095505c | 380 | |
517fb871 VS |
381 | // return a heap allocated duplicate |
382 | virtual wxxVariantData* Clone() const = 0 ; | |
a095505c | 383 | |
517fb871 VS |
384 | // returns the type info of the contentc |
385 | virtual const wxTypeInfo* GetTypeInfo() const = 0 ; | |
a095505c | 386 | |
517fb871 VS |
387 | // write the value into a string |
388 | virtual void Write( wxString &s ) const = 0 ; | |
a095505c | 389 | |
517fb871 VS |
390 | // read the value from a string |
391 | virtual void Read( const wxString &s) = 0 ; | |
a095505c SC |
392 | } ; |
393 | ||
394 | template<typename T> class WXDLLIMPEXP_BASE wxxVariantDataT : public wxxVariantData | |
395 | { | |
396 | public: | |
fa08490f SC |
397 | wxxVariantDataT(const T& d) : m_data(d) {} |
398 | virtual ~wxxVariantDataT() {} | |
a095505c | 399 | |
fa08490f SC |
400 | // get a ref to the stored data |
401 | T & Get() { return m_data; } | |
a095505c | 402 | |
fa08490f SC |
403 | // get a const ref to the stored data |
404 | const T & Get() const { return m_data; } | |
405 | ||
406 | // set the data | |
407 | void Set(const T& d) { m_data = d; } | |
a095505c | 408 | |
517fb871 VS |
409 | // return a heap allocated duplicate |
410 | virtual wxxVariantData* Clone() const { return new wxxVariantDataT<T>( Get() ) ; } | |
a095505c | 411 | |
517fb871 VS |
412 | // returns the type info of the contentc |
413 | virtual const wxTypeInfo* GetTypeInfo() const { return wxGetTypeInfo( (T*) NULL ) ; } | |
a095505c | 414 | |
517fb871 VS |
415 | // write the value into a string |
416 | virtual void Write( wxString &s ) const { wxStringWriteValue( s , m_data ) ; } | |
a095505c | 417 | |
517fb871 VS |
418 | // read the value from a string |
419 | virtual void Read( const wxString &s) { wxStringReadValue( s , m_data ) ; } | |
a095505c SC |
420 | |
421 | private: | |
422 | T m_data; | |
423 | }; | |
424 | ||
425 | class WXDLLIMPEXP_BASE wxxVariant | |
426 | { | |
427 | public : | |
fa08490f SC |
428 | wxxVariant() { m_data = NULL ; } |
429 | wxxVariant( wxxVariantData* data , const wxString& name = wxT("") ) : m_data(data) , m_name(name) {} | |
430 | wxxVariant( const wxxVariant &d ) { if ( d.m_data ) m_data = d.m_data->Clone() ; else m_data = NULL ; m_name = d.m_name ; } | |
431 | ||
432 | template<typename T> wxxVariant( T data , const wxString& name = wxT("") ) : | |
433 | m_data(new wxxVariantDataT<T>(data) ), m_name(name) {} | |
434 | ~wxxVariant() { delete m_data ; } | |
435 | ||
436 | // get a ref to the stored data | |
437 | template<typename T> T& Get() | |
438 | { | |
439 | wxxVariantDataT<T> *dataptr = dynamic_cast<wxxVariantDataT<T>*> (m_data) ; | |
440 | wxASSERT_MSG( dataptr , "Cast not possible" ) ; | |
441 | return dataptr->Get() ; | |
442 | } | |
443 | ||
444 | // get a ref to the stored data | |
445 | template<typename T> const T& Get() const | |
446 | { | |
447 | const wxxVariantDataT<T> *dataptr = dynamic_cast<const wxxVariantDataT<T>*> (m_data) ; | |
448 | wxASSERT_MSG( dataptr , "Cast not possible" ) ; | |
449 | return dataptr->Get() ; | |
450 | } | |
451 | ||
452 | // stores the data | |
453 | template<typename T> void Set(const T& data) const | |
454 | { | |
455 | delete m_data ; | |
456 | m_data = new wxxVariantDataT<T>(data) ; | |
457 | } | |
458 | ||
459 | wxxVariant& operator=(const wxxVariant &d) | |
460 | { | |
461 | m_data = d.m_data->Clone() ; | |
462 | m_name = d.m_name ; | |
463 | return *this ; | |
464 | } | |
465 | ||
466 | // gets the stored data casted to a wxObject* , returning NULL if cast is not possible | |
467 | wxObject* GetAsObject() ; | |
468 | ||
469 | // get the typeinfo of the stored object | |
470 | const wxTypeInfo* GetTypeInfo() const { return m_data->GetTypeInfo() ; } | |
471 | ||
aa8d7c2f | 472 | // write the value into a string |
fa08490f SC |
473 | void Write( wxString &s ) const { m_data->Write( s ) ; } |
474 | ||
475 | // read the value from a string | |
476 | void Read( const wxString &s) { m_data->Read( s ) ; } | |
477 | ||
478 | // returns this value as string | |
479 | wxString GetAsString() const | |
480 | { | |
481 | wxString s ; | |
482 | Write( s ) ; | |
483 | return s ; | |
484 | } | |
485 | ||
486 | void SetFromString( const wxString &s) | |
487 | { | |
488 | Read( s ) ; | |
489 | } | |
a095505c | 490 | private : |
517fb871 VS |
491 | wxxVariantData* m_data ; |
492 | wxString m_name ; | |
a095505c SC |
493 | } ; |
494 | ||
ab6e4913 SC |
495 | #include <wx/dynarray.h> |
496 | ||
497 | WX_DECLARE_OBJARRAY_WITH_DECL(wxxVariant, wxxVariantArray, class WXDLLIMPEXP_BASE); | |
498 | ||
a095505c SC |
499 | // ---------------------------------------------------------------------------- |
500 | // Property Support | |
501 | // | |
502 | // wxPropertyInfo is used to inquire of the property by name. It doesn't | |
503 | // provide access to the property, only information about it. If you | |
504 | // want access, look at wxPropertyAccessor. | |
505 | // ---------------------------------------------------------------------------- | |
506 | ||
507 | class WXDLLIMPEXP_BASE wxPropertyAccessor | |
508 | { | |
509 | public : | |
438edbc0 | 510 | #if WX_XTI_TEMPLATE_FIX |
4393b50c | 511 | class SetByRef ; |
fa08490f SC |
512 | class SetByRefRetBool ; |
513 | class SetRetBool ; | |
4393b50c | 514 | class SetAndGetByRef ; |
fa08490f | 515 | class SetAndGetByRefRetBool ; |
4393b50c | 516 | class GetByRef ; |
438edbc0 | 517 | #endif |
ab6e4913 | 518 | wxPropertyAccessor() { m_setterName = NULL ; m_getterName = NULL ; m_adderName = NULL ;} |
2d51f067 | 519 | virtual ~wxPropertyAccessor() {} |
ab6e4913 SC |
520 | |
521 | // Setting a simple property (non-collection) | |
a095505c | 522 | virtual void SetProperty(wxObject *object, const wxxVariant &value) const = 0 ; |
ab6e4913 SC |
523 | |
524 | // Getting a simple property (non-collection) | |
aa8d7c2f | 525 | virtual wxxVariant GetProperty(const wxObject *object) const = 0 ; |
ab6e4913 SC |
526 | |
527 | // Adding an element to a collection property | |
528 | virtual void AddToPropertyCollection(wxObject *object, const wxxVariant &value) const | |
529 | { wxASSERT_MSG(0,wxT("Collection Operation called on non Collection Property")) ; } | |
530 | ||
531 | // Getting a collection property | |
532 | virtual wxxVariantArray GetPropertyCollection( const wxObject *obj) const | |
533 | { wxASSERT_MSG(0,wxT("Collection Operation called on non Collection Property")) ; return wxxVariantArray() ; } | |
534 | ||
a095505c SC |
535 | virtual bool HasSetter() const = 0 ; |
536 | virtual bool HasGetter() const = 0 ; | |
ab6e4913 SC |
537 | virtual bool HasAdder() const = 0 ; |
538 | ||
517fb871 VS |
539 | const wxChar * GetGetterName() const { return m_setterName ; } |
540 | const wxChar * GetSetterName() const { return m_getterName ; } | |
ab6e4913 SC |
541 | const wxChar * GetAdderName() const { return m_adderName ; } |
542 | ||
517fb871 | 543 | virtual wxxVariant ReadValue( const wxString &value ) const = 0 ; |
aa8d7c2f | 544 | virtual void WriteValue( wxString& value , const wxObject *o ) const = 0 ; |
a095505c | 545 | protected : |
517fb871 VS |
546 | const wxChar *m_setterName ; |
547 | const wxChar *m_getterName ; | |
ab6e4913 | 548 | const wxChar *m_adderName ; |
a095505c SC |
549 | }; |
550 | ||
2d51f067 SC |
551 | class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor |
552 | { | |
553 | public : | |
554 | wxGenericPropertyAccessor( const wxChar* propertyName ) ; | |
555 | ~wxGenericPropertyAccessor() ; | |
556 | virtual void SetProperty(wxObject *object, const wxxVariant &value) const ; | |
557 | virtual wxxVariant GetProperty(const wxObject *object) const ; | |
ab6e4913 | 558 | |
2d51f067 SC |
559 | virtual bool HasSetter() const { return true ; } |
560 | virtual bool HasGetter() const { return true ; } | |
ab6e4913 SC |
561 | virtual bool HasAdder() const { return false ; } |
562 | ||
2d51f067 SC |
563 | virtual wxxVariant ReadValue( const wxString &value ) const ; |
564 | virtual void WriteValue( wxString& value , const wxObject *o ) const ; | |
565 | private : | |
566 | struct wxGenericPropertyAccessorInternal ; | |
567 | wxGenericPropertyAccessorInternal* m_data ; | |
568 | } ; | |
569 | ||
a095505c SC |
570 | template<class Klass, typename T> |
571 | class WXDLLIMPEXP_BASE wxPropertyAccessorT : public wxPropertyAccessor | |
572 | { | |
573 | public: | |
4393b50c | 574 | |
a095505c | 575 | typedef void (Klass::*setter_t)(T value); |
fa08490f | 576 | typedef bool (Klass::*setter_bool_t)(T value); |
fbbdc52c | 577 | typedef void (Klass::*setter_ref_t)(const T& value); |
fa08490f | 578 | typedef bool (Klass::*setter_ref_bool_t)(const T& value); |
a095505c SC |
579 | typedef T (Klass::*getter_t)() const; |
580 | typedef const T& (Klass::*getter_ref_t)() const; | |
581 | ||
ab6e4913 | 582 | wxPropertyAccessorT(setter_t setter, getter_t getter, const wxChar *s, const wxChar *g) |
fa08490f | 583 | : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(setter), m_setter_ref(NULL), m_getter(getter) ,m_getter_ref(NULL) {m_setterName = s;m_getterName=g ;} |
4393b50c SC |
584 | |
585 | wxPropertyAccessorT( getter_t getter, const wxChar *g) | |
fa08490f SC |
586 | : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(NULL), m_getter(getter) ,m_getter_ref(NULL) {m_setterName = "";m_getterName=g ;} |
587 | ||
ab6e4913 | 588 | wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetRetBool*,) setter_bool_t setter, getter_t getter, const wxChar *s, const wxChar *g) |
fa08490f | 589 | : m_setter_bool( setter ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(NULL), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;} |
4393b50c | 590 | |
ab6e4913 | 591 | wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRef*,) setter_ref_t setter, getter_t getter, const wxChar *s, const wxChar *g) |
fa08490f | 592 | : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(setter), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;} |
4393b50c | 593 | |
ab6e4913 | 594 | wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRefRetBool*,) setter_ref_bool_t setter, getter_t getter, const wxChar *s, const wxChar *g) |
fa08490f | 595 | : m_setter_bool( NULL ) , m_setter_ref_bool( setter ) , m_setter(NULL), m_setter_ref(NULL), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;} |
4393b50c | 596 | |
ab6e4913 | 597 | wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRef*,) setter_ref_t setter, getter_ref_t getter, const wxChar *s, const wxChar *g) |
fa08490f SC |
598 | : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;} |
599 | ||
ab6e4913 | 600 | wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRefRetBool*,) setter_ref_bool_t setter, getter_ref_t getter, const wxChar *s, const wxChar *g) |
fa08490f | 601 | : m_setter_bool( NULL ) , m_setter_ref_bool( setter ) , m_setter(NULL), m_setter_ref(NULL), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;} |
4393b50c | 602 | |
ab6e4913 | 603 | wxPropertyAccessorT(WX_XTI_PARAM_FIX(GetByRef*,) setter_t setter, getter_ref_t getter, const wxChar *s, const wxChar *g) |
fa08490f | 604 | : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;} |
4393b50c | 605 | |
517fb871 | 606 | // returns true if this accessor has a setter |
2d51f067 | 607 | bool HasSetter() const { return m_setter != NULL || m_setter_ref != NULL || m_setter_ref_bool != NULL || m_setter_bool ; } |
a095505c | 608 | |
517fb871 VS |
609 | // return true if this accessor has a getter |
610 | bool HasGetter() const { return m_getter != NULL || m_getter_ref != NULL ; } | |
a095505c | 611 | |
ab6e4913 | 612 | bool HasAdder() const { return true ; } |
517fb871 VS |
613 | // set the property this accessor is responsible for in an object |
614 | void SetProperty(wxObject *o, const wxxVariant &v) const | |
a095505c SC |
615 | { |
616 | Klass *obj = dynamic_cast<Klass*>(o); | |
fa08490f SC |
617 | T value ; |
618 | ||
619 | if ( wxGetTypeInfo((T*)NULL)->GetKind() == wxT_OBJECT && v.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR ) | |
620 | value = *v.Get<T*>(); | |
621 | else | |
622 | value = v.Get<T>(); | |
a095505c SC |
623 | if (m_setter) |
624 | (obj->*(m_setter))(value); | |
fa08490f SC |
625 | else if ( m_setter_ref ) |
626 | (obj->*(m_setter_ref))(value); | |
627 | else if ( m_setter_ref_bool ) | |
628 | (obj->*(m_setter_ref_bool))(value); | |
629 | else if ( m_setter_bool ) | |
630 | (obj->*(m_setter_bool))(value); | |
631 | else | |
632 | { | |
633 | wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ; | |
634 | } | |
635 | } | |
a095505c | 636 | |
517fb871 | 637 | // gets the property this accessor is responsible for from an object |
aa8d7c2f | 638 | wxxVariant GetProperty(const wxObject *o) const |
a095505c | 639 | { |
517fb871 | 640 | return wxxVariant( (wxxVariantData* ) DoGetProperty( o ) ) ; |
a095505c SC |
641 | } |
642 | ||
517fb871 VS |
643 | // write the property this accessor is responsible for from an object into |
644 | // a string | |
aa8d7c2f | 645 | void WriteValue( wxString& s , const wxObject *o ) const |
517fb871 VS |
646 | { |
647 | DoGetProperty( o )->Write( s ) ; | |
648 | } | |
649 | ||
517fb871 VS |
650 | // read a wxxVariant having the correct type for the property this accessor |
651 | // is responsible for from a string | |
652 | wxxVariant ReadValue( const wxString &value ) const | |
653 | { | |
654 | T data ; | |
655 | wxStringReadValue( value , data ) ; | |
656 | return wxxVariant( data ) ; | |
657 | } | |
a095505c SC |
658 | |
659 | private : | |
aa8d7c2f | 660 | wxxVariantDataT<T>* DoGetProperty(const wxObject *o) const |
a095505c | 661 | { |
aa8d7c2f | 662 | const Klass *obj = dynamic_cast<const Klass*>(o); |
517fb871 VS |
663 | if ( m_getter ) |
664 | return new wxxVariantDataT<T>( (obj->*(m_getter))() ) ; | |
665 | else | |
666 | return new wxxVariantDataT<T>( (obj->*(m_getter_ref))() ) ; | |
a095505c SC |
667 | } |
668 | ||
669 | setter_t m_setter; | |
670 | setter_ref_t m_setter_ref; | |
fa08490f SC |
671 | setter_ref_bool_t m_setter_ref_bool ; |
672 | setter_bool_t m_setter_bool ; | |
a095505c | 673 | getter_t m_getter; |
517fb871 | 674 | getter_ref_t m_getter_ref ; |
a095505c SC |
675 | }; |
676 | ||
ab6e4913 SC |
677 | template<class Klass, typename CollectionType , typename AddedElementType> |
678 | class WXDLLIMPEXP_BASE wxPropertyCollectionAccessorT : public wxPropertyAccessor | |
679 | { | |
680 | public: | |
681 | ||
682 | typedef void (Klass::*adder_t)(AddedElementType value); | |
683 | typedef const CollectionType& (Klass::*getter_t)() const ; | |
684 | ||
685 | wxPropertyCollectionAccessorT(adder_t adder, getter_t getter, const wxChar *a, const wxChar *g) | |
686 | : m_getter(getter), m_adder(adder) { m_adderName = a;m_getterName=g ;} | |
687 | ||
688 | ~wxPropertyCollectionAccessorT() {} | |
689 | ||
690 | // returns true if this accessor has a setter | |
691 | bool HasSetter() const { return false ;} | |
692 | ||
693 | // return true if this accessor has a getter | |
694 | bool HasGetter() const { return m_getter != NULL ;} | |
695 | ||
696 | // return true if this accessor has a getter | |
697 | bool HasAdder() const { return m_adder != NULL ;} | |
698 | ||
699 | // set the property this accessor is responsible for in an object | |
700 | void AddToPropertyCollection(wxObject *o, const wxxVariant &v) const | |
701 | { | |
702 | Klass *obj = dynamic_cast<Klass*>(o); | |
703 | AddedElementType value ; | |
704 | ||
705 | if ( wxGetTypeInfo((AddedElementType*)NULL)->GetKind() == wxT_OBJECT && v.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR ) | |
706 | value = *v.Get<AddedElementType*>(); | |
707 | else | |
708 | value = v.Get<AddedElementType>(); | |
709 | ||
710 | if (m_adder) | |
711 | (obj->*(m_adder))(value); | |
712 | else | |
713 | { | |
714 | wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ; | |
715 | } | |
716 | } | |
717 | ||
718 | // gets the property this accessor is responsible for from an object | |
719 | wxxVariantArray GetPropertyCollection(const wxObject *o) const | |
720 | { | |
721 | const Klass *obj = dynamic_cast<const Klass*>(o); | |
722 | ||
723 | wxxVariantArray result ; | |
724 | CollectionType::compatibility_iterator current = (obj->*(m_getter))().GetFirst(); | |
725 | while (current) | |
726 | { | |
727 | result.Add( new wxxVariant(current->GetData()) ) ; | |
728 | current = current->GetNext(); | |
729 | } | |
730 | return result ; | |
731 | } | |
732 | ||
733 | ||
734 | // set the property this accessor is responsible for in an object | |
735 | void SetProperty(wxObject *WXUNUSED(o), const wxxVariant &WXUNUSED(v)) const | |
736 | { | |
737 | wxASSERT_MSG(0,wxT("SetProperty called on Collection Property")) ; | |
738 | } | |
739 | ||
740 | // gets the property this accessor is responsible for from an object | |
741 | wxxVariant GetProperty(const wxObject *WXUNUSED(o)) const | |
742 | { | |
743 | wxASSERT_MSG(0,wxT("GetProperty called on Collection Property")) ; | |
744 | return wxxVariant() ; | |
745 | } | |
746 | ||
747 | // write the property this accessor is responsible for from an object into | |
748 | // a string | |
749 | void WriteValue( wxString& s , const wxObject *o ) const | |
750 | { | |
751 | wxASSERT_MSG(0,wxT("WriteValue called on Collection Property")) ; | |
752 | } | |
753 | ||
754 | // read a wxxVariant having the correct type for the property this accessor | |
755 | // is responsible for from a string | |
756 | wxxVariant ReadValue( const wxString &value ) const | |
757 | { | |
758 | wxASSERT_MSG(0,wxT("ReadValue called on Collection Property")) ; | |
759 | return wxxVariant() ; | |
760 | } | |
761 | ||
762 | private : | |
763 | getter_t m_getter; | |
764 | adder_t m_adder; | |
765 | }; | |
766 | ||
a095505c SC |
767 | class WXDLLIMPEXP_BASE wxPropertyInfo |
768 | { | |
769 | public : | |
ab6e4913 SC |
770 | wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* typeInfo , wxPropertyAccessor *accessor , wxxVariant dv ) : |
771 | m_name( name ) , m_typeInfo( typeInfo ) , m_accessor( accessor ) , m_defaultValue( dv ) , m_collectionElementTypeInfo(NULL) | |
fa08490f | 772 | { |
ab6e4913 SC |
773 | Insert(iter) ; |
774 | } | |
fa08490f | 775 | |
ab6e4913 SC |
776 | wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* collTypeInfo , const wxTypeInfo* elemTypeInfo , wxPropertyAccessor *accessor ) : |
777 | m_name( name ) , m_typeInfo( collTypeInfo ) , m_accessor( accessor ) , m_collectionElementTypeInfo(elemTypeInfo) | |
778 | { | |
779 | Insert(iter) ; | |
fa08490f | 780 | } |
ab6e4913 | 781 | |
fa08490f SC |
782 | // return the name of this property |
783 | const wxChar * GetName() const { return m_name ; } | |
784 | ||
ab6e4913 SC |
785 | // return the element type info of this property (for collections, otherwise NULL) |
786 | const wxTypeInfo * GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo ; } | |
fa08490f | 787 | |
ab6e4913 | 788 | // return the type info of this property |
fa08490f SC |
789 | const wxTypeInfo * GetTypeInfo() const { return m_typeInfo ; } |
790 | ||
791 | // return the accessor for this property | |
792 | wxPropertyAccessor* GetAccessor() const { return m_accessor ; } | |
793 | ||
794 | // returns NULL if this is the last property of this class | |
795 | wxPropertyInfo* GetNext() const { return m_next ; } | |
796 | ||
797 | // returns the default value of this property, its kind may be wxT_VOID if it is not valid | |
798 | wxxVariant GetDefaultValue() const { return m_defaultValue ; } | |
4393b50c | 799 | private : |
ab6e4913 SC |
800 | void Insert(wxPropertyInfo* &iter) |
801 | { | |
802 | m_next = NULL ; | |
803 | if ( iter == NULL ) | |
804 | iter = this ; | |
805 | else | |
806 | { | |
807 | wxPropertyInfo* i = iter ; | |
808 | while( i->m_next ) | |
809 | i = i->m_next ; | |
810 | ||
811 | i->m_next = this ; | |
812 | } | |
813 | } | |
814 | ||
517fb871 VS |
815 | const wxChar * m_name; |
816 | const wxChar * m_typeName ; | |
817 | const wxTypeInfo* m_typeInfo ; | |
ab6e4913 | 818 | const wxTypeInfo* m_collectionElementTypeInfo ; |
517fb871 | 819 | wxPropertyAccessor* m_accessor ; |
4393b50c | 820 | wxxVariant m_defaultValue; |
517fb871 VS |
821 | // string representation of the default value |
822 | // to be assigned by the designer to the property | |
823 | // when the component is dropped on the container. | |
824 | wxPropertyInfo* m_next ; | |
a095505c SC |
825 | }; |
826 | ||
827 | #define WX_BEGIN_PROPERTIES_TABLE(theClass) \ | |
2d51f067 | 828 | wxPropertyInfo *theClass::GetPropertiesStatic() \ |
a095505c SC |
829 | { \ |
830 | typedef theClass class_t; \ | |
517fb871 | 831 | static wxPropertyInfo* first = NULL ; |
a095505c SC |
832 | |
833 | #define WX_END_PROPERTIES_TABLE() \ | |
517fb871 | 834 | return first ; } |
a095505c | 835 | |
438edbc0 SC |
836 | |
837 | #if WX_XTI_TEMPLATE_FIX | |
838 | ||
a095505c | 839 | #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \ |
fa08490f | 840 | static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \ |
ab6e4913 | 841 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; |
fa08490f | 842 | |
6056c7c6 SC |
843 | #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \ |
844 | static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \ | |
845 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; | |
846 | ||
fa08490f SC |
847 | #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \ |
848 | static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetRetBool*)NULL , &setter , &getter , #setter , #getter ) ; \ | |
ab6e4913 | 849 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; |
4393b50c SC |
850 | |
851 | #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \ | |
852 | static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRef*)NULL, &setter , &getter , #setter , #getter ) ; \ | |
ab6e4913 | 853 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; |
4393b50c | 854 | |
fa08490f SC |
855 | #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \ |
856 | static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \ | |
ab6e4913 | 857 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; |
fa08490f SC |
858 | |
859 | #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \ | |
860 | static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetAndGetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \ | |
ab6e4913 | 861 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; |
fa08490f | 862 | |
438edbc0 SC |
863 | #else |
864 | ||
865 | #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \ | |
866 | static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \ | |
ab6e4913 SC |
867 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; |
868 | ||
869 | #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \ | |
870 | static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \ | |
871 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ; | |
438edbc0 SC |
872 | |
873 | #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \ | |
874 | WX_PROPERTY( name , type , setter , getter , defaultValue ) | |
875 | ||
876 | #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \ | |
877 | WX_PROPERTY( name , type , setter , getter , defaultValue ) | |
878 | ||
879 | #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \ | |
880 | WX_PROPERTY( name , type , setter , getter , defaultValue ) | |
881 | ||
882 | #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \ | |
883 | WX_PROPERTY( name , type , setter , getter , defaultValue ) | |
884 | ||
885 | #endif | |
886 | ||
4393b50c | 887 | #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \ |
517fb871 | 888 | static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \ |
ab6e4913 | 889 | static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; |
a095505c SC |
890 | |
891 | #define WX_DELEGATE( name , eventType , eventClass ) \ | |
517fb871 | 892 | static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \ |
ab6e4913 | 893 | static wxPropertyInfo _propertyInfo##name( first , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \ |
a095505c SC |
894 | |
895 | // ---------------------------------------------------------------------------- | |
896 | // Handler Info | |
897 | // | |
898 | // this is describing an event sink | |
899 | // ---------------------------------------------------------------------------- | |
900 | ||
901 | class wxHandlerInfo | |
902 | { | |
903 | public : | |
fa08490f SC |
904 | wxHandlerInfo( wxHandlerInfo* &iter , const wxChar *name , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) : |
905 | m_name( name ) , m_eventClassInfo( eventClassInfo ) , m_eventFunction( address ) | |
906 | { | |
907 | m_next = NULL ; | |
908 | if ( iter == NULL ) | |
909 | iter = this ; | |
910 | else | |
911 | { | |
912 | wxHandlerInfo* i = iter ; | |
913 | while( i->m_next ) | |
914 | i = i->m_next ; | |
915 | ||
916 | i->m_next = this ; | |
917 | } | |
918 | } | |
919 | ||
920 | // get the name of the handler method | |
921 | const wxChar * GetName() const { return m_name ; } | |
922 | ||
923 | // return the class info of the event | |
924 | const wxClassInfo * GetEventClassInfo() const { return m_eventClassInfo ; } | |
925 | ||
926 | // get the handler function pointer | |
927 | wxObjectEventFunction GetEventFunction() const { return m_eventFunction ; } | |
928 | ||
929 | // returns NULL if this is the last handler of this class | |
930 | wxHandlerInfo* GetNext() const { return m_next ; } | |
4393b50c | 931 | private : |
517fb871 VS |
932 | wxObjectEventFunction m_eventFunction ; |
933 | const wxChar * m_name; | |
934 | const wxClassInfo* m_eventClassInfo ; | |
935 | wxHandlerInfo* m_next ; | |
a095505c SC |
936 | }; |
937 | ||
938 | #define WX_HANDLER(name,eventClassType) \ | |
517fb871 | 939 | static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ; |
a095505c SC |
940 | |
941 | #define WX_BEGIN_HANDLERS_TABLE(theClass) \ | |
2d51f067 | 942 | wxHandlerInfo *theClass::GetHandlersStatic() \ |
a095505c SC |
943 | { \ |
944 | typedef theClass class_t; \ | |
517fb871 | 945 | static wxHandlerInfo* first = NULL ; |
a095505c SC |
946 | |
947 | #define WX_END_HANDLERS_TABLE() \ | |
517fb871 | 948 | return first ; } |
a095505c SC |
949 | |
950 | // ---------------------------------------------------------------------------- | |
951 | // Constructor Bridges | |
952 | // | |
953 | // allow to set up constructors with params during runtime | |
954 | // ---------------------------------------------------------------------------- | |
955 | ||
956 | class WXDLLIMPEXP_BASE wxConstructorBridge | |
957 | { | |
958 | public : | |
959 | virtual void Create(wxObject *o, wxxVariant *args) = 0; | |
960 | }; | |
961 | ||
962 | // Creator Bridges for all Numbers of Params | |
963 | ||
964 | // no params | |
965 | ||
966 | template<typename Class> | |
967 | struct wxConstructorBridge_0 : public wxConstructorBridge | |
968 | { | |
969 | void Create(wxObject *o, wxxVariant *) | |
970 | { | |
971 | Class *obj = dynamic_cast<Class*>(o); | |
972 | obj->Create(); | |
973 | } | |
974 | }; | |
975 | ||
976 | struct wxConstructorBridge_Dummy : public wxConstructorBridge | |
977 | { | |
978 | void Create(wxObject *, wxxVariant *) | |
979 | { | |
980 | } | |
981 | } ; | |
982 | ||
983 | #define WX_CONSTRUCTOR_0(klass) \ | |
517fb871 VS |
984 | wxConstructorBridge_0<klass> constructor##klass ; \ |
985 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
986 | const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \ | |
987 | const int klass::sm_constructorPropertiesCount##klass = 0 ; | |
a095505c SC |
988 | |
989 | #define WX_CONSTRUCTOR_DUMMY(klass) \ | |
517fb871 VS |
990 | wxConstructorBridge_Dummy constructor##klass ; \ |
991 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
992 | const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \ | |
993 | const int klass::sm_constructorPropertiesCount##klass = 0 ; | |
a095505c SC |
994 | |
995 | // 1 param | |
996 | ||
997 | template<typename Class, typename T0> | |
998 | struct wxConstructorBridge_1 : public wxConstructorBridge | |
999 | { | |
1000 | void Create(wxObject *o, wxxVariant *args) | |
1001 | { | |
1002 | Class *obj = dynamic_cast<Class*>(o); | |
1003 | obj->Create( | |
1004 | args[0].Get<T0>() | |
1005 | ); | |
1006 | } | |
1007 | }; | |
1008 | ||
1009 | #define WX_CONSTRUCTOR_1(klass,t0,v0) \ | |
517fb871 VS |
1010 | wxConstructorBridge_1<klass,t0> constructor##klass ; \ |
1011 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
1012 | const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \ | |
1013 | const int klass::sm_constructorPropertiesCount##klass = 1 ; | |
a095505c SC |
1014 | |
1015 | // 2 params | |
1016 | ||
1017 | template<typename Class, | |
1018 | typename T0, typename T1> | |
1019 | struct wxConstructorBridge_2 : public wxConstructorBridge | |
1020 | { | |
fbbdc52c | 1021 | void Create(wxObject *o, wxxVariant *args) |
a095505c SC |
1022 | { |
1023 | Class *obj = dynamic_cast<Class*>(o); | |
1024 | obj->Create( | |
1025 | args[0].Get<T0>() , | |
4393b50c | 1026 | args[1].Get<T1>() |
a095505c SC |
1027 | ); |
1028 | } | |
1029 | }; | |
1030 | ||
1031 | #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \ | |
517fb871 VS |
1032 | wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \ |
1033 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
1034 | const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \ | |
1035 | const int klass::sm_constructorPropertiesCount##klass = 2; | |
a095505c SC |
1036 | |
1037 | // 3 params | |
1038 | ||
1039 | template<typename Class, | |
1040 | typename T0, typename T1, typename T2> | |
1041 | struct wxConstructorBridge_3 : public wxConstructorBridge | |
1042 | { | |
fbbdc52c | 1043 | void Create(wxObject *o, wxxVariant *args) |
a095505c SC |
1044 | { |
1045 | Class *obj = dynamic_cast<Class*>(o); | |
1046 | obj->Create( | |
1047 | args[0].Get<T0>() , | |
1048 | args[1].Get<T1>() , | |
4393b50c | 1049 | args[2].Get<T2>() |
a095505c SC |
1050 | ); |
1051 | } | |
1052 | }; | |
1053 | ||
1054 | #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ | |
517fb871 VS |
1055 | wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \ |
1056 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
1057 | const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \ | |
1058 | const int klass::sm_constructorPropertiesCount##klass = 3 ; | |
a095505c SC |
1059 | |
1060 | // 4 params | |
1061 | ||
1062 | template<typename Class, | |
1063 | typename T0, typename T1, typename T2, typename T3> | |
1064 | struct wxConstructorBridge_4 : public wxConstructorBridge | |
1065 | { | |
fbbdc52c | 1066 | void Create(wxObject *o, wxxVariant *args) |
a095505c SC |
1067 | { |
1068 | Class *obj = dynamic_cast<Class*>(o); | |
1069 | obj->Create( | |
1070 | args[0].Get<T0>() , | |
1071 | args[1].Get<T1>() , | |
1072 | args[2].Get<T2>() , | |
4393b50c | 1073 | args[3].Get<T3>() |
a095505c SC |
1074 | ); |
1075 | } | |
1076 | }; | |
1077 | ||
1078 | #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ | |
517fb871 VS |
1079 | wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \ |
1080 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
1081 | const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \ | |
1082 | const int klass::sm_constructorPropertiesCount##klass = 4 ; | |
fbbdc52c SC |
1083 | |
1084 | // 5 params | |
1085 | ||
1086 | template<typename Class, | |
1087 | typename T0, typename T1, typename T2, typename T3, typename T4> | |
1088 | struct wxConstructorBridge_5 : public wxConstructorBridge | |
1089 | { | |
1090 | void Create(wxObject *o, wxxVariant *args) | |
1091 | { | |
1092 | Class *obj = dynamic_cast<Class*>(o); | |
1093 | obj->Create( | |
1094 | args[0].Get<T0>() , | |
1095 | args[1].Get<T1>() , | |
1096 | args[2].Get<T2>() , | |
1097 | args[3].Get<T3>() , | |
4393b50c | 1098 | args[4].Get<T4>() |
fbbdc52c SC |
1099 | ); |
1100 | } | |
1101 | }; | |
1102 | ||
1103 | #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ | |
fa08490f SC |
1104 | wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \ |
1105 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
1106 | const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \ | |
1107 | const int klass::sm_constructorPropertiesCount##klass = 5; | |
1108 | ||
1109 | // 6 params | |
1110 | ||
1111 | template<typename Class, | |
1112 | typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> | |
1113 | struct wxConstructorBridge_6 : public wxConstructorBridge | |
1114 | { | |
1115 | void Create(wxObject *o, wxxVariant *args) | |
1116 | { | |
1117 | Class *obj = dynamic_cast<Class*>(o); | |
1118 | obj->Create( | |
1119 | args[0].Get<T0>() , | |
1120 | args[1].Get<T1>() , | |
1121 | args[2].Get<T2>() , | |
1122 | args[3].Get<T3>() , | |
1123 | args[4].Get<T4>() , | |
1124 | args[5].Get<T5>() | |
1125 | ); | |
1126 | } | |
1127 | }; | |
1128 | ||
1129 | #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ | |
1130 | wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \ | |
1131 | wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \ | |
1132 | const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \ | |
1133 | const int klass::sm_constructorPropertiesCount##klass = 6; | |
1134 | ||
a095505c SC |
1135 | |
1136 | // ---------------------------------------------------------------------------- | |
1137 | // wxClassInfo | |
1138 | // ---------------------------------------------------------------------------- | |
1139 | ||
1140 | typedef wxObject *(*wxObjectConstructorFn)(void); | |
fa08490f | 1141 | typedef wxObject* (*wxVariantToObjectConverter)( wxxVariant &data ) ; |
a095505c SC |
1142 | typedef wxxVariant (*wxObjectToVariantConverter)( wxObject* ) ; |
1143 | ||
1144 | class WXDLLIMPEXP_BASE wxClassInfo | |
1145 | { | |
1146 | public: | |
1147 | wxClassInfo(const wxClassInfo **_Parents, | |
517fb871 VS |
1148 | const wxChar *_UnitName, |
1149 | const wxChar *_ClassName, | |
a095505c SC |
1150 | int size, |
1151 | wxObjectConstructorFn ctor , | |
2d51f067 SC |
1152 | wxPropertyInfo *_Props , |
1153 | wxHandlerInfo *_Handlers , | |
fa08490f SC |
1154 | wxConstructorBridge* _Constructor , |
1155 | const wxChar ** _ConstructorProperties , | |
1156 | const int _ConstructorPropertiesCount , | |
1157 | wxVariantToObjectConverter _PtrConverter1 , | |
1158 | wxVariantToObjectConverter _Converter2 , | |
1159 | wxObjectToVariantConverter _Converter3 | |
1160 | ) : m_parents(_Parents) , m_unitName(_UnitName) ,m_className(_ClassName), | |
1161 | m_objectSize(size), m_objectConstructor(ctor) , m_firstProperty(_Props ) , m_firstHandler(_Handlers ) , m_constructor( _Constructor ) , | |
1162 | m_constructorProperties(_ConstructorProperties) , m_constructorPropertiesCount(_ConstructorPropertiesCount), | |
1163 | m_variantOfPtrToObjectConverter( _PtrConverter1 ) , m_variantToObjectConverter( _Converter2 ) , m_objectToVariantConverter( _Converter3 ) , m_next(sm_first) | |
1164 | { | |
1165 | sm_first = this; | |
aa8d7c2f | 1166 | Register() ; |
fa08490f | 1167 | } |
a095505c | 1168 | |
2d51f067 SC |
1169 | wxClassInfo(const wxChar *_UnitName, const wxChar *_ClassName, const wxClassInfo **_Parents) : m_parents(_Parents) , m_unitName(_UnitName) ,m_className(_ClassName), |
1170 | m_objectSize(0), m_objectConstructor(NULL) , m_firstProperty(NULL ) , m_firstHandler(NULL ) , m_constructor( NULL ) , | |
1171 | m_constructorProperties(NULL) , m_constructorPropertiesCount(NULL), | |
1172 | m_variantOfPtrToObjectConverter( NULL ) , m_variantToObjectConverter( NULL ) , m_objectToVariantConverter( NULL ) , m_next(sm_first) | |
1173 | { | |
1174 | sm_first = this; | |
1175 | Register() ; | |
1176 | } | |
1177 | ||
aeec2045 | 1178 | virtual ~wxClassInfo() ; |
a095505c | 1179 | |
ab6e4913 SC |
1180 | // allocates an instance of this class, this object does not have to be initialized or fully constructed |
1181 | // as this call will be followed by a call to Create | |
1182 | virtual wxObject *AllocateObject() const { return m_objectConstructor ? (*m_objectConstructor)() : 0; } | |
1183 | ||
1184 | // 'old naming' for AllocateObject staying here for backward compatibility | |
1185 | wxObject *CreateObject() const { return AllocateObject() ; } | |
a095505c SC |
1186 | |
1187 | const wxChar *GetClassName() const { return m_className; } | |
1188 | const wxClassInfo **GetParents() const { return m_parents; } | |
1189 | int GetSize() const { return m_objectSize; } | |
1190 | ||
1191 | wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; } | |
1192 | static const wxClassInfo *GetFirst() { return sm_first; } | |
1193 | const wxClassInfo *GetNext() const { return m_next; } | |
1194 | static wxClassInfo *FindClass(const wxChar *className); | |
1195 | ||
1196 | // Climb upwards through inheritance hierarchy. | |
1197 | // Dual inheritance is catered for. | |
1198 | ||
1199 | bool IsKindOf(const wxClassInfo *info) const | |
1200 | { | |
517fb871 VS |
1201 | if ( info != 0 ) |
1202 | { | |
1203 | if ( info == this ) | |
1204 | return true ; | |
1205 | ||
1206 | for ( int i = 0 ; m_parents[i] ; ++ i ) | |
1207 | { | |
1208 | if ( m_parents[i]->IsKindOf( info ) ) | |
1209 | return true ; | |
1210 | } | |
1211 | } | |
1212 | return false ; | |
a095505c SC |
1213 | } |
1214 | ||
aa8d7c2f | 1215 | #ifdef WXWIN_COMPATIBILITY_2_4 |
a095505c | 1216 | // Initializes parent pointers and hash table for fast searching. |
aa8d7c2f | 1217 | wxDEPRECATED( static void InitializeClasses() ); |
a095505c | 1218 | // Cleans up hash table used for fast searching. |
aa8d7c2f SC |
1219 | wxDEPRECATED( static void CleanUpClasses() ); |
1220 | #endif | |
1221 | static void CleanUp(); | |
1222 | ||
517fb871 VS |
1223 | // returns the first property |
1224 | const wxPropertyInfo* GetFirstProperty() const { return m_firstProperty ; } | |
a095505c | 1225 | |
517fb871 VS |
1226 | // returns the first handler |
1227 | const wxHandlerInfo* GetFirstHandler() const { return m_firstHandler ; } | |
a095505c | 1228 | |
ab6e4913 SC |
1229 | // Call the Create upon an instance of the class, in the end the object is fully |
1230 | // initialized | |
fa08490f SC |
1231 | virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const |
1232 | { | |
1233 | wxASSERT_MSG( ParamCount == m_constructorPropertiesCount , wxT("Illegal Parameter Count for Create Method")) ; | |
1234 | m_constructor->Create( object , Params ) ; | |
1235 | } | |
a095505c | 1236 | |
517fb871 VS |
1237 | // get number of parameters for constructor |
1238 | virtual int GetCreateParamCount() const { return m_constructorPropertiesCount; } | |
a095505c | 1239 | |
ab6e4913 SC |
1240 | // get n-th constructor parameter |
1241 | virtual const wxChar* GetCreateParamName(int n) const { return m_constructorProperties[n] ; } | |
a095505c | 1242 | |
ab6e4913 SC |
1243 | // Runtime access to objects for simple properties (get/set) by property name, and variant data |
1244 | virtual void SetProperty (wxObject *object, const wxChar *propertyName, const wxxVariant &value) const ; | |
1245 | virtual wxxVariant GetProperty (wxObject *object, const wxChar *propertyName) const; | |
1246 | ||
1247 | // Runtime access to objects for collection properties by property name | |
1248 | virtual wxxVariantArray GetPropertyCollection(wxObject *object, const wxChar *propertyName) const ; | |
1249 | virtual void AddPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const ; | |
a095505c | 1250 | |
fa08490f | 1251 | // we must be able to cast variants to wxObject pointers, templates seem not to be suitable |
f0b7eadf | 1252 | wxObject* VariantToInstance( wxxVariant &data ) const |
fa08490f | 1253 | { if ( data.GetTypeInfo()->GetKind() == wxT_OBJECT ) |
f0b7eadf | 1254 | return m_variantToObjectConverter( data ) ; |
fa08490f SC |
1255 | else |
1256 | return m_variantOfPtrToObjectConverter( data ) ; | |
1257 | } | |
1258 | ||
1259 | wxxVariant InstanceToVariant( wxObject *object ) const { return m_objectToVariantConverter( object ) ; } | |
4393b50c | 1260 | |
517fb871 | 1261 | // find property by name |
fbbdc52c SC |
1262 | virtual const wxPropertyInfo *FindPropertyInfo (const wxChar *PropertyName) const ; |
1263 | ||
517fb871 | 1264 | // find handler by name |
fbbdc52c | 1265 | virtual const wxHandlerInfo *FindHandlerInfo (const wxChar *PropertyName) const ; |
a095505c | 1266 | |
2d51f067 SC |
1267 | // find property by name |
1268 | virtual const wxPropertyInfo *FindPropertyInfoInThisClass (const wxChar *PropertyName) const ; | |
1269 | ||
1270 | // find handler by name | |
1271 | virtual const wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *PropertyName) const ; | |
a095505c SC |
1272 | public: |
1273 | const wxChar *m_className; | |
1274 | int m_objectSize; | |
1275 | wxObjectConstructorFn m_objectConstructor; | |
1276 | ||
1277 | // class info object live in a linked list: | |
1278 | // pointers to its head and the next element in it | |
1279 | ||
1280 | static wxClassInfo *sm_first; | |
1281 | wxClassInfo *m_next; | |
1282 | ||
517fb871 | 1283 | // FIXME: this should be private (currently used directly by way too |
a095505c SC |
1284 | // many clients) |
1285 | static wxHashTable *sm_classTable; | |
1286 | ||
2d51f067 SC |
1287 | protected : |
1288 | wxPropertyInfo * m_firstProperty ; | |
1289 | wxHandlerInfo * m_firstHandler ; | |
a095505c | 1290 | private: |
fa08490f | 1291 | const wxClassInfo** m_parents ; |
fa08490f SC |
1292 | const wxChar* m_unitName; |
1293 | ||
1294 | wxConstructorBridge* m_constructor ; | |
1295 | const wxChar ** m_constructorProperties ; | |
1296 | const int m_constructorPropertiesCount ; | |
1297 | wxVariantToObjectConverter m_variantOfPtrToObjectConverter ; | |
1298 | wxVariantToObjectConverter m_variantToObjectConverter ; | |
1299 | wxObjectToVariantConverter m_objectToVariantConverter ; | |
a095505c | 1300 | |
2d51f067 | 1301 | const wxPropertyAccessor *FindAccessor (const wxChar *propertyName) const ; |
a095505c | 1302 | |
a095505c | 1303 | |
517fb871 | 1304 | // InitializeClasses() helper |
2d51f067 | 1305 | static wxClassInfo *GetBaseByName(const wxChar *name) ; |
d1d738f1 VS |
1306 | |
1307 | protected: | |
1308 | // registers the class | |
1309 | void Register(); | |
1310 | void Unregister(); | |
a095505c SC |
1311 | |
1312 | DECLARE_NO_COPY_CLASS(wxClassInfo) | |
1313 | }; | |
1314 | ||
2d51f067 | 1315 | |
a095505c SC |
1316 | WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name); |
1317 | ||
2d51f067 SC |
1318 | // ---------------------------------------------------------------------------- |
1319 | // wxDynamicObject | |
1320 | // ---------------------------------------------------------------------------- | |
1321 | // | |
1322 | // this object leads to having a pure runtime-instantiation | |
1323 | ||
1324 | class wxDynamicClassInfo : public wxClassInfo | |
1325 | { | |
1326 | public : | |
1327 | wxDynamicClassInfo( const wxChar *_UnitName, const wxChar *_ClassName , const wxClassInfo* superClass ) ; | |
1328 | virtual ~wxDynamicClassInfo() ; | |
1329 | ||
1330 | // constructs a wxDynamicObject with an instance | |
ab6e4913 | 1331 | virtual wxObject *AllocateObject() const ; |
2d51f067 SC |
1332 | |
1333 | // Call the Create method for a class | |
1334 | virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const ; | |
1335 | ||
1336 | // get number of parameters for constructor | |
1337 | virtual int GetCreateParamCount() const ; | |
1338 | ||
1339 | // get i-th constructor parameter | |
1340 | virtual const wxChar* GetCreateParamName(int i) const ; | |
1341 | ||
1342 | // Runtime access to objects by property name, and variant data | |
1343 | virtual void SetProperty (wxObject *object, const wxChar *PropertyName, const wxxVariant &Value) const ; | |
1344 | virtual wxxVariant GetProperty (wxObject *object, const wxChar *PropertyName) const ; | |
1345 | ||
1346 | void AddProperty( const wxChar *propertyName , const wxTypeInfo* typeInfo ) ; | |
1347 | void AddHandler( const wxChar *handlerName , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) ; | |
1348 | } ; | |
1349 | ||
a095505c SC |
1350 | // ---------------------------------------------------------------------------- |
1351 | // Dynamic class macros | |
1352 | // ---------------------------------------------------------------------------- | |
1353 | ||
1354 | #define _DECLARE_DYNAMIC_CLASS(name) \ | |
1355 | public: \ | |
1356 | static wxClassInfo sm_class##name; \ | |
1357 | static const wxClassInfo* sm_classParents##name[] ; \ | |
2d51f067 SC |
1358 | static wxPropertyInfo* GetPropertiesStatic() ; \ |
1359 | static wxHandlerInfo* GetHandlersStatic() ; \ | |
a095505c SC |
1360 | virtual wxClassInfo *GetClassInfo() const \ |
1361 | { return &name::sm_class##name; } | |
1362 | ||
1363 | #define DECLARE_DYNAMIC_CLASS(name) \ | |
f0b7eadf SC |
1364 | static wxConstructorBridge* sm_constructor##name ; \ |
1365 | static const wxChar * sm_constructorProperties##name[] ; \ | |
1366 | static const int sm_constructorPropertiesCount##name ; \ | |
1367 | _DECLARE_DYNAMIC_CLASS(name) | |
a095505c SC |
1368 | |
1369 | #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ | |
1370 | DECLARE_NO_ASSIGN_CLASS(name) \ | |
1371 | DECLARE_DYNAMIC_CLASS(name) | |
1372 | ||
1373 | #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \ | |
1374 | DECLARE_NO_COPY_CLASS(name) \ | |
1375 | DECLARE_DYNAMIC_CLASS(name) | |
1376 | ||
1377 | #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name) | |
1378 | #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name) | |
1379 | ||
1380 | // ----------------------------------- | |
1381 | // for concrete classes | |
1382 | // ----------------------------------- | |
1383 | ||
1384 | // Single inheritance with one base class | |
1385 | ||
1386 | #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \ | |
1387 | wxObject* wxConstructorFor##name() \ | |
1388 | { return new name; } \ | |
1389 | const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \ | |
fa08490f SC |
1390 | wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ |
1391 | wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ | |
a095505c SC |
1392 | wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \ |
1393 | (int) sizeof(name), \ | |
1394 | (wxObjectConstructorFn) wxConstructorFor##name , \ | |
fa08490f SC |
1395 | name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \ |
1396 | name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name); \ | |
1397 | template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\ | |
1398 | template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
dadaeb69 SC |
1399 | template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\ |
1400 | template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
f0b7eadf SC |
1401 | template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1402 | template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
1403 | template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ | |
fa08490f SC |
1404 | template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ |
1405 | template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } | |
1406 | ||
1407 | #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \ | |
1408 | wxObject* wxConstructorFor##name() \ | |
1409 | { return new name; } \ | |
1410 | const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \ | |
1411 | wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \ | |
1412 | wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ | |
1413 | wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ | |
1414 | wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \ | |
1415 | (int) sizeof(name), \ | |
1416 | (wxObjectConstructorFn) wxConstructorFor##name , \ | |
1417 | name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \ | |
1418 | name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \ | |
1419 | template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\ | |
1420 | template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
1421 | template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\ | |
1422 | template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
f0b7eadf SC |
1423 | template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1424 | template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
1425 | template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ | |
fa08490f SC |
1426 | template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ |
1427 | template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } | |
1428 | ||
1429 | #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \ | |
1430 | _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \ | |
1431 | const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ | |
1432 | const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ | |
1433 | WX_CONSTRUCTOR_DUMMY( name ) | |
a095505c SC |
1434 | |
1435 | #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \ | |
1436 | _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \ | |
2d51f067 SC |
1437 | wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ |
1438 | wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ | |
a095505c SC |
1439 | WX_CONSTRUCTOR_DUMMY( name ) |
1440 | ||
1441 | #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \ | |
1442 | _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit ) | |
1443 | ||
fa08490f SC |
1444 | #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \ |
1445 | _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit ) | |
1446 | ||
4393b50c | 1447 | // this is for classes that do not derive from wxobject, there are no creators for these |
a095505c SC |
1448 | |
1449 | #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \ | |
1450 | const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \ | |
1451 | wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \ | |
1452 | (int) sizeof(name), \ | |
1453 | (wxObjectConstructorFn) 0 , \ | |
517fb871 VS |
1454 | name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \ |
1455 | 0 , 0 , 0 ); \ | |
dadaeb69 SC |
1456 | template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1457 | template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
f0b7eadf SC |
1458 | template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1459 | template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
1460 | template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ | |
1461 | template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ | |
fa08490f | 1462 | template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } |
a095505c SC |
1463 | |
1464 | // this is for subclasses that still do not derive from wxobject | |
1465 | ||
1466 | #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \ | |
1467 | const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \ | |
1468 | wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \ | |
1469 | (int) sizeof(name), \ | |
1470 | (wxObjectConstructorFn) 0 , \ | |
517fb871 VS |
1471 | name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \ |
1472 | 0 , 0 , 0 ); \ | |
dadaeb69 SC |
1473 | template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1474 | template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
f0b7eadf SC |
1475 | template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1476 | template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
1477 | template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ | |
1478 | template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ | |
fa08490f | 1479 | template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } |
a095505c | 1480 | |
f0b7eadf | 1481 | |
a095505c SC |
1482 | // Multiple inheritance with two base classes |
1483 | ||
1484 | #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \ | |
1485 | wxObject* wxConstructorFor##name() \ | |
1486 | { return new name; } \ | |
1487 | const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \ | |
fa08490f | 1488 | wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ |
a095505c SC |
1489 | wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ |
1490 | wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \ | |
1491 | (int) sizeof(name), \ | |
1492 | (wxObjectConstructorFn) wxConstructorFor##name , \ | |
517fb871 VS |
1493 | name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \ |
1494 | name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \ | |
dadaeb69 SC |
1495 | template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1496 | template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
f0b7eadf SC |
1497 | template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1498 | template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
1499 | template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ | |
1500 | template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ | |
fa08490f | 1501 | template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } |
a095505c SC |
1502 | |
1503 | #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \ | |
1504 | _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \ | |
2d51f067 SC |
1505 | wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \ |
1506 | wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ | |
a095505c SC |
1507 | WX_CONSTRUCTOR_DUMMY( name ) |
1508 | ||
1509 | #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \ | |
517fb871 | 1510 | _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit) |
a095505c SC |
1511 | |
1512 | // ----------------------------------- | |
1513 | // for abstract classes | |
1514 | // ----------------------------------- | |
1515 | ||
1516 | // Single inheritance with one base class | |
1517 | ||
1518 | #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \ | |
1519 | const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \ | |
fa08490f SC |
1520 | wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ |
1521 | wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \ | |
1522 | wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \ | |
a095505c SC |
1523 | wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \ |
1524 | (int) sizeof(name), \ | |
1525 | (wxObjectConstructorFn) 0 , \ | |
fa08490f SC |
1526 | name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \ |
1527 | 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \ | |
dadaeb69 SC |
1528 | template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1529 | template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
f0b7eadf SC |
1530 | template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ |
1531 | template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ | |
1532 | template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ | |
1533 | template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \ | |
1534 | template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } | |
a095505c SC |
1535 | |
1536 | #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \ | |
1537 | _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \ | |
2d51f067 SC |
1538 | wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \ |
1539 | wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } | |
a095505c SC |
1540 | |
1541 | // Multiple inheritance with two base classes | |
1542 | ||
1543 | #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ | |
1544 | wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \ | |
1545 | wxT(#basename2), (int) sizeof(name), \ | |
1546 | (wxObjectConstructorFn) 0); | |
1547 | ||
1548 | #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS | |
1549 | #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2 | |
1550 | ||
aeec2045 | 1551 | #endif |