changeset 1301:55697486ef42

TextblockIterator::getAllocation: use start & end args rather than entire Word. This matters for the case of plain text, where an entire line is currently passed to dw as one very long Word.
author corvid <corvid@lavabit.com>
date Thu, 03 Sep 2009 03:03:06 +0000
parents 2ea7cd263703
children d5af811c56f9 29b4740d571e
files dw/textblock.cc
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dw/textblock.cc	Wed Sep 02 21:22:04 2009 +0200
+++ b/dw/textblock.cc	Thu Sep 03 03:03:06 2009 +0000
@@ -2159,14 +2159,32 @@
 
    allocation->x =
       textblock->allocation.x + textblock->lineXOffsetWidget (line);
+
    for (int i = line->firstWord; i < index; i++) {
       Word *w = textblock->words->getRef(i);
       allocation->x += w->size.width + w->effSpace;
    }
+   if (start > 0 && word->content.type == core::Content::TEXT) {
+      allocation->x += textblock->layout->textWidth (word->style->font,
+                                                     word->content.text,
+                                                     start);
+   }
    allocation->y =
       textblock->allocation.y
       + textblock->lineYOffsetWidget (line) + line->ascent - word->size.ascent;
+
    allocation->width = word->size.width;
+   if (word->content.type == core::Content::TEXT) {
+      int wordEnd = strlen(word->content.text);
+
+      if (start > 0 || end < wordEnd) {
+         end = misc::min(end, wordEnd); /* end could be INT_MAX */
+         allocation->width =
+            textblock->layout->textWidth (word->style->font,
+                                          word->content.text + start,
+                                          end - start);
+      }
+   }
    allocation->ascent = word->size.ascent;
    allocation->descent = word->size.descent;
 }