diff --git a/src/apps/haiku-depot/textview/ParagraphLayout.cpp b/src/apps/haiku-depot/textview/ParagraphLayout.cpp index c7fc592620..187d11c6fc 100644 --- a/src/apps/haiku-depot/textview/ParagraphLayout.cpp +++ b/src/apps/haiku-depot/textview/ParagraphLayout.cpp @@ -255,7 +255,7 @@ ParagraphLayout::Draw(BView* view, const BPoint& offset) int lineCount = fLineInfos.CountItems(); for (int i = 0; i < lineCount; i++) { const LineInfo& line = fLineInfos.ItemAtFast(i); - _DrawLine(view, line); + _DrawLine(view, offset, line); } } @@ -283,8 +283,10 @@ ParagraphLayout::_Init() void ParagraphLayout::_ValidateLayout() { - if (!fLayoutValid) + if (!fLayoutValid) { _Layout(); + fLayoutValid = true; + } } @@ -674,27 +676,28 @@ ParagraphLayout::_IncludeStyleInLine(LineInfo& line, void -ParagraphLayout::_DrawLine(BView* view, const LineInfo& line) const +ParagraphLayout::_DrawLine(BView* view, const BPoint& offset, + const LineInfo& line) const { int textOffset = line.textOffset; int spanCount = line.layoutedSpans.CountItems(); for (int i = 0; i < spanCount; i++) { const TextSpan& span = line.layoutedSpans.ItemAtFast(i); - _DrawSpan(view, span, textOffset); + _DrawSpan(view, offset, span, textOffset); textOffset += span.CharCount(); } } void -ParagraphLayout::_DrawSpan(BView* view, const TextSpan& span, - int32 textOffset) const +ParagraphLayout::_DrawSpan(BView* view, BPoint offset, + const TextSpan& span, int32 textOffset) const { const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset); const LineInfo& line = fLineInfos.ItemAtFast(glyph.lineIndex); - float x = glyph.x; - float y = line.y + line.maxAscent; + offset.x += glyph.x; + offset.y += line.y + line.maxAscent; const CharacterStyle& style = span.Style(); @@ -708,7 +711,7 @@ ParagraphLayout::_DrawSpan(BView* view, const TextSpan& span, delta.space = line.extraWhiteSpacing; // TODO: Fix in app_server: First glyph should not be shifted by delta. - x -= delta.nonspace; + offset.x -= delta.nonspace; - view->DrawString(span.Text(), BPoint(x, y), &delta); + view->DrawString(span.Text(), offset, &delta); } diff --git a/src/apps/haiku-depot/textview/ParagraphLayout.h b/src/apps/haiku-depot/textview/ParagraphLayout.h index 25cf2b7740..68ad43ada0 100644 --- a/src/apps/haiku-depot/textview/ParagraphLayout.h +++ b/src/apps/haiku-depot/textview/ParagraphLayout.h @@ -179,6 +179,8 @@ public: virtual ~ParagraphLayout(); void SetParagraph(const Paragraph& paragraph); + const ParagraphStyle& Style() const + { return fParagraphStyle; } void SetWidth(float width); float Width() const @@ -205,9 +207,10 @@ private: void _IncludeStyleInLine(LineInfo& line, const CharacterStyle& style); - void _DrawLine(BView* view, + void _DrawLine(BView* view, const BPoint& offset, const LineInfo& line) const; - void _DrawSpan(BView* view, const TextSpan& span, + void _DrawSpan(BView* view, BPoint offset, + const TextSpan& span, int32 textOffset) const; private: @@ -221,4 +224,8 @@ private: LineInfoList fLineInfos; }; + +typedef BReference ParagraphLayoutRef; + + #endif // PARAGRAPH_LAYOUT_H