]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dataobj.cpp
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDataObject class
4 // Author: Julian Smart
6 // Copyright: (c) 1998 Julian Smart
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "dataobj.h"
18 #include "wx/dataobj.h"
23 #pragma message disable nosimpint
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
32 //-------------------------------------------------------------------------
34 //-------------------------------------------------------------------------
37 Atom g_bitmapAtom
= 0;
40 //-------------------------------------------------------------------------
42 //-------------------------------------------------------------------------
44 wxDataFormat::wxDataFormat()
46 // do *not* call PrepareFormats() from here for 2 reasons:
48 // 1. we will have time to do it later because some other Set function
49 // must be called before we really need them
51 // 2. doing so prevents us from declaring global wxDataFormats because
52 // calling PrepareFormats (and thus gdk_atom_intern) before GDK is
53 // initialised will result in a crash
54 m_type
= wxDF_INVALID
;
58 wxDataFormat::wxDataFormat( wxDataFormatId type
)
64 wxDataFormat::wxDataFormat( const wxChar
*id
)
70 wxDataFormat::wxDataFormat( const wxString
&id
)
76 wxDataFormat::wxDataFormat( NativeFormat format
)
82 void wxDataFormat::SetType( wxDataFormatId type
)
87 if (m_type
== wxDF_TEXT
)
88 m_format
= g_textAtom
;
90 if (m_type
== wxDF_BITMAP
)
91 m_format
= g_bitmapAtom
;
93 if (m_type
== wxDF_FILENAME
)
94 m_format
= g_fileAtom
;
97 wxFAIL_MSG( wxT("invalid dataformat") );
101 wxDataFormatId
wxDataFormat::GetType() const
106 wxString
wxDataFormat::GetId() const
108 char *t
= XGetAtomName ((Display
*) wxGetDisplay(), m_format
);
109 wxString
ret( t
); // this will convert from ascii to Unicode
115 void wxDataFormat::SetId( NativeFormat format
)
120 if (m_format
== g_textAtom
)
123 if (m_format
== g_bitmapAtom
)
124 m_type
= wxDF_BITMAP
;
126 if (m_format
== g_fileAtom
)
127 m_type
= wxDF_FILENAME
;
129 m_type
= wxDF_PRIVATE
;
132 void wxDataFormat::SetId( const wxChar
*id
)
135 m_type
= wxDF_PRIVATE
;
137 m_format
= XInternAtom( wxGlobalDisplay(),
138 tmp
.mbc_str(), FALSE
);
141 void wxDataFormat::PrepareFormats()
144 g_textAtom
= XInternAtom( wxGlobalDisplay(), "STRING", FALSE
);
146 g_bitmapAtom
= XInternAtom( wxGlobalDisplay(), "PIXMAP", FALSE
);
148 g_fileAtom
= XInternAtom( wxGlobalDisplay(), "file:ALL", FALSE
);
151 // ----------------------------------------------------------------------------
153 // ----------------------------------------------------------------------------
155 wxDataObject::~wxDataObject()
159 // ----------------------------------------------------------------------------
160 // wxBitmapDataObject
161 // ----------------------------------------------------------------------------
163 size_t wxBitmapDataObject::GetDataSize() const
165 return sizeof(Pixmap
);
168 bool wxBitmapDataObject::GetDataHere(void* buf
) const
170 if( !GetBitmap().Ok() )
173 (*(Pixmap
*)buf
) = (Pixmap
)GetBitmap().GetDrawable();
178 bool wxBitmapDataObject::SetData(size_t len
, const void* buf
)
180 if( len
!= sizeof(Pixmap
) )
183 WXPixmap pixmap
= (WXPixmap
)*(Pixmap
*)buf
;
185 m_bitmap
.Create( pixmap
);
190 #endif // wxUSE_CLIPBOARD