#include "wx/beforestd.h"
#include <map>
#include <string>
+#include <list>
#include "wx/afterstd.h"
using namespace std ;
// this are compiler induced specialization which are never used anywhere
-WX_ILLEGAL_TYPE_SPECIALIZATION( char const * )
-WX_ILLEGAL_TYPE_SPECIALIZATION( char * )
-WX_ILLEGAL_TYPE_SPECIALIZATION( unsigned char * )
-WX_ILLEGAL_TYPE_SPECIALIZATION( int * )
-WX_ILLEGAL_TYPE_SPECIALIZATION( bool * )
-WX_ILLEGAL_TYPE_SPECIALIZATION( long * )
-WX_ILLEGAL_TYPE_SPECIALIZATION( wxString * )
+wxILLEGAL_TYPE_SPECIALIZATION( char const * )
+wxILLEGAL_TYPE_SPECIALIZATION( char * )
+wxILLEGAL_TYPE_SPECIALIZATION( unsigned char * )
+wxILLEGAL_TYPE_SPECIALIZATION( int * )
+wxILLEGAL_TYPE_SPECIALIZATION( bool * )
+wxILLEGAL_TYPE_SPECIALIZATION( long * )
+wxILLEGAL_TYPE_SPECIALIZATION( wxString * )
-WX_COLLECTION_TYPE_INFO( wxString , wxArrayString ) ;
+wxCOLLECTION_TYPE_INFO( wxString , wxArrayString ) ;
template<> void wxCollectionToVariantArray( wxArrayString const &theArray, wxxVariantArray &value)
{
wxArrayCollectionToVariantArray( theArray , value ) ;
}
-wxTypeInfoMap *wxTypeInfo::sm_typeTable = NULL ;
+wxTypeInfoMap *wxTypeInfo::ms_typeTable = NULL ;
wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName)
{
- wxTypeInfoMap::iterator iter = sm_typeTable->find(typeName) ;
- wxASSERT_MSG( iter != sm_typeTable->end() , wxT("lookup for a non-existent type-info") ) ;
+ wxTypeInfoMap::iterator iter = ms_typeTable->find(typeName) ;
+ wxASSERT_MSG( iter != ms_typeTable->end() , wxT("lookup for a non-existent type-info") ) ;
return (wxTypeInfo *)iter->second;
}
wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) :
wxTypeInfo ( wxT_DELEGATE , to , from , wxEmptyString )
-{ m_eventClass = eventClass ; m_eventType = eventType ;}
+{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = -1 ;}
+
+wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , int lastEventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) :
+wxTypeInfo ( wxT_DELEGATE , to , from , wxEmptyString )
+{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = lastEventType; }
void wxTypeInfo::Register()
{
- if ( sm_typeTable == NULL )
- sm_typeTable = new wxTypeInfoMap() ;
+ if ( ms_typeTable == NULL )
+ ms_typeTable = new wxTypeInfoMap() ;
if( !m_name.IsEmpty() )
- (*sm_typeTable)[m_name] = this ;
+ (*ms_typeTable)[m_name] = this ;
}
void wxTypeInfo::Unregister()
{
if( !m_name.IsEmpty() )
- sm_typeTable->erase(m_name);
+ ms_typeTable->erase(m_name);
}
// removing header dependancy on string tokenizer
struct wxDynamicObject::wxDynamicObjectInternal
{
+ wxDynamicObjectInternal() {}
+
#if wxUSE_UNICODE
map<wstring,wxxVariant> m_properties ;
#else
#endif
} ;
+typedef list< wxDynamicObject* > wxDynamicObjectList ;
+
+struct wxDynamicClassInfo::wxDynamicClassInfoInternal
+{
+ wxDynamicObjectList m_dynamicObjects ;
+} ;
+
// instantiates this object with an instance of its superclass
wxDynamicObject::wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info)
{
wxDynamicObject::~wxDynamicObject()
{
+ dynamic_cast<const wxDynamicClassInfo*>(m_classInfo)->m_data->m_dynamicObjects.remove( this ) ;
delete m_data ;
delete m_superClassInstance ;
}
return m_data->m_properties[propertyName] ;
}
+void wxDynamicObject::RemoveProperty( const wxChar *propertyName )
+{
+ wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Removing Unknown Property in a Dynamic Object") ) ;
+ m_data->m_properties.erase( propertyName ) ;
+}
+
+void wxDynamicObject::RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName )
+{
+ wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(oldPropertyName),wxT("Renaming Unknown Property in a Dynamic Object") ) ;
+ wxxVariant value = m_data->m_properties[oldPropertyName] ;
+ m_data->m_properties.erase( oldPropertyName ) ;
+ m_data->m_properties[newPropertyName] = value ;
+}
+
+
// ----------------------------------------------------------------------------
// wxDynamiClassInfo
// ----------------------------------------------------------------------------
{
GetParents()[0] = superClass ;
GetParents()[1] = NULL ;
+ m_data = new wxDynamicClassInfoInternal ;
}
wxDynamicClassInfo::~wxDynamicClassInfo()
{
delete[] GetParents() ;
+ delete m_data ;
}
wxObject *wxDynamicClassInfo::AllocateObject() const
{
wxObject* parent = GetParents()[0]->AllocateObject() ;
- return new wxDynamicObject( parent , this ) ;
+ wxDynamicObject *obj = new wxDynamicObject( parent , this ) ;
+ m_data->m_dynamicObjects.push_back( obj ) ;
+ return obj ;
}
void wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxxVariant *params) const
// removes an existing runtime-property
void wxDynamicClassInfo::RemoveProperty( const wxChar *propertyName )
{
+ for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin() ; iter != m_data->m_dynamicObjects.end() ; ++iter )
+ (*iter)->RemoveProperty( propertyName ) ;
delete FindPropertyInfoInThisClass(propertyName) ;
}
wxASSERT_MSG( pi ,wxT("not existing property") ) ;
pi->m_name = newPropertyName ;
dynamic_cast<wxGenericPropertyAccessor*>(pi->GetAccessor())->RenameProperty( oldPropertyName , newPropertyName ) ;
+ for ( wxDynamicObjectList::iterator iter = m_data->m_dynamicObjects.begin() ; iter != m_data->m_dynamicObjects.end() ; ++iter )
+ (*iter)->RenameProperty( oldPropertyName , newPropertyName ) ;
}
// renames an existing runtime-handler