TextDocumentLayout: Added GetTextBounds().

This commit is contained in:
Stephan Aßmus 2013-12-06 23:16:22 +01:00
parent 586ec1c10b
commit 60eb71494a
2 changed files with 32 additions and 0 deletions

View File

@ -105,6 +105,33 @@ TextDocumentLayout::Draw(BView* view, const BPoint& offset,
}
void
TextDocumentLayout::GetTextBounds(int32 textOffset, float& x1, float& y1,
float& x2, float& y2)
{
_ValidateLayout();
int32 paragraphs = fParagraphLayouts.CountItems();
for (int32 i = 0; i < paragraphs; i++) {
const ParagraphLayoutInfo& layout = fParagraphLayouts.ItemAtFast(i);
int32 length = layout.layout->CountGlyphs();
if (textOffset > length) {
textOffset -= length;
continue;
}
layout.layout->GetTextBounds(textOffset, x1, y1, x2, y2);
return;
}
x1 = 0.0f;
y1 = 0.0f;
x2 = 0.0f;
y2 = 0.0f;
}
// #pragma mark - private

View File

@ -86,6 +86,11 @@ public:
void Draw(BView* view, const BPoint& offset,
const BRect& updateRect);
void GetTextBounds(int32 textOffset,
float& x1, float& y1,
float& x2, float& y2);
private:
void _Init();
void _ValidateLayout();