git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4130
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxDataFormat::wxDataFormat()
{
wxDataFormat::wxDataFormat()
{
+ // do *not* call PrepareFormats() from here for 2 reasons:
+ //
+ // 1. we will have time to do it later because some other Set function
+ // must be called before we really need them
+ //
+ // 2. doing so prevents us from declaring global wxDataFormats because
+ // calling PrepareFormats (and thus gdk_atom_intern) before GDK is
+ // initialised will result in a crash
m_type = wxDF_INVALID;
m_format = (GdkAtom) 0;
}
m_type = wxDF_INVALID;
m_format = (GdkAtom) 0;
}
void wxDataFormat::SetType( wxDataFormatId type )
{
void wxDataFormat::SetType( wxDataFormatId type )
{
m_type = type;
if (m_type == wxDF_TEXT)
m_type = type;
if (m_type == wxDF_TEXT)
void wxDataFormat::SetId( NativeFormat format )
{
void wxDataFormat::SetId( NativeFormat format )
{
m_format = format;
if (m_format == g_textAtom)
m_format = format;
if (m_format == g_textAtom)
void wxDataFormat::SetId( const wxChar *id )
{
void wxDataFormat::SetId( const wxChar *id )
{
m_type = wxDF_PRIVATE;
wxString tmp( id );
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
m_type = wxDF_PRIVATE;
wxString tmp( id );
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
bool wxFileDataObject::GetDataHere(void *buf) const
{
wxString filenames;
bool wxFileDataObject::GetDataHere(void *buf) const
{
wxString filenames;
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
filenames += m_filenames[i];
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
filenames += m_filenames[i];
- filenames += (wxChar) 0;
+ filenames += (wxChar) 0;
memcpy( buf, filenames.mbc_str(), filenames.Len() + 1 );
return TRUE;
memcpy( buf, filenames.mbc_str(), filenames.Len() + 1 );
return TRUE;
size_t wxFileDataObject::GetDataSize() const
{
size_t res = 0;
size_t wxFileDataObject::GetDataSize() const
{
size_t res = 0;
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
res += m_filenames[i].Len();
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
res += m_filenames[i].Len();
return res + 1;
}
bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
{
/* TODO */
return res + 1;
}
bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
{
/* TODO */
wxString file( (const char *)buf ); /* char, not wxChar */
AddFile( file );
wxString file( (const char *)buf ); /* char, not wxChar */
AddFile( file );
}
m_bitmap = image.ConvertToBitmap();
}
m_bitmap = image.ConvertToBitmap();
wxDataFormat::wxDataFormat()
{
wxDataFormat::wxDataFormat()
{
+ // do *not* call PrepareFormats() from here for 2 reasons:
+ //
+ // 1. we will have time to do it later because some other Set function
+ // must be called before we really need them
+ //
+ // 2. doing so prevents us from declaring global wxDataFormats because
+ // calling PrepareFormats (and thus gdk_atom_intern) before GDK is
+ // initialised will result in a crash
m_type = wxDF_INVALID;
m_format = (GdkAtom) 0;
}
m_type = wxDF_INVALID;
m_format = (GdkAtom) 0;
}
void wxDataFormat::SetType( wxDataFormatId type )
{
void wxDataFormat::SetType( wxDataFormatId type )
{
m_type = type;
if (m_type == wxDF_TEXT)
m_type = type;
if (m_type == wxDF_TEXT)
void wxDataFormat::SetId( NativeFormat format )
{
void wxDataFormat::SetId( NativeFormat format )
{
m_format = format;
if (m_format == g_textAtom)
m_format = format;
if (m_format == g_textAtom)
void wxDataFormat::SetId( const wxChar *id )
{
void wxDataFormat::SetId( const wxChar *id )
{
m_type = wxDF_PRIVATE;
wxString tmp( id );
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
m_type = wxDF_PRIVATE;
wxString tmp( id );
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
bool wxFileDataObject::GetDataHere(void *buf) const
{
wxString filenames;
bool wxFileDataObject::GetDataHere(void *buf) const
{
wxString filenames;
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
filenames += m_filenames[i];
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
filenames += m_filenames[i];
- filenames += (wxChar) 0;
+ filenames += (wxChar) 0;
memcpy( buf, filenames.mbc_str(), filenames.Len() + 1 );
return TRUE;
memcpy( buf, filenames.mbc_str(), filenames.Len() + 1 );
return TRUE;
size_t wxFileDataObject::GetDataSize() const
{
size_t res = 0;
size_t wxFileDataObject::GetDataSize() const
{
size_t res = 0;
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
res += m_filenames[i].Len();
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
res += m_filenames[i].Len();
return res + 1;
}
bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
{
/* TODO */
return res + 1;
}
bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
{
/* TODO */
wxString file( (const char *)buf ); /* char, not wxChar */
AddFile( file );
wxString file( (const char *)buf ); /* char, not wxChar */
AddFile( file );
}
m_bitmap = image.ConvertToBitmap();
}
m_bitmap = image.ConvertToBitmap();