From 45344b388060ed6cb27b494cf553d7223bd3e33b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Jun 2007 12:50:43 +0000 Subject: [PATCH] provide overloads for all kinds of strings for wxDataFormat ctor to allow passing strings as formats implicitly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46321 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/dataform.h | 11 ++++++++++- include/wx/gtk1/dataform.h | 12 +++++++++++- src/gtk/dataobj.cpp | 2 +- src/gtk1/dataobj.cpp | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/wx/gtk/dataform.h b/include/wx/gtk/dataform.h index 78803ff7da..1fc8372227 100644 --- a/include/wx/gtk/dataform.h +++ b/include/wx/gtk/dataform.h @@ -20,9 +20,15 @@ public: wxDataFormat(); wxDataFormat( wxDataFormatId type ); - wxDataFormat( const wxString &id ); wxDataFormat( NativeFormat format ); + // we have to provide all the overloads to allow using strings instead of + // data formats (as a lot of existing code does) + wxDataFormat( const wxString& id ) { InitFromString(id); } + wxDataFormat( const char *id ) { InitFromString(id); } + wxDataFormat( const wchar_t *id ) { InitFromString(id); } + wxDataFormat( const wxCStrData& id ) { InitFromString(id); } + wxDataFormat& operator=(const wxDataFormat& format) { m_type = format.m_type; m_format = format.m_format; return *this; } wxDataFormat& operator=(NativeFormat format) @@ -56,6 +62,9 @@ public: void SetType( wxDataFormatId type ); private: + // common part of ctors from format name + void InitFromString(const wxString& id); + wxDataFormatId m_type; NativeFormat m_format; diff --git a/include/wx/gtk1/dataform.h b/include/wx/gtk1/dataform.h index 5d143ed9aa..ad27104edd 100644 --- a/include/wx/gtk1/dataform.h +++ b/include/wx/gtk1/dataform.h @@ -20,9 +20,16 @@ public: wxDataFormat(); wxDataFormat( wxDataFormatId type ); - wxDataFormat( const wxString &id ); wxDataFormat( NativeFormat format ); + // we have to provide all the overloads to allow using strings instead of + // data formats (as a lot of existing code does) + wxDataFormat( const wxString& id ) { InitFromString(id); } + wxDataFormat( const char *id ) { InitFromString(id); } + wxDataFormat( const wchar_t *id ) { InitFromString(id); } + wxDataFormat( const wxCStrData& id ) { InitFromString(id); } + + wxDataFormat& operator=(const wxDataFormat& format) { m_type = format.m_type; m_format = format.m_format; return *this; } wxDataFormat& operator=(NativeFormat format) @@ -56,6 +63,9 @@ public: void SetType( wxDataFormatId type ); private: + // common part of ctors from format name + void InitFromString(const wxString& id); + wxDataFormatId m_type; NativeFormat m_format; diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index 4c3e4225eb..89ad8d2de0 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -58,7 +58,7 @@ wxDataFormat::wxDataFormat( wxDataFormatId type ) SetType( type ); } -wxDataFormat::wxDataFormat( const wxString &id ) +void wxDataFormat::InitFromString( const wxString &id ) { PrepareFormats(); SetId( id ); diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index 97b7bc8510..927d7e14da 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -58,7 +58,7 @@ wxDataFormat::wxDataFormat( wxDataFormatId type ) SetType( type ); } -wxDataFormat::wxDataFormat( const wxString &id ) +void wxDataFormat::InitFromString( const wxString &id ) { PrepareFormats(); SetId( id ); -- 2.45.2