]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dnd/dnd.cpp
Fix wrong configure test for abi::__forced_unwind in previous commit.
[wxWidgets.git] / samples / dnd / dnd.cpp
index 7916600905d9c13fcb6f080b9f10e733462946d1..90662218120584f4b57dcde6ee6e8f25b9c7ed47 100644 (file)
@@ -27,7 +27,7 @@
 #include "wx/metafile.h"
 #include "wx/dirctrl.h"
 
-#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #if wxUSE_DRAG_AND_DROP
     #include "dnd_copy.xpm"
@@ -227,6 +227,7 @@ public:
 #endif // wxUSE_METAFILE
 
     void OnCopyFiles(wxCommandEvent& event);
+    void OnCopyURL(wxCommandEvent& event);
 
     void OnUsePrimary(wxCommandEvent& event);
 
@@ -816,6 +817,7 @@ enum
     Menu_PasteBitmap,
     Menu_PasteMFile,
     Menu_CopyFiles,
+    Menu_CopyURL,
     Menu_UsePrimary,
     Menu_Shape_New = 500,
     Menu_Shape_Edit,
@@ -844,6 +846,7 @@ BEGIN_EVENT_TABLE(DnDFrame, wxFrame)
     EVT_MENU(Menu_PasteMFile, DnDFrame::OnPasteMetafile)
 #endif // wxUSE_METAFILE
     EVT_MENU(Menu_CopyFiles,  DnDFrame::OnCopyFiles)
+    EVT_MENU(Menu_CopyURL,    DnDFrame::OnCopyURL)
     EVT_MENU(Menu_UsePrimary, DnDFrame::OnUsePrimary)
 
     EVT_UPDATE_UI(Menu_DragMoveDef, DnDFrame::OnUpdateUIMoveByDefault)
@@ -974,6 +977,7 @@ DnDFrame::DnDFrame()
 #endif // wxUSE_METAFILE
     clip_menu->AppendSeparator();
     clip_menu->Append(Menu_CopyFiles, wxT("Copy &files\tCtrl-F"));
+    clip_menu->Append(Menu_CopyURL, wxT("Copy &URL\tCtrl-U"));
     clip_menu->AppendSeparator();
     clip_menu->AppendCheckItem(Menu_UsePrimary, wxT("Use &primary selection\tCtrl-P"));
 
@@ -1485,6 +1489,27 @@ void DnDFrame::OnCopyFiles(wxCommandEvent& WXUNUSED(event))
 #endif // MSW/!MSW
 }
 
+void DnDFrame::OnCopyURL(wxCommandEvent& WXUNUSED(event))
+{
+    // Just hard code it for now, we could ask the user but the point here is
+    // to test copying URLs, it doesn't really matter what it is.
+    const wxString url("http://www.wxwidgets.org/");
+
+    wxClipboardLocker locker;
+    if ( !!locker && wxTheClipboard->AddData(new wxURLDataObject(url)) )
+    {
+        wxLogStatus(this, "Copied URL \"%s\" to %s.",
+                    url,
+                    GetMenuBar()->IsChecked(Menu_UsePrimary)
+                        ? "primary selection"
+                        : "clipboard");
+    }
+    else
+    {
+        wxLogError("Failed to copy URL.");
+    }
+}
+
 // ---------------------------------------------------------------------------
 // text clipboard
 // ---------------------------------------------------------------------------