diff --git a/contrib/include/wx/stc/stc.h b/contrib/include/wx/stc/stc.h index ca1c3a4a23..ea61f4ab6b 100644 --- a/contrib/include/wx/stc/stc.h +++ b/contrib/include/wx/stc/stc.h @@ -2284,6 +2284,12 @@ public: // Load the contents of filename into the editor bool LoadFile(const wxString& filename); + // Allow for simulating a DnD DragOver + wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def); + + // Allow for simulating a DnD DropText + bool DoDropText(long x, long y, const wxString& data); + //---------------------------------------------------------------------- diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 6f7f6a59f0..d51b8d04a0 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -2115,7 +2115,7 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename) if (!file.IsOpened()) return FALSE; - bool success = file.Write(GetText()); + bool success = file.Write(GetText(), *wxConvCurrent); if (success) SetSavePoint(); @@ -2131,13 +2131,22 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (file.IsOpened()) { wxString contents; +#if wxUSE_UNICODE + wxMemoryBuffer buffer; +#else + wxString buffer; +#endif off_t len = file.Length(); - if (len > 0) { - wxChar *buf = contents.GetWriteBuf(len); - success = (file.Read(buf, len) == len); - contents.UngetWriteBuf(); + void *bufptr = buffer.GetWriteBuf(len); + success = (file.Read(bufptr, len) == len); + buffer.UngetWriteBuf(len); +#if #wxUSE_UNICODE + contents = wxString(buffer, *wxConvCurrent); +#else + contents = buffer; +#endif } else success = true; // empty file is ok @@ -2154,6 +2163,16 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) } +wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { + return m_swx->DoDragOver(x, y, def); +} + + +bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { + return m_swx->DoDropText(x, y, data); +} + + //---------------------------------------------------------------------- // Event handlers diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index be24cc98f7..fa23c2587b 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -320,7 +320,7 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename) if (!file.IsOpened()) return FALSE; - bool success = file.Write(GetText()); + bool success = file.Write(GetText(), *wxConvCurrent); if (success) SetSavePoint(); @@ -336,13 +336,22 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (file.IsOpened()) { wxString contents; +#if wxUSE_UNICODE + wxMemoryBuffer buffer; +#else + wxString buffer; +#endif off_t len = file.Length(); - if (len > 0) { - wxChar *buf = contents.GetWriteBuf(len); - success = (file.Read(buf, len) == len); - contents.UngetWriteBuf(); + void *bufptr = buffer.GetWriteBuf(len); + success = (file.Read(bufptr, len) == len); + buffer.UngetWriteBuf(len); +#if #wxUSE_UNICODE + contents = wxString(buffer, *wxConvCurrent); +#else + contents = buffer; +#endif } else success = true; // empty file is ok @@ -359,6 +368,16 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) } +wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { + return m_swx->DoDragOver(x, y, def); +} + + +bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { + return m_swx->DoDropText(x, y, data); +} + + //---------------------------------------------------------------------- // Event handlers diff --git a/contrib/src/stc/stc.h.in b/contrib/src/stc/stc.h.in index c120c728d4..0ccc6852da 100644 --- a/contrib/src/stc/stc.h.in +++ b/contrib/src/stc/stc.h.in @@ -200,6 +200,12 @@ public: // Load the contents of filename into the editor bool LoadFile(const wxString& filename); + // Allow for simulating a DnD DragOver + wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def); + + // Allow for simulating a DnD DropText + bool DoDropText(long x, long y, const wxString& data); + //----------------------------------------------------------------------