HaikuDepot: Paragraph: Added Length() method.
This commit is contained in:
@@ -123,3 +123,16 @@ Paragraph::Insert(int32 offset, const TextSpan& newSpan)
|
|||||||
&& fTextSpans.Add(newSpan, index + 1)
|
&& fTextSpans.Add(newSpan, index + 1)
|
||||||
&& fTextSpans.Add(spanAfter, index + 2);
|
&& 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 Append(const TextSpan& span);
|
||||||
bool Insert(int32 offset, const TextSpan& span);
|
bool Insert(int32 offset, const TextSpan& span);
|
||||||
|
|
||||||
|
int32 Length() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ParagraphStyle fStyle;
|
ParagraphStyle fStyle;
|
||||||
TextSpanList fTextSpans;
|
TextSpanList fTextSpans;
|
||||||
|
|||||||
Reference in New Issue
Block a user