From 4794d69c847e884efd629604ceb6b7fa02630e80 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 20 Feb 2007 12:54:44 +0000 Subject: [PATCH] Fixed a problem with tabs when text spills over the end of the tab stops git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextbuffer.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 41351256a6..52434a8a57 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -4165,6 +4165,9 @@ wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject* #define USE_KERNING_FIX 1 +// If insufficient tabs are defined, this is the tab width used +#define WIDTH_FOR_DEFAULT_TABS 50 + /// Draw the item bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int WXUNUSED(style)) { @@ -4346,8 +4349,18 @@ bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttrEx& attr, c for (int i = 0; i < tabCount && not_found; ++i) { nextTabPos = tabArray.Item(i); - if (nextTabPos > tabPos) + + // Find the next tab position. + // Even if we're at the end of the tab array, we must still draw the chunk. + + if (nextTabPos > tabPos || (i == (tabCount - 1))) { + if (nextTabPos <= tabPos) + { + int defaultTabWidth = ConvertTenthsMMToPixels(dc, WIDTH_FOR_DEFAULT_TABS); + nextTabPos = tabPos + defaultTabWidth; + } + not_found = false; if (selected) { @@ -4473,12 +4486,23 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz dc.GetTextExtent(stringFragment, & w, & h); width += w; int absoluteWidth = width + position.x; + bool notFound = true; for (int i = 0; i < tabCount && notFound; ++i) { nextTabPos = tabArray.Item(i); - if (nextTabPos > absoluteWidth) + + // Find the next tab position. + // Even if we're at the end of the tab array, we must still process the chunk. + + if (nextTabPos > absoluteWidth || (i == (tabCount - 1))) { + if (nextTabPos <= absoluteWidth) + { + int defaultTabWidth = ((wxRichTextPlainText*) this)->ConvertTenthsMMToPixels(dc, WIDTH_FOR_DEFAULT_TABS); + nextTabPos = absoluteWidth + defaultTabWidth; + } + notFound = false; width = nextTabPos - position.x; } -- 2.45.2