Author: zooey Date: 2009-10-21 15:06:06 +0200 (Wed, 21 Oct 2009) New Revision: 33702 Changeset: http://dev.haiku-os.org/changeset/33702/haiku Modified: haiku/trunk/src/kits/interface/textview_support/LineBuffer.cpp haiku/trunk/src/kits/interface/textview_support/LineBuffer.h Log: * added helper method MaxWidth() to BTextView::LineBuffer Modified: haiku/trunk/src/kits/interface/textview_support/LineBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/LineBuffer.cpp 2009-10-21 13:05:02 UTC (rev 33701) +++ haiku/trunk/src/kits/interface/textview_support/LineBuffer.cpp 2009-10-21 13:06:06 UTC (rev 33702) @@ -105,3 +105,20 @@ for (long i = index; i < fItemCount; i++) fBuffer[i].offset += delta; } + + +float +BTextView::LineBuffer::MaxWidth() const +{ + if (fItemCount == 0) + return 0; + + float maxWidth = 0; + STELine* line = &fBuffer[0]; + for (int32 i = 0; i < fItemCount; i++) { + if (maxWidth < line->width) + maxWidth = line->width; + line++; + } + return maxWidth; +} Modified: haiku/trunk/src/kits/interface/textview_support/LineBuffer.h =================================================================== --- haiku/trunk/src/kits/interface/textview_support/LineBuffer.h 2009-10-21 13:05:02 UTC (rev 33701) +++ haiku/trunk/src/kits/interface/textview_support/LineBuffer.h 2009-10-21 13:06:06 UTC (rev 33702) @@ -15,7 +15,7 @@ long offset; // offset of first character of line float origin; // pixel position of top of line float ascent; // maximum ascent for line - float width; // not used for now, but could be + float width; // cached width of line in pixels }; @@ -31,11 +31,12 @@ int32 OffsetToLine(int32 offset) const; int32 PixelToLine(float pixel) const; - + void BumpOrigin(float delta, int32 index); void BumpOffset(int32 delta, int32 index); long NumLines() const; + float MaxWidth() const; STELine * operator[](int32 index) const; };