+wxDataFormat::wxDataFormat( NativeFormat format )
+{
+ PrepareFormats();
+ SetId( format );
+}
+
+void wxDataFormat::SetType( wxDataFormatId type )
+{
+ PrepareFormats();
+ m_type = type;
+
+ if (m_type == wxDF_TEXT)
+ m_format = g_textAtom;
+ else
+ if (m_type == wxDF_BITMAP)
+ m_format = g_pngAtom;
+ else
+ if (m_type == wxDF_FILENAME)
+ m_format = g_fileAtom;
+ else
+ {
+ wxFAIL_MSG( wxT("invalid dataformat") );
+ }
+}
+
+wxDataFormatId wxDataFormat::GetType() const
+{
+ return m_type;
+}
+
+wxString wxDataFormat::GetId() const
+{
+ char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format);
+ wxString ret( t ); // this will convert from ascii to Unicode
+ if (t)
+ XFree( t );
+ return ret;
+}
+
+void wxDataFormat::SetId( NativeFormat format )
+{
+ PrepareFormats();
+ m_format = format;
+
+ if (m_format == g_textAtom)
+ m_type = wxDF_TEXT;
+ else
+ if (m_format == g_pngAtom)
+ m_type = wxDF_BITMAP;
+ else
+ if (m_format == g_fileAtom)
+ m_type = wxDF_FILENAME;
+ else
+ m_type = wxDF_PRIVATE;
+}
+
+void wxDataFormat::SetId( const wxChar *id )
+{
+ PrepareFormats();
+ m_type = wxDF_PRIVATE;
+ wxString tmp( id );
+ m_format = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
+}
+
+void wxDataFormat::PrepareFormats()
+{
+ if (!g_textAtom)
+ g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
+ if (!g_pngAtom)
+ g_pngAtom = XInternAtom( (Display*) wxGetDisplay(), "image/png", FALSE );
+ if (!g_fileAtom)
+ g_fileAtom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE );
+}
+
+#if 0