wxDataObjectComposite/Custom seem to work

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-08 17:05:51 +00:00
parent fe26d444bb
commit 19d89516dd
4 changed files with 43 additions and 23 deletions

View File

@@ -2352,10 +2352,15 @@ wxLayoutList::Draw(wxDC &dc,
} }
InvalidateUpdateRect(); InvalidateUpdateRect();
WXLO_DEBUG(("Selection is %s : l%d,%ld/%ld,%ld", #ifdef DEBUG
m_Selection.m_valid ? "valid" : "invalid", if ( m_Selection.m_valid )
m_Selection.m_CursorA.x, m_Selection.m_CursorA.y, {
m_Selection.m_CursorB.x, m_Selection.m_CursorB.y)); 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 * wxLayoutObject *

View File

@@ -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 // event tables
@@ -1079,12 +1079,11 @@ wxLayoutWindow::Paste(bool primary)
{ {
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
wxLayoutDataObject wxldo; wxLayoutDataObject wxldo;
if (wxTheClipboard->IsSupported( wxldo.GetFormat() )) if ( wxTheClipboard->GetData(wxldo) )
{ {
wxTheClipboard->GetData(wxldo);
{
}
//FIXME: missing functionality m_llist->Insert(wxldo.GetList()); //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
wxLayoutImportText(m_llist, wxldo.GetLayoutData());
SetDirty();
} }
else else
#endif #endif
@@ -1113,8 +1112,14 @@ wxLayoutWindow::Copy(bool invalidate)
m_llist->EndSelection(); m_llist->EndSelection();
} }
wxLayoutDataObject wldo; #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
wxLayoutList *llist = m_llist->GetSelection(&wldo, invalidate); // 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) if(! llist)
return FALSE; return FALSE;
// Export selection as text: // Export selection as text:
@@ -1139,18 +1144,20 @@ wxLayoutWindow::Copy(bool invalidate)
text = text.Mid(0,len-1); text = text.Mid(0,len-1);
} }
if (wxTheClipboard->Open()) if (!wxTheClipboard->Open())
{ return FALSE;
wxTextDataObject *data = new wxTextDataObject( text );
bool rc = wxTheClipboard->SetData( data );
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT #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 #endif
wxTheClipboard->Close();
return rc; bool rc = wxTheClipboard->SetData( data );
}
wxTheClipboard->Close();
return FALSE; return rc;
} }
bool bool

View File

@@ -229,7 +229,11 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void 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; if (!wxTheClipboard) return;

View File

@@ -229,7 +229,11 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void 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; if (!wxTheClipboard) return;