X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/338dd992160bf20205743c092b353d96ef7604fb..60435227b10297510316a88f67758fb6b6d93c10:/src/motif/dataobj.cpp diff --git a/src/motif/dataobj.cpp b/src/motif/dataobj.cpp index 90e41f267a..2a4eb9404d 100644 --- a/src/motif/dataobj.cpp +++ b/src/motif/dataobj.cpp @@ -1,22 +1,22 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: dataobj.cpp +// Name: src/motif/dataobj.cpp // Purpose: wxDataObject class // Author: Julian Smart -// Id: $Id$ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "dataobj.h" -#endif - -#include "wx/defs.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" #if wxUSE_CLIPBOARD #include "wx/dataobj.h" -#include "wx/app.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/utils.h" +#endif #ifdef __VMS__ #pragma message disable nosimpint @@ -25,14 +25,15 @@ #ifdef __VMS__ #pragma message enable nosimpint #endif -#include "wx/utils.h" + +#include "wx/motif/private.h" //------------------------------------------------------------------------- // global data //------------------------------------------------------------------------- Atom g_textAtom = 0; -Atom g_pngAtom = 0; +Atom g_bitmapAtom = 0; Atom g_fileAtom = 0; //------------------------------------------------------------------------- @@ -59,12 +60,6 @@ wxDataFormat::wxDataFormat( wxDataFormatId type ) SetType( type ); } -wxDataFormat::wxDataFormat( const wxChar *id ) -{ - PrepareFormats(); - SetId( id ); -} - wxDataFormat::wxDataFormat( const wxString &id ) { PrepareFormats(); @@ -86,7 +81,7 @@ void wxDataFormat::SetType( wxDataFormatId type ) m_format = g_textAtom; else if (m_type == wxDF_BITMAP) - m_format = g_pngAtom; + m_format = g_bitmapAtom; else if (m_type == wxDF_FILENAME) m_format = g_fileAtom; @@ -105,7 +100,7 @@ wxString wxDataFormat::GetId() const { char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format); wxString ret( t ); // this will convert from ascii to Unicode - if (t) + if (t) XFree( t ); return ret; } @@ -118,7 +113,7 @@ void wxDataFormat::SetId( NativeFormat format ) if (m_format == g_textAtom) m_type = wxDF_TEXT; else - if (m_format == g_pngAtom) + if (m_format == g_bitmapAtom) m_type = wxDF_BITMAP; else if (m_format == g_fileAtom) @@ -127,74 +122,61 @@ void wxDataFormat::SetId( NativeFormat format ) m_type = wxDF_PRIVATE; } -void wxDataFormat::SetId( const wxChar *id ) +void wxDataFormat::SetId( const wxString& id ) { PrepareFormats(); m_type = wxDF_PRIVATE; - wxString tmp( id ); - m_format = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for? + m_format = XInternAtom( wxGlobalDisplay(), + id.mbc_str(), False ); } void wxDataFormat::PrepareFormats() { if (!g_textAtom) - g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE ); - if (!g_pngAtom) - g_pngAtom = XInternAtom( (Display*) wxGetDisplay(), "image/png", FALSE ); + g_textAtom = XInternAtom( wxGlobalDisplay(), "STRING", False ); + if (!g_bitmapAtom) + g_bitmapAtom = XInternAtom( wxGlobalDisplay(), "PIXMAP", False ); if (!g_fileAtom) - g_fileAtom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE ); + g_fileAtom = XInternAtom( wxGlobalDisplay(), "file:ALL", False ); } -#if 0 - // ---------------------------------------------------------------------------- -// wxPrivateDataObject +// wxDataObject // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject ) - -void wxPrivateDataObject::Free() +wxDataObject::~wxDataObject() { - if ( m_data ) - free(m_data); } -wxPrivateDataObject::wxPrivateDataObject() -{ - wxString id = wxT("application/"); - id += wxTheApp->GetAppName(); - - m_format.SetId( id ); +// ---------------------------------------------------------------------------- +// wxBitmapDataObject +// ---------------------------------------------------------------------------- - m_size = 0; - m_data = (void *)NULL; +size_t wxBitmapDataObject::GetDataSize() const +{ + return sizeof(Pixmap); } -void wxPrivateDataObject::SetData( const void *data, size_t size ) +bool wxBitmapDataObject::GetDataHere(void* buf) const { - Free(); + if( !GetBitmap().IsOk() ) + return false; - m_size = size; - m_data = malloc(size); + (*(Pixmap*)buf) = (Pixmap)GetBitmap().GetDrawable(); - memcpy( m_data, data, size ); + return true; } -void wxPrivateDataObject::WriteData( void *dest ) const +bool wxBitmapDataObject::SetData(size_t len, const void* buf) { - WriteData( m_data, dest ); -} + if( len != sizeof(Pixmap) ) + return false; -size_t wxPrivateDataObject::GetSize() const -{ - return m_size; -} + WXPixmap pixmap = (WXPixmap)*(Pixmap*)buf; -void wxPrivateDataObject::WriteData( const void *data, void *dest ) const -{ - memcpy( dest, data, GetSize() ); -} + m_bitmap.Create( pixmap ); -#endif // 0 + return true; +} #endif // wxUSE_CLIPBOARD