From ce364c4ecd5e313e62eb7107dab59b52f267bccb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2012 22:27:44 +0000 Subject: [PATCH] Reimplement wxTextEntry::DoSetValue() in wxStyledTextCtrl. The version inherited from the base class does work already but calling Scintilla SetText() directly should be more efficient than selecting everything and then calling ReplaceSelection() as the base class version does, less code is executed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/stc/stc.h | 1 + src/stc/stc.cpp | 11 +++++++++++ src/stc/stc.cpp.in | 11 +++++++++++ src/stc/stc.h.in | 1 + 4 files changed, 24 insertions(+) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index d53593a846..091c57ced4 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -4710,6 +4710,7 @@ public: static wxVersionInfo GetLibraryVersionInfo(); protected: + virtual void DoSetValue(const wxString& value, int flags); virtual wxString DoGetValue() const { return GetText(); } virtual wxWindow *GetEditableWindow() { return this; } diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 759030263b..2d7199ee05 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -4372,6 +4372,17 @@ void wxStyledTextCtrl::ScrollToColumn(int column) { } +void wxStyledTextCtrl::DoSetValue(const wxString& value, int flags) +{ + if ( flags & SetValue_SelectionOnly ) + ReplaceSelection(value); + else + SetText(value); + + // We don't send wxEVT_COMMAND_TEXT_UPDATED anyhow, so ignore the + // SetValue_SendEvent bit of the flags +} + #if wxUSE_TEXTCTRL bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType) { diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index b7cfbc8ec1..888f75d478 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -510,6 +510,17 @@ void wxStyledTextCtrl::ScrollToColumn(int column) { } +void wxStyledTextCtrl::DoSetValue(const wxString& value, int flags) +{ + if ( flags & SetValue_SelectionOnly ) + ReplaceSelection(value); + else + SetText(value); + + // We don't send wxEVT_COMMAND_TEXT_UPDATED anyhow, so ignore the + // SetValue_SendEvent bit of the flags +} + #if wxUSE_TEXTCTRL bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType) { diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index d18af6b451..abbfe19b2a 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -452,6 +452,7 @@ public: static wxVersionInfo GetLibraryVersionInfo(); protected: + virtual void DoSetValue(const wxString& value, int flags); virtual wxString DoGetValue() const { return GetText(); } virtual wxWindow *GetEditableWindow() { return this; }