Move WidthBuffer and TextGapBuffer into BPrivate and use them from there in BPoseView and BTextView. This (correctly) fixes the previous gcc4 build issues.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27675 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5cb80a0cd8
commit
90b7764dc3
@ -40,7 +40,8 @@ enum undo_state {
|
||||
};
|
||||
|
||||
namespace BPrivate {
|
||||
class BPoseView;
|
||||
class WidthBuffer;
|
||||
class TextGapBuffer;
|
||||
} // namespace BPrivate
|
||||
|
||||
class BTextView : public BView {
|
||||
@ -264,10 +265,8 @@ private:
|
||||
struct LayoutData;
|
||||
class LineBuffer;
|
||||
class StyleBuffer;
|
||||
class TextGapBuffer;
|
||||
class TextTrackState;
|
||||
class UndoBuffer;
|
||||
class WidthBuffer;
|
||||
|
||||
// UndoBuffer derivatives
|
||||
class CutUndoBuffer;
|
||||
@ -277,7 +276,6 @@ private:
|
||||
class TypingUndoBuffer;
|
||||
|
||||
friend class TextTrackState;
|
||||
friend class BPrivate::BPoseView;
|
||||
friend status_t _init_interface_kit_();
|
||||
|
||||
virtual void _ReservedTextView3();
|
||||
@ -381,7 +379,7 @@ private:
|
||||
void _HandleInputMethodLocationRequest();
|
||||
void _CancelInputMethod();
|
||||
|
||||
TextGapBuffer* fText;
|
||||
BPrivate::TextGapBuffer* fText;
|
||||
LineBuffer* fLines;
|
||||
StyleBuffer* fStyles;
|
||||
BRect fTextRect;
|
||||
@ -420,7 +418,7 @@ private:
|
||||
|
||||
uint32 _reserved[8];
|
||||
|
||||
static WidthBuffer* sWidths;
|
||||
static BPrivate::WidthBuffer* sWidths;
|
||||
};
|
||||
|
||||
#endif // _TEXTVIEW_H
|
||||
|
@ -41,6 +41,10 @@ class BFont;
|
||||
// as fonts can be classified also by spacing mode and other attributes.
|
||||
#define USE_DANO_WIDTHBUFFER 0
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class TextGapBuffer;
|
||||
|
||||
struct _width_table_ {
|
||||
#if USE_DANO_WIDTHBUFFER
|
||||
BFont font; // corresponding font
|
||||
@ -53,15 +57,14 @@ struct _width_table_ {
|
||||
void *widths; // width table
|
||||
};
|
||||
|
||||
|
||||
class BTextView::WidthBuffer : public _BTextViewSupportBuffer_<_width_table_> {
|
||||
class WidthBuffer : public _BTextViewSupportBuffer_<_width_table_> {
|
||||
public:
|
||||
WidthBuffer();
|
||||
virtual ~WidthBuffer();
|
||||
|
||||
float StringWidth(const char *inText, int32 fromOffset, int32 length,
|
||||
const BFont *inStyle);
|
||||
float StringWidth(BTextView::TextGapBuffer &gapBuffer, int32 fromOffset,
|
||||
float StringWidth(TextGapBuffer &gapBuffer, int32 fromOffset,
|
||||
int32 length, const BFont *inStyle);
|
||||
|
||||
private:
|
||||
@ -75,4 +78,6 @@ private:
|
||||
static uint32 Hash(uint32);
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif // __WIDTHBUFFER_H
|
||||
|
@ -904,7 +904,7 @@ _init_interface_kit_()
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
BTextView::sWidths = new BTextView::WidthBuffer;
|
||||
BTextView::sWidths = new BPrivate::WidthBuffer;
|
||||
|
||||
_init_global_fonts_();
|
||||
|
||||
|
@ -150,7 +150,7 @@ struct BTextView::LayoutData {
|
||||
};
|
||||
|
||||
// Initialized/finalized by init/fini_interface_kit
|
||||
BTextView::WidthBuffer* BTextView::sWidths = NULL;
|
||||
BPrivate::WidthBuffer* BTextView::sWidths = NULL;
|
||||
|
||||
|
||||
const static rgb_color kBlackColor = { 0, 0, 0, 255 };
|
||||
@ -3009,7 +3009,7 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont,
|
||||
if (initialColor == NULL)
|
||||
initialColor = &kBlackColor;
|
||||
|
||||
fText = new TextGapBuffer;
|
||||
fText = new BPrivate::TextGapBuffer;
|
||||
fLines = new LineBuffer;
|
||||
fStyles = new StyleBuffer(&font, initialColor);
|
||||
|
||||
|
@ -18,8 +18,9 @@
|
||||
|
||||
#include "TextGapBuffer.h"
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
BTextView::TextGapBuffer::TextGapBuffer()
|
||||
TextGapBuffer::TextGapBuffer()
|
||||
: fExtraCount(2048),
|
||||
fItemCount(0),
|
||||
fBuffer(NULL),
|
||||
@ -35,7 +36,7 @@ BTextView::TextGapBuffer::TextGapBuffer()
|
||||
}
|
||||
|
||||
|
||||
BTextView::TextGapBuffer::~TextGapBuffer()
|
||||
TextGapBuffer::~TextGapBuffer()
|
||||
{
|
||||
free(fBuffer);
|
||||
free(fScratchBuffer);
|
||||
@ -43,7 +44,7 @@ BTextView::TextGapBuffer::~TextGapBuffer()
|
||||
|
||||
|
||||
void
|
||||
BTextView::TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
|
||||
TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
|
||||
{
|
||||
if (inNumItems < 1)
|
||||
return;
|
||||
@ -66,7 +67,7 @@ BTextView::TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32
|
||||
|
||||
|
||||
void
|
||||
BTextView::TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 inAtIndex)
|
||||
TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 inAtIndex)
|
||||
{
|
||||
off_t fileSize;
|
||||
|
||||
@ -102,7 +103,7 @@ BTextView::TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumI
|
||||
|
||||
|
||||
void
|
||||
BTextView::TextGapBuffer::RemoveRange(int32 start, int32 end)
|
||||
TextGapBuffer::RemoveRange(int32 start, int32 end)
|
||||
{
|
||||
long inAtIndex = start;
|
||||
long inNumItems = end - start;
|
||||
@ -124,7 +125,7 @@ BTextView::TextGapBuffer::RemoveRange(int32 start, int32 end)
|
||||
|
||||
|
||||
void
|
||||
BTextView::TextGapBuffer::MoveGapTo(int32 toIndex)
|
||||
TextGapBuffer::MoveGapTo(int32 toIndex)
|
||||
{
|
||||
if (toIndex == fGapIndex)
|
||||
return;
|
||||
@ -153,7 +154,7 @@ BTextView::TextGapBuffer::MoveGapTo(int32 toIndex)
|
||||
|
||||
|
||||
void
|
||||
BTextView::TextGapBuffer::SizeGapTo(long inCount)
|
||||
TextGapBuffer::SizeGapTo(long inCount)
|
||||
{
|
||||
if (inCount == fGapCount)
|
||||
return;
|
||||
@ -169,7 +170,7 @@ BTextView::TextGapBuffer::SizeGapTo(long inCount)
|
||||
|
||||
|
||||
const char *
|
||||
BTextView::TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
||||
TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
||||
{
|
||||
char *result = "";
|
||||
if (_numBytes == NULL)
|
||||
@ -226,7 +227,7 @@ BTextView::TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
||||
|
||||
|
||||
bool
|
||||
BTextView::TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta)
|
||||
TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta)
|
||||
{
|
||||
long numChars = *ioDelta;
|
||||
for (long i = 0; i < numChars; i++) {
|
||||
@ -244,7 +245,7 @@ BTextView::TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta)
|
||||
|
||||
|
||||
const char *
|
||||
BTextView::TextGapBuffer::Text()
|
||||
TextGapBuffer::Text()
|
||||
{
|
||||
const char *realText = RealText();
|
||||
|
||||
@ -273,7 +274,7 @@ BTextView::TextGapBuffer::Text()
|
||||
|
||||
|
||||
const char *
|
||||
BTextView::TextGapBuffer::RealText()
|
||||
TextGapBuffer::RealText()
|
||||
{
|
||||
MoveGapTo(fItemCount);
|
||||
fBuffer[fItemCount] = '\0';
|
||||
@ -283,7 +284,7 @@ BTextView::TextGapBuffer::RealText()
|
||||
|
||||
|
||||
void
|
||||
BTextView::TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
|
||||
TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
|
||||
{
|
||||
if (buffer == NULL)
|
||||
return;
|
||||
@ -324,14 +325,17 @@ BTextView::TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
|
||||
|
||||
|
||||
bool
|
||||
BTextView::TextGapBuffer::PasswordMode() const
|
||||
TextGapBuffer::PasswordMode() const
|
||||
{
|
||||
return fPasswordMode;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BTextView::TextGapBuffer::SetPasswordMode(bool state)
|
||||
TextGapBuffer::SetPasswordMode(bool state)
|
||||
{
|
||||
fPasswordMode = state;
|
||||
}
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
|
||||
class BFile;
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class BTextView::TextGapBuffer {
|
||||
class TextGapBuffer {
|
||||
public:
|
||||
TextGapBuffer();
|
||||
virtual ~TextGapBuffer();
|
||||
@ -60,16 +61,18 @@ protected:
|
||||
|
||||
|
||||
inline int32
|
||||
BTextView::TextGapBuffer::Length() const
|
||||
TextGapBuffer::Length() const
|
||||
{
|
||||
return fItemCount;
|
||||
}
|
||||
|
||||
|
||||
inline char
|
||||
BTextView::TextGapBuffer::RealCharAt(long index) const
|
||||
TextGapBuffer::RealCharAt(long index) const
|
||||
{
|
||||
return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];
|
||||
}
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif //__TEXTGAPBUFFER_H
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
const static uint32 kTableCount = 128;
|
||||
const static uint32 kInvalidCode = 0xFFFFFFFF;
|
||||
@ -59,7 +60,7 @@ CharToCode(const char *text, const int32 charLen)
|
||||
|
||||
/*! \brief Initializes the object.
|
||||
*/
|
||||
BTextView::WidthBuffer::WidthBuffer()
|
||||
WidthBuffer::WidthBuffer()
|
||||
:
|
||||
_BTextViewSupportBuffer_<_width_table_>(1, 0)
|
||||
{
|
||||
@ -68,7 +69,7 @@ BTextView::WidthBuffer::WidthBuffer()
|
||||
|
||||
/*! \brief Frees the allocated resources.
|
||||
*/
|
||||
BTextView::WidthBuffer::~WidthBuffer()
|
||||
WidthBuffer::~WidthBuffer()
|
||||
{
|
||||
for (int32 x = 0; x < fItemCount; x++)
|
||||
delete[] (hashed_escapement *)fBuffer[x].widths;
|
||||
@ -83,7 +84,7 @@ BTextView::WidthBuffer::~WidthBuffer()
|
||||
\return The space (in pixels) required to draw the given string.
|
||||
*/
|
||||
float
|
||||
BTextView::WidthBuffer::StringWidth(const char *inText, int32 fromOffset,
|
||||
WidthBuffer::StringWidth(const char *inText, int32 fromOffset,
|
||||
int32 length, const BFont *inStyle)
|
||||
{
|
||||
if (inText == NULL || length == 0)
|
||||
@ -142,14 +143,14 @@ BTextView::WidthBuffer::StringWidth(const char *inText, int32 fromOffset,
|
||||
|
||||
|
||||
/*! \brief Returns how much room is required to draw a string in the font.
|
||||
\param inBuffer The BTextView::TextGapBuffer to be examined.
|
||||
\param fromOffset The offset in the BTextView::TextGapBuffer where to begin the examination.
|
||||
\param inBuffer The TextGapBuffer to be examined.
|
||||
\param fromOffset The offset in the TextGapBuffer where to begin the examination.
|
||||
\param lenght The amount of bytes to be examined.
|
||||
\param inStyle The font.
|
||||
\return The space (in pixels) required to draw the given string.
|
||||
*/
|
||||
float
|
||||
BTextView::WidthBuffer::StringWidth(BTextView::TextGapBuffer &inBuffer, int32 fromOffset, int32 length,
|
||||
WidthBuffer::StringWidth(TextGapBuffer &inBuffer, int32 fromOffset, int32 length,
|
||||
const BFont *inStyle)
|
||||
{
|
||||
const char* text = inBuffer.GetString(fromOffset, &length);
|
||||
@ -165,7 +166,7 @@ BTextView::WidthBuffer::StringWidth(BTextView::TextGapBuffer &inBuffer, int32 fr
|
||||
\c false if not.
|
||||
*/
|
||||
bool
|
||||
BTextView::WidthBuffer::FindTable(const BFont *inStyle, int32 *outIndex)
|
||||
WidthBuffer::FindTable(const BFont *inStyle, int32 *outIndex)
|
||||
{
|
||||
if (inStyle == NULL)
|
||||
return false;
|
||||
@ -199,7 +200,7 @@ BTextView::WidthBuffer::FindTable(const BFont *inStyle, int32 *outIndex)
|
||||
\return The index of the newly created table.
|
||||
*/
|
||||
int32
|
||||
BTextView::WidthBuffer::InsertTable(const BFont *font)
|
||||
WidthBuffer::InsertTable(const BFont *font)
|
||||
{
|
||||
_width_table_ table;
|
||||
|
||||
@ -230,7 +231,7 @@ BTextView::WidthBuffer::InsertTable(const BFont *font)
|
||||
for the given charachter, \c false if not.
|
||||
*/
|
||||
bool
|
||||
BTextView::WidthBuffer::GetEscapement(uint32 value, int32 index, float *escapement)
|
||||
WidthBuffer::GetEscapement(uint32 value, int32 index, float *escapement)
|
||||
{
|
||||
const _width_table_ &table = fBuffer[index];
|
||||
const hashed_escapement *widths = static_cast<hashed_escapement *>(table.widths);
|
||||
@ -256,7 +257,7 @@ BTextView::WidthBuffer::GetEscapement(uint32 value, int32 index, float *escapeme
|
||||
|
||||
|
||||
uint32
|
||||
BTextView::WidthBuffer::Hash(uint32 val)
|
||||
WidthBuffer::Hash(uint32 val)
|
||||
{
|
||||
uint32 shifted = val >> 24;
|
||||
uint32 result = (val >> 15) + (shifted * 3);
|
||||
@ -280,7 +281,7 @@ BTextView::WidthBuffer::Hash(uint32 val)
|
||||
the size of the font).
|
||||
*/
|
||||
float
|
||||
BTextView::WidthBuffer::HashEscapements(const char *inText, int32 numChars, int32 textLen,
|
||||
WidthBuffer::HashEscapements(const char *inText, int32 numChars, int32 textLen,
|
||||
int32 tableIndex, const BFont *inStyle)
|
||||
{
|
||||
ASSERT(inText != NULL);
|
||||
@ -359,3 +360,6 @@ BTextView::WidthBuffer::HashEscapements(const char *inText, int32 numChars, int3
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
@ -9306,7 +9306,7 @@ TPoseViewFilter::Filter(BMessage *message, BHandler **)
|
||||
float BPoseView::sFontHeight = -1;
|
||||
font_height BPoseView::sFontInfo = { 0, 0, 0 };
|
||||
bigtime_t BPoseView::sLastKeyTime = 0;
|
||||
BTextView::WidthBuffer* BPoseView::sWidthBuffer = new BTextView::WidthBuffer;
|
||||
BPrivate::WidthBuffer* BPoseView::sWidthBuffer = new BPrivate::WidthBuffer;
|
||||
BFont BPoseView::sCurrentFont;
|
||||
OffscreenBitmap *BPoseView::sOffscreen = new OffscreenBitmap;
|
||||
char BPoseView::sMatchString[] = "";
|
||||
|
@ -665,7 +665,7 @@ class BPoseView : public BView {
|
||||
BRect fDeskbarFrame;
|
||||
|
||||
// TODO: Get rid of this.
|
||||
static BTextView::WidthBuffer *sWidthBuffer;
|
||||
static BPrivate::WidthBuffer *sWidthBuffer;
|
||||
|
||||
static OffscreenBitmap *sOffscreen;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user