X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0a5145a23ef3d7d203b546ad2e172153d8473b4..0af07cc24519a07e1948169568c979fea7465ce2:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 62acf0a2fa..252cfe22af 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -54,6 +54,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_BUFFER_RESET) IMPLEMENT_CLASS( wxRichTextCtrl, wxControl ) @@ -140,12 +141,6 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); } - GetBuffer().Reset(); - GetBuffer().SetRichTextCtrl(this); - - SetCaret(new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16)); - GetCaret()->Show(); - if (style & wxTE_READONLY) SetEditable(false); @@ -170,6 +165,12 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetBackgroundStyle(wxBG_STYLE_CUSTOM); + GetBuffer().Reset(); + GetBuffer().SetRichTextCtrl(this); + + SetCaret(new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16)); + GetCaret()->Show(); + // Tell the sizers to use the given or best size SetInitialSize(size); @@ -201,7 +202,6 @@ wxRichTextCtrl::~wxRichTextCtrl() /// Member initialisation void wxRichTextCtrl::Init() { - m_freezeCount = 0; m_contextMenu = NULL; m_caret = NULL; m_caretPosition = -1; @@ -217,25 +217,13 @@ void wxRichTextCtrl::Init() m_caretPositionForDefaultStyle = -2; } -/// Call Freeze to prevent refresh -void wxRichTextCtrl::Freeze() -{ - m_freezeCount ++; -} - -/// Call Thaw to refresh -void wxRichTextCtrl::Thaw() +void wxRichTextCtrl::DoThaw() { - m_freezeCount --; - - if (m_freezeCount == 0) - { - if (GetBuffer().GetDirty()) - LayoutContent(); - else - SetupScrollbars(); - Refresh(false); - } + if (GetBuffer().GetDirty()) + LayoutContent(); + else + SetupScrollbars(); + Refresh(false); } /// Clear all text @@ -248,7 +236,9 @@ void wxRichTextCtrl::Clear() m_caretAtLineStart = false; m_selectionRange.SetRange(-2, -2); - if (m_freezeCount == 0) + Scroll(0,0); + + if (!IsFrozen()) { LayoutContent(); Refresh(false); @@ -269,11 +259,12 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) #else wxPaintDC dc(this); #endif - PrepareDC(dc); - if (m_freezeCount > 0) + if (IsFrozen()) return; + PrepareDC(dc); + dc.SetFont(GetFont()); // Paint the background @@ -1789,7 +1780,7 @@ void wxRichTextCtrl::OnScroll(wxScrollWinEvent& event) /// Set up scrollbars, e.g. after a resize void wxRichTextCtrl::SetupScrollbars(bool atTop) { - if (m_freezeCount) + if (IsFrozen()) return; if (GetBuffer().IsEmpty()) @@ -2250,6 +2241,8 @@ void wxRichTextCtrl::SetInsertionPoint(long pos) SelectNone(); m_caretPosition = pos - 1; + + PositionCaret(); } void wxRichTextCtrl::SetInsertionPointEnd()