]>
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 m_type
= wxDF_INVALID
;
41 wxDataFormat::wxDataFormat( wxDataFormatId type
)
43 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
47 wxDataFormat::wxDataFormat( const wxChar
*id
)
49 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
53 wxDataFormat::wxDataFormat( const wxString
&id
)
55 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
59 wxDataFormat::wxDataFormat( const wxDataFormat
&format
)
61 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
62 m_type
= format
.GetType();
63 m_id
= format
.GetId();
65 m_atom
= ((wxDataFormat
&)format
).GetAtom(); // const_cast
68 wxDataFormat::wxDataFormat( const Atom atom
)
70 if (!g_textAtom
) g_textAtom
= XInternAtom( (Display
*) wxGetDisplay(), "STRING", FALSE
);
75 if (m_atom
== g_textAtom
)
80 if (m_atom == GDK_TARGET_BITMAP)
86 m_type
= wxDF_PRIVATE
;
87 m_id
= XGetAtomName( (Display
*) wxGetDisplay(), m_atom
);
89 if (m_id
== wxT("file:ALL"))
91 m_type
= wxDF_FILENAME
;
96 void wxDataFormat::SetType( wxDataFormatId type
)
100 if (m_type
== wxDF_TEXT
)
102 m_id
= wxT("STRING");
105 if (m_type
== wxDF_BITMAP
)
107 m_id
= wxT("BITMAP");
110 if (m_type
== wxDF_FILENAME
)
112 m_id
= wxT("file:ALL");
116 wxFAIL_MSG( wxT("invalid dataformat") );
122 void wxDataFormat::SetId( const wxChar
*id
)
124 m_type
= wxDF_PRIVATE
;
129 Atom
wxDataFormat::GetAtom()
135 if (m_type
== wxDF_TEXT
)
141 if (m_type == wxDF_BITMAP)
143 m_atom = GDK_TARGET_BITMAP;
147 if (m_type
== wxDF_PRIVATE
)
149 m_atom
= XInternAtom( (Display
*) wxGetDisplay(), wxMBSTRINGCAST m_id
.mbc_str(), FALSE
);
152 if (m_type
== wxDF_FILENAME
)
154 m_atom
= XInternAtom( (Display
*) wxGetDisplay(), "file:ALL", FALSE
);
168 // ----------------------------------------------------------------------------
169 // wxPrivateDataObject
170 // ----------------------------------------------------------------------------
172 IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject
, wxDataObject
)
174 void wxPrivateDataObject::Free()
180 wxPrivateDataObject::wxPrivateDataObject()
182 wxString id
= wxT("application/");
183 id
+= wxTheApp
->GetAppName();
185 m_format
.SetId( id
);
188 m_data
= (void *)NULL
;
191 void wxPrivateDataObject::SetData( const void *data
, size_t size
)
196 m_data
= malloc(size
);
198 memcpy( m_data
, data
, size
);
201 void wxPrivateDataObject::WriteData( void *dest
) const
203 WriteData( m_data
, dest
);
206 size_t wxPrivateDataObject::GetSize() const
211 void wxPrivateDataObject::WriteData( const void *data
, void *dest
) const
213 memcpy( dest
, data
, GetSize() );
218 #endif // wxUSE_CLIPBOARD