Use LineHeight() instead of StyledWidthUTF8Safe() to get the height of
the line in PointAt(), since the former didn't return the correct result, due to the fact that there were 0 charachters on that line. Fixed a bug in TextHeight() which ended up doubling the height of the line if we requested the last line. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20745 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1636,7 +1636,7 @@ BTextView::PointAt(int32 inOffset, float *outHeight) const
|
|||||||
// TODO: Cleanup.
|
// TODO: Cleanup.
|
||||||
|
|
||||||
BPoint result;
|
BPoint result;
|
||||||
int32 textLength = fText->Length();
|
const int32 textLength = fText->Length();
|
||||||
int32 lineNum = LineAt(inOffset);
|
int32 lineNum = LineAt(inOffset);
|
||||||
STELine* line = (*fLines)[lineNum];
|
STELine* line = (*fLines)[lineNum];
|
||||||
float height = 0;
|
float height = 0;
|
||||||
@@ -1662,11 +1662,8 @@ BTextView::PointAt(int32 inOffset, float *outHeight) const
|
|||||||
|
|
||||||
// special case: go down one line if inOffset is a newline
|
// special case: go down one line if inOffset is a newline
|
||||||
if (inOffset == textLength && (*fText)[inOffset - 1] == B_ENTER) {
|
if (inOffset == textLength && (*fText)[inOffset - 1] == B_ENTER) {
|
||||||
float ascent, descent;
|
|
||||||
StyledWidthUTF8Safe(inOffset, 1, &ascent, &descent);
|
|
||||||
|
|
||||||
result.y += height;
|
result.y += height;
|
||||||
height = ascent + descent;
|
height = LineHeight(CountLines() - 1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int32 offset = line->offset;
|
int32 offset = line->offset;
|
||||||
@@ -1894,7 +1891,7 @@ BTextView::TextHeight(int32 startLine, int32 endLine) const
|
|||||||
|
|
||||||
float height = (*fLines)[endLine + 1]->origin - (*fLines)[startLine]->origin;
|
float height = (*fLines)[endLine + 1]->origin - (*fLines)[startLine]->origin;
|
||||||
|
|
||||||
if (endLine == numLines - 1 && (*fText)[fText->Length() - 1] == B_ENTER)
|
if (startLine != endLine && endLine == numLines - 1 && (*fText)[fText->Length() - 1] == B_ENTER)
|
||||||
height += (*fLines)[endLine + 1]->origin - (*fLines)[endLine]->origin;
|
height += (*fLines)[endLine + 1]->origin - (*fLines)[endLine]->origin;
|
||||||
|
|
||||||
return ceilf(height);
|
return ceilf(height);
|
||||||
@@ -3363,18 +3360,13 @@ BTextView::FindLineBreak(int32 fromOffset, float *outAscent, float *outDescent,
|
|||||||
bool foundNewline = done;
|
bool foundNewline = done;
|
||||||
done = true;
|
done = true;
|
||||||
int32 pos = delta - 1;
|
int32 pos = delta - 1;
|
||||||
if ((*fText)[offset + pos] != B_SPACE &&
|
if (!CanEndLine(offset + pos))
|
||||||
(*fText)[offset + pos] != B_TAB &&
|
|
||||||
(*fText)[offset + pos] != B_ENTER)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
strWidth -= (deltaWidth + tabWidth);
|
strWidth -= (deltaWidth + tabWidth);
|
||||||
|
|
||||||
for ( ; ((offset + pos) > offset); pos--) {
|
for ( ; ((offset + pos) > offset); pos--) {
|
||||||
uchar theChar = (*fText)[offset + pos];
|
if (!CanEndLine(offset + pos))
|
||||||
if (theChar != B_SPACE &&
|
|
||||||
theChar != B_TAB &&
|
|
||||||
theChar != B_ENTER)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user