+ if (m_type == wxDF_TEXT)
+ m_format = g_textAtom;
+ else
+ if (m_type == wxDF_BITMAP)
+ m_format = g_bitmapAtom;
+ 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_bitmapAtom)
+ 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( wxGlobalDisplay(),
+ tmp.mbc_str(), False );
+}
+
+void wxDataFormat::PrepareFormats()
+{
+ if (!g_textAtom)
+ g_textAtom = XInternAtom( wxGlobalDisplay(), "STRING", False );
+ if (!g_bitmapAtom)
+ g_bitmapAtom = XInternAtom( wxGlobalDisplay(), "PIXMAP", False );
+ if (!g_fileAtom)
+ g_fileAtom = XInternAtom( wxGlobalDisplay(), "file:ALL", False );
+}