diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index f6833830de..d5aa2324ef 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -743,9 +743,6 @@ protected: int overflow(int i); #endif // wxHAS_TEXT_WINDOW_STREAM - virtual bool DoLoadFile(const wxString& file, int fileType); - virtual bool DoSaveFile(const wxString& file, int fileType); - // Another wxTextAreaBase override. virtual bool IsValidPosition(long pos) const { diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index a3a43e6998..ed3e07f505 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -851,23 +851,16 @@ bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType) { SetValue(text); + DiscardEdits(); + m_filename = filename; + return true; } } #endif // wxUSE_FFILE - return false; -} - -bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int fileType) -{ - if ( wxTextAreaBase::DoLoadFile(filename, fileType) ) - { - DiscardEdits(); - m_filename = filename; - return true; - } wxLogError(_("File couldn't be loaded.")); + return false; } @@ -875,10 +868,19 @@ bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType) { #if wxUSE_FFILE wxFFile file(filename, wxT("w")); - return file.IsOpened() && file.Write(GetValue(), *wxConvCurrent); -#else - return false; + if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) ) + { + // if it worked, save for future calls + m_filename = filename; + + // it's not modified any longer + DiscardEdits(); + + return true; + } #endif // wxUSE_FFILE + + return false; } bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType) @@ -895,21 +897,6 @@ bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType) return DoSaveFile(filenameToUse, fileType); } -bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int fileType) -{ - if ( wxTextAreaBase::DoSaveFile(filename, fileType) ) - { - // if it worked, save for future calls - m_filename = filename; - - // it's not modified any longer - DiscardEdits(); - - return true; - } - return false; -} - // ---------------------------------------------------------------------------- // stream-like insertion operator // ----------------------------------------------------------------------------