]> git.saurik.com Git - wxWidgets.git/commitdiff
readded clipboard support to richedit sample and fixed a fatal bug in
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 3 Nov 1999 01:13:04 +0000 (01:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 3 Nov 1999 01:13:04 +0000 (01:13 +0000)
wxCustomDataObject (uninitialized m_data) which this allowed to discover

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/richedit/wxllist.cpp
samples/richedit/wxllist.h
samples/richedit/wxlwindow.cpp
src/common/dobjcmn.cpp

index 8391d6740777ac012523c0a2c4806a9b79e255db..ac6046b184e4c3dbc80c74322ab785d7a3860fba 100644 (file)
@@ -2844,9 +2844,8 @@ wxLayoutList::GetSelection(wxLayoutDataObject *wxlo, bool invalidate)
             exp->content.object->Write(string);
          delete exp;
       }
-#if 0 // FIXME: DnD/Clipboard API has changed, what should this be?
-      wxlo->SetData(string.c_str(), string.Length()+1);
-#endif
+
+      wxlo->SetLayoutData(string);
    }
    return llist;
 }
index 39fe17864628ad2613af736940a3866e15939ddd..fac6223d86180f710d3272e6b88a8c8b44b78e22 100644 (file)
@@ -1218,13 +1218,15 @@ private:
 class wxLayoutDataObject : public wxCustomDataObject
 {
 public:
-   wxLayoutDataObject(void)
+   wxLayoutDataObject()
       {
-#if 0 // TODO: No longer exists, what should we do instead?
-         SetId("application/wxlayoutlist");
-#endif
-         //m_format.SetAtom((GdkAtom) 222222);
+         SetFormat("application/wxlayoutlist");
       }
+
+   // type safe wrappers
+   void SetLayoutData(const wxString& text)
+      { SetData(text.length() + 1, text.c_str()); }
+   const char *GetLayoutData() const { return (const char *)GetData(); }
 };
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
index 43ec7781c48bca7184141435c294dd5c69c05b85..415ac983ea7818f5da50638eddb8b09580df78d8 100644 (file)
@@ -1080,21 +1080,19 @@ wxLayoutWindow::Paste(bool primary)
    // Read some text
    if (wxTheClipboard->Open())
    {
-#if __WXGTK__
       if(primary)
          wxTheClipboard->UsePrimarySelection();
-#endif
-#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
+
       wxLayoutDataObject wxldo;
       if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
       {
-         wxTheClipboard->GetData(&wxldo);
-         {
-         }
-         //FIXME: missing functionality  m_llist->Insert(wxldo.GetList());
+         wxTheClipboard->GetData(wxldo);
+
+         // now we can access the data we had put into wxLayoutDataObject in
+         // wxLayoutList::GetSelection by calling its GetLayoutData() - the
+         // trouble is that I don't know what to do with it! (VZ)
       }
       else
-#endif
       {
          wxTextDataObject data;
          if (wxTheClipboard->IsSupported( data.GetFormat() ))
@@ -1120,8 +1118,8 @@ wxLayoutWindow::Copy(bool invalidate)
       m_llist->EndSelection();
    }
 
-   wxLayoutDataObject wldo;
-   wxLayoutList *llist = m_llist->GetSelection(&wldo, invalidate);
+   wxLayoutDataObject *wldo = new wxLayoutDataObject;
+   wxLayoutList *llist = m_llist->GetSelection(wldo, invalidate);
    if(! llist)
       return FALSE;
    // Export selection as text:
@@ -1149,11 +1147,12 @@ wxLayoutWindow::Copy(bool invalidate)
 
    if (wxTheClipboard->Open())
    {
-      wxTextDataObject *data = new wxTextDataObject( text );
-      bool  rc = wxTheClipboard->SetData( data );
-#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
-      rc |= wxTheClipboard->AddData( &wldo );
-#endif
+      wxDataObjectComposite *dobj = new wxDataObjectComposite;
+      dobj->Add(new wxTextDataObject(text));
+      dobj->Add(wldo);
+
+      bool rc = wxTheClipboard->SetData(dobj);
+
       wxTheClipboard->Close();
       return rc;
    }
index 53a4041c7b409ef636edd4adfcfa71dcfe987f48..708d9e36ba9a35044d7513aabb6549daf46864f5 100644 (file)
@@ -232,9 +232,9 @@ void wxFileDataObjectBase::SetFilenames(const wxChar* filenames)
 wxCustomDataObject::wxCustomDataObject(const wxDataFormat& format)
     : wxDataObjectSimple(format)
 {
+    m_data = (void *)NULL;
 }
 
-
 wxCustomDataObject::~wxCustomDataObject()
 {
     Free();