From 4b08e76925e7143d1d33ad4f16edf589f053486b Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 28 Nov 2008 15:52:52 +0000 Subject: [PATCH] Fixed centering and right-justification when combined with left indentation (bug #10221). Fixed wrapping problem for long lines (bug #10149). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@57001 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 ++ src/richtext/richtextbuffer.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 7453a343d7..de3c7ca0e8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -107,6 +107,8 @@ All (GUI): before pressing Delete. - Fixed inability to select no superscript and no subscript in wxRichTextCtrl's formatting dialog. +- Fixed centering and right-justification when combined with left indentation. +- Fixed wrapping problem for long lines. - Fixed wxHTML's pagebreaks computation in tables (D.J.Stauffer). - Fixed wxHtmlWindow::SelectionToText() to correctly insert newlines after single-cell paragraphs. diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 489aacec12..8e5fa04a79 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -4169,12 +4169,12 @@ void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttrEx& attr, const wx // centering, right-justification if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE) { - pos.x = (rect.GetWidth() - size.x)/2 + pos.x; + pos.x = (rect.GetWidth() - (pos.x - rect.x) - size.x)/2 + pos.x; line->SetPosition(pos); } else if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_RIGHT) { - pos.x = pos.x + rect.GetWidth() - size.x; + pos.x = rect.x + rect.GetWidth() - size.x; line->SetPosition(pos); } @@ -4759,7 +4759,7 @@ bool wxRichTextParagraph::FindWrapPosition(const wxRichTextRange& range, wxDC& d widthBefore = 0; size_t i; - for (i = (size_t) range.GetStart(); i < (size_t) range.GetEnd(); i++) + for (i = (size_t) range.GetStart(); i <= (size_t) range.GetEnd(); i++) { int widthFromStartOfThisRange = g_GlobalPartialTextExtents[i - GetRange().GetStart()] - widthBefore;