X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/72e7876ba5ad16a1b03bb2449ea7886ec648854a..c920350185de42376da247722e885e7a79116e61:/src/mac/dataobj.cpp diff --git a/src/mac/dataobj.cpp b/src/mac/dataobj.cpp index fbaf93061d..c2f75326c0 100644 --- a/src/mac/dataobj.cpp +++ b/src/mac/dataobj.cpp @@ -33,6 +33,7 @@ #include "wx/dataobj.h" #include "wx/mstream.h" #include "wx/image.h" +#include "wx/mac/private.h" // ---------------------------------------------------------------------------- // functions @@ -44,56 +45,40 @@ wxDataFormat::wxDataFormat() { - m_vType = wxDF_INVALID; - m_vFormat = 0; + m_type = wxDF_INVALID; + m_format = 0; } -wxDataFormat::wxDataFormat( - wxDataFormatId vType -) +wxDataFormat::wxDataFormat( wxDataFormatId vType ) { - PrepareFormats(); SetType(vType); } -wxDataFormat::wxDataFormat( - const wxChar* zId -) +wxDataFormat::wxDataFormat( const wxChar* zId) { - PrepareFormats(); SetId(zId); } -wxDataFormat::wxDataFormat( - const wxString& rId -) +wxDataFormat::wxDataFormat( const wxString& rId) { - PrepareFormats(); SetId(rId); } -wxDataFormat::wxDataFormat( - NativeFormat vFormat -) +wxDataFormat::wxDataFormat( NativeFormat vFormat) { - PrepareFormats(); SetId(vFormat); } -void wxDataFormat::SetType( - wxDataFormatId vType -) +void wxDataFormat::SetType( wxDataFormatId Type ) { - m_vType = vType; - - if (m_vType == wxDF_TEXT) - m_vFormat = 0; - else - if (m_vType == wxDF_BITMAP) - m_vFormat = 0; - else - if (m_vType == wxDF_FILENAME) - m_vFormat = 0; + m_type = Type; + + if (m_type == wxDF_TEXT) + m_format = 'TEXT'; + else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE ) + m_format = 'PICT'; + else if (m_type == wxDF_FILENAME) + m_format = kDragFlavorTypeHFS ; else { wxFAIL_MSG( wxT("invalid dataformat") ); @@ -102,56 +87,37 @@ void wxDataFormat::SetType( wxDataFormatId wxDataFormat::GetType() const { - return m_vType; + return m_type; } wxString wxDataFormat::GetId() const { - wxString sRet(""); // TODO: gdk_atom_name( m_format ) ); + wxString sRet(""); // TODO: to name of ( m_format ) ); return sRet; } -void wxDataFormat::SetId( - NativeFormat vFormat -) +void wxDataFormat::SetId( NativeFormat format ) { - m_vFormat = vFormat; -// TODO: -/* - if (m_format == g_textAtom) + m_format = format; + + if (m_format == 'TEXT') m_type = wxDF_TEXT; else - if (m_format == g_pngAtom) + if (m_format == 'PICT') m_type = wxDF_BITMAP; else - if (m_format == g_fileAtom) + if (m_format == kDragFlavorTypeHFS ) m_type = wxDF_FILENAME; else m_type = wxDF_PRIVATE; -*/ } -void wxDataFormat::SetId( - const wxChar* zId -) +void wxDataFormat::SetId( const wxChar* zId ) { wxString tmp(zId); - m_vType = wxDF_PRIVATE; - m_vFormat = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); -} - -void wxDataFormat::PrepareFormats() -{ -// TODO: -/* - if (!g_textAtom) - g_textAtom = gdk_atom_intern( "STRING", FALSE ); - if (!g_pngAtom) - g_pngAtom = gdk_atom_intern( "image/png", FALSE ); - if (!g_fileAtom) - g_fileAtom = gdk_atom_intern( "file:ALL", FALSE ); -*/ + m_type = wxDF_PRIVATE; + m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); } //------------------------------------------------------------------------- @@ -233,7 +199,7 @@ bool wxFileDataObject::SetData( , const void* pBuf ) { - /* TODO */ + m_filenames.Empty(); wxString sFile( (const char *)pBuf); /* char, not wxChar */ @@ -315,7 +281,7 @@ bool wxBitmapDataObject::SetData( return FALSE; } - m_bitmap = vImage.ConvertToBitmap(); + m_bitmap = wxBitmap( vImage ) ; return m_bitmap.Ok(); } @@ -324,17 +290,18 @@ void wxBitmapDataObject::DoConvertToPng() if (!m_bitmap.Ok()) return; - wxImage vImage(m_bitmap); - wxPNGHandler vHandler; - wxCountingOutputStream vCount; + wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL, + wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") ); - vHandler.SaveFile(&vImage, vCount); + wxImage image = m_bitmap.ConvertToImage(); - m_pngSize = vCount.GetSize() + 100; // sometimes the size seems to vary ??? - m_pngData = malloc(m_pngSize); + wxCountingOutputStream count; + image.SaveFile(count, wxBITMAP_TYPE_PNG); - wxMemoryOutputStream vMstream((char*) m_pngData, m_pngSize); + m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ??? + m_pngData = malloc(m_pngSize); - vHandler.SaveFile(&vImage, vMstream ); + wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize); + image.SaveFile(mstream, wxBITMAP_TYPE_PNG); }