#include "wx/msw/dib.h"
#ifndef CFSTR_SHELLURL
-#define CFSTR_SHELLURL _T("UniformResourceLocator")
+#define CFSTR_SHELLURL wxT("UniformResourceLocator")
#endif
// ----------------------------------------------------------------------------
// 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
ULONG m_nCount, // number of formats we support
m_nCurrent; // current enum position
- DECLARE_NO_COPY_CLASS(wxIEnumFORMATETC)
+ wxDECLARE_NO_COPY_CLASS(wxIEnumFORMATETC);
};
// ----------------------------------------------------------------------------
bool m_mustDelete;
- DECLARE_NO_COPY_CLASS(wxIDataObject)
+ wxDECLARE_NO_COPY_CLASS(wxIDataObject);
};
// ============================================================================
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
*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,
return p;
}
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
const wxChar *wxDataObject::GetFormatName(wxDataFormat format)
{
#endif // VC++
}
-#endif // Debug
+#endif // wxDEBUG_LEVEL
// ----------------------------------------------------------------------------
// wxBitmapDataObject supports CF_DIB format
#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;
// Work around bug in Wine headers
#if defined(__WINE__) && defined(CFSTR_SHELLURL) && wxUSE_UNICODE
#undef CFSTR_SHELLURL
-#define CFSTR_SHELLURL _T("CFSTR_SHELLURL")
+#define CFSTR_SHELLURL wxT("CFSTR_SHELLURL")
#endif
class CFSTR_SHELLURLDataObject : public wxCustomDataObject
{ return GetDataHere(buf); }
#endif
- DECLARE_NO_COPY_CLASS(CFSTR_SHELLURLDataObject)
+ wxDECLARE_NO_COPY_CLASS(CFSTR_SHELLURLDataObject);
};
wxURLDataObject::wxURLDataObject(const wxString& url)
{
- // we support CF_TEXT and CFSTR_SHELLURL formats which are basicly the same
- // but it seems that some browsers only provide one of them so we have to
- // support both
+ // we support CF_TEXT and CFSTR_SHELLURL formats which are basically the
+ // same but it seems that some browsers only provide one of them so we have
+ // to support both
Add(new wxTextDataObject);
Add(new CFSTR_SHELLURLDataObject());
wxString wxURLDataObject::GetURL() const
{
wxString url;
- wxCHECK_MSG( m_dataObjectLast, url, _T("no data in wxURLDataObject") );
+ wxCHECK_MSG( m_dataObjectLast, url, wxT("no data in wxURLDataObject") );
size_t len = m_dataObjectLast->GetDataSize();
void wxURLDataObject::SetURL(const wxString& url)
{
- SetData(wxDataFormat(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT),
- url.Length()+1, url.c_str());
+ wxCharBuffer urlMB(url.mb_str());
+ 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);
+ }
- // CFSTR_SHELLURL is always supposed to be ANSI...
- wxWX2MBbuf urlA = (wxWX2MBbuf)url.mbc_str();
- size_t len = strlen(urlA);
- SetData(wxDataFormat(CFSTR_SHELLURL), len+1, (const char*)urlA);
+#if wxUSE_UNICODE
+ // notice that SetData() takes size in bytes
+ SetData(wxDF_UNICODETEXT, (url.length() + 1)*sizeof(wxChar), url.wc_str());
+#endif
}
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
static const wxChar *GetTymedName(DWORD tymed)
{
{
}
-#ifdef __WXDEBUG__
const wxChar *wxDataObject::GetFormatName(wxDataFormat WXUNUSED(format))
{
return NULL;
}
-#endif // __WXDEBUG__
#endif // wxUSE_DATAOBJ