unicode conversion support for dataobjects
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27290 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ed8a085221
commit
2575829710
@ -345,6 +345,18 @@ public:
|
||||
virtual bool GetDataHere(void *buf) const { return GetDataHere(GetPreferredFormat(), buf); }
|
||||
virtual bool SetData(size_t len, const void *buf) { return SetData(GetPreferredFormat(), len, buf); }
|
||||
|
||||
size_t GetDataSize(const wxDataFormat& format) const;
|
||||
bool GetDataHere(const wxDataFormat& format, void *pBuf) const;
|
||||
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf);
|
||||
#elif wxUSE_UNICODE && defined(__WXMAC__)
|
||||
virtual size_t GetFormatCount(Direction WXUNUSED(dir) = Get) const { return 2; }
|
||||
virtual void GetAllFormats(wxDataFormat *formats,
|
||||
wxDataObjectBase::Direction WXUNUSED(dir) = Get) const;
|
||||
|
||||
virtual size_t GetDataSize() const { return GetDataSize(GetPreferredFormat()); }
|
||||
virtual bool GetDataHere(void *buf) const { return GetDataHere(GetPreferredFormat(), buf); }
|
||||
virtual bool SetData(size_t len, const void *buf) { return SetData(GetPreferredFormat(), len, buf); }
|
||||
|
||||
size_t GetDataSize(const wxDataFormat& format) const;
|
||||
bool GetDataHere(const wxDataFormat& format, void *pBuf) const;
|
||||
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf);
|
||||
|
@ -282,6 +282,57 @@ bool wxTextDataObject::SetData(const wxDataFormat& format,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#elif wxUSE_UNICODE && defined(__WXMAC__)
|
||||
|
||||
size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const
|
||||
{
|
||||
if (format == wxDF_UNICODETEXT)
|
||||
{
|
||||
// host native is UTF16
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
|
||||
return strlen( (const char*) buffer ) + 1;
|
||||
}
|
||||
else // == wxDF_TEXT
|
||||
{
|
||||
wxCharBuffer buffer = wxConvLibc.cWX2MB( GetText().c_str() );
|
||||
return strlen( (const char*) buffer ) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
|
||||
{
|
||||
if (format == wxDF_UNICODETEXT)
|
||||
{
|
||||
// host native is UTF16
|
||||
wxMBConvUTF16BE converter ;
|
||||
wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
|
||||
strcpy( (char*) buf, (const char*) buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxCharBuffer buffer = wxConvLibc.cWX2MB( GetText().c_str() );
|
||||
strcpy( (char*) buf, (const char*) buffer );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxTextDataObject::SetData(const wxDataFormat& format,
|
||||
size_t WXUNUSED(len), const void *buf)
|
||||
{
|
||||
if (format == wxDF_UNICODETEXT)
|
||||
{
|
||||
// host native is UTF16
|
||||
wxMBConvUTF16BE converter ;
|
||||
SetText( converter.cMB2WX( (const char*) buf ) );
|
||||
}
|
||||
else
|
||||
SetText( wxConvLibc.cMB2WX( (const char*) buf ) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
size_t wxTextDataObject::GetDataSize() const
|
||||
|
@ -166,6 +166,19 @@ bool wxDataObject::IsSupportedFormat(
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextDataObject
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
void wxTextDataObject::GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction dir) const
|
||||
{
|
||||
*formats++ = wxDataFormat( wxDF_TEXT );
|
||||
*formats = wxDataFormat( wxDF_UNICODETEXT );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFileDataObject
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user