]>
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
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"
15 #include "wx/dataobj.h"
20 #pragma message disable nosimpint
24 #pragma message enable nosimpint
27 #include "wx/motif/private.h"
29 //-------------------------------------------------------------------------
31 //-------------------------------------------------------------------------
34 Atom g_bitmapAtom
= 0;
37 //-------------------------------------------------------------------------
39 //-------------------------------------------------------------------------
41 wxDataFormat::wxDataFormat()
43 // do *not* call PrepareFormats() from here for 2 reasons:
45 // 1. we will have time to do it later because some other Set function
46 // must be called before we really need them
48 // 2. doing so prevents us from declaring global wxDataFormats because
49 // calling PrepareFormats (and thus gdk_atom_intern) before GDK is
50 // initialised will result in a crash
51 m_type
= wxDF_INVALID
;
55 wxDataFormat::wxDataFormat( wxDataFormatId type
)
61 wxDataFormat::wxDataFormat( const wxChar
*id
)
67 wxDataFormat::wxDataFormat( const wxString
&id
)
73 wxDataFormat::wxDataFormat( NativeFormat format
)
79 void wxDataFormat::SetType( wxDataFormatId type
)
84 if (m_type
== wxDF_TEXT
)
85 m_format
= g_textAtom
;
87 if (m_type
== wxDF_BITMAP
)
88 m_format
= g_bitmapAtom
;
90 if (m_type
== wxDF_FILENAME
)
91 m_format
= g_fileAtom
;
94 wxFAIL_MSG( wxT("invalid dataformat") );
98 wxDataFormatId
wxDataFormat::GetType() const
103 wxString
wxDataFormat::GetId() const
105 char *t
= XGetAtomName ((Display
*) wxGetDisplay(), m_format
);
106 wxString
ret( t
); // this will convert from ascii to Unicode
112 void wxDataFormat::SetId( NativeFormat format
)
117 if (m_format
== g_textAtom
)
120 if (m_format
== g_bitmapAtom
)
121 m_type
= wxDF_BITMAP
;
123 if (m_format
== g_fileAtom
)
124 m_type
= wxDF_FILENAME
;
126 m_type
= wxDF_PRIVATE
;
129 void wxDataFormat::SetId( const wxChar
*id
)
132 m_type
= wxDF_PRIVATE
;
134 m_format
= XInternAtom( wxGlobalDisplay(),
135 tmp
.mbc_str(), False
);
138 void wxDataFormat::PrepareFormats()
141 g_textAtom
= XInternAtom( wxGlobalDisplay(), "STRING", False
);
143 g_bitmapAtom
= XInternAtom( wxGlobalDisplay(), "PIXMAP", False
);
145 g_fileAtom
= XInternAtom( wxGlobalDisplay(), "file:ALL", False
);
148 // ----------------------------------------------------------------------------
150 // ----------------------------------------------------------------------------
152 wxDataObject::~wxDataObject()
156 // ----------------------------------------------------------------------------
157 // wxBitmapDataObject
158 // ----------------------------------------------------------------------------
160 size_t wxBitmapDataObject::GetDataSize() const
162 return sizeof(Pixmap
);
165 bool wxBitmapDataObject::GetDataHere(void* buf
) const
167 if( !GetBitmap().Ok() )
170 (*(Pixmap
*)buf
) = (Pixmap
)GetBitmap().GetDrawable();
175 bool wxBitmapDataObject::SetData(size_t len
, const void* buf
)
177 if( len
!= sizeof(Pixmap
) )
180 WXPixmap pixmap
= (WXPixmap
)*(Pixmap
*)buf
;
182 m_bitmap
.Create( pixmap
);
187 #endif // wxUSE_CLIPBOARD