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