]>
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"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #include "wx/dataobj.h"
26 #pragma message disable nosimpint
30 #pragma message enable nosimpint
33 #include "wx/motif/private.h"
35 //-------------------------------------------------------------------------
37 //-------------------------------------------------------------------------
40 Atom g_bitmapAtom
= 0;
43 //-------------------------------------------------------------------------
45 //-------------------------------------------------------------------------
47 wxDataFormat::wxDataFormat()
49 // do *not* call PrepareFormats() from here for 2 reasons:
51 // 1. we will have time to do it later because some other Set function
52 // must be called before we really need them
54 // 2. doing so prevents us from declaring global wxDataFormats because
55 // calling PrepareFormats (and thus gdk_atom_intern) before GDK is
56 // initialised will result in a crash
57 m_type
= wxDF_INVALID
;
61 wxDataFormat::wxDataFormat( wxDataFormatId type
)
67 wxDataFormat::wxDataFormat( const wxChar
*id
)
73 wxDataFormat::wxDataFormat( const wxString
&id
)
79 wxDataFormat::wxDataFormat( NativeFormat format
)
85 void wxDataFormat::SetType( wxDataFormatId type
)
90 if (m_type
== wxDF_TEXT
)
91 m_format
= g_textAtom
;
93 if (m_type
== wxDF_BITMAP
)
94 m_format
= g_bitmapAtom
;
96 if (m_type
== wxDF_FILENAME
)
97 m_format
= g_fileAtom
;
100 wxFAIL_MSG( wxT("invalid dataformat") );
104 wxDataFormatId
wxDataFormat::GetType() const
109 wxString
wxDataFormat::GetId() const
111 char *t
= XGetAtomName ((Display
*) wxGetDisplay(), m_format
);
112 wxString
ret( t
); // this will convert from ascii to Unicode
118 void wxDataFormat::SetId( NativeFormat format
)
123 if (m_format
== g_textAtom
)
126 if (m_format
== g_bitmapAtom
)
127 m_type
= wxDF_BITMAP
;
129 if (m_format
== g_fileAtom
)
130 m_type
= wxDF_FILENAME
;
132 m_type
= wxDF_PRIVATE
;
135 void wxDataFormat::SetId( const wxChar
*id
)
138 m_type
= wxDF_PRIVATE
;
140 m_format
= XInternAtom( wxGlobalDisplay(),
141 tmp
.mbc_str(), False
);
144 void wxDataFormat::PrepareFormats()
147 g_textAtom
= XInternAtom( wxGlobalDisplay(), "STRING", False
);
149 g_bitmapAtom
= XInternAtom( wxGlobalDisplay(), "PIXMAP", False
);
151 g_fileAtom
= XInternAtom( wxGlobalDisplay(), "file:ALL", False
);
154 // ----------------------------------------------------------------------------
156 // ----------------------------------------------------------------------------
158 wxDataObject::~wxDataObject()
162 // ----------------------------------------------------------------------------
163 // wxBitmapDataObject
164 // ----------------------------------------------------------------------------
166 size_t wxBitmapDataObject::GetDataSize() const
168 return sizeof(Pixmap
);
171 bool wxBitmapDataObject::GetDataHere(void* buf
) const
173 if( !GetBitmap().Ok() )
176 (*(Pixmap
*)buf
) = (Pixmap
)GetBitmap().GetDrawable();
181 bool wxBitmapDataObject::SetData(size_t len
, const void* buf
)
183 if( len
!= sizeof(Pixmap
) )
186 WXPixmap pixmap
= (WXPixmap
)*(Pixmap
*)buf
;
188 m_bitmap
.Create( pixmap
);
193 #endif // wxUSE_CLIPBOARD