Added DoDragOver and DoDropText from Angelo Mandato, and ensured that

my unicode LoadFile/SaveFile changes were in the .in file this time.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@23690 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-09-18 22:28:25 +00:00
parent faa232e903
commit ac0f346dca
4 changed files with 60 additions and 10 deletions

View File

@@ -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);
//----------------------------------------------------------------------

View File

@@ -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

View File

@@ -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

View File

@@ -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);
//----------------------------------------------------------------------