X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd5bf2a6e3a7d03e8b1f97e989eecdcc63f7151f..c127177f8dc31dbe99764852b8dbcc047d3ad826:/src/gtk/dataobj.cpp diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index 6f8a442e14..cbcce96e5f 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -17,6 +17,13 @@ #include "gdk/gdk.h" + +//------------------------------------------------------------------------- +// global data +//------------------------------------------------------------------------- + +GdkAtom g_textAtom = 0; + //------------------------------------------------------------------------- // wxDataFormat //------------------------------------------------------------------------- @@ -25,6 +32,7 @@ IMPLEMENT_CLASS(wxDataFormat, wxObject) wxDataFormat::wxDataFormat() { + if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); m_type = wxDF_INVALID; m_hasAtom = FALSE; m_atom = (GdkAtom) 0; @@ -32,16 +40,25 @@ wxDataFormat::wxDataFormat() wxDataFormat::wxDataFormat( wxDataType type ) { + if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); SetType( type ); } +wxDataFormat::wxDataFormat( const wxChar *id ) +{ + if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); + SetId( id ); +} + wxDataFormat::wxDataFormat( const wxString &id ) { + if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); SetId( id ); } wxDataFormat::wxDataFormat( wxDataFormat &format ) { + if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); m_type = format.GetType(); m_id = format.GetId(); m_hasAtom = TRUE; @@ -50,11 +67,12 @@ wxDataFormat::wxDataFormat( wxDataFormat &format ) wxDataFormat::wxDataFormat( const GdkAtom atom ) { + if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); m_hasAtom = TRUE; m_atom = atom; - if (m_atom == GDK_TARGET_STRING) + if (m_atom == g_textAtom) { m_type = wxDF_TEXT; } else @@ -66,7 +84,7 @@ wxDataFormat::wxDataFormat( const GdkAtom atom ) m_type = wxDF_PRIVATE; m_id = gdk_atom_name( m_atom ); - if (m_id == "file:ALL") + if (m_id == _T("file:ALL")) { m_type = wxDF_FILENAME; } @@ -79,21 +97,21 @@ void wxDataFormat::SetType( wxDataType type ) if (m_type == wxDF_TEXT) { - m_id = "STRING"; + m_id = _T("STRING"); } else if (m_type == wxDF_BITMAP) { - m_id = "BITMAP"; + m_id = _T("BITMAP"); } else if (m_type == wxDF_FILENAME) { - m_id = "file:ALL"; + m_id = _T("file:ALL"); } else { - wxFAIL_MSG( "invalid dataformat" ); + wxFAIL_MSG( _T("invalid dataformat") ); } m_hasAtom = FALSE; @@ -109,7 +127,7 @@ wxString wxDataFormat::GetId() const return m_id; } -void wxDataFormat::SetId( const wxString &id ) +void wxDataFormat::SetId( const wxChar *id ) { m_type = wxDF_PRIVATE; m_id = id; @@ -124,8 +142,8 @@ GdkAtom wxDataFormat::GetAtom() if (m_type == wxDF_TEXT) { - m_atom = GDK_TARGET_STRING; - } + m_atom = g_textAtom; + } else if (m_type == wxDF_BITMAP) { @@ -134,7 +152,7 @@ GdkAtom wxDataFormat::GetAtom() else if (m_type == wxDF_PRIVATE) { - m_atom = gdk_atom_intern( WXSTRINGCAST( m_id ), FALSE ); + m_atom = gdk_atom_intern( MBSTRINGCAST m_id.mbc_str(), FALSE ); } else if (m_type == wxDF_FILENAME) @@ -241,7 +259,7 @@ void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const if (dobj->GetFormat().GetAtom() == format.GetAtom()) { - return dobj->WriteData( dest ); + dobj->WriteData( dest ); } node = node->Next(); @@ -279,7 +297,7 @@ wxString wxDataObject::GetFormatId() const GdkAtom wxDataObject::GetFormatAtom() const { - GdkAtom ret = m_format.GetAtom(); + GdkAtom ret = ((wxDataObject*) this)->m_format.GetAtom(); return ret; } @@ -323,7 +341,7 @@ size_t wxTextDataObject::GetSize() const void wxTextDataObject::WriteString( const wxString &str, void *dest ) const { - memcpy( dest, m_data.c_str(), GetSize() ); + memcpy( dest, str.mb_str(), str.Len()+1 ); } // ---------------------------------------------------------------------------- @@ -340,7 +358,7 @@ wxFileDataObject::wxFileDataObject() void wxFileDataObject::AddFile( const wxString &file ) { m_files += file; - m_files += (char)0; + m_files += (wxChar)0; } wxString wxFileDataObject::GetFiles() const @@ -350,7 +368,7 @@ wxString wxFileDataObject::GetFiles() const void wxFileDataObject::WriteData( void *dest ) const { - memcpy( dest, m_files.c_str(), GetSize() ); + memcpy( dest, m_files.mbc_str(), GetSize() ); } size_t wxFileDataObject::GetSize() const @@ -409,7 +427,7 @@ IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject ) wxPrivateDataObject::wxPrivateDataObject() { - m_id = "application/"; + m_id = _T("application/"); m_id += wxTheApp->GetAppName(); m_format.SetId( m_id );