1 /* 2 * Copyright 2001-2006, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Marc Flerackers (mflerackers@androme.be) 7 */ 8 9 #include <SupportDefs.h> 10 #include "TextViewSupportBuffer.h" 11 12 struct STELine { 13 long offset; // offset of first character of line 14 float origin; // pixel position of top of line 15 float ascent; // maximum ascent for line 16 float width; // not used for now, but could be 17 }; 18 19 20 // _BLineBuffer_ class --------------------------------------------------------- 21 class _BLineBuffer_ : public _BTextViewSupportBuffer_<STELine> { 22 23 public: 24 _BLineBuffer_(); 25 virtual ~_BLineBuffer_(); 26 27 void InsertLine(STELine *inLine, int32 index); 28 void RemoveLines(int32 index, int32 count = 1); 29 void RemoveLineRange(int32 fromOffset, int32 toOffset); 30 31 int32 OffsetToLine(int32 offset) const; 32 int32 PixelToLine(float pixel) const; 33 34 void BumpOrigin(float delta, int32 index); 35 void BumpOffset(int32 delta, int32 index); 36 37 long NumLines() const; 38 STELine * operator[](int32 index) const; 39 }; 40 41 42 inline int32 43 _BLineBuffer_::NumLines() const 44 { 45 return fItemCount - 1; 46 } 47 48 49 inline STELine * 50 _BLineBuffer_::operator[](int32 index) const 51 { 52 return &fBuffer[index]; 53 } 54