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#ifndef __LINE_BUFFER_H
9#define __LINE_BUFFER_H
10
11
12#include <SupportDefs.h>
13#include <TextView.h>
14
15#include "TextViewSupportBuffer.h"
16
17struct STELine {
18	long		offset;		// offset of first character of line
19	float		origin;		// pixel position of top of line
20	float		ascent;		// maximum ascent for line
21	float		width;		// cached width of line in pixels
22};
23
24
25class BTextView::LineBuffer : public _BTextViewSupportBuffer_<STELine> {
26
27public:
28								LineBuffer();
29	virtual						~LineBuffer();
30
31			void				InsertLine(STELine* inLine, int32 index);
32			void				RemoveLines(int32 index, int32 count = 1);
33			void				RemoveLineRange(int32 fromOffset,
34									int32 toOffset);
35
36			int32				OffsetToLine(int32 offset) const;
37			int32				PixelToLine(float pixel) const;
38
39			void				BumpOrigin(float delta, int32 index);
40			void				BumpOffset(int32 delta, int32 index);
41
42			int32				NumLines() const;
43			float				MaxWidth() const;
44			STELine*			operator[](int32 index) const;
45};
46
47
48inline int32
49BTextView::LineBuffer::NumLines() const
50{
51	return fItemCount - 1;
52}
53
54
55inline STELine *
56BTextView::LineBuffer::operator[](int32 index) const
57{
58	return &fBuffer[index];
59}
60
61
62#endif	// __LINE_BUFFER_H
63