X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c681bd248f610c0dafecf6a6b413d889ef700eeb..2d35020a8dd1a0908f4e76af323cc0d413d6b8c3:/src/common/xti.cpp?ds=sidebyside diff --git a/src/common/xti.cpp b/src/common/xti.cpp index 1d6042308f..5320362612 100644 --- a/src/common/xti.cpp +++ b/src/common/xti.cpp @@ -37,6 +37,7 @@ #include "wx/beforestd.h" #include #include +#include #include "wx/afterstd.h" using namespace std ; @@ -52,7 +53,7 @@ wxEnumData::wxEnumData( wxEnumMemberData* data ) {} ; } -bool wxEnumData::HasEnumMemberValue(const wxChar *name, int *value) +bool wxEnumData::HasEnumMemberValue(const wxChar *name, int *value) const { int i; for (i = 0; m_members[i].m_name ; i++ ) @@ -67,7 +68,7 @@ bool wxEnumData::HasEnumMemberValue(const wxChar *name, int *value) return false ; } -int wxEnumData::GetEnumMemberValue(const wxChar *name) +int wxEnumData::GetEnumMemberValue(const wxChar *name) const { int i; for (i = 0; m_members[i].m_name ; i++ ) @@ -80,7 +81,7 @@ int wxEnumData::GetEnumMemberValue(const wxChar *name) return 0 ; } -const wxChar *wxEnumData::GetEnumMemberName(int value) +const wxChar *wxEnumData::GetEnumMemberName(int value) const { int i; for (i = 0; m_members[i].m_name ; i++) @@ -90,13 +91,13 @@ const wxChar *wxEnumData::GetEnumMemberName(int value) return wxT("") ; } -int wxEnumData::GetEnumMemberValueByIndex( int idx ) +int wxEnumData::GetEnumMemberValueByIndex( int idx ) const { // we should cache the count in order to avoid out-of-bounds errors return m_members[idx].m_value ; } -const wxChar * wxEnumData::GetEnumMemberNameByIndex( int idx ) +const wxChar * wxEnumData::GetEnumMemberNameByIndex( int idx ) const { // we should cache the count in order to avoid out-of-bounds errors return m_members[idx].m_name ; @@ -118,7 +119,7 @@ template<> void wxStringReadValue(const wxString &s , bool &data ) { int intdata ; wxSscanf(s, _T("%d"), &intdata ) ; - data = bool(intdata) ; + data = (bool)intdata ; } template<> void wxStringWriteValue(wxString &s , const bool &data ) @@ -255,32 +256,32 @@ wxBuiltInTypeInfo s_typeInfowxString( wxT_STRING , &wxToStringConverter 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; } #if wxUSE_UNICODE -wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const char *6name) : +wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const char *name) : wxTypeInfo( kind , to , from , name) { wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;} #endif @@ -291,21 +292,25 @@ wxTypeInfo( kind , to , from , name) 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 @@ -544,6 +549,8 @@ wxObject* wxxVariant::GetAsObject() struct wxDynamicObject::wxDynamicObjectInternal { + wxDynamicObjectInternal() {} + #if wxUSE_UNICODE map m_properties ; #else @@ -551,6 +558,13 @@ struct wxDynamicObject::wxDynamicObjectInternal #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) { @@ -561,6 +575,7 @@ wxDynamicObject::wxDynamicObject(wxObject* superClassInstance, const wxDynamicCl wxDynamicObject::~wxDynamicObject() { + dynamic_cast(m_classInfo)->m_data->m_dynamicObjects.remove( this ) ; delete m_data ; delete m_superClassInstance ; } @@ -577,6 +592,21 @@ wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const 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 // ---------------------------------------------------------------------------- @@ -586,17 +616,21 @@ wxClassInfo( unitName, className , new const wxClassInfo*[2]) { 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 @@ -651,6 +685,8 @@ void wxDynamicClassInfo::AddHandler( const wxChar *handlerName , wxObjectEventFu // 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) ; } @@ -667,6 +703,8 @@ void wxDynamicClassInfo::RenameProperty( const wxChar *oldPropertyName , const w wxASSERT_MSG( pi ,wxT("not existing property") ) ; pi->m_name = newPropertyName ; dynamic_cast(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