Fixed bug 516, worked some more on AutoResize() (which is still not correct, but improves the situation, looks like bug 161 wasn't completely fixed yet)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17342 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -413,7 +413,11 @@ BTextView::Draw(BRect updateRect)
|
|||||||
int32 startLine = LineAt(BPoint(0.0f, updateRect.top));
|
int32 startLine = LineAt(BPoint(0.0f, updateRect.top));
|
||||||
int32 endLine = LineAt(BPoint(0.0f, updateRect.bottom));
|
int32 endLine = LineAt(BPoint(0.0f, updateRect.bottom));
|
||||||
|
|
||||||
DrawLines(startLine, endLine);
|
// TODO: DrawLines draw the text over and over, causing the text to
|
||||||
|
// antialias against itself. In theory we should use an offscreen bitmap
|
||||||
|
// to draw the text which would eliminate the problem.
|
||||||
|
//DrawLines(startLine, endLine);
|
||||||
|
Refresh(OffsetAt(startLine), OffsetAt(endLine + 1), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2828,7 +2832,7 @@ BTextView::HandleBackspace()
|
|||||||
DeleteText(fSelStart, fSelEnd);
|
DeleteText(fSelStart, fSelEnd);
|
||||||
fClickOffset = fSelEnd = fSelStart;
|
fClickOffset = fSelEnd = fSelStart;
|
||||||
|
|
||||||
Refresh(fSelStart, fSelEnd, true, false);
|
Refresh(fSelStart, fSelEnd, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3201,7 +3205,7 @@ BTextView::Refresh(int32 fromOffset, int32 toOffset, bool erase, bool scroll)
|
|||||||
UpdateScrollbars();
|
UpdateScrollbars();
|
||||||
|
|
||||||
if (scroll)
|
if (scroll)
|
||||||
ScrollToOffset(fSelEnd);
|
ScrollToSelection();
|
||||||
|
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
@@ -4015,28 +4019,30 @@ BTextView::AutoResize(bool redraw)
|
|||||||
{
|
{
|
||||||
// TODO: Review this
|
// TODO: Review this
|
||||||
if (fResizable) {
|
if (fResizable) {
|
||||||
float width = 0;
|
float oldWidth = Bounds().Width() + 1;
|
||||||
|
float newWidth = 0;
|
||||||
for (int32 i = 0; i < CountLines(); i++)
|
for (int32 i = 0; i < CountLines(); i++)
|
||||||
width = max_c(width, LineWidth(i));
|
newWidth += LineWidth(i);
|
||||||
|
|
||||||
float oldWidth = ceilf(Bounds().Width());
|
BRect newRect(0, 0, ceilf(newWidth), ceilf(TextHeight(0, 0)) + 1);
|
||||||
float textRectPadding = Bounds().right - fTextRect.right;
|
|
||||||
width += fTextRect.left + textRectPadding;
|
|
||||||
width = ceilf(width);
|
|
||||||
|
|
||||||
if (fContainerView != NULL) {
|
if (fContainerView != NULL) {
|
||||||
fContainerView->ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines())));
|
fContainerView->ResizeTo(newRect.Width(), newRect.Height());
|
||||||
if (fAlignment == B_ALIGN_CENTER)
|
if (fAlignment == B_ALIGN_CENTER)
|
||||||
fContainerView->MoveBy((oldWidth - width) / 2, 0);
|
fContainerView->MoveBy((oldWidth - newRect.Width()) / 2, 0);
|
||||||
else if (fAlignment == B_ALIGN_RIGHT)
|
else if (fAlignment == B_ALIGN_RIGHT)
|
||||||
fContainerView->MoveBy(oldWidth - width, 0);
|
fContainerView->MoveBy(oldWidth - newRect.Width(), 0);
|
||||||
fContainerView->Invalidate();
|
fContainerView->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
fTextRect.right = Bounds().right - textRectPadding;
|
fTextRect = newRect.InsetBySelf(1, 1);
|
||||||
|
|
||||||
if (redraw)
|
if (redraw)
|
||||||
DrawLines(0, CountLines());
|
DrawLines(0, 0);
|
||||||
|
|
||||||
|
// Erase the old text (TODO: Might not work for alignments different than B_ALIGN_LEFT)
|
||||||
|
SetLowColor(ViewColor());
|
||||||
|
FillRect(BRect(fTextRect.right, fTextRect.top, Bounds().right, fTextRect.bottom), B_SOLID_LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -272,17 +272,6 @@ BTextControl::Draw(BRect updateRect)
|
|||||||
StrokeLine(BPoint(rect.right, rect.top + 1.0f));
|
StrokeLine(BPoint(rect.right, rect.top + 1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
// area around text view
|
|
||||||
|
|
||||||
SetHighColor(fText->ViewColor());
|
|
||||||
rect.InsetBy(1, 1);
|
|
||||||
BRegion region(rect);
|
|
||||||
BRegion updateRegion(updateRect);
|
|
||||||
// why is there no IntersectWith(BRect &) version?
|
|
||||||
region.IntersectWith(&updateRegion);
|
|
||||||
region.Exclude(fText->Frame());
|
|
||||||
FillRegion(®ion);
|
|
||||||
|
|
||||||
// label
|
// label
|
||||||
|
|
||||||
if (Label()) {
|
if (Label()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user