#include <string.h>
-#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
-#endif
-
+// open/close
bool wxOpenClipboard()
{
- // TODO
- return FALSE;
+ return TRUE;
}
bool wxCloseClipboard()
{
- // TODO
- return FALSE;
+ return TRUE;
}
-bool wxEmptyClipboard()
+bool wxIsClipboardOpened()
{
- // TODO
- return FALSE;
+ return TRUE;
}
-bool wxClipboardOpen()
+// get/set data
+
+bool wxEmptyClipboard()
{
- // TODO
- return FALSE;
+ ZeroScrap() ;
+ return TRUE;
}
-bool wxIsClipboardFormatAvailable(int dataFormat)
+bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height)
{
- // TODO
return FALSE;
}
-bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
+void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
- // TODO
- return FALSE;
+ return NULL;
}
-wxObject *wxGetClipboardData(int dataFormat, long *len)
+
+// clipboard formats
+
+bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
- // TODO
- return NULL;
+ return FALSE;
}
-int wxEnumClipboardFormats(int dataFormat)
+wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
{
- // TODO
- return 0;
+ return wxDataFormat();
}
-int wxRegisterClipboardFormat(char *formatName)
+int wxRegisterClipboardFormat(wxChar *formatName)
{
- // TODO
return 0;
}
-bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
+bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int maxCount)
{
- // TODO
return FALSE;
}
* Generalized clipboard implementation by Matthew Flatt
*/
-wxClipboard *wxTheClipboard = NULL;
+IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
-void wxInitClipboard()
+wxClipboard::wxClipboard()
{
- if (!wxTheClipboard)
- wxTheClipboard = new wxClipboard;
+ m_clearOnExit = FALSE;
}
-wxClipboard::wxClipboard()
+wxClipboard::~wxClipboard()
{
- clipOwner = NULL;
- cbString = NULL;
+ if ( m_clearOnExit )
+ {
+ Clear();
+ }
}
-wxClipboard::~wxClipboard()
+void wxClipboard::Clear()
{
- if (clipOwner)
- clipOwner->BeingReplaced();
- if (cbString)
- delete[] cbString;
+}
+
+bool wxClipboard::Flush()
+{
+ return FALSE;
+}
+
+bool wxClipboard::Open()
+{
+ return wxOpenClipboard();
+}
+
+bool wxClipboard::IsOpened() const
+{
+ return wxIsClipboardOpened();
}
static int FormatStringToID(char *str)
return wxRegisterClipboardFormat(str);
}
+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;
+}
+/*
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
{
bool got_selection;
cbString = NULL;
}
}
-
char *wxClipboard::GetClipboardString(long time)
{
char *str;
return str;
}
+
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
{
if (clipOwner) {
return receivedString;
}
}
+*/