Refactor wxStyledTextCtrl to share common file save/load code.

Keep the code for saving and loading text contents from files in a single
place instead of doing it differently in wxTextCtrl and wxStyledTextCtrl.

This required adding Set/GetValue() methods to wxTextAreaBase just so that its
DoLoad/SaveFile() could use them, even if they are the same as wxTextEntryBase
methods and are overridden in wxTextCtrlBase to be implemented in terms of the
latter.

Notice that wxRichTextCtrl might need to be refactored to use this code too in
the future.

Also notice that this reverts the change of r62081 which replaced SetValue()
with ChangeValue() in DoLoadFile() as wxTextAreaBase only has SetValue() and
it's not worth adding ChangeValue() to it too just to preserve this recent
change in behaviour.

Closes #10715.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62139 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-09-26 13:26:16 +00:00
parent 65702d2fe9
commit 3396739da1
6 changed files with 132 additions and 132 deletions

View File

@@ -582,11 +582,13 @@ public:
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
wxTextCoord *col,
wxTextCoord *row) const;
virtual wxString GetValue() const = 0;
virtual void SetValue(const wxString& value) = 0;
protected:
// implementation of loading/saving
virtual bool DoLoadFile(const wxString& file, int fileType) = 0;
virtual bool DoSaveFile(const wxString& file, int fileType) = 0;
virtual bool DoLoadFile(const wxString& file, int fileType);
virtual bool DoSaveFile(const wxString& file, int fileType);
// the name of the last file loaded with LoadFile() which will be used by
@@ -611,6 +613,16 @@ class WXDLLIMPEXP_CORE wxTextCtrlIface : public wxTextAreaBase,
public:
wxTextCtrlIface() { }
// wxTextAreaBase overrides
virtual wxString GetValue() const
{
return wxTextEntryBase::GetValue();
}
virtual void SetValue(const wxString& value)
{
wxTextEntryBase::SetValue(value);
}
private:
wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface);
};
@@ -683,6 +695,16 @@ public:
virtual bool GetStyle(long position, wxTextAttr& style);
virtual bool SetDefaultStyle(const wxTextAttr& style);
// wxTextAreaBase overrides
virtual wxString GetValue() const
{
return wxTextEntry::GetValue();
}
virtual void SetValue(const wxString& value)
{
wxTextEntry::SetValue(value);
}
protected:
// override streambuf method
#if wxHAS_TEXT_WINDOW_STREAM