X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7b284e5c62523c9a43e26977672b4ff7c5b8981..65fd2fc2616552e4204223b7c2b69d9bc87c1f2d:/src/mac/carbon/dataobj.cpp diff --git a/src/mac/carbon/dataobj.cpp b/src/mac/carbon/dataobj.cpp index 5de37f5e06..748c387ad6 100644 --- a/src/mac/carbon/dataobj.cpp +++ b/src/mac/carbon/dataobj.cpp @@ -14,19 +14,19 @@ #if wxUSE_DATAOBJ +#include "wx/dataobj.h" + #ifndef WX_PRECOMP -#include "wx/intl.h" + #include "wx/intl.h" + #include "wx/log.h" + #include "wx/dcmemory.h" + #include "wx/image.h" #endif -#include "wx/log.h" -#include "wx/dataobj.h" -#include "wx/dcmemory.h" #include "wx/mstream.h" -#include "wx/image.h" #include "wx/metafile.h" #include "wx/tokenzr.h" - #include "wx/mac/private.h" #ifndef __DARWIN__ @@ -49,11 +49,6 @@ wxDataFormat::wxDataFormat( wxDataFormatId vType ) SetType( vType ); } -wxDataFormat::wxDataFormat( const wxChar *zId ) -{ - SetId( zId ); -} - wxDataFormat::wxDataFormat( const wxString& rId ) { SetId( rId ); @@ -130,14 +125,14 @@ void wxDataFormat::SetId( NativeFormat format ) default: m_type = wxDF_PRIVATE; char text[5]; - strncpy( text, (char*)&format, 4 ); + memcpy( text, (const char*)&format, 4 ); text[4] = 0; m_id = wxString::FromAscii( text ); break; } } -void wxDataFormat::SetId( const wxChar* zId ) +void wxDataFormat::SetId( const wxString& zId ) { m_type = wxDF_PRIVATE; m_id = zId; @@ -171,14 +166,14 @@ bool wxDataObject::IsSupportedFormat( const wxDataFormat& rFormat, Direction vDi } else { - wxDataFormat* pFormats = new wxDataFormat[nFormatCount]; + wxDataFormat *pFormats = new wxDataFormat[nFormatCount]; GetAllFormats( pFormats, vDir ); for (size_t n = 0; n < nFormatCount; n++) { if (pFormats[n] == rFormat) { - found = true; + found = true; break; } } @@ -205,16 +200,16 @@ void wxTextDataObject::GetAllFormats( wxDataFormat *formats, wxDataObjectBase::D // wxFileDataObject // ---------------------------------------------------------------------------- -void wxFileDataObject::GetFileNames(wxCharBuffer &buf) const +void wxFileDataObject::GetFileNames( wxCharBuffer &buf ) const { wxString filenames; - + for (size_t i = 0; i < m_filenames.GetCount(); i++) { filenames += m_filenames[i]; filenames += wxT('\n'); } - + buf = filenames.fn_str(); } @@ -224,9 +219,11 @@ bool wxFileDataObject::GetDataHere( void *pBuf ) const return false; wxCharBuffer buf; - GetFileNames( buf ); + size_t buffLength; - memcpy( pBuf, (const char*) buf, strlen(buf) + 1 ); + GetFileNames( buf ); + buffLength = strlen( buf ); + memcpy( pBuf, (const char*)buf, buffLength + 1 ); return true; } @@ -234,22 +231,26 @@ bool wxFileDataObject::GetDataHere( void *pBuf ) const size_t wxFileDataObject::GetDataSize() const { wxCharBuffer buf; + size_t buffLength; + GetFileNames( buf ); + buffLength = strlen( buf ); - return strlen(buf) + 1; + return buffLength + 1; } bool wxFileDataObject::SetData( size_t nSize, const void *pBuf ) { wxString filenames; + #if wxUSE_UNICODE - filenames = wxString( (const char*) pBuf , *wxConvFileName ); + filenames = wxString( (const char*)pBuf, *wxConvFileName ); #else - filenames = wxString( wxConvFileName->cMB2WX( pBuf ) , wxConvLocal ); + filenames = wxString (wxConvLocal.cWC2WX(wxConvFileName->cMB2WC( (const char*)pBuf))); #endif - m_filenames = wxStringTokenize( filenames , wxT("\n") , wxTOKEN_STRTOK ); - + m_filenames = wxStringTokenize( filenames, wxT("\n"), wxTOKEN_STRTOK ); + return true; } @@ -305,8 +306,10 @@ void wxBitmapDataObject::Clear() { if (m_pictHandle != NULL) { +#ifndef __LP64__ if (m_pictCreated) KillPicture( (PicHandle)m_pictHandle ); +#endif m_pictHandle = NULL; } @@ -350,16 +353,21 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf ) // ownership is transferred to the bitmap m_pictCreated = false; +#ifndef __LP64__ Rect frame; wxMacGetPictureBounds( picHandle, &frame ); - +#if wxUSE_METAFILE wxMetafile mf; mf.SetHMETAFILE( (WXHMETAFILE)m_pictHandle ); +#endif wxMemoryDC mdc; m_bitmap.Create( frame.right - frame.left, frame.bottom - frame.top ); mdc.SelectObject( m_bitmap ); +#if wxUSE_METAFILE mf.Play( &mdc ); +#endif mdc.SelectObject( wxNullBitmap ); +#endif return m_bitmap.Ok(); }