]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/clipbrd.cpp
added automatic growing of in-place wxTextCtrls for generic wxListCtrl and wxTreeCtrl
[wxWidgets.git] / src / msw / clipbrd.cpp
index ba954e8263c64bab77e7e3c6e1ac4583055a6ab1..9a2d7b327cfc75eff43843e18c41720fd4a250c2 100644 (file)
@@ -146,10 +146,27 @@ bool wxIsClipboardOpened()
 
 bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
 {
-    // for bitmaps, DIBs will also do
-    return (::IsClipboardFormatAvailable(dataFormat) != 0) ||
-           (dataFormat.GetFormatId() == CF_BITMAP &&
-            ::IsClipboardFormatAvailable(CF_DIB));
+    if ( ::IsClipboardFormatAvailable(dataFormat) )
+    {
+        // ok from the first try
+        return TRUE;
+    }
+
+    // for several standard formats, we can convert from some other ones too
+    switch ( dataFormat.GetFormatId() )
+    {
+        // for bitmaps, DIBs will also do
+        case CF_BITMAP:
+            return ::IsClipboardFormatAvailable(CF_DIB) != 0;
+
+#if wxUSE_ENH_METAFILE && !defined(__WIN16__)
+        case CF_METAFILEPICT:
+            return ::IsClipboardFormatAvailable(CF_ENHMETAFILE) != 0;
+#endif // wxUSE_ENH_METAFILE
+
+        default:
+            return FALSE;
+    }
 }
 
 bool wxSetClipboardData(wxDataFormat dataFormat,
@@ -208,7 +225,10 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
                 break;
             }
 
-#if wxUSE_METAFILE
+    // VZ: I'm told that this code works, but it doesn't seem to work for me
+    //     and, anyhow, I'd be highly surprized if it did. So I leave it here
+    //     but IMNSHO it is completely broken.
+#if wxUSE_METAFILE && !defined(wxMETAFILE_IS_ENH)
         case wxDF_METAFILE:
             {
                 wxMetafile *wxMF = (wxMetafile *)data;
@@ -225,7 +245,20 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
                 handle = SetClipboardData(CF_METAFILEPICT, data);
                 break;
             }
-#endif
+#endif // wxUSE_METAFILE
+
+#if wxUSE_ENH_METAFILE && !defined(__WIN16__)
+        case wxDF_ENHMETAFILE:
+            {
+                wxEnhMetaFile *emf = (wxEnhMetaFile *)data;
+                wxEnhMetaFile emfCopy = *emf;
+
+                handle = SetClipboardData(CF_ENHMETAFILE,
+                                          (void *)emfCopy.GetHENHMETAFILE());
+            }
+            break;
+#endif // wxUSE_ENH_METAFILE
+
         case CF_SYLK:
         case CF_DIF:
         case CF_TIFF:
@@ -319,7 +352,9 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
                 wxBM->SetWidth(bm.bmWidth);
                 wxBM->SetHeight(bm.bmHeight);
                 wxBM->SetDepth(bm.bmPlanes);
+#if WXWIN_COMPATIBILITY_2
                 wxBM->SetOk(TRUE);
+#endif // WXWIN_COMPATIBILITY_2
                 retval = wxBM;
                 break;
             }
@@ -437,7 +472,7 @@ void wxClipboard::Clear()
 #if wxUSE_OLE_CLIPBOARD
     if ( FAILED(OleSetClipboard(NULL)) )
     {
-        wxLogLastError("OleSetClipboard(NULL)");
+        wxLogLastError(wxT("OleSetClipboard(NULL)"));
     }
 #endif
 }
@@ -447,7 +482,7 @@ bool wxClipboard::Flush()
 #if wxUSE_OLE_CLIPBOARD
     if ( FAILED(OleFlushClipboard()) )
     {
-        wxLogLastError("OleFlushClipboard");
+        wxLogLastError(wxT("OleFlushClipboard"));
 
         return FALSE;
     }
@@ -483,7 +518,9 @@ bool wxClipboard::IsOpened() const
 
 bool wxClipboard::SetData( wxDataObject *data )
 {
+#if !wxUSE_OLE_CLIPBOARD
     (void)wxEmptyClipboard();
+#endif // wxUSE_OLE_CLIPBOARD
 
     if ( data )
         return AddData(data);
@@ -666,7 +703,6 @@ bool wxClipboard::GetData( wxDataObject& data )
         formatEtc.ptd      = NULL;
         formatEtc.dwAspect = DVASPECT_CONTENT;
         formatEtc.lindex   = -1;
-        formatEtc.tymed    = TYMED_HGLOBAL;
 
         size_t nSupportedFormats = supportedFormats.GetCount();
         for ( size_t n = 0; !result && (n < nSupportedFormats); n++ )
@@ -674,6 +710,25 @@ bool wxClipboard::GetData( wxDataObject& data )
             STGMEDIUM medium;
             formatEtc.cfFormat = supportedFormats[n];
 
+            // use the appropriate tymed
+            switch ( formatEtc.cfFormat )
+            {
+                case CF_BITMAP:
+                    formatEtc.tymed = TYMED_GDI;
+                    break;
+
+                case CF_METAFILEPICT:
+                    formatEtc.tymed = TYMED_MFPICT;
+                    break;
+
+                case CF_ENHMETAFILE:
+                    formatEtc.tymed = TYMED_ENHMF;
+                    break;
+
+                default:
+                    formatEtc.tymed = TYMED_HGLOBAL;
+            }
+
             // try to get data
             hr = pDataObject->GetData(&formatEtc, &medium);
             if ( FAILED(hr) )
@@ -768,6 +823,6 @@ bool wxClipboard::GetData( wxDataObject& data )
 }
 
 #else
-    #error "Please turn wxUSE_CLIPBOARD on to compile this file."
+//    #error "Please turn wxUSE_CLIPBOARD on to compile this file."
 #endif // wxUSE_CLIPBOARD