X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/74d38ad8e2e1d2859cccaf0ac59c50c3bce555e5..ae7f6528ed6086845c3a7853bc6939705221656a:/src/gtk1/dataobj.cpp diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index 77b0e87066..cfbf0deb8a 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -17,7 +17,7 @@ #include "wx/mstream.h" #include "wx/image.h" -#include "gdk/gdk.h" +#include //------------------------------------------------------------------------- // global data @@ -152,15 +152,18 @@ wxDataObject::wxDataObject() bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) const { size_t nFormatCount = GetFormatCount(dir); - if ( nFormatCount == 1 ) { + if ( nFormatCount == 1 ) + { return format == GetPreferredFormat(); } - else { + else + { wxDataFormat *formats = new wxDataFormat[nFormatCount]; GetAllFormats(formats,dir); size_t n; - for ( n = 0; n < nFormatCount; n++ ) { + for ( n = 0; n < nFormatCount; n++ ) + { if ( formats[n] == format ) break; } @@ -204,7 +207,7 @@ size_t wxFileDataObject::GetDataSize() const return res + 1; } -bool wxFileDataObject::SetData(size_t size, const void *buf) +bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf) { // VZ: old format #if 0 @@ -327,40 +330,44 @@ bool wxBitmapDataObject::SetData(size_t size, const void *buf) { Clear(); + wxCHECK_MSG( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL, + FALSE, wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") ); + m_pngSize = size; m_pngData = malloc(m_pngSize); - memcpy( m_pngData, buf, m_pngSize ); + memcpy(m_pngData, buf, m_pngSize); - wxMemoryInputStream mstream( (char*) m_pngData, m_pngSize ); + wxMemoryInputStream mstream((char*) m_pngData, m_pngSize); wxImage image; - wxPNGHandler handler; - if ( !handler.LoadFile( &image, mstream ) ) + if ( !image.LoadFile( mstream, wxBITMAP_TYPE_PNG ) ) { return FALSE; } - m_bitmap = image.ConvertToBitmap(); + m_bitmap = wxBitmap(image); return m_bitmap.Ok(); } void wxBitmapDataObject::DoConvertToPng() { - if (!m_bitmap.Ok()) + if ( !m_bitmap.Ok() ) return; - wxImage image( m_bitmap ); - wxPNGHandler handler; + wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL, + wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") ); + + wxImage image = m_bitmap.ConvertToImage(); wxCountingOutputStream count; - handler.SaveFile( &image, count ); + image.SaveFile(count, wxBITMAP_TYPE_PNG); m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ??? m_pngData = malloc(m_pngSize); - wxMemoryOutputStream mstream( (char*) m_pngData, m_pngSize ); - handler.SaveFile( &image, mstream ); + wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize); + image.SaveFile(mstream, wxBITMAP_TYPE_PNG); }