From f98779189c9b9822bbb7521f87fc109fc34bc35e Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 29 Nov 2010 20:20:46 +0000 Subject: [PATCH] Fix for caret positioning inaccuracy when there are tabs and a non-zero control margin git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@66297 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextbuffer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 9667f37b35..87822c7cc6 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -5429,6 +5429,8 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph); wxASSERT (para != NULL); + int relativeX = position.x - GetParent()->GetPosition().x; + wxTextAttrEx textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes()); // Always assume unformatted text, since at this level we have no knowledge @@ -5519,9 +5521,9 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz textExtents.Add(oldWidth + p[j]); if (textExtents.GetCount() > 0) - absoluteWidth = textExtents[textExtents.GetCount()-1] + position.x; + absoluteWidth = textExtents[textExtents.GetCount()-1] + relativeX; else - absoluteWidth = position.x; + absoluteWidth = relativeX; } else #endif @@ -5550,7 +5552,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz notFound = false; - width = nextTabPos - position.x; + width = nextTabPos - relativeX; #if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS if (g_UseGlobalPartialTextExtents)