X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9dc6871e8fc67ab4db88857af993d398e8edf387..fb3e83b60a5eeb499bb2934ce4fa0f0cdff5fbec:/src/common/xti.cpp?ds=sidebyside diff --git a/src/common/xti.cpp b/src/common/xti.cpp index 6911bfe7ac..21aa7a1170 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,15 +256,15 @@ wxBuiltInTypeInfo s_typeInfowxString( wxT_STRING , &wxToStringConverter void wxCollectionToVariantArray( wxArrayString const &theArray, wxxVariantArray &value) { @@ -279,13 +280,23 @@ wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName) return (wxTypeInfo *)iter->second; } +#if wxUSE_UNICODE +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 + wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const wxString &name) : wxTypeInfo( kind , to , from , name) { wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;} 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() { @@ -538,7 +549,20 @@ wxObject* wxxVariant::GetAsObject() struct wxDynamicObject::wxDynamicObjectInternal { + wxDynamicObjectInternal() {} + +#if wxUSE_UNICODE + map m_properties ; +#else map m_properties ; +#endif +} ; + +typedef list< wxDynamicObject* > wxDynamicObjectList ; + +struct wxDynamicClassInfo::wxDynamicClassInfoInternal +{ + wxDynamicObjectList m_dynamicObjects ; } ; // instantiates this object with an instance of its superclass @@ -551,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 ; } @@ -567,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 // ---------------------------------------------------------------------------- @@ -576,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 @@ -641,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) ; } @@ -657,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