]> git.saurik.com Git - wxWidgets.git/blame - src/common/xti.cpp
copy bitmaps to runtime directory
[wxWidgets.git] / src / common / xti.cpp
CommitLineData
a095505c
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/xti.cpp
3// Purpose: runtime metadata information (extended class info
4// Author: Stefan Csomor
30fd71e6 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
14f355c2 13#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a095505c
SC
14#pragma implementation "xti.h"
15#endif
16
17// For compilers that support precompilation, includes "wx.h".
18#include "wx/wxprec.h"
19
20#ifdef __BORLANDC__
21#pragma hdrstop
22#endif
23
24#ifndef WX_PRECOMP
25 #include "wx/hash.h"
26 #include "wx/object.h"
27#endif
28
29#include "wx/xml/xml.h"
30#include "wx/tokenzr.h"
b8d5be01 31#include "wx/list.h"
a095505c
SC
32#include <string.h>
33
30bfc425 34#if wxUSE_EXTENDED_RTTI
a095505c 35
ab6e4913 36#include "wx/beforestd.h"
2d51f067
SC
37#include <map>
38#include <string>
ab6e4913 39#include "wx/afterstd.h"
2d51f067
SC
40
41using namespace std ;
42
a095505c
SC
43// ----------------------------------------------------------------------------
44// Enum Support
45// ----------------------------------------------------------------------------
46
30fd71e6 47wxEnumData::wxEnumData( wxEnumMemberData* data )
a095505c 48{
30fd71e6 49 m_members = data ;
a095505c
SC
50 for ( m_count = 0; m_members[m_count].m_name ; m_count++)
51 {} ;
52}
53
54bool wxEnumData::HasEnumMemberValue(const wxChar *name, int *value)
55{
56 int i;
57 for (i = 0; m_members[i].m_name ; i++ )
58 {
59 if (!strcmp(name, m_members[i].m_name))
60 {
61 if ( value )
62 *value = m_members[i].m_value;
63 return true ;
64 }
65 }
66 return false ;
67}
68
69int wxEnumData::GetEnumMemberValue(const wxChar *name)
70{
71 int i;
72 for (i = 0; m_members[i].m_name ; i++ )
73 {
74 if (!strcmp(name, m_members[i].m_name))
75 {
76 return m_members[i].m_value;
77 }
78 }
0c03c79e 79 return 0 ;
a095505c
SC
80}
81
82const wxChar *wxEnumData::GetEnumMemberName(int value)
83{
84 int i;
85 for (i = 0; m_members[i].m_name ; i++)
86 if (value == m_members[i].m_value)
87 return m_members[i].m_name;
88
89 return wxT("") ;
90}
91
30fd71e6 92int wxEnumData::GetEnumMemberValueByIndex( int idx )
a095505c
SC
93{
94 // we should cache the count in order to avoid out-of-bounds errors
95 return m_members[idx].m_value ;
96}
97
30fd71e6 98const char * wxEnumData::GetEnumMemberNameByIndex( int idx )
a095505c
SC
99{
100 // we should cache the count in order to avoid out-of-bounds errors
101 return m_members[idx].m_name ;
102}
103
104// ----------------------------------------------------------------------------
105// Type Information
106// ----------------------------------------------------------------------------
a095505c 107// ----------------------------------------------------------------------------
30fd71e6 108// value streaming
a095505c
SC
109// ----------------------------------------------------------------------------
110
a095505c 111// streamer specializations
45212047 112// for all built-in types
a095505c 113
45212047 114// bool
a095505c 115
45212047
SC
116template<> void wxStringReadValue(const wxString &s , bool &data )
117{
118 int intdata ;
119 wxSscanf(s, _T("%d"), &intdata ) ;
120 data = bool(intdata) ;
121}
a095505c 122
45212047 123template<> void wxStringWriteValue(wxString &s , const bool &data )
a095505c 124{
45212047 125 s = wxString::Format("%d", data ) ;
a095505c
SC
126}
127
45212047
SC
128// char
129
130template<> void wxStringReadValue(const wxString &s , char &data )
a095505c 131{
45212047
SC
132 int intdata ;
133 wxSscanf(s, _T("%d"), &intdata ) ;
134 data = char(intdata) ;
135}
136
137template<> void wxStringWriteValue(wxString &s , const char &data )
138{
139 s = wxString::Format("%d", data ) ;
140}
141
142// unsigned char
143
144template<> void wxStringReadValue(const wxString &s , unsigned char &data )
145{
146 int intdata ;
147 wxSscanf(s, _T("%d"), &intdata ) ;
66c57129 148 data = (unsigned char)(intdata) ;
45212047
SC
149}
150
151template<> void wxStringWriteValue(wxString &s , const unsigned char &data )
152{
153 s = wxString::Format("%d", data ) ;
a095505c
SC
154}
155
30fd71e6 156// int
a095505c 157
30fd71e6 158template<> void wxStringReadValue(const wxString &s , int &data )
a095505c
SC
159{
160 wxSscanf(s, _T("%d"), &data ) ;
161}
162
30fd71e6 163template<> void wxStringWriteValue(wxString &s , const int &data )
a095505c
SC
164{
165 s = wxString::Format("%d", data ) ;
166}
167
45212047
SC
168// unsigned int
169
170template<> void wxStringReadValue(const wxString &s , unsigned int &data )
171{
172 wxSscanf(s, _T("%d"), &data ) ;
173}
174
175template<> void wxStringWriteValue(wxString &s , const unsigned int &data )
176{
177 s = wxString::Format("%d", data ) ;
178}
179
180// long
181
182template<> void wxStringReadValue(const wxString &s , long &data )
183{
184 wxSscanf(s, _T("%ld"), &data ) ;
185}
186
187template<> void wxStringWriteValue(wxString &s , const long &data )
188{
189 s = wxString::Format("%ld", data ) ;
190}
191
192// unsigned long
193
194template<> void wxStringReadValue(const wxString &s , unsigned long &data )
195{
196 wxSscanf(s, _T("%ld"), &data ) ;
197}
198
199template<> void wxStringWriteValue(wxString &s , const unsigned long &data )
200{
201 s = wxString::Format("%ld", data ) ;
202}
203
204// float
205
206template<> void wxStringReadValue(const wxString &s , float &data )
207{
208 wxSscanf(s, _T("%f"), &data ) ;
209}
210
211template<> void wxStringWriteValue(wxString &s , const float &data )
212{
213 s = wxString::Format("%f", data ) ;
214}
215
216// double
217
218template<> void wxStringReadValue(const wxString &s , double &data )
219{
220 wxSscanf(s, _T("%lf"), &data ) ;
221}
222
223template<> void wxStringWriteValue(wxString &s , const double &data )
224{
225 s = wxString::Format("%lf", data ) ;
226}
227
a095505c
SC
228// wxString
229
30fd71e6 230template<> void wxStringReadValue(const wxString &s , wxString &data )
a095505c
SC
231{
232 data = s ;
233}
234
30fd71e6 235template<> void wxStringWriteValue(wxString &s , const wxString &data )
a095505c
SC
236{
237 s = data ;
238}
239
c1d6d0f9
SC
240// built-ins
241//
b8d5be01
SC
242
243template<> const wxTypeInfo* wxGetTypeInfo( void * )
244{
245 static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ;
246 return &s_typeInfo ;
247}
248
249template<> const wxTypeInfo* wxGetTypeInfo( bool * )
250{
251 static wxBuiltInTypeInfo s_typeInfo( wxT_BOOL , &wxToStringConverter<bool> , &wxFromStringConverter<bool>) ;
252 return &s_typeInfo ;
253}
254
255template<> const wxTypeInfo* wxGetTypeInfo( char * )
256{
257 static wxBuiltInTypeInfo s_typeInfo( wxT_CHAR , &wxToStringConverter<char> , &wxFromStringConverter<char>) ;
258 return &s_typeInfo ;
259}
260
261template<> const wxTypeInfo* wxGetTypeInfo( unsigned char * )
262{
263 static wxBuiltInTypeInfo s_typeInfo( wxT_UCHAR , &wxToStringConverter< unsigned char > , &wxFromStringConverter<unsigned char>) ;
264 return &s_typeInfo ;
265}
266
267template<> const wxTypeInfo* wxGetTypeInfo( int * )
268{
269 static wxBuiltInTypeInfo s_typeInfo( wxT_CHAR , &wxToStringConverter<int> , &wxFromStringConverter<int>) ;
270 return &s_typeInfo ;
271}
272
273template<> const wxTypeInfo* wxGetTypeInfo( unsigned int * )
274{
275 static wxBuiltInTypeInfo s_typeInfo( wxT_UCHAR , &wxToStringConverter<unsigned int> , &wxFromStringConverter<unsigned int>) ;
276 return &s_typeInfo ;
277}
278
279template<> const wxTypeInfo* wxGetTypeInfo( long * )
280{
281 static wxBuiltInTypeInfo s_typeInfo( wxT_LONG , &wxToStringConverter<long> , &wxFromStringConverter<long>) ;
282 return &s_typeInfo ;
283}
284
285template<> const wxTypeInfo* wxGetTypeInfo( unsigned long * )
286{
287 static wxBuiltInTypeInfo s_typeInfo( wxT_ULONG , &wxToStringConverter<unsigned long> , &wxFromStringConverter<unsigned long>) ;
288 return &s_typeInfo ;
289}
290
291template<> const wxTypeInfo* wxGetTypeInfo( float * )
292{
293 static wxBuiltInTypeInfo s_typeInfo( wxT_FLOAT , &wxToStringConverter<float> , &wxFromStringConverter<float>) ;
294 return &s_typeInfo ;
295}
296
297template<> const wxTypeInfo* wxGetTypeInfo( double * )
298{
299 static wxBuiltInTypeInfo s_typeInfo( wxT_DOUBLE , &wxToStringConverter<double> , &wxFromStringConverter<double>) ;
300 return &s_typeInfo ;
301}
302
303template<> const wxTypeInfo* wxGetTypeInfo( wxString * )
304{
305 static wxBuiltInTypeInfo s_typeInfo( wxT_STRING , &wxToStringConverter<wxString> , &wxFromStringConverter<wxString>) ;
306 return &s_typeInfo ;
307}
308
309// this are compiler induced specialization which are never used anywhere
310
311WX_ILLEGAL_TYPE_SPECIALIZATION( char const * )
312WX_ILLEGAL_TYPE_SPECIALIZATION( char * )
313WX_ILLEGAL_TYPE_SPECIALIZATION( unsigned char * )
314WX_ILLEGAL_TYPE_SPECIALIZATION( int * )
315WX_ILLEGAL_TYPE_SPECIALIZATION( bool * )
316WX_ILLEGAL_TYPE_SPECIALIZATION( long * )
317WX_ILLEGAL_TYPE_SPECIALIZATION( wxString * )
318
319//
320
321// make wxWindowList known
322
cb73e600 323WX_COLLECTION_TYPE_INFO( wxString , wxArrayString ) ;
b8d5be01
SC
324
325template<> void wxCollectionToVariantArray( wxArrayString const &theArray, wxxVariantArray &value)
326{
327 wxArrayCollectionToVariantArray( theArray , value ) ;
328}
329
cb73e600 330wxTypeInfoMap *wxTypeInfo::sm_typeTable = NULL ;
b8d5be01 331
cb73e600
SC
332wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName)
333{
334 return (wxTypeInfo *)sm_typeTable->find(typeName)->second;
335}
b8d5be01 336
cb73e600
SC
337wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from ) :
338wxTypeInfo( kind , to , from , classInfo->GetClassName() )
339{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;}
45212047 340
cb73e600
SC
341wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) :
342 wxTypeInfo ( wxT_DELEGATE , to , from , wxEmptyString )
343 { m_eventClass = eventClass ; m_eventType = eventType ;}
45212047 344
cb73e600
SC
345void wxTypeInfo::Register()
346{
347 if ( sm_typeTable == NULL )
348 sm_typeTable = new wxTypeInfoMap() ;
45212047 349
cb73e600
SC
350 if( !m_name.IsEmpty() )
351 (*sm_typeTable)[m_name] = this ;
45212047
SC
352}
353
cb73e600
SC
354void wxTypeInfo::Unregister()
355{
356 if( !m_name.IsEmpty() )
357 sm_typeTable->erase(m_name);
358 }
45212047 359
a095505c
SC
360// removing header dependancy on string tokenizer
361
30fd71e6 362void wxSetStringToArray( const wxString &s , wxArrayString &array )
a095505c
SC
363{
364 wxStringTokenizer tokenizer(s, wxT("| \t\n"), wxTOKEN_STRTOK);
365 wxString flag;
366 array.Clear() ;
367 while (tokenizer.HasMoreTokens())
368 {
369 array.Add(tokenizer.GetNextToken()) ;
370 }
371}
372
373// ----------------------------------------------------------------------------
30fd71e6 374// wxClassInfo
a095505c
SC
375// ----------------------------------------------------------------------------
376
2d51f067 377const wxPropertyAccessor *wxClassInfo::FindAccessor(const char *PropertyName) const
a095505c 378{
fbbdc52c 379 const wxPropertyInfo* info = FindPropertyInfo( PropertyName ) ;
30fd71e6 380
a095505c
SC
381 if ( info )
382 return info->GetAccessor() ;
383
384 return NULL ;
385}
386
2d51f067 387const wxPropertyInfo *wxClassInfo::FindPropertyInfoInThisClass (const char *PropertyName) const
a095505c
SC
388{
389 const wxPropertyInfo* info = GetFirstProperty() ;
390
391 while( info )
392 {
393 if ( strcmp( info->GetName() , PropertyName ) == 0 )
394 return info ;
395 info = info->GetNext() ;
396 }
397
2d51f067
SC
398 return 0;
399}
400
401const wxPropertyInfo *wxClassInfo::FindPropertyInfo (const char *PropertyName) const
402{
403 const wxPropertyInfo* info = FindPropertyInfoInThisClass( PropertyName ) ;
404 if ( info )
405 return info ;
406
a095505c
SC
407 const wxClassInfo** parents = GetParents() ;
408 for ( int i = 0 ; parents[i] ; ++ i )
409 {
fbbdc52c 410 if ( ( info = parents[i]->FindPropertyInfo( PropertyName ) ) != NULL )
a095505c
SC
411 return info ;
412 }
413
414 return 0;
415}
416
2d51f067 417const wxHandlerInfo *wxClassInfo::FindHandlerInfoInThisClass (const char *PropertyName) const
fbbdc52c
SC
418{
419 const wxHandlerInfo* info = GetFirstHandler() ;
420
421 while( info )
422 {
423 if ( strcmp( info->GetName() , PropertyName ) == 0 )
424 return info ;
425 info = info->GetNext() ;
426 }
427
2d51f067
SC
428 return 0;
429}
430
431const wxHandlerInfo *wxClassInfo::FindHandlerInfo (const char *PropertyName) const
432{
433 const wxHandlerInfo* info = FindHandlerInfoInThisClass( PropertyName ) ;
434
435 if ( info )
436 return info ;
437
fbbdc52c
SC
438 const wxClassInfo** parents = GetParents() ;
439 for ( int i = 0 ; parents[i] ; ++ i )
440 {
441 if ( ( info = parents[i]->FindHandlerInfo( PropertyName ) ) != NULL )
442 return info ;
443 }
444
445 return 0;
446}
447
448
2d51f067 449void wxClassInfo::SetProperty(wxObject *object, const char *propertyName, const wxxVariant &value) const
a095505c
SC
450{
451 const wxPropertyAccessor *accessor;
452
453 accessor = FindAccessor(propertyName);
454 wxASSERT(accessor->HasSetter());
455 accessor->SetProperty( object , value ) ;
456}
457
2d51f067 458wxxVariant wxClassInfo::GetProperty(wxObject *object, const char *propertyName) const
a095505c
SC
459{
460 const wxPropertyAccessor *accessor;
461
462 accessor = FindAccessor(propertyName);
463 wxASSERT(accessor->HasGetter());
b8d5be01
SC
464 wxxVariant result ;
465 accessor->GetProperty(object,result);
466 return result ;
a095505c
SC
467}
468
b8d5be01 469wxxVariantArray wxClassInfo::GetPropertyCollection(wxObject *object, const wxChar *propertyName) const
ab6e4913
SC
470{
471 const wxPropertyAccessor *accessor;
472
473 accessor = FindAccessor(propertyName);
474 wxASSERT(accessor->HasGetter());
b8d5be01
SC
475 wxxVariantArray result ;
476 accessor->GetPropertyCollection(object,result);
477 return result ;
ab6e4913
SC
478}
479
b8d5be01 480void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const
ab6e4913
SC
481{
482 const wxPropertyAccessor *accessor;
483
484 accessor = FindAccessor(propertyName);
485 wxASSERT(accessor->HasAdder());
486 accessor->AddToPropertyCollection( object , value ) ;
487}
488
cb73e600
SC
489void wxClassInfo::GetProperties( wxPropertyInfoMap &map ) const
490{
491 const wxPropertyInfo *pi = GetFirstProperty() ;
492 while( pi )
493 {
494 if ( map.find( pi->GetName() ) == map.end() )
495 map[pi->GetName()] = (wxPropertyInfo*) pi ;
496
497 pi = pi->GetNext() ;
498 }
499
500 const wxClassInfo** parents = GetParents() ;
501 for ( int i = 0 ; parents[i] ; ++ i )
502 {
503 parents[i]->GetProperties( map ) ;
504 }
505}
506
a095505c
SC
507/*
508VARIANT TO OBJECT
509*/
510
66c57129 511wxObject* wxxVariant::GetAsObject()
a095505c
SC
512{
513 const wxClassTypeInfo *ti = dynamic_cast<const wxClassTypeInfo*>( m_data->GetTypeInfo() ) ;
514 if ( ti )
515 return ti->GetClassInfo()->VariantToInstance(*this) ;
516 else
517 return NULL ;
518}
519
2d51f067
SC
520// ----------------------------------------------------------------------------
521// wxDynamicObject support
522// ----------------------------------------------------------------------------
523//
524// Dynamic Objects are objects that have a real superclass instance and carry their
525// own attributes in a hash map. Like this it is possible to create the objects and
526// stream them, as if their class information was already available from compiled data
527
528struct wxDynamicObject::wxDynamicObjectInternal
529{
530 map<string,wxxVariant> m_properties ;
531} ;
532
533// instantiates this object with an instance of its superclass
b8d5be01 534wxDynamicObject::wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info)
2d51f067
SC
535{
536 m_superClassInstance = superClassInstance ;
537 m_classInfo = info ;
538 m_data = new wxDynamicObjectInternal ;
539}
540
541wxDynamicObject::~wxDynamicObject()
542{
543 delete m_data ;
544 delete m_superClassInstance ;
545}
546
547void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxxVariant &value)
548{
549 wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
550 m_data->m_properties[propertyName] = value ;
551}
552
553wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const
554{
555 wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
556 return m_data->m_properties[propertyName] ;
557}
558
559// ----------------------------------------------------------------------------
560// wxDynamiClassInfo
561// ----------------------------------------------------------------------------
562
563wxDynamicClassInfo::wxDynamicClassInfo( const wxChar *unitName, const wxChar *className , const wxClassInfo* superClass ) :
b8d5be01 564 wxClassInfo( unitName, className , new const wxClassInfo*[2])
2d51f067
SC
565{
566 GetParents()[0] = superClass ;
567 GetParents()[1] = NULL ;
568}
569
570wxDynamicClassInfo::~wxDynamicClassInfo()
571{
572 delete[] GetParents() ;
573}
574
b8d5be01 575wxObject *wxDynamicClassInfo::AllocateObject() const
2d51f067 576{
ab6e4913 577 wxObject* parent = GetParents()[0]->AllocateObject() ;
2d51f067
SC
578 return new wxDynamicObject( parent , this ) ;
579}
580
b8d5be01 581void wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxxVariant *params) const
2d51f067
SC
582{
583 wxDynamicObject *dynobj = dynamic_cast< wxDynamicObject *>( object ) ;
584 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::Create on an object other than wxDynamicObject") ) ;
585 GetParents()[0]->Create( dynobj->GetSuperClassInstance() , paramCount , params ) ;
586}
587
588// get number of parameters for constructor
b8d5be01 589int wxDynamicClassInfo::GetCreateParamCount() const
2d51f067
SC
590{
591 return GetParents()[0]->GetCreateParamCount() ;
592}
593
594// get i-th constructor parameter
b8d5be01 595const wxChar* wxDynamicClassInfo::GetCreateParamName(int i) const
2d51f067
SC
596{
597 return GetParents()[0]->GetCreateParamName( i ) ;
598}
599
600void wxDynamicClassInfo::SetProperty(wxObject *object, const char *propertyName, const wxxVariant &value) const
601{
602 wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
603 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
604 if ( FindPropertyInfoInThisClass(propertyName) )
605 dynobj->SetProperty( propertyName , value ) ;
606 else
607 GetParents()[0]->SetProperty( dynobj->GetSuperClassInstance() , propertyName , value ) ;
608}
609
610wxxVariant wxDynamicClassInfo::GetProperty(wxObject *object, const char *propertyName) const
611{
612 wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
613 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
614 if ( FindPropertyInfoInThisClass(propertyName) )
615 return dynobj->GetProperty( propertyName ) ;
616 else
617 return GetParents()[0]->GetProperty( dynobj->GetSuperClassInstance() , propertyName ) ;
618}
619
b8d5be01 620void wxDynamicClassInfo::AddProperty( const wxChar *propertyName , const wxTypeInfo* typeInfo )
2d51f067 621{
cb73e600 622 new wxPropertyInfo( m_firstProperty , this , propertyName , typeInfo , new wxGenericPropertyAccessor( propertyName ) , wxxVariant() ) ;
2d51f067
SC
623}
624
b8d5be01 625void wxDynamicClassInfo::AddHandler( const wxChar *handlerName , wxObjectEventFunction address , const wxClassInfo* eventClassInfo )
2d51f067
SC
626{
627 new wxHandlerInfo( m_firstHandler , handlerName , address , eventClassInfo ) ;
628}
629
630// ----------------------------------------------------------------------------
631// wxGenericPropertyAccessor
632// ----------------------------------------------------------------------------
633
634struct wxGenericPropertyAccessor::wxGenericPropertyAccessorInternal
635{
b8d5be01 636 char filler ;
2d51f067
SC
637} ;
638
b8d5be01
SC
639wxGenericPropertyAccessor::wxGenericPropertyAccessor( const wxString& propertyName )
640: wxPropertyAccessor( NULL , NULL , NULL , NULL )
2d51f067
SC
641{
642 m_data = new wxGenericPropertyAccessorInternal ;
b8d5be01
SC
643 m_propertyName = propertyName ;
644 m_getterName = wxT("Get")+propertyName ;
645 m_setterName = wxT("Set")+propertyName ;
2d51f067
SC
646}
647
648wxGenericPropertyAccessor::~wxGenericPropertyAccessor()
649{
650 delete m_data ;
651}
b8d5be01 652void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxxVariant &value) const
2d51f067
SC
653{
654 wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
655 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
b8d5be01 656 dynobj->SetProperty(m_propertyName , value ) ;
2d51f067
SC
657}
658
b8d5be01 659void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxxVariant& value) const
2d51f067
SC
660{
661 const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject * >( object ) ;
662 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
b8d5be01 663 value = dynobj->GetProperty( m_propertyName ) ;
2d51f067 664}
a095505c 665#endif