macro naming changes, delegate api calls getting property info, object info exposed for beforewriteobject

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23375 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2003-09-04 01:12:11 +00:00
parent 9dabddc292
commit 8805dbab72
6 changed files with 119 additions and 73 deletions

View File

@ -94,7 +94,7 @@ template<> void wxStringWriteValue(wxString &s , const wxDateTime &data )
s = data.Format(wxT("%Y-%m-%d %H:%M:%S")) ;
}
WX_CUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter<wxDateTime> , wxFromStringConverter<wxDateTime>)
wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter<wxDateTime> , wxFromStringConverter<wxDateTime>)
#endif

View File

@ -56,57 +56,57 @@
#if wxUSE_EXTENDED_RTTI
WX_BEGIN_ENUM( wxFontEncoding )
WX_ENUM_MEMBER( wxFONTENCODING_SYSTEM )
WX_ENUM_MEMBER( wxFONTENCODING_DEFAULT )
wxBEGIN_ENUM( wxFontEncoding )
wxENUM_MEMBER( wxFONTENCODING_SYSTEM )
wxENUM_MEMBER( wxFONTENCODING_DEFAULT )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_1 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_2 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_3 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_4 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_5 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_6 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_7 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_8 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_9 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_10 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_11 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_12 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_13 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_14 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_15 )
WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_MAX )
WX_ENUM_MEMBER( wxFONTENCODING_KOI8 )
WX_ENUM_MEMBER( wxFONTENCODING_ALTERNATIVE )
WX_ENUM_MEMBER( wxFONTENCODING_BULGARIAN )
WX_ENUM_MEMBER( wxFONTENCODING_CP437 )
WX_ENUM_MEMBER( wxFONTENCODING_CP850 )
WX_ENUM_MEMBER( wxFONTENCODING_CP852 )
WX_ENUM_MEMBER( wxFONTENCODING_CP855 )
WX_ENUM_MEMBER( wxFONTENCODING_CP866 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_1 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_2 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_3 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_4 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_5 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_6 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_7 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_8 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_9 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_10 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_11 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_12 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_13 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_14 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_15 )
wxENUM_MEMBER( wxFONTENCODING_ISO8859_MAX )
wxENUM_MEMBER( wxFONTENCODING_KOI8 )
wxENUM_MEMBER( wxFONTENCODING_ALTERNATIVE )
wxENUM_MEMBER( wxFONTENCODING_BULGARIAN )
wxENUM_MEMBER( wxFONTENCODING_CP437 )
wxENUM_MEMBER( wxFONTENCODING_CP850 )
wxENUM_MEMBER( wxFONTENCODING_CP852 )
wxENUM_MEMBER( wxFONTENCODING_CP855 )
wxENUM_MEMBER( wxFONTENCODING_CP866 )
WX_ENUM_MEMBER( wxFONTENCODING_CP874 )
WX_ENUM_MEMBER( wxFONTENCODING_CP932 )
WX_ENUM_MEMBER( wxFONTENCODING_CP936 )
WX_ENUM_MEMBER( wxFONTENCODING_CP949 )
WX_ENUM_MEMBER( wxFONTENCODING_CP950 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1250 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1251 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1252 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1253 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1254 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1255 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1256 )
WX_ENUM_MEMBER( wxFONTENCODING_CP1257 )
WX_ENUM_MEMBER( wxFONTENCODING_CP12_MAX )
WX_ENUM_MEMBER( wxFONTENCODING_UTF7 )
WX_ENUM_MEMBER( wxFONTENCODING_UTF8 )
WX_ENUM_MEMBER( wxFONTENCODING_GB2312 )
WX_ENUM_MEMBER( wxFONTENCODING_BIG5 )
WX_ENUM_MEMBER( wxFONTENCODING_SHIFT_JIS )
WX_ENUM_MEMBER( wxFONTENCODING_EUC_JP )
WX_ENUM_MEMBER( wxFONTENCODING_UNICODE )
WX_END_ENUM( wxFontEncoding )
wxENUM_MEMBER( wxFONTENCODING_CP874 )
wxENUM_MEMBER( wxFONTENCODING_CP932 )
wxENUM_MEMBER( wxFONTENCODING_CP936 )
wxENUM_MEMBER( wxFONTENCODING_CP949 )
wxENUM_MEMBER( wxFONTENCODING_CP950 )
wxENUM_MEMBER( wxFONTENCODING_CP1250 )
wxENUM_MEMBER( wxFONTENCODING_CP1251 )
wxENUM_MEMBER( wxFONTENCODING_CP1252 )
wxENUM_MEMBER( wxFONTENCODING_CP1253 )
wxENUM_MEMBER( wxFONTENCODING_CP1254 )
wxENUM_MEMBER( wxFONTENCODING_CP1255 )
wxENUM_MEMBER( wxFONTENCODING_CP1256 )
wxENUM_MEMBER( wxFONTENCODING_CP1257 )
wxENUM_MEMBER( wxFONTENCODING_CP12_MAX )
wxENUM_MEMBER( wxFONTENCODING_UTF7 )
wxENUM_MEMBER( wxFONTENCODING_UTF8 )
wxENUM_MEMBER( wxFONTENCODING_GB2312 )
wxENUM_MEMBER( wxFONTENCODING_BIG5 )
wxENUM_MEMBER( wxFONTENCODING_SHIFT_JIS )
wxENUM_MEMBER( wxFONTENCODING_EUC_JP )
wxENUM_MEMBER( wxFONTENCODING_UNICODE )
wxEND_ENUM( wxFontEncoding )
#endif
// ----------------------------------------------------------------------------

