* Removed all *Ptr types (and just use pointers to the type instead).
* minor style guide changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15044 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,44 +1,29 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2004, Haiku, Inc.
|
* Copyright 2001-2005, Haiku, Inc. All Rights Reserved.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* Marc Flerackers ([email protected])
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
* Stefano Ceccherini ([email protected])
|
||||||
// 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:
|
|
||||||
//
|
/** Style storage used by BTextView */
|
||||||
// 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: StyleBuffer.cpp
|
|
||||||
// Authors: Marc Flerackers ([email protected])
|
|
||||||
// Stefano Ceccherini ([email protected])
|
|
||||||
// Description: Style storage used by BTextView
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include "InlineInput.h"
|
#include "InlineInput.h"
|
||||||
#include "StyleBuffer.h"
|
#include "StyleBuffer.h"
|
||||||
|
|
||||||
#include <View.h> // For B_FONT_FAMILY_AND_STYLE, B_FONT_SIZE, etc.
|
#include <View.h>
|
||||||
|
|
||||||
// _BStyleRunDescBuffer_
|
|
||||||
|
|
||||||
_BStyleRunDescBuffer_::_BStyleRunDescBuffer_()
|
_BStyleRunDescBuffer_::_BStyleRunDescBuffer_()
|
||||||
: _BTextViewSupportBuffer_<STEStyleRunDesc>(20)
|
: _BTextViewSupportBuffer_<STEStyleRunDesc>(20)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleRunDescBuffer_::InsertDesc(STEStyleRunDescPtr inDesc, int32 index)
|
_BStyleRunDescBuffer_::InsertDesc(STEStyleRunDesc* inDesc, int32 index)
|
||||||
{
|
{
|
||||||
InsertItemsAt(1, index, inDesc);
|
InsertItemsAt(1, index, inDesc);
|
||||||
}
|
}
|
||||||
@@ -88,17 +73,18 @@ _BStyleRunDescBuffer_::BumpOffset(int32 delta, int32 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _BStyleRecordBuffer_
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
_BStyleRecordBuffer_::_BStyleRecordBuffer_()
|
_BStyleRecordBuffer_::_BStyleRecordBuffer_()
|
||||||
: _BTextViewSupportBuffer_<STEStyleRecord>()
|
: _BTextViewSupportBuffer_<STEStyleRecord>()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -137,16 +123,14 @@ _BStyleRecordBuffer_::InsertRecord(const BFont *inFont,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleRecordBuffer_::CommitRecord(
|
_BStyleRecordBuffer_::CommitRecord(int32 index)
|
||||||
int32 index)
|
|
||||||
{
|
{
|
||||||
fBuffer[index].refs++;
|
fBuffer[index].refs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleRecordBuffer_::RemoveRecord(
|
_BStyleRecordBuffer_::RemoveRecord(int32 index)
|
||||||
int32 index)
|
|
||||||
{
|
{
|
||||||
fBuffer[index].refs--;
|
fBuffer[index].refs--;
|
||||||
}
|
}
|
||||||
@@ -154,14 +138,14 @@ _BStyleRecordBuffer_::RemoveRecord(
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
_BStyleRecordBuffer_::MatchRecord(const BFont *inFont,
|
_BStyleRecordBuffer_::MatchRecord(const BFont *inFont,
|
||||||
const rgb_color *inColor, int32 *outIndex)
|
const rgb_color *inColor, int32 *outIndex)
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < fItemCount; i++) {
|
for (int32 i = 0; i < fItemCount; i++) {
|
||||||
if ( (*inFont == fBuffer[i].style.font) &&
|
if (*inFont == fBuffer[i].style.font
|
||||||
(inColor->red == fBuffer[i].style.color.red) &&
|
&& inColor->red == fBuffer[i].style.color.red
|
||||||
(inColor->green == fBuffer[i].style.color.green) &&
|
&& inColor->green == fBuffer[i].style.color.green
|
||||||
(inColor->blue == fBuffer[i].style.color.blue) &&
|
&& inColor->blue == fBuffer[i].style.color.blue
|
||||||
(inColor->alpha == fBuffer[i].style.color.alpha) ) {
|
&& inColor->alpha == fBuffer[i].style.color.alpha) {
|
||||||
*outIndex = i;
|
*outIndex = i;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -171,7 +155,8 @@ _BStyleRecordBuffer_::MatchRecord(const BFont *inFont,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _BStyleBuffer_
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
_BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor)
|
_BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor)
|
||||||
{
|
{
|
||||||
@@ -180,6 +165,7 @@ _BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor)
|
|||||||
fNullStyle.color = *inColor;
|
fNullStyle.color = *inColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::InvalidateNullStyle()
|
_BStyleBuffer_::InvalidateNullStyle()
|
||||||
{
|
{
|
||||||
@@ -199,7 +185,7 @@ _BStyleBuffer_::SyncNullStyle(int32 offset)
|
|||||||
{
|
{
|
||||||
if ((fValidNullStyle) || (fStyleRunDesc.ItemCount() < 1))
|
if ((fValidNullStyle) || (fStyleRunDesc.ItemCount() < 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int32 index = OffsetToRun(offset);
|
int32 index = OffsetToRun(offset);
|
||||||
fNullStyle = fStyleRecord[fStyleRunDesc[index]->index]->style;
|
fNullStyle = fStyleRecord[fStyleRunDesc[index]->index]->style;
|
||||||
|
|
||||||
@@ -209,7 +195,7 @@ _BStyleBuffer_::SyncNullStyle(int32 offset)
|
|||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
|
_BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
|
||||||
const rgb_color *inColor, int32 offset)
|
const rgb_color *inColor, int32 offset)
|
||||||
{
|
{
|
||||||
if ((fValidNullStyle) || (fStyleRunDesc.ItemCount() < 1))
|
if ((fValidNullStyle) || (fStyleRunDesc.ItemCount() < 1))
|
||||||
SetStyle(inMode, inFont, &fNullStyle.font, inColor, &fNullStyle.color);
|
SetStyle(inMode, inFont, &fNullStyle.font, inColor, &fNullStyle.color);
|
||||||
@@ -218,14 +204,14 @@ _BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
|
|||||||
fNullStyle = fStyleRecord[fStyleRunDesc[index]->index]->style;
|
fNullStyle = fStyleRecord[fStyleRunDesc[index]->index]->style;
|
||||||
SetStyle(inMode, inFont, &fNullStyle.font, inColor, &fNullStyle.color);
|
SetStyle(inMode, inFont, &fNullStyle.font, inColor, &fNullStyle.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
fValidNullStyle = true;
|
fValidNullStyle = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
@@ -236,8 +222,8 @@ _BStyleBuffer_::GetNullStyle(const BFont **font,
|
|||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
_BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
||||||
int32 textLen, uint32 inMode,
|
int32 textLen, uint32 inMode, const BFont *inFont,
|
||||||
const BFont *inFont, const rgb_color *inColor)
|
const rgb_color *inColor)
|
||||||
{
|
{
|
||||||
if (inFont == NULL)
|
if (inFont == NULL)
|
||||||
inFont = &fNullStyle.font;
|
inFont = &fNullStyle.font;
|
||||||
@@ -263,18 +249,18 @@ _BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
|||||||
int32 offset = fromOffset;
|
int32 offset = fromOffset;
|
||||||
int32 runIndex = OffsetToRun(offset);
|
int32 runIndex = OffsetToRun(offset);
|
||||||
do {
|
do {
|
||||||
STEStyleRunDesc runDesc = *fStyleRunDesc[runIndex];
|
STEStyleRunDesc runDesc = *fStyleRunDesc[runIndex];
|
||||||
int32 runEnd = textLen;
|
int32 runEnd = textLen;
|
||||||
if (runIndex < (fStyleRunDesc.ItemCount() - 1))
|
if (runIndex < fStyleRunDesc.ItemCount() - 1)
|
||||||
runEnd = fStyleRunDesc[runIndex + 1]->offset;
|
runEnd = fStyleRunDesc[runIndex + 1]->offset;
|
||||||
|
|
||||||
STEStyle style = fStyleRecord[runDesc.index]->style;
|
STEStyle style = fStyleRecord[runDesc.index]->style;
|
||||||
SetStyle(inMode, inFont, &style.font, inColor, &style.color);
|
SetStyle(inMode, inFont, &style.font, inColor, &style.color);
|
||||||
|
|
||||||
styleIndex = fStyleRecord.InsertRecord(&style.font, &style.color);
|
styleIndex = fStyleRecord.InsertRecord(&style.font, &style.color);
|
||||||
|
|
||||||
if ( (runDesc.offset == offset) && (runIndex > 0) &&
|
if (runDesc.offset == offset && runIndex > 0
|
||||||
(fStyleRunDesc[runIndex - 1]->index == styleIndex) ) {
|
&& fStyleRunDesc[runIndex - 1]->index == styleIndex) {
|
||||||
RemoveStyles(runIndex);
|
RemoveStyles(runIndex);
|
||||||
runIndex--;
|
runIndex--;
|
||||||
}
|
}
|
||||||
@@ -291,7 +277,7 @@ _BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
|||||||
fStyleRunDesc[runIndex]->index = styleIndex;
|
fStyleRunDesc[runIndex]->index = styleIndex;
|
||||||
fStyleRecord.CommitRecord(styleIndex);
|
fStyleRecord.CommitRecord(styleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toOffset < runEnd) {
|
if (toOffset < runEnd) {
|
||||||
STEStyleRunDesc newDesc;
|
STEStyleRunDesc newDesc;
|
||||||
newDesc.offset = toOffset;
|
newDesc.offset = toOffset;
|
||||||
@@ -300,13 +286,13 @@ _BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
|||||||
fStyleRecord.CommitRecord(newDesc.index);
|
fStyleRecord.CommitRecord(newDesc.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runIndex++;
|
runIndex++;
|
||||||
offset = runEnd;
|
offset = runEnd;
|
||||||
} while (offset < toOffset);
|
} while (offset < toOffset);
|
||||||
|
|
||||||
if ( (offset == toOffset) && (runIndex < fStyleRunDesc.ItemCount()) &&
|
if (offset == toOffset && runIndex < fStyleRunDesc.ItemCount()
|
||||||
(fStyleRunDesc[runIndex]->index == styleIndex) )
|
&& fStyleRunDesc[runIndex]->index == styleIndex)
|
||||||
RemoveStyles(runIndex);
|
RemoveStyles(runIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +307,7 @@ _BStyleBuffer_::GetStyle(int32 inOffset, BFont *outFont, rgb_color *outColor) co
|
|||||||
*outColor = fNullStyle.color;
|
*outColor = fNullStyle.color;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 runIndex = OffsetToRun(inOffset);
|
int32 runIndex = OffsetToRun(inOffset);
|
||||||
int32 styleIndex = fStyleRunDesc[runIndex]->index;
|
int32 styleIndex = fStyleRunDesc[runIndex]->index;
|
||||||
|
|
||||||
@@ -332,31 +318,32 @@ _BStyleBuffer_::GetStyle(int32 inOffset, BFont *outFont, rgb_color *outColor) co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STEStyleRangePtr
|
STEStyleRange*
|
||||||
_BStyleBuffer_::GetStyleRange(int32 startOffset, int32 endOffset) const
|
_BStyleBuffer_::GetStyleRange(int32 startOffset, int32 endOffset) const
|
||||||
{
|
{
|
||||||
STEStyleRangePtr result = NULL;
|
STEStyleRange* result = NULL;
|
||||||
|
|
||||||
int32 startIndex = OffsetToRun(startOffset);
|
int32 startIndex = OffsetToRun(startOffset);
|
||||||
int32 endIndex = OffsetToRun(endOffset);
|
int32 endIndex = OffsetToRun(endOffset);
|
||||||
|
|
||||||
int32 numStyles = endIndex - startIndex + 1;
|
int32 numStyles = endIndex - startIndex + 1;
|
||||||
numStyles = (numStyles < 1) ? 1 : numStyles;
|
numStyles = (numStyles < 1) ? 1 : numStyles;
|
||||||
result = (STEStyleRangePtr)malloc(sizeof(int32) +
|
|
||||||
(sizeof(STEStyleRun) * numStyles));
|
|
||||||
|
|
||||||
|
result = (STEStyleRange*)malloc(sizeof(int32)
|
||||||
|
+ sizeof(STEStyleRun) * numStyles);
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
result->count = numStyles;
|
result->count = numStyles;
|
||||||
STEStyleRunPtr run = &result->runs[0];
|
STEStyleRun* run = &result->runs[0];
|
||||||
|
|
||||||
for (int32 index = 0; index < numStyles; index++) {
|
for (int32 index = 0; index < numStyles; index++) {
|
||||||
*run = (*this)[startIndex + index];
|
*run = (*this)[startIndex + index];
|
||||||
run->offset -= startOffset;
|
run->offset -= startOffset;
|
||||||
run->offset = (run->offset < 0) ? 0 : run->offset;
|
run->offset = (run->offset < 0) ? 0 : run->offset;
|
||||||
run++;
|
run++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,24 +359,24 @@ _BStyleBuffer_::RemoveStyleRange(int32 fromOffset, int32 toOffset)
|
|||||||
RemoveStyles(fromIndex + 1, count);
|
RemoveStyles(fromIndex + 1, count);
|
||||||
toIndex = fromIndex;
|
toIndex = fromIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
fStyleRunDesc.BumpOffset(fromOffset - toOffset, fromIndex + 1);
|
fStyleRunDesc.BumpOffset(fromOffset - toOffset, fromIndex + 1);
|
||||||
|
|
||||||
if ((toIndex == fromIndex) && (toIndex < (fStyleRunDesc.ItemCount() - 1))) {
|
if (toIndex == fromIndex && toIndex < fStyleRunDesc.ItemCount() - 1) {
|
||||||
STEStyleRunDescPtr runDesc = fStyleRunDesc[toIndex + 1];
|
STEStyleRunDesc* runDesc = fStyleRunDesc[toIndex + 1];
|
||||||
runDesc->offset = fromOffset;
|
runDesc->offset = fromOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromIndex < (fStyleRunDesc.ItemCount() - 1)) {
|
if (fromIndex < fStyleRunDesc.ItemCount() - 1) {
|
||||||
STEStyleRunDescPtr runDesc = fStyleRunDesc[fromIndex];
|
STEStyleRunDesc* runDesc = fStyleRunDesc[fromIndex];
|
||||||
if (runDesc->offset == (runDesc + 1)->offset) {
|
if (runDesc->offset == (runDesc + 1)->offset) {
|
||||||
RemoveStyles(fromIndex);
|
RemoveStyles(fromIndex);
|
||||||
fromIndex--;
|
fromIndex--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fromIndex >= 0) && (fromIndex < (fStyleRunDesc.ItemCount() - 1))) {
|
if (fromIndex >= 0 && fromIndex < fStyleRunDesc.ItemCount() - 1) {
|
||||||
STEStyleRunDescPtr runDesc = fStyleRunDesc[fromIndex];
|
STEStyleRunDesc* runDesc = fStyleRunDesc[fromIndex];
|
||||||
if (runDesc->index == (runDesc + 1)->index)
|
if (runDesc->index == (runDesc + 1)->index)
|
||||||
RemoveStyles(fromIndex + 1);
|
RemoveStyles(fromIndex + 1);
|
||||||
}
|
}
|
||||||
@@ -399,27 +386,28 @@ _BStyleBuffer_::RemoveStyleRange(int32 fromOffset, int32 toOffset)
|
|||||||
void
|
void
|
||||||
_BStyleBuffer_::RemoveStyles(int32 index, int32 count)
|
_BStyleBuffer_::RemoveStyles(int32 index, int32 count)
|
||||||
{
|
{
|
||||||
for (int32 i = index; i < (index + count); i++)
|
for (int32 i = index; i < (index + count); i++) {
|
||||||
fStyleRecord.RemoveRecord(fStyleRunDesc[i]->index);
|
fStyleRecord.RemoveRecord(fStyleRunDesc[i]->index);
|
||||||
|
}
|
||||||
|
|
||||||
fStyleRunDesc.RemoveDescs(index, count);
|
fStyleRunDesc.RemoveDescs(index, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
_BStyleBuffer_::Iterate(int32 fromOffset, int32 length, _BInlineInput_ *input,
|
_BStyleBuffer_::Iterate(int32 fromOffset, int32 length, _BInlineInput_ *input,
|
||||||
const BFont **outFont, const rgb_color **outColor,
|
const BFont **outFont, const rgb_color **outColor,
|
||||||
float *outAscent, float *outDescent, uint32 *) const
|
float *outAscent, float *outDescent, uint32 *) const
|
||||||
{
|
{
|
||||||
// TODO: Handle the _BInlineInput_ style here in some way
|
// TODO: Handle the _BInlineInput_ style here in some way
|
||||||
int32 numRuns = fStyleRunDesc.ItemCount();
|
int32 numRuns = fStyleRunDesc.ItemCount();
|
||||||
if (length < 1 || numRuns < 1)
|
if (length < 1 || numRuns < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32 result = length;
|
int32 result = length;
|
||||||
int32 runIndex = fStyleRunDesc.OffsetToRun(fromOffset);
|
int32 runIndex = fStyleRunDesc.OffsetToRun(fromOffset);
|
||||||
STEStyleRunDescPtr run = fStyleRunDesc[runIndex];
|
STEStyleRunDesc* run = fStyleRunDesc[runIndex];
|
||||||
|
|
||||||
if (outFont != NULL)
|
if (outFont != NULL)
|
||||||
*outFont = &fStyleRecord[run->index]->style.font;
|
*outFont = &fStyleRecord[run->index]->style.font;
|
||||||
if (outColor != NULL)
|
if (outColor != NULL)
|
||||||
@@ -428,13 +416,12 @@ _BStyleBuffer_::Iterate(int32 fromOffset, int32 length, _BInlineInput_ *input,
|
|||||||
*outAscent = fStyleRecord[run->index]->ascent;
|
*outAscent = fStyleRecord[run->index]->ascent;
|
||||||
if (outDescent != NULL)
|
if (outDescent != NULL)
|
||||||
*outDescent = fStyleRecord[run->index]->descent;
|
*outDescent = fStyleRecord[run->index]->descent;
|
||||||
|
|
||||||
if (runIndex < (numRuns - 1)) {
|
if (runIndex < numRuns - 1) {
|
||||||
int32 nextOffset = (run + 1)->offset - fromOffset;
|
int32 nextOffset = (run + 1)->offset - fromOffset;
|
||||||
result = (result > nextOffset) ? nextOffset : result;
|
result = (result > nextOffset) ? nextOffset : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,18 +442,18 @@ _BStyleBuffer_::BumpOffset(int32 delta, int32 index)
|
|||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::SetStyle(uint32 mode, const BFont *fromFont,
|
_BStyleBuffer_::SetStyle(uint32 mode, const BFont *fromFont,
|
||||||
BFont *toFont, const rgb_color *fromColor,
|
BFont *toFont, const rgb_color *fromColor,
|
||||||
rgb_color *toColor)
|
rgb_color *toColor)
|
||||||
{
|
{
|
||||||
if (mode & B_FONT_FAMILY_AND_STYLE)
|
if (mode & B_FONT_FAMILY_AND_STYLE)
|
||||||
toFont->SetFamilyAndStyle(fromFont->FamilyAndStyle());
|
toFont->SetFamilyAndStyle(fromFont->FamilyAndStyle());
|
||||||
|
|
||||||
if (mode & B_FONT_SIZE)
|
if (mode & B_FONT_SIZE)
|
||||||
toFont->SetSize(fromFont->Size());
|
toFont->SetSize(fromFont->Size());
|
||||||
|
|
||||||
if (mode & B_FONT_SHEAR)
|
if (mode & B_FONT_SHEAR)
|
||||||
toFont->SetShear(fromFont->Shear());
|
toFont->SetShear(fromFont->Shear());
|
||||||
|
|
||||||
if (!mode || (mode == B_FONT_ALL))
|
if (!mode || (mode == B_FONT_ALL))
|
||||||
*toColor = *fromColor;
|
*toColor = *fromColor;
|
||||||
}
|
}
|
||||||
@@ -476,24 +463,25 @@ STEStyleRun
|
|||||||
_BStyleBuffer_::operator[](int32 index) const
|
_BStyleBuffer_::operator[](int32 index) const
|
||||||
{
|
{
|
||||||
STEStyleRun run;
|
STEStyleRun run;
|
||||||
|
|
||||||
if (fStyleRunDesc.ItemCount() < 1) {
|
if (fStyleRunDesc.ItemCount() < 1) {
|
||||||
run.offset = 0;
|
run.offset = 0;
|
||||||
run.style = fNullStyle;
|
run.style = fNullStyle;
|
||||||
} else {
|
} else {
|
||||||
STEStyleRunDescPtr runDesc = fStyleRunDesc[index];
|
STEStyleRunDesc* runDesc = fStyleRunDesc[index];
|
||||||
STEStyleRecordPtr record = fStyleRecord[runDesc->index];
|
const STEStyleRecord* record = fStyleRecord[runDesc->index];
|
||||||
run.offset = runDesc->offset;
|
run.offset = runDesc->offset;
|
||||||
run.style = record->style;
|
run.style = record->style;
|
||||||
}
|
}
|
||||||
|
|
||||||
return run;
|
return run;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
_BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
||||||
rgb_color *outColor, bool *sameColor, int32 fromOffset, int32 toOffset) const
|
rgb_color *outColor, bool *sameColor, int32 fromOffset,
|
||||||
|
int32 toOffset) const
|
||||||
{
|
{
|
||||||
uint32 mode = B_FONT_ALL;
|
uint32 mode = B_FONT_ALL;
|
||||||
|
|
||||||
@@ -508,14 +496,14 @@ _BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
|||||||
*sameColor = true;
|
*sameColor = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 fromIndex = OffsetToRun(fromOffset);
|
int32 fromIndex = OffsetToRun(fromOffset);
|
||||||
int32 toIndex = OffsetToRun(toOffset - 1);
|
int32 toIndex = OffsetToRun(toOffset - 1);
|
||||||
|
|
||||||
if (fromIndex == toIndex) {
|
if (fromIndex == toIndex) {
|
||||||
int32 styleIndex = fStyleRunDesc[fromIndex]->index;
|
int32 styleIndex = fStyleRunDesc[fromIndex]->index;
|
||||||
STEStylePtr style = &fStyleRecord[styleIndex]->style;
|
const STEStyle* style = &fStyleRecord[styleIndex]->style;
|
||||||
|
|
||||||
if (ioMode)
|
if (ioMode)
|
||||||
*ioMode = mode;
|
*ioMode = mode;
|
||||||
if (outFont)
|
if (outFont)
|
||||||
@@ -524,44 +512,41 @@ _BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
|||||||
*outColor = style->color;
|
*outColor = style->color;
|
||||||
if (sameColor)
|
if (sameColor)
|
||||||
*sameColor = true;
|
*sameColor = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
bool oneColor = true;
|
bool oneColor = true;
|
||||||
int32 styleIndex = fStyleRunDesc[toIndex]->index;
|
int32 styleIndex = fStyleRunDesc[toIndex]->index;
|
||||||
STEStyle theStyle = fStyleRecord[styleIndex]->style;
|
STEStyle theStyle = fStyleRecord[styleIndex]->style;
|
||||||
STEStylePtr style = NULL;
|
STEStyle* style = NULL;
|
||||||
|
|
||||||
for (int32 i = fromIndex; i < toIndex; i++) {
|
for (int32 i = fromIndex; i < toIndex; i++) {
|
||||||
styleIndex = fStyleRunDesc[i]->index;
|
styleIndex = fStyleRunDesc[i]->index;
|
||||||
style = &fStyleRecord[styleIndex]->style;
|
style = &fStyleRecord[styleIndex]->style;
|
||||||
|
|
||||||
if (mode & B_FONT_FAMILY_AND_STYLE) {
|
if (mode & B_FONT_FAMILY_AND_STYLE) {
|
||||||
if (theStyle.font != style->font)
|
if (theStyle.font != style->font)
|
||||||
mode &= ~B_FONT_FAMILY_AND_STYLE;
|
mode &= ~B_FONT_FAMILY_AND_STYLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & B_FONT_SIZE) {
|
if (mode & B_FONT_SIZE) {
|
||||||
if (theStyle.font.Size() != style->font.Size())
|
if (theStyle.font.Size() != style->font.Size())
|
||||||
mode &= ~B_FONT_SIZE;
|
mode &= ~B_FONT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & B_FONT_SHEAR) {
|
if (mode & B_FONT_SHEAR) {
|
||||||
if (theStyle.font.Shear() != style->font.Shear())
|
if (theStyle.font.Shear() != style->font.Shear())
|
||||||
mode &= ~B_FONT_SHEAR;
|
mode &= ~B_FONT_SHEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (theStyle.color.red != style->color.red) ||
|
if (theStyle.color.red != style->color.red
|
||||||
(theStyle.color.green != style->color.green) ||
|
|| theStyle.color.green != style->color.green
|
||||||
(theStyle.color.blue != style->color.blue) ||
|
|| theStyle.color.blue != style->color.blue
|
||||||
(theStyle.color.alpha != style->color.alpha) ) {
|
|| theStyle.color.alpha != style->color.alpha)
|
||||||
oneColor = false;
|
oneColor = false;
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Finish this: handle B_FONT_FACE, B_FONT_FLAGS, etc.
|
// TODO: Finish this: handle B_FONT_FACE, B_FONT_FLAGS, etc.
|
||||||
// if needed
|
// if needed
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioMode)
|
if (ioMode)
|
||||||
*ioMode = mode;
|
*ioMode = mode;
|
||||||
if (outFont)
|
if (outFont)
|
||||||
|
|||||||
@@ -1,28 +1,11 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2004, Haiku, Inc.
|
* Copyright 2001-2005, Haiku, Inc. All Rights Reserved.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* Marc Flerackers ([email protected])
|
||||||
// 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: StyleBuffer.h
|
|
||||||
// Author: Marc Flerackers ([email protected])
|
|
||||||
// Description: Style storage used by BTextView
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
@@ -34,19 +17,19 @@
|
|||||||
typedef struct STEStyle {
|
typedef struct STEStyle {
|
||||||
BFont font; // font
|
BFont font; // font
|
||||||
rgb_color color; // pen color
|
rgb_color color; // pen color
|
||||||
} STEStyle, *STEStylePtr;
|
} STEStyle;
|
||||||
|
|
||||||
|
|
||||||
typedef struct STEStyleRun {
|
typedef struct STEStyleRun {
|
||||||
long offset; // byte offset of first character of run
|
long offset; // byte offset of first character of run
|
||||||
STEStyle style; // style info
|
STEStyle style; // style info
|
||||||
} STEStyleRun, *STEStyleRunPtr;
|
} STEStyleRun;
|
||||||
|
|
||||||
|
|
||||||
typedef struct STEStyleRange {
|
typedef struct STEStyleRange {
|
||||||
long count; // number of style runs
|
long count; // number of style runs
|
||||||
STEStyleRun runs[1]; // array of count number of runs
|
STEStyleRun runs[1]; // array of count number of runs
|
||||||
} STEStyleRange, *STEStyleRangePtr;
|
} STEStyleRange;
|
||||||
|
|
||||||
|
|
||||||
typedef struct STEStyleRecord {
|
typedef struct STEStyleRecord {
|
||||||
@@ -54,32 +37,31 @@ typedef struct STEStyleRecord {
|
|||||||
float ascent; // ascent for this style
|
float ascent; // ascent for this style
|
||||||
float descent; // descent for this style
|
float descent; // descent for this style
|
||||||
STEStyle style; // style info
|
STEStyle style; // style info
|
||||||
} STEStyleRecord, *STEStyleRecordPtr;
|
} STEStyleRecord;
|
||||||
|
|
||||||
|
|
||||||
typedef struct STEStyleRunDesc {
|
typedef struct STEStyleRunDesc {
|
||||||
long offset; // byte offset of first character of run
|
long offset; // byte offset of first character of run
|
||||||
long index; // index of corresponding style record
|
long index; // index of corresponding style record
|
||||||
} STEStyleRunDesc, *STEStyleRunDescPtr;
|
} STEStyleRunDesc;
|
||||||
|
|
||||||
|
|
||||||
// _BStyleRunDescBuffer_ class -------------------------------------------------
|
// _BStyleRunDescBuffer_ class -------------------------------------------------
|
||||||
class _BStyleRunDescBuffer_ : public _BTextViewSupportBuffer_<STEStyleRunDesc> {
|
class _BStyleRunDescBuffer_ : public _BTextViewSupportBuffer_<STEStyleRunDesc> {
|
||||||
|
public:
|
||||||
|
_BStyleRunDescBuffer_();
|
||||||
|
|
||||||
public:
|
void InsertDesc(STEStyleRunDesc* inDesc, int32 index);
|
||||||
_BStyleRunDescBuffer_();
|
|
||||||
|
|
||||||
void InsertDesc(STEStyleRunDescPtr inDesc, int32 index);
|
|
||||||
void RemoveDescs(int32 index, int32 count = 1);
|
void RemoveDescs(int32 index, int32 count = 1);
|
||||||
|
|
||||||
long OffsetToRun(int32 offset) const;
|
long OffsetToRun(int32 offset) const;
|
||||||
void BumpOffset(int32 delta, int32 index);
|
void BumpOffset(int32 delta, int32 index);
|
||||||
|
|
||||||
const STEStyleRunDescPtr operator[](int32 index) const;
|
STEStyleRunDesc* operator[](int32 index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline const STEStyleRunDescPtr
|
inline STEStyleRunDesc*
|
||||||
_BStyleRunDescBuffer_::operator[](int32 index) const
|
_BStyleRunDescBuffer_::operator[](int32 index) const
|
||||||
{
|
{
|
||||||
return &fBuffer[index];
|
return &fBuffer[index];
|
||||||
@@ -88,22 +70,21 @@ _BStyleRunDescBuffer_::operator[](int32 index) const
|
|||||||
|
|
||||||
// _BStyleRecordBuffer_ class --------------------------------------------------
|
// _BStyleRecordBuffer_ class --------------------------------------------------
|
||||||
class _BStyleRecordBuffer_ : public _BTextViewSupportBuffer_<STEStyleRecord> {
|
class _BStyleRecordBuffer_ : public _BTextViewSupportBuffer_<STEStyleRecord> {
|
||||||
|
public:
|
||||||
|
_BStyleRecordBuffer_();
|
||||||
|
|
||||||
public:
|
|
||||||
_BStyleRecordBuffer_();
|
|
||||||
|
|
||||||
int32 InsertRecord(const BFont *inFont, const rgb_color *inColor);
|
int32 InsertRecord(const BFont *inFont, const rgb_color *inColor);
|
||||||
void CommitRecord(int32 index);
|
void CommitRecord(int32 index);
|
||||||
void RemoveRecord(int32 index);
|
void RemoveRecord(int32 index);
|
||||||
|
|
||||||
bool MatchRecord(const BFont *inFont, const rgb_color *inColor,
|
bool MatchRecord(const BFont *inFont, const rgb_color *inColor,
|
||||||
int32 *outIndex);
|
int32 *outIndex);
|
||||||
|
|
||||||
const STEStyleRecordPtr operator[](int32 index) const;
|
STEStyleRecord* operator[](int32 index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline const STEStyleRecordPtr
|
inline STEStyleRecord*
|
||||||
_BStyleRecordBuffer_::operator[](int32 index) const
|
_BStyleRecordBuffer_::operator[](int32 index) const
|
||||||
{
|
{
|
||||||
return &fBuffer[index];
|
return &fBuffer[index];
|
||||||
@@ -111,58 +92,58 @@ _BStyleRecordBuffer_::operator[](int32 index) const
|
|||||||
|
|
||||||
|
|
||||||
class _BInlineInput_;
|
class _BInlineInput_;
|
||||||
|
|
||||||
// _BStyleBuffer_ class --------------------------------------------------------
|
// _BStyleBuffer_ class --------------------------------------------------------
|
||||||
class _BStyleBuffer_ {
|
class _BStyleBuffer_ {
|
||||||
|
public:
|
||||||
|
_BStyleBuffer_(const BFont *inFont,
|
||||||
|
const rgb_color *inColor);
|
||||||
|
|
||||||
public:
|
void InvalidateNullStyle();
|
||||||
_BStyleBuffer_(const BFont *inFont,
|
bool IsValidNullStyle() const;
|
||||||
const rgb_color *inColor);
|
|
||||||
|
|
||||||
void InvalidateNullStyle();
|
|
||||||
bool IsValidNullStyle() const;
|
|
||||||
|
|
||||||
void SyncNullStyle(int32 offset);
|
|
||||||
void SetNullStyle(uint32 inMode, const BFont *inFont,
|
|
||||||
const rgb_color *inColor, int32 offset = 0);
|
|
||||||
void GetNullStyle(const BFont **font,
|
|
||||||
const rgb_color **color) const;
|
|
||||||
|
|
||||||
void SetStyleRange(int32 fromOffset, int32 toOffset,
|
|
||||||
int32 textLen, uint32 inMode,
|
|
||||||
const BFont *inFont, const rgb_color *inColor);
|
|
||||||
void GetStyle(int32 inOffset, BFont *outFont,
|
|
||||||
rgb_color *outColor) const;
|
|
||||||
void ContinuousGetStyle(BFont *, uint32 *, rgb_color *,
|
|
||||||
bool *, int32, int32) const;
|
|
||||||
STEStyleRangePtr GetStyleRange(int32 startOffset, int32 endOffset) const;
|
|
||||||
|
|
||||||
void RemoveStyleRange(int32 fromOffset, int32 toOffset);
|
|
||||||
void RemoveStyles(int32 index, int32 count = 1);
|
|
||||||
|
|
||||||
int32 Iterate(int32 fromOffset, int32 length, _BInlineInput_ *,
|
|
||||||
const BFont **outFont = NULL,
|
|
||||||
const rgb_color **outColor = NULL,
|
|
||||||
float *outAscent = NULL,
|
|
||||||
float *outDescen = NULL, uint32 * = NULL) const;
|
|
||||||
|
|
||||||
int32 OffsetToRun(int32 offset) const;
|
|
||||||
void BumpOffset(int32 delta, int32 index);
|
|
||||||
|
|
||||||
void SetStyle(uint32 mode, const BFont *fromFont,
|
|
||||||
BFont *toFont, const rgb_color *fromColor,
|
|
||||||
rgb_color *toColor);
|
|
||||||
|
|
||||||
STEStyleRun operator[](int32 index) const;
|
|
||||||
|
|
||||||
int32 NumRuns() const;
|
|
||||||
const _BStyleRunDescBuffer_& RunBuffer() const;
|
|
||||||
const _BStyleRecordBuffer_& RecordBuffer() const;
|
|
||||||
|
|
||||||
protected:
|
void SyncNullStyle(int32 offset);
|
||||||
_BStyleRunDescBuffer_ fStyleRunDesc;
|
void SetNullStyle(uint32 inMode, const BFont *inFont,
|
||||||
_BStyleRecordBuffer_ fStyleRecord;
|
const rgb_color *inColor, int32 offset = 0);
|
||||||
bool fValidNullStyle;
|
void GetNullStyle(const BFont **font,
|
||||||
STEStyle fNullStyle;
|
const rgb_color **color) const;
|
||||||
|
|
||||||
|
void SetStyleRange(int32 fromOffset, int32 toOffset,
|
||||||
|
int32 textLen, uint32 inMode,
|
||||||
|
const BFont *inFont, const rgb_color *inColor);
|
||||||
|
void GetStyle(int32 inOffset, BFont *outFont,
|
||||||
|
rgb_color *outColor) const;
|
||||||
|
void ContinuousGetStyle(BFont *, uint32 *, rgb_color *,
|
||||||
|
bool *, int32, int32) const;
|
||||||
|
STEStyleRange* GetStyleRange(int32 startOffset, int32 endOffset) const;
|
||||||
|
|
||||||
|
void RemoveStyleRange(int32 fromOffset, int32 toOffset);
|
||||||
|
void RemoveStyles(int32 index, int32 count = 1);
|
||||||
|
|
||||||
|
int32 Iterate(int32 fromOffset, int32 length, _BInlineInput_ *,
|
||||||
|
const BFont **outFont = NULL,
|
||||||
|
const rgb_color **outColor = NULL,
|
||||||
|
float *outAscent = NULL,
|
||||||
|
float *outDescen = NULL, uint32 * = NULL) const;
|
||||||
|
|
||||||
|
int32 OffsetToRun(int32 offset) const;
|
||||||
|
void BumpOffset(int32 delta, int32 index);
|
||||||
|
|
||||||
|
void SetStyle(uint32 mode, const BFont *fromFont,
|
||||||
|
BFont *toFont, const rgb_color *fromColor,
|
||||||
|
rgb_color *toColor);
|
||||||
|
|
||||||
|
STEStyleRun operator[](int32 index) const;
|
||||||
|
int32 NumRuns() const;
|
||||||
|
|
||||||
|
const _BStyleRunDescBuffer_& RunBuffer() const;
|
||||||
|
const _BStyleRecordBuffer_& RecordBuffer() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
_BStyleRunDescBuffer_ fStyleRunDesc;
|
||||||
|
_BStyleRecordBuffer_ fStyleRecord;
|
||||||
|
bool fValidNullStyle;
|
||||||
|
STEStyle fNullStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1655,14 +1655,14 @@ text_run_array *
|
|||||||
BTextView::RunArray(int32 startOffset, int32 endOffset, int32 *outSize) const
|
BTextView::RunArray(int32 startOffset, int32 endOffset, int32 *outSize) const
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
STEStyleRangePtr styleRange = fStyles->GetStyleRange(startOffset, endOffset - 1);
|
|
||||||
|
|
||||||
|
STEStyleRange* styleRange = fStyles->GetStyleRange(startOffset, endOffset - 1);
|
||||||
if (styleRange == NULL)
|
if (styleRange == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
text_run_array *res = (text_run_array *)malloc(sizeof(int32) +
|
text_run_array *res = (text_run_array *)malloc(sizeof(int32)
|
||||||
(sizeof(text_run) * styleRange->count));
|
+ (sizeof(text_run) * styleRange->count));
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
if (outSize)
|
if (outSize)
|
||||||
*outSize = 0;
|
*outSize = 0;
|
||||||
@@ -1720,7 +1720,7 @@ BTextView::PointAt(int32 inOffset, float *outHeight) const
|
|||||||
BPoint result;
|
BPoint result;
|
||||||
int32 textLength = fText->Length();
|
int32 textLength = fText->Length();
|
||||||
int32 lineNum = LineAt(inOffset);
|
int32 lineNum = LineAt(inOffset);
|
||||||
STELinePtr line = (*fLines)[lineNum];
|
STELine* line = (*fLines)[lineNum];
|
||||||
float height = 0;
|
float height = 0;
|
||||||
|
|
||||||
result.x = 0.0;
|
result.x = 0.0;
|
||||||
@@ -1810,7 +1810,7 @@ BTextView::OffsetAt(BPoint point) const
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32 lineNum = LineAt(point);
|
int32 lineNum = LineAt(point);
|
||||||
STELinePtr line = (*fLines)[lineNum];
|
STELine* line = (*fLines)[lineNum];
|
||||||
|
|
||||||
// special case: if point is within the text rect and PixelToLine()
|
// special case: if point is within the text rect and PixelToLine()
|
||||||
// tells us that it's on the last line, but if point is actually
|
// tells us that it's on the last line, but if point is actually
|
||||||
@@ -2028,7 +2028,7 @@ BTextView::LineWidth(int32 lineNum) const
|
|||||||
if (lineNum < 0 || lineNum >= fLines->NumLines())
|
if (lineNum < 0 || lineNum >= fLines->NumLines())
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
STELinePtr line = (*fLines)[lineNum];
|
STELine* line = (*fLines)[lineNum];
|
||||||
return StyledWidth(line->offset, (line + 1)->offset - line->offset);
|
return StyledWidth(line->offset, (line + 1)->offset - line->offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3060,7 +3060,7 @@ BTextView::HandlePageKey(uint32 inPageKey)
|
|||||||
|
|
||||||
bool shiftDown = mods & B_SHIFT_KEY;
|
bool shiftDown = mods & B_SHIFT_KEY;
|
||||||
|
|
||||||
STELinePtr line = NULL;
|
STELine* line = NULL;
|
||||||
|
|
||||||
int32 start = fSelStart, end = fSelEnd;
|
int32 start = fSelStart, end = fSelEnd;
|
||||||
|
|
||||||
@@ -3300,8 +3300,8 @@ BTextView::RecalculateLineBreaks(int32 *startLine, int32 *endLine)
|
|||||||
int32 lineIndex = (*startLine > 0) ? *startLine - 1 : 0;
|
int32 lineIndex = (*startLine > 0) ? *startLine - 1 : 0;
|
||||||
int32 recalThreshold = (*fLines)[*endLine + 1]->offset;
|
int32 recalThreshold = (*fLines)[*endLine + 1]->offset;
|
||||||
float width = fTextRect.Width();
|
float width = fTextRect.Width();
|
||||||
STELinePtr curLine = (*fLines)[lineIndex];
|
STELine* curLine = (*fLines)[lineIndex];
|
||||||
STELinePtr nextLine = curLine + 1;
|
STELine* nextLine = curLine + 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
float ascent, descent;
|
float ascent, descent;
|
||||||
@@ -3654,7 +3654,7 @@ BTextView::DrawLines(int32 startLine, int32 endLine, int32 startOffset,
|
|||||||
|
|
||||||
BRect eraseRect = clipRect;
|
BRect eraseRect = clipRect;
|
||||||
long startEraseLine = startLine;
|
long startEraseLine = startLine;
|
||||||
STELinePtr line = (*fLines)[startLine];
|
STELine* line = (*fLines)[startLine];
|
||||||
if (erase && startOffset != -1) {
|
if (erase && startOffset != -1) {
|
||||||
// erase only to the right of startOffset
|
// erase only to the right of startOffset
|
||||||
startEraseLine++;
|
startEraseLine++;
|
||||||
|
|||||||
Reference in New Issue
Block a user