From: Stefan Csomor Date: Sun, 1 Jul 2012 15:46:26 +0000 (+0000) Subject: native hook for supported datatypes X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f31c06b39e4eaff67776ab2e823a83f924d7a145 native hook for supported datatypes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71915 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/osx/dataobj.h b/include/wx/osx/dataobj.h index b01694a15e..8d9ea7a5c0 100644 --- a/include/wx/osx/dataobj.h +++ b/include/wx/osx/dataobj.h @@ -31,6 +31,10 @@ public: // returns true if any of the accepted formats of this dataobj is in the pasteboard bool HasDataInPasteboard( void * pasteboardRef ); bool GetFromPasteboard( void * pasteboardRef ); + +#if wxOSX_USE_COCOA + virtual void AddSupportedTypes( void* cfarray); +#endif }; #endif // _WX_MAC_DATAOBJ_H_ diff --git a/src/osx/carbon/dataobj.cpp b/src/osx/carbon/dataobj.cpp index 754b6386c8..db8e5dd548 100644 --- a/src/osx/carbon/dataobj.cpp +++ b/src/osx/carbon/dataobj.cpp @@ -594,6 +594,46 @@ bool wxDataObject::HasDataInPasteboard( void * pb ) return hasData; } +#if wxOSX_USE_COCOA + +void wxDataObject::AddSupportedTypes( void* cfarray) +{ + wxDataFormat *array = new wxDataFormat[ GetFormatCount() ]; + GetAllFormats( array ); + + for (size_t i = 0; i < GetFormatCount(); i++) + { + wxDataFormat dataFormat = array[ i ]; + + if ( dataFormat.GetType() == wxDF_UNICODETEXT || dataFormat.GetType() == wxDF_TEXT ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeUTF16PlainText); + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypePlainText); + } + else if ( dataFormat.GetType() == wxDF_FILENAME ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeFileURL); + CFArrayAppendValue((CFMutableArrayRef)cfarray, kPasteboardTypeFileURLPromise); + } + else if ( dataFormat.GetType() == wxDF_HTML ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeHTML); + } + else if ( dataFormat.GetType() == wxDF_BITMAP ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeTIFF); + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypePICT); + } + else if ( dataFormat.GetType() == wxDF_METAFILE ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypePDF); + } + } + delete[] array; +} + +#endif + // ---------------------------------------------------------------------------- // wxTextDataObject // ----------------------------------------------------------------------------