+bool wxClipboard::SetData( wxDataObject *data )
+{
+ (void)wxEmptyClipboard();
+
+ if ( data )
+ return AddData(data);
+ else
+ return TRUE;
+}
+
+bool wxClipboard::AddData( wxDataObject *data )
+{
+ wxCHECK_MSG( data, FALSE, wxT("data is invalid") );
+
+#if wxUSE_DATAOBJ
+ wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
+
+ wxDataFormat format = data->GetFormat();
+
+ switch ( format )
+ {
+ case wxDF_TEXT:
+ case wxDF_OEMTEXT:
+ {
+ wxTextDataObject* textDataObject = (wxTextDataObject*) data;
+ wxString str(textDataObject->GetText());
+ return wxSetClipboardData(format, str.c_str());
+ }
+
+ case wxDF_BITMAP:
+ case wxDF_DIB:
+ {
+ wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
+ wxBitmap bitmap(bitmapDataObject->GetBitmap());
+ return wxSetClipboardData(data->GetFormat(), &bitmap);
+ }
+
+#if wxUSE_METAFILE
+ case wxDF_METAFILE:
+ {
+ wxMetafileDataObject* metaFileDataObject =
+ (wxMetafileDataObject*) data;
+ wxMetafile metaFile = metaFileDataObject->GetMetafile();
+ return wxSetClipboardData(wxDF_METAFILE, &metaFile,
+ metaFileDataObject->GetWidth(),
+ metaFileDataObject->GetHeight());
+ }
+#endif // wxUSE_METAFILE
+
+ default:
+ return wxSetClipboardData(data);
+ }
+#else // !wxUSE_DATAOBJ
+ return FALSE;
+#endif
+}
+
+void wxClipboard::Close()
+{
+ wxCloseClipboard();
+}
+
+bool wxClipboard::IsSupported( wxDataFormat format )
+{
+ return wxIsClipboardFormatAvailable(format);
+}
+
+bool wxClipboard::GetData( wxDataObject& data )
+{
+#if wxUSE_DATAOBJ
+ wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
+
+ wxDataFormat format = data.GetFormat();
+ switch ( format )
+ {
+ case wxDF_TEXT:
+ case wxDF_OEMTEXT:
+ {
+ wxTextDataObject& textDataObject = (wxTextDataObject &)data;
+ char* s = (char*)wxGetClipboardData(format);
+ if ( !s )
+ return FALSE;
+
+ textDataObject.SetText(s);
+ delete [] s;
+
+ return TRUE;
+ }
+
+ case wxDF_BITMAP:
+ case wxDF_DIB:
+ {
+ wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
+ wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat());
+ if ( !bitmap )
+ return FALSE;
+
+ bitmapDataObject.SetBitmap(*bitmap);
+ delete bitmap;
+
+ return TRUE;
+ }
+#if wxUSE_METAFILE
+ case wxDF_METAFILE:
+ {
+ wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;
+ wxMetafile* metaFile = (wxMetafile *)wxGetClipboardData(wxDF_METAFILE);
+ if ( !metaFile )
+ return FALSE;
+
+ metaFileDataObject.SetMetafile(*metaFile);
+ delete metaFile;
+
+ return TRUE;
+ }
+#endif // wxUSE_METAFILE
+ }
+#else // !wxUSE_DATAOBJ
+ wxFAIL_MSG( wxT("no clipboard implementation") );
+#endif
+ return FALSE;
+}
+/*