From b03b33e2e64ad63f7637dcff9ffc52b9a3fcb9eb Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 24 Apr 1999 16:00:28 +0000 Subject: [PATCH] DnD with Unicode fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2274 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/dnd.h | 2 +- include/wx/gtk1/dnd.h | 2 +- samples/dnd/dnd.cpp | 14 +++++++------- src/gtk/dataobj.cpp | 4 ++-- src/gtk/dnd.cpp | 3 ++- src/gtk1/dataobj.cpp | 4 ++-- src/gtk1/dnd.cpp | 3 ++- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/wx/gtk/dnd.h b/include/wx/gtk/dnd.h index cf5ff44913..0e76509e1a 100644 --- a/include/wx/gtk/dnd.h +++ b/include/wx/gtk/dnd.h @@ -111,7 +111,7 @@ public: virtual bool OnData( int x, int y ); /* you have to override OnDropData to get at the text */ - virtual bool OnDropText( int x, int y, const char *text ) = 0; + virtual bool OnDropText( int x, int y, const wxChar *text ) = 0; }; diff --git a/include/wx/gtk1/dnd.h b/include/wx/gtk1/dnd.h index cf5ff44913..0e76509e1a 100644 --- a/include/wx/gtk1/dnd.h +++ b/include/wx/gtk1/dnd.h @@ -111,7 +111,7 @@ public: virtual bool OnData( int x, int y ); /* you have to override OnDropData to get at the text */ - virtual bool OnDropText( int x, int y, const char *text ) = 0; + virtual bool OnDropText( int x, int y, const wxChar *text ) = 0; }; diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index a4db60f67e..6014a1b10a 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -42,7 +42,7 @@ class DnDText : public wxTextDropTarget public: DnDText(wxListBox *pOwner) { m_pOwner = pOwner; } - virtual bool OnDropText(long x, long y, const char *psz ); + virtual bool OnDropText(int x, int y, const wxChar* psz ); private: wxListBox *m_pOwner; @@ -53,8 +53,8 @@ class DnDFile : public wxFileDropTarget public: DnDFile(wxListBox *pOwner) { m_pOwner = pOwner; } - virtual bool OnDropFiles(long x, long y, - size_t nFiles, const char * const aszFiles[] ); + virtual bool OnDropFiles(int x, int y, + size_t nFiles, const wxChar* const aszFiles[] ); private: wxListBox *m_pOwner; @@ -349,18 +349,18 @@ DnDFrame::~DnDFrame() // ---------------------------------------------------------------------------- // Notifications called by the base class // ---------------------------------------------------------------------------- -bool DnDText::OnDropText(long, long, const char *psz) +bool DnDText::OnDropText( int, int, const wxChar *psz ) { m_pOwner->Append(psz); return TRUE; } -bool DnDFile::OnDropFiles(long, long, size_t nFiles, - const char * const aszFiles[]) +bool DnDFile::OnDropFiles( int, int, size_t nFiles, + const wxChar* const aszFiles[]) { wxString str; - str.Printf("%d files dropped", nFiles); + str.Printf( _T("%d files dropped"), nFiles); m_pOwner->Append(str); for ( size_t n = 0; n < nFiles; n++ ) { m_pOwner->Append(aszFiles[n]); diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index 246e603722..c36564b559 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -341,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, m_data.mbc_str(), GetSize() ); } // ---------------------------------------------------------------------------- @@ -368,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 diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 225318a235..ae53201b1b 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -470,7 +470,7 @@ bool wxTextDropTarget::OnData( int x, int y ) wxTextDataObject data; if (!GetData( &data )) return FALSE; - OnDropText( x, y, data.GetText().mbc_str() ); + OnDropText( x, y, data.GetText() ); return TRUE; } @@ -591,6 +591,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), if (data_object->GetFormat().GetAtom() == selection_data->target) { size_t data_size = data_object->GetSize(); + if (data_size > 0) { guchar *buffer = new guchar[data_size]; diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index 246e603722..c36564b559 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -341,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, m_data.mbc_str(), GetSize() ); } // ---------------------------------------------------------------------------- @@ -368,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 diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 225318a235..ae53201b1b 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -470,7 +470,7 @@ bool wxTextDropTarget::OnData( int x, int y ) wxTextDataObject data; if (!GetData( &data )) return FALSE; - OnDropText( x, y, data.GetText().mbc_str() ); + OnDropText( x, y, data.GetText() ); return TRUE; } @@ -591,6 +591,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), if (data_object->GetFormat().GetAtom() == selection_data->target) { size_t data_size = data_object->GetSize(); + if (data_size > 0) { guchar *buffer = new guchar[data_size]; -- 2.45.2