X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e90c1d2a19361551eb07778280f22be3e759cf64..9874b4ee8308b8989c5df7db4f3559625299d0a4:/src/motif/clipbrd.cpp diff --git a/src/motif/clipbrd.cpp b/src/motif/clipbrd.cpp index 84dca0b0f0..f80067e6f9 100644 --- a/src/motif/clipbrd.cpp +++ b/src/motif/clipbrd.cpp @@ -85,7 +85,7 @@ bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() ); int success = XmClipboardRetrieve((Display*) wxGetDisplay(), - window, "TEXT(", (XtPointer) 0, 0, & numBytes, & privateId) ; + window, "TEXT", (XtPointer) 0, 0, & numBytes, & privateId) ; // Assume only text is supported. If we have anything at all, // or the clipboard is locked so we're not sure, we say we support it. @@ -95,7 +95,7 @@ bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) return TRUE; } -bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width, int height) +bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int WXUNUSED(width), int WXUNUSED(height)) { if (dataFormat != wxDF_TEXT) return FALSE; @@ -128,7 +128,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width, int h XmClipboardCopy((Display*) wxGetDisplay(), window, itemId, - "TEXT(", + "TEXT", (XtPointer) data, strlen(data) + 1, 0, @@ -171,7 +171,7 @@ wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len) } result = XmClipboardRetrieve((Display*) wxGetDisplay(), window, - "TEXT(", + "TEXT", (XtPointer) data, currentDataSize, &numBytes, @@ -213,18 +213,18 @@ wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat) return wxDF_INVALID; } -wxDataFormat wxRegisterClipboardFormat(char *formatName) +wxDataFormat wxRegisterClipboardFormat(char *WXUNUSED(formatName)) { // Not supported return (wxDataFormat) wxDF_INVALID; } -bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount) +bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int WXUNUSED(maxCount)) { // Only wxDF_TEXT supported if (dataFormat == wxDF_TEXT) { - strcpy(formatName, "TEXT("); + strcpy(formatName, "TEXT"); return TRUE; } else @@ -237,8 +237,6 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int max IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject) -wxClipboard* wxTheClipboard = (wxClipboard*) NULL; - wxClipboard::wxClipboard() { m_open = FALSE; @@ -275,30 +273,36 @@ bool wxClipboard::SetData( wxDataObject *data ) wxCHECK_MSG( data, FALSE, "data is invalid" ); wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); - switch (data->GetFormat()) + Clear(); + + return AddData( data ); +} + +bool wxClipboard::AddData( wxDataObject *data ) +{ + wxCHECK_MSG( data, FALSE, "data is invalid" ); + wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); + + wxDataFormat::NativeFormat format = data->GetPreferredFormat().GetType(); + switch ( format ) { case wxDF_TEXT: case wxDF_OEMTEXT: { wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxString str(textDataObject->GetText()); - return wxSetClipboardData(data->GetFormat(), (wxObject*) (const char*) str); - break; + return wxSetClipboardData(format, (wxObject*) (const char*) str); } -/* +#if 0 case wxDF_BITMAP: case wxDF_DIB: { wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; wxBitmap bitmap(bitmapDataObject->GetBitmap()); - return wxSetClipboardData(data->GetFormat(), & bitmap); + return wxSetClipboardData(data->GetType(), & bitmap); break; } -*/ - default: - { - return FALSE; - } +#endif // 0 } return FALSE; @@ -312,25 +316,26 @@ void wxClipboard::Close() wxCloseClipboard(); } -bool wxClipboard::IsSupported( wxDataFormat format) +bool wxClipboard::IsSupported( const wxDataFormat& format) { return wxIsClipboardFormatAvailable(format); } -bool wxClipboard::GetData( wxDataObject *data ) +bool wxClipboard::GetData( wxDataObject& data ) { wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); - switch (data->GetFormat()) + wxDataFormat::NativeFormat format = data.GetPreferredFormat().GetType(); + switch ( format ) { case wxDF_TEXT: case wxDF_OEMTEXT: { - wxTextDataObject* textDataObject = (wxTextDataObject*) data; - char* s = (char*) wxGetClipboardData(data->GetFormat()); + wxTextDataObject& textDataObject = (wxTextDataObject &) data; + char* s = (char*) wxGetClipboardData(format); if (s) { - textDataObject->SetText(s); + textDataObject.SetText(s); delete[] s; return TRUE; } @@ -343,7 +348,7 @@ bool wxClipboard::GetData( wxDataObject *data ) case wxDF_DIB: { wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; - wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetFormat()); + wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetType()); if (bitmap) { bitmapDataObject->SetBitmap(* bitmap); @@ -363,26 +368,6 @@ bool wxClipboard::GetData( wxDataObject *data ) return FALSE; } -//----------------------------------------------------------------------------- -// wxClipboardModule -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule) - -bool wxClipboardModule::OnInit() -{ - wxTheClipboard = new wxClipboard(); - - return TRUE; -} - -void wxClipboardModule::OnExit() -{ - if (wxTheClipboard) delete wxTheClipboard; - wxTheClipboard = (wxClipboard*) NULL; -} - - #if 0 /* @@ -413,7 +398,7 @@ wxClipboard::~wxClipboard() static int FormatStringToID(char *str) { - if (!strcmp(str, "TEXT(")) + if (!strcmp(str, "TEXT")) return wxDF_TEXT; return wxRegisterClipboardFormat(str); @@ -499,7 +484,7 @@ char *wxClipboard::GetClipboardString(long time) char *str; long length; - str = GetClipboardData("TEXT(", &length, time); + str = GetClipboardData("TEXT", &length, time); if (!str) { str = new char[1]; *str = 0; @@ -516,7 +501,7 @@ char *wxClipboard::GetClipboardData(char *format, long *length, long time) else return NULL; } else if (cbString) { - if (!strcmp(format, "TEXT(")) + if (!strcmp(format, "TEXT")) return copystring(cbString); else return NULL;