X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..30962327c9d5a850d9dc00864b1ffb448a832e6f:/src/mac/carbon/dataobj.cpp diff --git a/src/mac/carbon/dataobj.cpp b/src/mac/carbon/dataobj.cpp index bec4f2bd60..c810f7c418 100644 --- a/src/mac/carbon/dataobj.cpp +++ b/src/mac/carbon/dataobj.cpp @@ -17,24 +17,29 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "dataobj.h" #endif // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_DATAOBJ + #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" +#ifndef __DARWIN__ #include +#endif // ---------------------------------------------------------------------------- // functions @@ -94,13 +99,10 @@ void wxDataFormat::SetType( wxDataFormatId Type ) wxString wxDataFormat::GetId() const { - // note that m_format is not a pointer to string, it *is* itself a 4 - // character string - char text[5] ; - strncpy( text , (char*) &m_format , 4 ) ; - text[4] = 0 ; + wxCHECK_MSG( !IsStandard(), wxEmptyString , + wxT("name of predefined format cannot be retrieved") ); - return wxString::FromAscii( text ) ; + return m_id ; } void wxDataFormat::SetId( NativeFormat format ) @@ -116,13 +118,32 @@ void wxDataFormat::SetId( NativeFormat format ) else if (m_format == kDragFlavorTypeHFS ) m_type = wxDF_FILENAME; else + { m_type = wxDF_PRIVATE; + char text[5] ; + strncpy( text , (char*) &format , 4 ) ; + text[4] = 0 ; + m_id = wxString::FromAscii( text ) ; + } } void wxDataFormat::SetId( const wxChar* zId ) { m_type = wxDF_PRIVATE; - m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); + m_id = zId ; + m_format = 'WXPR' ; +} + +bool wxDataFormat::operator==(const wxDataFormat& format) const +{ + if ( IsStandard() || format.IsStandard() ) + { + return ( format.m_type == m_type ) ; + } + else + { + return ( m_id == format.m_id ) ; + } } //------------------------------------------------------------------------- @@ -251,7 +272,8 @@ wxBitmapDataObject::wxBitmapDataObject( Init(); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + m_pictHandle = m_bitmap.GetBitmapData()->GetPictHandle() ; + m_pictCreated = false ; } } @@ -268,7 +290,8 @@ void wxBitmapDataObject::SetBitmap( wxBitmapDataObjectBase::SetBitmap(rBitmap); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + m_pictHandle = m_bitmap.GetBitmapData()->GetPictHandle() ; + m_pictCreated = false ; } } @@ -314,11 +337,19 @@ 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(); } + +#endif \ No newline at end of file