]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dataobj.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dataobj.cpp
3 // Purpose: wxDataObject class
4 // Author: Julian Smart
5 // Copyright: (c) 1998 Julian Smart
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
14 #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 wxString
&id
)
69 wxDataFormat::wxDataFormat( NativeFormat format
)
75 void wxDataFormat::SetType( wxDataFormatId type
)
80 if (m_type
== wxDF_TEXT
)
81 m_format
= g_textAtom
;
83 if (m_type
== wxDF_BITMAP
)
84 m_format
= g_bitmapAtom
;
86 if (m_type
== wxDF_FILENAME
)
87 m_format
= g_fileAtom
;
90 wxFAIL_MSG( wxT("invalid dataformat") );
94 wxDataFormatId
wxDataFormat::GetType() const
99 wxString
wxDataFormat::GetId() const
101 char *t
= XGetAtomName ((Display
*) wxGetDisplay(), m_format
);
102 wxString
ret( t
); // this will convert from ascii to Unicode
108 void wxDataFormat::SetId( NativeFormat format
)
113 if (m_format
== g_textAtom
)
116 if (m_format
== g_bitmapAtom
)
117 m_type
= wxDF_BITMAP
;
119 if (m_format
== g_fileAtom
)
120 m_type
= wxDF_FILENAME
;
122 m_type
= wxDF_PRIVATE
;
125 void wxDataFormat::SetId( const wxString
& id
)
128 m_type
= wxDF_PRIVATE
;
129 m_format
= XInternAtom( wxGlobalDisplay(),
130 id
.mbc_str(), False
);
133 void wxDataFormat::PrepareFormats()
136 g_textAtom
= XInternAtom( wxGlobalDisplay(), "STRING", False
);
138 g_bitmapAtom
= XInternAtom( wxGlobalDisplay(), "PIXMAP", False
);
140 g_fileAtom
= XInternAtom( wxGlobalDisplay(), "file:ALL", False
);
143 // ----------------------------------------------------------------------------
145 // ----------------------------------------------------------------------------
147 wxDataObject::~wxDataObject()
151 // ----------------------------------------------------------------------------
152 // wxBitmapDataObject
153 // ----------------------------------------------------------------------------
155 size_t wxBitmapDataObject::GetDataSize() const
157 return sizeof(Pixmap
);
160 bool wxBitmapDataObject::GetDataHere(void* buf
) const
162 if( !GetBitmap().IsOk() )
165 (*(Pixmap
*)buf
) = (Pixmap
)GetBitmap().GetDrawable();
170 bool wxBitmapDataObject::SetData(size_t len
, const void* buf
)
172 if( len
!= sizeof(Pixmap
) )
175 WXPixmap pixmap
= (WXPixmap
)*(Pixmap
*)buf
;
177 m_bitmap
.Create( pixmap
);
182 #endif // wxUSE_CLIPBOARD