Files
haiku-beta6/src/kits/interface/BTextView/LineBuffer.h
T
Stefano Ceccherini 5302d71190 Fixed LineWidth(): now it calls StyledWidth(). It's not an issue, since charachter widths are cached by _BWidthBuffer_.
Marc Flerackers lend me a hand and now alignments should work much better (if not perfectly)

Some cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9119 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-09-30 12:49:34 +00:00

79 lines
2.5 KiB
C++

//------------------------------------------------------------------------------
// Copyright (c) 2001-2004, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: LineBuffer.h
// Author: Marc Flerackers ([email protected])
// Description: Line storage used by BTextView
//------------------------------------------------------------------------------
#include <SupportDefs.h>
#include "TextViewSupportBuffer.h"
typedef struct STELine {
long offset; // offset of first character of line
float origin; // pixel position of top of line
float ascent; // maximum ascent for line
} STELine, *STELinePtr;
// _BLineBuffer_ class ---------------------------------------------------------
class _BLineBuffer_ : public _BTextViewSupportBuffer_<STELine> {
public:
_BLineBuffer_();
virtual ~_BLineBuffer_();
void InsertLine(STELine *inLine, int32 index);
void RemoveLines(int32 index, int32 count = 1);
void RemoveLineRange(int32 fromOffset, int32 toOffset);
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;
const STELinePtr operator[](int32 index) const;
};
inline int32
_BLineBuffer_::NumLines() const
{
return fItemCount - 1;
}
inline const STELinePtr
_BLineBuffer_::operator[](int32 index) const
{
return &fBuffer[index];
}
/*
* $Log $
*
* $Id $
*
*/