X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1cf9b41c2db31c498547849f6ebf5532f9e94107..80a779275ae04443c568dca919adb26cf6f5002c:/src/mac/carbon/dataobj.cpp?ds=inline diff --git a/src/mac/carbon/dataobj.cpp b/src/mac/carbon/dataobj.cpp index dd1ab8a38d..07a1e39a98 100644 --- a/src/mac/carbon/dataobj.cpp +++ b/src/mac/carbon/dataobj.cpp @@ -14,16 +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__ @@ -96,7 +99,7 @@ void wxDataFormat::SetType( wxDataFormatId dataType ) wxString wxDataFormat::GetId() const { - wxCHECK_MSG( !IsStandard(), wxEmptyString , + wxCHECK_MSG( !IsStandard(), wxEmptyString, wxT("name of predefined format cannot be retrieved") ); return m_id; @@ -127,7 +130,7 @@ 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; @@ -168,14 +171,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; } } @@ -202,45 +205,56 @@ void wxTextDataObject::GetAllFormats( wxDataFormat *formats, wxDataObjectBase::D // wxFileDataObject // ---------------------------------------------------------------------------- -bool wxFileDataObject::GetDataHere( void *pBuf ) const +void wxFileDataObject::GetFileNames( wxCharBuffer &buf ) const { - if (pBuf == NULL) - return false; - - wxString sFilenames; + wxString filenames; for (size_t i = 0; i < m_filenames.GetCount(); i++) { - sFilenames += m_filenames[i]; - sFilenames += (wxChar)0; + filenames += m_filenames[i]; + filenames += wxT('\n'); } - memcpy( pBuf, sFilenames.mbc_str(), sFilenames.Len() + 1 ); + buf = filenames.fn_str(); +} + +bool wxFileDataObject::GetDataHere( void *pBuf ) const +{ + if (pBuf == NULL) + return false; + + wxCharBuffer buf; + size_t buffLength; + + GetFileNames( buf ); + buffLength = strlen( buf ); + memcpy( pBuf, (const char*)buf, buffLength + 1 ); return true; } size_t wxFileDataObject::GetDataSize() const { - size_t nRes = 0; + wxCharBuffer buf; + size_t buffLength; - for (size_t i = 0; i < m_filenames.GetCount(); i++) - { - nRes += m_filenames[i].Len(); - nRes += 1; - } + GetFileNames( buf ); + buffLength = strlen( buf ); - return nRes + 1; + return buffLength + 1; } -bool wxFileDataObject::SetData( size_t WXUNUSED(nSize), const void *pBuf ) +bool wxFileDataObject::SetData( size_t nSize, const void *pBuf ) { - m_filenames.Empty(); + wxString filenames; + +#if wxUSE_UNICODE + filenames = wxString( (const char*)pBuf, *wxConvFileName ); +#else + filenames = wxString (wxConvLocal.cWC2WX(wxConvFileName->cMB2WC( (const char*)pBuf))); +#endif - // only add if this is not an empty string - // we can therefore clear the list by just setting an empty string - if ((*(const char*)pBuf) != 0) - AddFile( wxString::FromAscii( (char*)pBuf) ); + m_filenames = wxStringTokenize( filenames, wxT("\n"), wxTOKEN_STRTOK ); return true; } @@ -297,8 +311,10 @@ void wxBitmapDataObject::Clear() { if (m_pictHandle != NULL) { +#ifndef __LP64__ if (m_pictCreated) KillPicture( (PicHandle)m_pictHandle ); +#endif m_pictHandle = NULL; } @@ -342,8 +358,9 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf ) // ownership is transferred to the bitmap m_pictCreated = false; - Rect frame ; - wxMacGetPictureBounds( picHandle , &frame ) ; +#ifndef __LP64__ + Rect frame; + wxMacGetPictureBounds( picHandle, &frame ); wxMetafile mf; mf.SetHMETAFILE( (WXHMETAFILE)m_pictHandle ); @@ -352,6 +369,7 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf ) mdc.SelectObject( m_bitmap ); mf.Play( &mdc ); mdc.SelectObject( wxNullBitmap ); +#endif return m_bitmap.Ok(); }