]>
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 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #include "wx/dataobj.h"
22 #pragma message disable nosimpint
26 #pragma message enable nosimpint
29 #include "wx/motif/private.h"
31 //-------------------------------------------------------------------------
33 //-------------------------------------------------------------------------
36 Atom g_bitmapAtom
= 0;
39 //-------------------------------------------------------------------------
41 //-------------------------------------------------------------------------
43 wxDataFormat::wxDataFormat()
45 // do *not* call PrepareFormats() from here for 2 reasons:
47 // 1. we will have time to do it later because some other Set function
48 // must be called before we really need them
50 // 2. doing so prevents us from declaring global wxDataFormats because
51 // calling PrepareFormats (and thus gdk_atom_intern) before GDK is
52 // initialised will result in a crash
53 m_type
= wxDF_INVALID
;
57 wxDataFormat::wxDataFormat( wxDataFormatId type
)
63 wxDataFormat::wxDataFormat( const wxChar
*id
)
69 wxDataFormat::wxDataFormat( const wxString
&id
)
75 wxDataFormat::wxDataFormat( NativeFormat format
)
81 void wxDataFormat::SetType( wxDataFormatId type
)
86 if (m_type
== wxDF_TEXT
)
87 m_format
= g_textAtom
;
89 if (m_type
== wxDF_BITMAP
)
90 m_format
= g_bitmapAtom
;
92 if (m_type
== wxDF_FILENAME
)
93 m_format
= g_fileAtom
;
96 wxFAIL_MSG( wxT("invalid dataformat") );
100 wxDataFormatId
wxDataFormat::GetType() const
105 wxString
wxDataFormat::GetId() const
107 char *t
= XGetAtomName ((Display
*) wxGetDisplay(), m_format
);
108 wxString
ret( t
); // this will convert from ascii to Unicode
114 void wxDataFormat::SetId( NativeFormat format
)
119 if (m_format
== g_textAtom
)
122 if (m_format
== g_bitmapAtom
)
123 m_type
= wxDF_BITMAP
;
125 if (m_format
== g_fileAtom
)
126 m_type
= wxDF_FILENAME
;
128 m_type
= wxDF_PRIVATE
;
131 void wxDataFormat::SetId( const wxChar
*id
)
134 m_type
= wxDF_PRIVATE
;
136 m_format
= XInternAtom( wxGlobalDisplay(),
137 tmp
.mbc_str(), False
);
140 void wxDataFormat::PrepareFormats()
143 g_textAtom
= XInternAtom( wxGlobalDisplay(), "STRING", False
);
145 g_bitmapAtom
= XInternAtom( wxGlobalDisplay(), "PIXMAP", False
);
147 g_fileAtom
= XInternAtom( wxGlobalDisplay(), "file:ALL", False
);
150 // ----------------------------------------------------------------------------
152 // ----------------------------------------------------------------------------
154 wxDataObject::~wxDataObject()
158 // ----------------------------------------------------------------------------
159 // wxBitmapDataObject
160 // ----------------------------------------------------------------------------
162 size_t wxBitmapDataObject::GetDataSize() const
164 return sizeof(Pixmap
);
167 bool wxBitmapDataObject::GetDataHere(void* buf
) const
169 if( !GetBitmap().Ok() )
172 (*(Pixmap
*)buf
) = (Pixmap
)GetBitmap().GetDrawable();
177 bool wxBitmapDataObject::SetData(size_t len
, const void* buf
)
179 if( len
!= sizeof(Pixmap
) )
182 WXPixmap pixmap
= (WXPixmap
)*(Pixmap
*)buf
;
184 m_bitmap
.Create( pixmap
);
189 #endif // wxUSE_CLIPBOARD