From 19d89516ddcaefc55172cb8b5eaa1306eae599f4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 8 Nov 1999 17:05:51 +0000 Subject: [PATCH 1/1] wxDataObjectComposite/Custom seem to work git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/richedit/wxllist.cpp | 13 +++++++---- samples/richedit/wxlwindow.cpp | 41 ++++++++++++++++++++-------------- src/gtk/clipbrd.cpp | 6 ++++- src/gtk1/clipbrd.cpp | 6 ++++- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/samples/richedit/wxllist.cpp b/samples/richedit/wxllist.cpp index 9ea3e73f2b..94e81f7d7b 100644 --- a/samples/richedit/wxllist.cpp +++ b/samples/richedit/wxllist.cpp @@ -2352,10 +2352,15 @@ wxLayoutList::Draw(wxDC &dc, } InvalidateUpdateRect(); - WXLO_DEBUG(("Selection is %s : l%d,%ld/%ld,%ld", - m_Selection.m_valid ? "valid" : "invalid", - m_Selection.m_CursorA.x, m_Selection.m_CursorA.y, - m_Selection.m_CursorB.x, m_Selection.m_CursorB.y)); +#ifdef DEBUG + if ( m_Selection.m_valid ) + { + WXLO_DEBUG(("Selection is %s : %ld,%ld/%ld,%ld", + m_Selection.m_valid ? "valid" : "invalid", + m_Selection.m_CursorA.x, m_Selection.m_CursorA.y, + m_Selection.m_CursorB.x, m_Selection.m_CursorB.y)); + } +#endif } wxLayoutObject * diff --git a/samples/richedit/wxlwindow.cpp b/samples/richedit/wxlwindow.cpp index 441d5a28cc..7ca4640d1a 100644 --- a/samples/richedit/wxlwindow.cpp +++ b/samples/richedit/wxlwindow.cpp @@ -88,7 +88,7 @@ static const int Y_SCROLL_PAGE = 20; -#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 0 +#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 1 // ---------------------------------------------------------------------------- // event tables @@ -1079,12 +1079,11 @@ wxLayoutWindow::Paste(bool primary) { #if wxUSE_PRIVATE_CLIPBOARD_FORMAT wxLayoutDataObject wxldo; - if (wxTheClipboard->IsSupported( wxldo.GetFormat() )) + if ( wxTheClipboard->GetData(wxldo) ) { - wxTheClipboard->GetData(wxldo); - { - } //FIXME: missing functionality m_llist->Insert(wxldo.GetList()); + wxLayoutImportText(m_llist, wxldo.GetLayoutData()); + SetDirty(); } else #endif @@ -1113,8 +1112,14 @@ wxLayoutWindow::Copy(bool invalidate) m_llist->EndSelection(); } - wxLayoutDataObject wldo; - wxLayoutList *llist = m_llist->GetSelection(&wldo, invalidate); +#if wxUSE_PRIVATE_CLIPBOARD_FORMAT + // the data object which holds all different data objects, one for each + // format we support + wxDataObjectComposite *data = new wxDataObjectComposite; +#endif + + wxLayoutDataObject *wldo = new wxLayoutDataObject; + wxLayoutList *llist = m_llist->GetSelection(wldo, invalidate); if(! llist) return FALSE; // Export selection as text: @@ -1139,18 +1144,20 @@ wxLayoutWindow::Copy(bool invalidate) text = text.Mid(0,len-1); } - if (wxTheClipboard->Open()) - { - wxTextDataObject *data = new wxTextDataObject( text ); - bool rc = wxTheClipboard->SetData( data ); + if (!wxTheClipboard->Open()) + return FALSE; + #if wxUSE_PRIVATE_CLIPBOARD_FORMAT - rc |= wxTheClipboard->AddData( &wldo ); + data->Add(wldo, TRUE /* preferred */); + data->Add(new wxTextDataObject(text)); +#else + wxTextDataObject *data = new wxTextDataObject( text ); #endif - wxTheClipboard->Close(); - return rc; - } - - return FALSE; + + bool rc = wxTheClipboard->SetData( data ); + + wxTheClipboard->Close(); + return rc; } bool diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index eb5efb10a0..dc4bbe9c90 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -229,7 +229,11 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) //----------------------------------------------------------------------------- static void -selection_handler( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, gpointer WXUNUSED(data) ) +selection_handler( GtkWidget *WXUNUSED(widget), + GtkSelectionData *selection_data, + guint WXUNUSED(info), + guint WXUNUSED(time), + gpointer WXUNUSED(data) ) { if (!wxTheClipboard) return; diff --git a/src/gtk1/clipbrd.cpp b/src/gtk1/clipbrd.cpp index eb5efb10a0..dc4bbe9c90 100644 --- a/src/gtk1/clipbrd.cpp +++ b/src/gtk1/clipbrd.cpp @@ -229,7 +229,11 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) //----------------------------------------------------------------------------- static void -selection_handler( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, gpointer WXUNUSED(data) ) +selection_handler( GtkWidget *WXUNUSED(widget), + GtkSelectionData *selection_data, + guint WXUNUSED(info), + guint WXUNUSED(time), + gpointer WXUNUSED(data) ) { if (!wxTheClipboard) return; -- 2.45.2