implementation streamlined
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -24,6 +24,9 @@
|
|||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#include "wx/metafile.h"
|
#include "wx/metafile.h"
|
||||||
|
#include "wx/tokenzr.h"
|
||||||
|
|
||||||
|
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
@@ -202,45 +205,50 @@ void wxTextDataObject::GetAllFormats( wxDataFormat *formats, wxDataObjectBase::D
|
|||||||
// wxFileDataObject
|
// wxFileDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxFileDataObject::GetFileNames(wxCharBuffer &buf) const
|
||||||
|
{
|
||||||
|
wxString filenames;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m_filenames.GetCount(); i++)
|
||||||
|
{
|
||||||
|
filenames += m_filenames[i];
|
||||||
|
filenames += wxT('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = filenames.fn_str();
|
||||||
|
}
|
||||||
|
|
||||||
bool wxFileDataObject::GetDataHere( void *pBuf ) const
|
bool wxFileDataObject::GetDataHere( void *pBuf ) const
|
||||||
{
|
{
|
||||||
if (pBuf == NULL)
|
if (pBuf == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxString sFilenames;
|
wxCharBuffer buf;
|
||||||
|
GetFileNames( buf );
|
||||||
|
|
||||||
for (size_t i = 0; i < m_filenames.GetCount(); i++)
|
memcpy( pBuf, (const char*) buf, strlen(buf) + 1 );
|
||||||
{
|
|
||||||
sFilenames += m_filenames[i];
|
|
||||||
sFilenames += (wxChar)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy( pBuf, sFilenames.mbc_str(), sFilenames.Len() + 1 );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxFileDataObject::GetDataSize() const
|
size_t wxFileDataObject::GetDataSize() const
|
||||||
{
|
{
|
||||||
size_t nRes = 0;
|
wxCharBuffer buf;
|
||||||
|
GetFileNames( buf );
|
||||||
|
|
||||||
for (size_t i = 0; i < m_filenames.GetCount(); i++)
|
return strlen(buf) + 1;
|
||||||
{
|
|
||||||
nRes += m_filenames[i].Len();
|
|
||||||
nRes += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nRes + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileDataObject::SetData( size_t WXUNUSED(nSize), const void *pBuf )
|
bool wxFileDataObject::SetData( size_t nSize, const void *pBuf )
|
||||||
{
|
{
|
||||||
m_filenames.Empty();
|
wxString filenames;
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
filenames = wxString( (const char*) pBuf , *wxConvFileName );
|
||||||
|
#else
|
||||||
|
filenames = wxString( wxConvFileName->cMB2WX( pBuf ) , wxConvLocal );
|
||||||
|
#endif
|
||||||
|
|
||||||
// only add if this is not an empty string
|
m_filenames = wxStringTokenize( filenames , wxT("\n") , wxTOKEN_STRTOK );
|
||||||
// we can therefore clear the list by just setting an empty string
|
|
||||||
if ((*(const char*)pBuf) != 0)
|
|
||||||
AddFile( wxString::FromAscii( (char*)pBuf) );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user