]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ole/dataobj.cpp
better native types for carbon
[wxWidgets.git] / src / msw / ole / dataobj.cpp
index bc81929a074efb77850422309ff864d1ae942a97..07884ba7ede2f9f8609e4bb6e72e7e3380383a3e 100644 (file)
 // functions
 // ----------------------------------------------------------------------------
 
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
     static const wxChar *GetTymedName(DWORD tymed);
-#else // !Debug
+#else // !wxDEBUG_LEVEL
     #define GetTymedName(tymed) wxEmptyString
-#endif // Debug/!Debug
+#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
 
 // ----------------------------------------------------------------------------
 // wxIEnumFORMATETC interface implementation
@@ -90,7 +90,7 @@ private:
     ULONG       m_nCount,   // number of formats we support
                 m_nCurrent; // current enum position
 
-    DECLARE_NO_COPY_CLASS(wxIEnumFORMATETC)
+    wxDECLARE_NO_COPY_CLASS(wxIEnumFORMATETC);
 };
 
 // ----------------------------------------------------------------------------
@@ -126,7 +126,7 @@ private:
 
     bool m_mustDelete;
 
-    DECLARE_NO_COPY_CLASS(wxIDataObject)
+    wxDECLARE_NO_COPY_CLASS(wxIDataObject);
 };
 
 // ============================================================================
@@ -686,13 +686,14 @@ size_t wxDataObject::GetBufferOffset(const wxDataFormat& format )
     return NeedsVerbatimData(format) ? 0 : sizeof(size_t);
 }
 
-const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size,
-                                               const wxDataFormat& format )
+const void *wxDataObject::GetSizeFromBuffer(const void *buffer,
+                                            size_t *size,
+                                            const wxDataFormat& WXUNUSED(format))
 {
     // hack: the third parameter is declared non-const in Wine's headers so
     // cast away the const
-    size_t realsz = ::HeapSize(::GetProcessHeap(), 0,
-                               wx_const_cast(void*, buffer));
+    const size_t realsz = ::HeapSize(::GetProcessHeap(), 0,
+                                     const_cast<void*>(buffer));
     if ( realsz == (size_t)-1 )
     {
         // note that HeapSize() does not set last error
@@ -702,18 +703,7 @@ const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size,
 
     *size = realsz;
 
-    // check if this data has its size prepended (as it was by default for wx
-    // programs prior 2.6.3):
-    size_t *p = (size_t *)buffer;
-    if ( *p == realsz )
-    {
-        if ( NeedsVerbatimData(format) )
-            wxLogDebug(wxT("Apparent data format mismatch: size not needed"));
-
-        p++; // this data has its size prepended; skip first DWORD
-    }
-
-    return p;
+    return buffer;
 }
 
 void* wxDataObject::SetSizeInBuffer( void* buffer, size_t size,
@@ -729,7 +719,7 @@ void* wxDataObject::SetSizeInBuffer( void* buffer, size_t size,
     return p;
 }
 
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
 
 const wxChar *wxDataObject::GetFormatName(wxDataFormat format)
 {
@@ -774,7 +764,7 @@ const wxChar *wxDataObject::GetFormatName(wxDataFormat format)
     #endif // VC++
 }
 
-#endif // Debug
+#endif // wxDEBUG_LEVEL
 
 // ----------------------------------------------------------------------------
 // wxBitmapDataObject supports CF_DIB format
@@ -1139,7 +1129,7 @@ bool wxFileDataObject::GetDataHere(void *WXUNUSED_IN_WINCE(pData)) const
 #endif // wxUSE_UNICODE_MSLU
         {
             len = m_filenames[i].length();
-            memcpy(pbuf, m_filenames[i].c_str(), len*sizeOfChar);
+            memcpy(pbuf, m_filenames[i].wx_str(), len*sizeOfChar);
         }
 
         pbuf += len*sizeOfChar;
@@ -1209,7 +1199,7 @@ public:
         { return GetDataHere(buf); }
 #endif
 
-    DECLARE_NO_COPY_CLASS(CFSTR_SHELLURLDataObject)
+    wxDECLARE_NO_COPY_CLASS(CFSTR_SHELLURLDataObject);
 };
 
 
@@ -1259,18 +1249,22 @@ void wxURLDataObject::SetURL(const wxString& url)
     if ( urlMB )
     {
         const size_t len = strlen(urlMB) + 1; // size with trailing NUL
+#if !wxUSE_UNICODE
         SetData(wxDF_TEXT, len, urlMB);
+#endif
         SetData(wxDataFormat(CFSTR_SHELLURL), len, urlMB);
     }
 
+#if wxUSE_UNICODE
     SetData(wxDF_UNICODETEXT, url.length() + 1, url.wc_str());
+#endif
 }
 
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------
 
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
 
 static const wxChar *GetTymedName(DWORD tymed)
 {
@@ -1311,12 +1305,10 @@ void wxDataObject::SetAutoDelete()
 {
 }
 
-#ifdef __WXDEBUG__
 const wxChar *wxDataObject::GetFormatName(wxDataFormat WXUNUSED(format))
 {
     return NULL;
 }
-#endif // __WXDEBUG__
 
 #endif // wxUSE_DATAOBJ