]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed a problem with tabs when text spills over the end of the tab stops
authorJulian Smart <julian@anthemion.co.uk>
Tue, 20 Feb 2007 12:54:44 +0000 (12:54 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Tue, 20 Feb 2007 12:54:44 +0000 (12:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextbuffer.cpp

index 41351256a677b3e59a4dfab5ab463c1d25c7dc4f..52434a8a579be27b67711cdf7dd35ef787cf6ac4 100644 (file)
@@ -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;
                 }