HaikuDepot: Paragraph: Added Length() method.

This commit is contained in:
Stephan Aßmus
2013-09-02 12:15:15 +02:00
parent 4710193014
commit 6f1dbba164
2 changed files with 15 additions and 0 deletions
@@ -123,3 +123,16 @@ Paragraph::Insert(int32 offset, const TextSpan& newSpan)
&& fTextSpans.Add(newSpan, index + 1)
&& fTextSpans.Add(spanAfter, index + 2);
}
int32
Paragraph::Length() const
{
int32 length = 0;
for (int32 i = fTextSpans.CountItems() - 1; i >= 0; i--) {
const TextSpan& span = fTextSpans.ItemAtFast(i);
length += span.CharCount();
}
return length;
}
@@ -33,6 +33,8 @@ public:
bool Append(const TextSpan& span);
bool Insert(int32 offset, const TextSpan& span);
int32 Length() const;
private:
ParagraphStyle fStyle;
TextSpanList fTextSpans;