View File

@ -79,7 +79,7 @@ template<> void wxStringWriteValue(wxString &s , const wxPoint &data )
s = wxString::Format(wxT("%d,%d"), data.x , data.y ) ;
}
WX_CUSTOM_TYPE_INFO(wxPoint, wxToStringConverter<wxPoint> , wxFromStringConverter<wxPoint>)
wxCUSTOM_TYPE_INFO(wxPoint, wxToStringConverter<wxPoint> , wxFromStringConverter<wxPoint>)
template<> void wxStringReadValue(const wxString &s , wxSize &data )
{
@ -91,7 +91,7 @@ template<> void wxStringWriteValue(wxString &s , const wxSize &data )
s = wxString::Format(wxT("%d,%d"), data.x , data.y ) ;
}
WX_CUSTOM_TYPE_INFO(wxSize, wxToStringConverter<wxSize> , wxFromStringConverter<wxSize>)
wxCUSTOM_TYPE_INFO(wxSize, wxToStringConverter<wxSize> , wxFromStringConverter<wxSize>)
#endif

View File

@ -255,15 +255,15 @@ wxBuiltInTypeInfo s_typeInfowxString( wxT_STRING , &wxToStringConverter<wxString
// 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)
{
@ -546,13 +546,31 @@ wxObject* wxxVariant::GetAsObject()
// own attributes in a hash map. Like this it is possible to create the objects and
// stream them, as if their class information was already available from compiled data
// can't keep the attributes in a hash map, because if someone renames a property in
// the class info, then things go potty later on when we try to iterate through
// the property values by name.
struct wxDynamicProperty__
{
#if wxUSE_UNICODE
wstring name;
#else
string name;
#endif
wxxVariant value;
wxDynamicProperty__ *next;
};
struct wxDynamicObject::wxDynamicObjectInternal
{
wxDynamicObjectInternal() : m_properties(NULL) {}
wxDynamicProperty__ *m_properties;
#if 0
#if wxUSE_UNICODE
map<wstring,wxxVariant> m_properties ;
#else
map<string,wxxVariant> m_properties ;
#endif
#endif
} ;
// instantiates this object with an instance of its superclass
@ -572,13 +590,39 @@ wxDynamicObject::~wxDynamicObject()
void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxxVariant &value)
{
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
m_data->m_properties[propertyName] = value ;
wxDynamicProperty__ *prop;
prop = m_data->m_properties;
while (prop)
{
if (!strcmp(prop->name.c_str(), propertyName))
{
prop->value = value;
return;
}
prop = prop->next;
}
prop = new wxDynamicProperty__;
prop->name = propertyName;
prop->value = value;
prop->next = m_data->m_properties;
m_data->m_properties = prop;
// m_data->m_properties[propertyName] = value ;
}
wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const
{
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
return m_data->m_properties[propertyName] ;
wxDynamicProperty__ *prop;
prop = m_data->m_properties;
while (prop)
{
if (!strcmp(prop->name.c_str(), propertyName))
return prop->value;
prop = prop->next;
}
// FIXME: needs to return something a little more sane here.
return wxxVariant();
// return m_data->m_properties[propertyName] ;
}
// ----------------------------------------------------------------------------

View File

@ -198,7 +198,7 @@ void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , c
DoBeginWriteElement() ;
wxxVariant value = data[i] ;
if ( persister->BeforeWriteProperty( this , pi , value ) )
if ( persister->BeforeWriteProperty( this , obj, pi , value ) )
{
const wxClassTypeInfo* cti = dynamic_cast< const wxClassTypeInfo* > ( elementType ) ;
if ( cti )
@ -270,7 +270,7 @@ void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , c
if ( cti && value.GetAsObject() == NULL )
return ;
if ( persister->BeforeWriteProperty( this , pi , value ) )
if ( persister->BeforeWriteProperty( this , obj, pi , value ) )
{
DoBeginWriteProperty( pi ) ;
if ( cti )
@ -501,7 +501,7 @@ void wxRuntimeDepersister::SetPropertyAsObject(int objectID,
void wxRuntimeDepersister::SetConnect(int eventSourceObjectID,
const wxClassInfo *WXUNUSED(eventSourceClassInfo),
const wxDelegateTypeInfo *delegateInfo ,
const wxPropertyInfo *delegateInfo ,
const wxClassInfo *WXUNUSED(eventSinkClassInfo) ,
const wxHandlerInfo* handlerInfo ,
int eventSinkObjectID )
@ -511,22 +511,22 @@ void wxRuntimeDepersister::SetConnect(int eventSourceObjectID,
if ( ehsource && ehsink )
{
if( delegateInfo->GetLastEventType() == -1 )
const wxDelegateTypeInfo *delegateTypeInfo = dynamic_cast<const wxDelegateTypeInfo*>(delegateInfo->GetTypeInfo());
if( delegateTypeInfo && delegateTypeInfo->GetLastEventType() == -1 )
{
ehsource->Connect( -1 , delegateInfo->GetEventType() ,
ehsource->Connect( -1 , delegateTypeInfo->GetEventType() ,
handlerInfo->GetEventFunction() , NULL /*user data*/ ,
ehsink ) ;
}
else
{
for ( wxEventType iter = delegateInfo->GetEventType() ; iter <= delegateInfo->GetLastEventType() ; ++iter )
for ( wxEventType iter = delegateTypeInfo->GetEventType() ; iter <= delegateTypeInfo->GetLastEventType() ; ++iter )
{
ehsource->Connect( -1 , iter ,
handlerInfo->GetEventFunction() , NULL /*user data*/ ,
ehsink ) ;
}
}
}
}
}
@ -750,7 +750,7 @@ void wxCodeDepersister::AddToPropertyCollectionAsObject(int WXUNUSED(objectID),
void wxCodeDepersister::SetConnect(int eventSourceObjectID,
const wxClassInfo *WXUNUSED(eventSourceClassInfo),
const wxDelegateTypeInfo *delegateInfo ,
const wxPropertyInfo *delegateInfo ,
const wxClassInfo *eventSinkClassInfo ,
const wxHandlerInfo* handlerInfo ,
int eventSinkObjectID )
@ -758,7 +758,9 @@ void wxCodeDepersister::SetConnect(int eventSourceObjectID,
wxString ehsource = m_data->GetObjectName( eventSourceObjectID ) ;
wxString ehsink = m_data->GetObjectName(eventSinkObjectID) ;
wxString ehsinkClass = eventSinkClassInfo->GetClassName() ;
int eventType = delegateInfo->GetEventType() ;
const wxDelegateTypeInfo *delegateTypeInfo = dynamic_cast<const wxDelegateTypeInfo*>(delegateInfo->GetTypeInfo());
wxASSERT_MSG(delegateTypeInfo, "delegate has no type info");
int eventType = delegateTypeInfo->GetEventType() ;
wxString handlerName = handlerInfo->GetName() ;
m_fp->WriteString( wxString::Format( wxT("\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;") ,

View File

@ -438,7 +438,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
wxString handlerName = resstring.Mid(pos+1) ;
wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ) ;
callbacks->SetConnect( objectID , classInfo , dynamic_cast<const wxDelegateTypeInfo*>(pi->GetTypeInfo()) , sinkClassInfo ,
callbacks->SetConnect( objectID , classInfo , pi , sinkClassInfo ,
sinkClassInfo->FindHandlerInfo(handlerName) , sinkOid ) ;
}