X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..7b9da2077d0975db6c965a85c91d5aca671ab5e3:/src/mac/clipbrd.cpp diff --git a/src/mac/clipbrd.cpp b/src/mac/clipbrd.cpp index 3fe9ebfb72..36f4c0f4d9 100644 --- a/src/mac/clipbrd.cpp +++ b/src/mac/clipbrd.cpp @@ -23,68 +23,60 @@ #include -#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; } @@ -92,26 +84,38 @@ bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount) * 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) @@ -122,6 +126,129 @@ 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; @@ -196,7 +323,6 @@ void wxClipboard::SetClipboardString(char *str, long time) cbString = NULL; } } - char *wxClipboard::GetClipboardString(long time) { char *str; @@ -211,6 +337,7 @@ char *wxClipboard::GetClipboardString(long time) return str; } + char *wxClipboard::GetClipboardData(char *format, long *length, long time) { if (clipOwner) { @@ -234,4 +361,5 @@ char *wxClipboard::GetClipboardData(char *format, long *length, long time) return receivedString; } } +*/