X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/63b8dd39b88479c7171f388f9310be8a0561eb89..01526d4f6cd7dd242e561aa24066f8ca0290a9ac:/src/mac/carbon/dataobj.cpp diff --git a/src/mac/carbon/dataobj.cpp b/src/mac/carbon/dataobj.cpp index b384ac7036..33e738e0b9 100644 --- a/src/mac/carbon/dataobj.cpp +++ b/src/mac/carbon/dataobj.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "dataobj.h" #endif @@ -27,14 +27,15 @@ #ifndef WX_PRECOMP #include "wx/intl.h" #endif -#include "wx/defs.h" #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/mac/private.h" -#include "Scrap.h" +#include // ---------------------------------------------------------------------------- // functions @@ -86,7 +87,9 @@ void wxDataFormat::SetType( wxDataFormatId Type ) { wxFAIL_MSG( wxT("invalid dataformat") ); - m_format = '????'; + // this is '????' but it can't be used in the code because ??' is + // parsed as a trigraph! + m_format = 0x3f3f3f3f; } } @@ -164,6 +167,19 @@ bool wxDataObject::IsSupportedFormat( } } +// ---------------------------------------------------------------------------- +// wxTextDataObject +// ---------------------------------------------------------------------------- + +#if wxUSE_UNICODE +void wxTextDataObject::GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction dir) const +{ + *formats++ = wxDataFormat( wxDF_TEXT ); + *formats = wxDataFormat( wxDF_UNICODETEXT ); +} + +#endif + // ---------------------------------------------------------------------------- // wxFileDataObject // ---------------------------------------------------------------------------- @@ -204,7 +220,10 @@ bool wxFileDataObject::SetData( { m_filenames.Empty(); - AddFile(wxString::FromAscii((char*)pBuf)); + // only add if this is not an empty string + // we can therefore clear the list by just setting an empty string + if ( (*(char*)pBuf) != 0 ) + AddFile(wxString::FromAscii((char*)pBuf)); return TRUE; } @@ -233,7 +252,8 @@ wxBitmapDataObject::wxBitmapDataObject( Init(); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + m_pictHandle = wxMacCreatePicHandle( rBitmap ) ; + m_pictCreated = true ; } } @@ -250,7 +270,8 @@ void wxBitmapDataObject::SetBitmap( wxBitmapDataObjectBase::SetBitmap(rBitmap); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + m_pictHandle = wxMacCreatePicHandle( rBitmap ) ; + m_pictCreated = true ; } } @@ -296,11 +317,17 @@ bool wxBitmapDataObject::SetData( PicHandle picHandle = (PicHandle) NewHandle( nSize ) ; memcpy( *picHandle , pBuf , nSize ) ; m_pictHandle = picHandle ; + // ownership is transferred to the bitmap m_pictCreated = false ; Rect frame = (**picHandle).picFrame ; - m_bitmap.SetPict( picHandle ) ; - m_bitmap.SetWidth( frame.right - frame.left ) ; - m_bitmap.SetHeight( frame.bottom - frame.top ) ; + wxMetafile mf ; + mf.SetHMETAFILE( (WXHMETAFILE) m_pictHandle ) ; + wxMemoryDC mdc ; + m_bitmap.Create( frame.right - frame.left ,frame.bottom - frame.top ) ; + mdc.SelectObject(m_bitmap ) ; + mf.Play( &mdc ) ; + mdc.SelectObject( wxNullBitmap ) ; + return m_bitmap.Ok(); }