]>
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 ///////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "dataobj.h"
18 #include "wx/dataobj.h"
24 //-------------------------------------------------------------------------
26 //-------------------------------------------------------------------------
30 //-------------------------------------------------------------------------
32 //-------------------------------------------------------------------------
34 wxDataFormat::wxDataFormat()
36 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
37 m_type
= wxDF_INVALID
;
42 wxDataFormat::wxDataFormat( wxDataFormatId type
)
44 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
48 wxDataFormat::wxDataFormat( const wxChar
*id
)
50 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
54 wxDataFormat::wxDataFormat( const wxString
&id
)
56 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
60 wxDataFormat::wxDataFormat( const wxDataFormat
&format
)
62 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
63 m_type
= format
.GetType();
64 m_id
= format
.GetId();
66 m_atom
= ((wxDataFormat
&)format
).GetAtom(); // const_cast
69 wxDataFormat::wxDataFormat( const Atom atom
)
71 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
76 if (m_atom
== g_textAtom
)
81 if (m_atom == GDK_TARGET_BITMAP)
87 m_type
= wxDF_PRIVATE
;
88 m_id
= XGetAtomName( (Display
*) wxGetDisplay(), m_atom
);
90 if (m_id
== wxT("file:ALL"))
92 m_type
= wxDF_FILENAME
;
97 void wxDataFormat::SetType( wxDataFormatId type
)
101 if (m_type
== wxDF_TEXT
)
103 m_id
= wxT("STRING");
106 if (m_type
== wxDF_BITMAP
)
108 m_id
= wxT("BITMAP");
111 if (m_type
== wxDF_FILENAME
)
113 m_id
= wxT("file:ALL");
117 wxFAIL_MSG( wxT("invalid dataformat") );
123 void wxDataFormat::SetId( const wxChar
*id
)
125 m_type
= wxDF_PRIVATE
;
130 Atom
wxDataFormat::GetAtom()
136 if (m_type
== wxDF_TEXT
)
142 if (m_type == wxDF_BITMAP)
144 m_atom = GDK_TARGET_BITMAP;
148 if (m_type
== wxDF_PRIVATE
)
150 m_atom
= XInternAtom( (Display
*) wxGetDisplay(), wxMBSTRINGCAST m_id
.mbc_str(), FALSE
);
153 if (m_type
== wxDF_FILENAME
)
155 m_atom
= XInternAtom( (Display
*) wxGetDisplay(), "file:ALL", FALSE
);
169 // ----------------------------------------------------------------------------
170 // wxPrivateDataObject
171 // ----------------------------------------------------------------------------
173 IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject
, wxDataObject
)
175 void wxPrivateDataObject::Free()
181 wxPrivateDataObject::wxPrivateDataObject()
183 wxString id
= wxT("application/");
184 id
+= wxTheApp
->GetAppName();
186 m_format
.SetId( id
);
189 m_data
= (void *)NULL
;
192 void wxPrivateDataObject::SetData( const void *data
, size_t size
)
197 m_data
= malloc(size
);
199 memcpy( m_data
, data
, size
);
202 void wxPrivateDataObject::WriteData( void *dest
) const
204 WriteData( m_data
, dest
);
207 size_t wxPrivateDataObject::GetSize() const
212 void wxPrivateDataObject::WriteData( const void *data
, void *dest
) const
214 memcpy( dest
, data
, GetSize() );
219 #endif // wxUSE_CLIPBOARD