More changes to StyleBuffer. Now BTextView::AutoResize() has a minimum

size of 3 pixels. To be verified, but seems to work better.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18657 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-08-28 10:06:18 +00:00
parent ffe3f107c4
commit b12f75cfdc
3 changed files with 18 additions and 17 deletions

View File

@ -85,8 +85,7 @@ _BStyleRecordBuffer_::_BStyleRecordBuffer_()
int32 int32
_BStyleRecordBuffer_::InsertRecord(const BFont *inFont, _BStyleRecordBuffer_::InsertRecord(const BFont *inFont, const rgb_color *inColor)
const rgb_color *inColor)
{ {
int32 index = 0; int32 index = 0;
@ -111,14 +110,14 @@ _BStyleRecordBuffer_::InsertRecord(const BFont *inFont,
} }
// no unused space, expand the buffer // no unused space, expand the buffer
index = fItemCount; const STEStyle style = { *inFont, *inColor };
STEStyleRecord newRecord; const STEStyleRecord newRecord = {
newRecord.refs = 0; 0,
newRecord.ascent = fh.ascent; fh.ascent,
newRecord.descent = fh.descent + fh.leading; fh.descent + fh.leading,
newRecord.style.font = *inFont; style
newRecord.style.color = *inColor; };
InsertItemsAt(1, index, &newRecord); InsertItemsAt(1, fItemCount, &newRecord);
return index; return index;
} }
@ -176,8 +175,9 @@ SetStyleFromMode(uint32 mode, const BFont *fromFont, BFont *toFont,
_BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor) _BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor)
:
fValidNullStyle(true)
{ {
fValidNullStyle = true;
fNullStyle.font = *inFont; fNullStyle.font = *inFont;
fNullStyle.color = *inColor; fNullStyle.color = *inColor;
} }
@ -227,8 +227,7 @@ _BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
void void
_BStyleBuffer_::GetNullStyle(const BFont **font, _BStyleBuffer_::GetNullStyle(const BFont **font, const rgb_color **color) const
const rgb_color **color) const
{ {
if (font) if (font)
*font = &fNullStyle.font; *font = &fNullStyle.font;

View File

@ -138,7 +138,7 @@ class _BStyleBuffer_ {
const _BStyleRunDescBuffer_& RunBuffer() const; const _BStyleRunDescBuffer_& RunBuffer() const;
const _BStyleRecordBuffer_& RecordBuffer() const; const _BStyleRecordBuffer_& RecordBuffer() const;
protected: private:
_BStyleRunDescBuffer_ fStyleRunDesc; _BStyleRunDescBuffer_ fStyleRunDesc;
_BStyleRecordBuffer_ fStyleRecord; _BStyleRecordBuffer_ fStyleRecord;
bool fValidNullStyle; bool fValidNullStyle;

View File

@ -4021,6 +4021,8 @@ BTextView::AutoResize(bool redraw)
for (int32 i = 0; i < CountLines(); i++) for (int32 i = 0; i < CountLines(); i++)
newWidth += LineWidth(i); newWidth += LineWidth(i);
if (newWidth < 3)
newWidth = 3;
BRect newRect(0, 0, ceilf(newWidth) + 1, ceilf(TextHeight(0, 0)) + 1); BRect newRect(0, 0, ceilf(newWidth) + 1, ceilf(TextHeight(0, 0)) + 1);
if (fContainerView != NULL) { if (fContainerView != NULL) {