Quite a cleanup action to avoid polluting the global namespace with private

BTextView classes:

* Declared the directly used BTextView helper classes as private BTextView
  classes and changed all affected files.
* Realized that Tracker's BPoseView was (accidentally?) using what used to
  be _BWidthBuffer_. It had declared it's own class with the same name and
  same members/size in headers/private/tracker/TextViewSupport.h, but the
  implementation was nowhere to be found. I can only explain this that
  the BTextView implementation was then actually linked and used. But the big
  problem was that it was used without locking (unlike in BTextView)! When
  many Tracker windows opened during system startup or later and they happened
  to each request characters not yet in the cache, I imagine things could have
  gone bad and corrupted memory. Anyways, since I can see the usefulness of
  the cache, BPoseView uses BTextView::WidthBuffer on purpose now. And I moved
  the locking inside BTextView::WidthBuffer::StringWidth().
* Adjusted InterfaceDefs.cpp accordingly.
* TODO: Move subsequent classes into BTextView namespace as well, ie derived
  classes that BTextView doesn't directly know about. All stuff in src/kits/
   inteface/textview_support/
* Added preliminary and not yet implemented layout friendly BTextView
  constructors.
* I will try to handle the insets imposed by BTextView::fTextRect a bit
  differently when used inside the new layout management framework. For this,
  I added BTextView::SetInsets() and GetInsets(). SetInsets() doesn't do
  anything yet.

So far, everything seems to work still... ;-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27654 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-09-20 15:08:40 +00:00
parent 8121345989
commit a682d9819f
20 changed files with 505 additions and 443 deletions

View File

@ -6,22 +6,15 @@
#define _TEXTVIEW_H
#include <BeBuild.h>
#include <Locker.h>
#include <View.h>
class BMessageRunner;
class BBitmap;
class BClipboard;
class BFile;
class BList;
class _BTextGapBuffer_;
class _BLineBuffer_;
class _BStyleBuffer_;
class _BWidthBuffer_;
class _BUndoBuffer_;
class _BInlineInput_;
class _BTextTrackState_;
class _BTextChangeResult_;
class BMessageRunner;
extern "C" status_t _init_interface_kit_();
@ -46,6 +39,7 @@ enum undo_state {
B_UNDO_DROP
};
class BTextView : public BView {
public:
BTextView(BRect frame, const char* name,
@ -56,6 +50,15 @@ public:
BRect textRect, const BFont* initialFont,
const rgb_color* initialColor,
uint32 resizeMask, uint32 flags);
BTextView(const char* name,
uint32 flags
= B_WILL_DRAW | B_PULSE_NEEDED);
BTextView(const char* name,
const BFont* initialFont,
const rgb_color* initialColor,
uint32 flags);
BTextView(BMessage* data);
virtual ~BTextView();
@ -172,6 +175,12 @@ public:
void SetTextRect(BRect rect);
BRect TextRect() const;
void SetInsets(float _leftInset, float topInset,
float rightInset, float bottomInset);
void GetInsets(float* _leftInset, float* _topInset,
float* _rightInset,
float* _bottomInset) const;
void SetStylable(bool stylable);
bool IsStylable() const;
void SetTabWidth(float width);
@ -231,8 +240,17 @@ protected:
BHandler** _handler);
private:
friend status_t _init_interface_kit_();
friend class _BTextTrackState_;
class InlineInput;
struct LayoutData;
class LineBuffer;
class StyleBuffer;
class TextGapBuffer;
class TextTrackState;
class UndoBuffer;
class WidthBuffer;
friend class TextTrackState;
friend status_t _init_interface_kit_();
virtual void _ReservedTextView3();
virtual void _ReservedTextView4();
@ -275,11 +293,9 @@ private:
void _DoInsertText(const char* inText,
int32 inLength, int32 inOffset,
const text_run_array* inRuns,
_BTextChangeResult_* outResult);
const text_run_array* inRuns);
void _DoDeleteText(int32 fromOffset, int32 toOffset,
_BTextChangeResult_* outResult);
void _DoDeleteText(int32 fromOffset, int32 toOffset);
void _DrawLine(BView* view, const int32 &startLine,
const int32& startOffset, const bool& erase,
@ -337,12 +353,9 @@ private:
void _HandleInputMethodLocationRequest();
void _CancelInputMethod();
static void LockWidthBuffer();
static void UnlockWidthBuffer();
_BTextGapBuffer_* fText;
_BLineBuffer_* fLines;
_BStyleBuffer_* fStyles;
TextGapBuffer* fText;
LineBuffer* fLines;
StyleBuffer* fStyles;
BRect fTextRect;
float fMinTextRectWidth;
int32 fSelStart;
@ -368,19 +381,16 @@ private:
color_space fColorSpace;
bool fResizable;
BView* fContainerView;
_BUndoBuffer_* fUndo;
_BInlineInput_* fInline;
UndoBuffer* fUndo;
InlineInput* fInline;
BMessageRunner * fDragRunner;
BMessageRunner * fClickRunner;
BPoint fWhere;
_BTextTrackState_* fTrackingMouse;
_BTextChangeResult_* fTextChange;
TextTrackState* fTrackingMouse;
uint32 _reserved[8];
uint32 _reserved[9];
static _BWidthBuffer_* sWidths;
static sem_id sWidthSem;
static int32 sWidthAtom;
static WidthBuffer* sWidths;
};
#endif // _TEXTVIEW_H

View File

@ -21,16 +21,20 @@
*
* File: WidthBuffer.cpp
* Author: Stefano Ceccherini (burton666@libero.it)
* Description: _BWidthBuffer_ stores charachters widths in a hash table, to be able
* Description: WidthBuffer stores charachters widths in a hash table, to be able
* to retrieve them without passing through the app server.
* Used by BTextView and OpenTracker.
*/
#ifndef __WIDTHBUFFER_H
#define __WIDTHBUFFER_H
#include <TextView.h>
#include "TextViewSupportBuffer.h"
class BFont; // forward declaration
class BFont;
// TODO: enable this as soon as we are sure opentracker works
// with our libraries, since using a BFont here (as Dano does) is much better,
@ -50,16 +54,15 @@ struct _width_table_ {
};
class _BTextGapBuffer_;
class _BWidthBuffer_ : public _BTextViewSupportBuffer_<_width_table_> {
class BTextView::WidthBuffer : public _BTextViewSupportBuffer_<_width_table_> {
public:
_BWidthBuffer_();
virtual ~_BWidthBuffer_();
WidthBuffer();
virtual ~WidthBuffer();
float StringWidth(const char *inText, int32 fromOffset, int32 length,
const BFont *inStyle);
float StringWidth(_BTextGapBuffer_ &gapBuffer, int32 fromOffset, int32 length,
const BFont *inStyle);
float StringWidth(BTextView::TextGapBuffer &gapBuffer, int32 fromOffset,
int32 length, const BFont *inStyle);
private:
bool FindTable(const BFont *font, int32 *outIndex);

View File

@ -1,100 +0,0 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
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 applies to all licensees
and 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 TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED 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.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
/****************************************************************************
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
** **
** DANGER, WILL ROBINSON! **
** **
** The interfaces contained here are part of BeOS's **
** **
** >> PRIVATE NOT FOR PUBLIC USE << **
** **
** implementation. **
** **
** These interfaces WILL CHANGE in future releases. **
** If you use them, your app WILL BREAK at some future time. **
** **
** (And yes, this does mean that binaries built from OpenTracker will not **
** be compatible with some future releases of the OS. When that happens, **
** we will provide an updated version of this file to keep compatibility.) **
** **
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
****************************************************************************/
#ifndef _TEXTVIEWSUPPORT_H
#define _TEXTVIEWSUPPORT_H
// This is a stub of text view width buffer
// It relies on the implementation of _BWidthBuffer_ in libbe and should
// not be modified
struct _width_table_ {
#if B_BEOS_VERSION_DANO
BFont font; // corresponding font
#else
int32 fontCode; // font code
float fontSize; // font size
#endif
int32 hashCount; // number of hashed items
int32 tableCount; // size of table
void *widths; // width table
};
template<class T> class _BTextViewSupportBuffer_ {
public:
_BTextViewSupportBuffer_(int32, int32);
virtual ~_BTextViewSupportBuffer_();
protected:
int32 mExtraCount;
int32 mItemCount;
int32 mBufferCount;
T *mBuffer;
};
class _BWidthBuffer_ : public _BTextViewSupportBuffer_<_width_table_> {
public:
_BWidthBuffer_();
virtual ~_BWidthBuffer_();
float StringWidth(const char *inText, int32 fromOffset, int32 length,
const BFont *inStyle);
};
#endif /* _TEXTVIEWSUPPORT_H */

View File

@ -904,12 +904,7 @@ _init_interface_kit_()
if (status < B_OK)
return status;
sem_id widthSem = create_sem(0, "BTextView WidthBuffer Sem");
if (widthSem < 0)
return widthSem;
BTextView::sWidthSem = widthSem;
BTextView::sWidthAtom = 0;
BTextView::sWidths = new _BWidthBuffer_;
BTextView::sWidths = new BTextView::WidthBuffer;
_init_global_fonts_();

View File

@ -1,11 +1,12 @@
/*
* Copyright 2001-2008, Haiku Inc.
* Copyright 2001-2008, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Hiroshi Lockheimer (BTextView is based on his STEEngine)
* Marc Flerackers (mflerackers@androme.be)
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
* Stephan Aßmus <superstippi@gmx.de>
*/
/*! BTextView displays and manages styled text. */
@ -15,7 +16,8 @@
// - Consider using BObjectList instead of BList
// for disallowed characters (it would remove a lot of reinterpret_casts)
// - Check for correctness and possible optimizations the calls to _Refresh(),
// to refresh only changed parts of text (currently we often redraw the whole text)
// to refresh only changed parts of text (currently we often redraw the whole
// text)
// Known Bugs:
// - Double buffering doesn't work well (disabled by default)
@ -87,30 +89,49 @@ enum {
};
class _BTextTrackState_ {
class BTextView::TextTrackState {
public:
_BTextTrackState_(BMessenger messenger);
~_BTextTrackState_();
TextTrackState(BMessenger messenger);
~TextTrackState();
void SimulateMouseMovement(BTextView *view);
void SimulateMouseMovement(BTextView* view);
int32 clickOffset;
bool shiftDown;
BRect selectionRect;
int32 anchor;
int32 selStart;
int32 selEnd;
public:
int32 clickOffset;
bool shiftDown;
BRect selectionRect;
int32 anchor;
int32 selStart;
int32 selEnd;
private:
BMessageRunner *fRunner;
BMessageRunner* fRunner;
};
struct BTextView::LayoutData {
LayoutData(float leftInset, float topInset, float rightInset,
float bottomInset)
: leftInset(leftInset),
topInset(topInset),
rightInset(rightInset),
bottomInset(bottomInset),
valid(false)
{
}
float leftInset;
float topInset;
float rightInset;
float bottomInset;
BSize min;
bool valid;
};
// Initialized/finalized by init/fini_interface_kit
_BWidthBuffer_* BTextView::sWidths = NULL;
sem_id BTextView::sWidthSem = B_BAD_SEM_ID;
int32 BTextView::sWidthAtom = 0;
BTextView::WidthBuffer* BTextView::sWidths = NULL;
const static rgb_color kBlackColor = { 0, 0, 0, 255 };
@ -158,14 +179,16 @@ static property_info sPropertyList[] = {
"text_run_array",
{ B_GET_PROPERTY, 0 },
{ B_RANGE_SPECIFIER, B_REVERSE_RANGE_SPECIFIER, 0 },
"Returns the style information for the text in the specified range in the BTextView.", 0,
"Returns the style information for the text in the specified range in "
"the BTextView.", 0,
{ B_RAW_TYPE, 0 },
},
{
"text_run_array",
{ B_SET_PROPERTY, 0 },
{ B_RANGE_SPECIFIER, B_REVERSE_RANGE_SPECIFIER, 0 },
"Sets the style information for the text in the specified range in the BTextView.", 0,
"Sets the style information for the text in the specified range in the "
"BTextView.", 0,
{ B_RAW_TYPE, 0 },
},
{ 0 }
@ -176,7 +199,8 @@ static property_info sPropertyList[] = {
\param frame The rect which will enclose the BTextView object.
\param name The name of the object.
\param textRect Determines the area of the text within the BTextView object.
\param resizeMask The resizing mask for the BTextView, passed to the BView constructor.
\param resizeMask The resizing mask for the BTextView, passed to the BView
constructor.
\param flags The flags for the BTextView, passed to the BView constructor.
*/
BTextView::BTextView(BRect frame, const char *name, BRect textRect,
@ -192,9 +216,12 @@ BTextView::BTextView(BRect frame, const char *name, BRect textRect,
\param frame The rect which will enclose the BTextView object.
\param name The name of the object.
\param textRect Determines the area of the text within the BTextView object.
\param initialFont The BTextView will display its text using this font, unless otherwise specified.
\param initialColor The BTextView will display its text using this color, unless otherwise specified.
\param resizeMask The resizing mask for the BTextView, passed to the BView constructor.
\param initialFont The BTextView will display its text using this font,
unless otherwise specified.
\param initialColor The BTextView will display its text using this color,
unless otherwise specified.
\param resizeMask The resizing mask for the BTextView, passed to the BView
constructor.
\param flags The flags for the BTextView, passed to the BView constructor.
*/
BTextView::BTextView(BRect frame, const char *name, BRect textRect,
@ -207,6 +234,35 @@ BTextView::BTextView(BRect frame, const char *name, BRect textRect,
}
/*! \brief Creates a BTextView object with the given attributes.
\param name The name of the object.
\param flags The flags for the BTextView, passed to the BView constructor.
*/
BTextView::BTextView(const char* name, uint32 flags)
: BView(name, flags | B_FRAME_EVENTS | B_PULSE_NEEDED
| B_INPUT_METHOD_AWARE)
{
// TODO: ...
}
/*! \brief Creates a BTextView object with the given attributes.
\param name The name of the object.
\param initialFont The BTextView will display its text using this font,
unless otherwise specified.
\param initialColor The BTextView will display its text using this color,
unless otherwise specified.
\param flags The flags for the BTextView, passed to the BView constructor.
*/
BTextView::BTextView(const char* name, const BFont* initialFont,
const rgb_color* initialColor, uint32 flags)
: BView(name, flags | B_FRAME_EVENTS | B_PULSE_NEEDED
| B_INPUT_METHOD_AWARE)
{
// TODO: ...
}
/*! \brief Creates a BTextView object from the passed BMessage.
\param archive The BMessage from which the object shall be created.
*/
@ -268,15 +324,19 @@ BTextView::BTextView(BMessage *archive)
fDisallowedChars = new BList;
disallowedCount /= sizeof(int32);
for (int32 x = 0; x < disallowedCount; x++)
fDisallowedChars->AddItem(reinterpret_cast<void *>(disallowedChars[x]));
for (int32 x = 0; x < disallowedCount; x++) {
fDisallowedChars->AddItem(
reinterpret_cast<void *>(disallowedChars[x]));
}
}
ssize_t runSize = 0;
const void *flattenedRun = NULL;
if (archive->FindData("_runs", B_RAW_TYPE, &flattenedRun, &runSize) == B_OK) {
text_run_array *runArray = UnflattenRunArray(flattenedRun, (int32 *)&runSize);
if (archive->FindData("_runs", B_RAW_TYPE, &flattenedRun, &runSize)
== B_OK) {
text_run_array *runArray = UnflattenRunArray(flattenedRun,
(int32*)&runSize);
if (runArray) {
SetRunArray(0, TextLength(), runArray);
FreeRunArray(runArray);
@ -305,7 +365,8 @@ BTextView::~BTextView()
}
/*! \brief Static function used to istantiate a BTextView object from the given BMessage.
/*! \brief Static function used to istantiate a BTextView object from the given
BMessage.
\param archive The BMessage from which the object shall be created.
\return A constructed BTextView as a BArchivable object.
*/
@ -458,7 +519,7 @@ BTextView::MouseDown(BPoint where)
_StopMouseTracking();
BMessenger messenger(this);
fTrackingMouse = new (nothrow) _BTextTrackState_(messenger);
fTrackingMouse = new (nothrow) TextTrackState(messenger);
if (fTrackingMouse == NULL)
return;
@ -477,12 +538,15 @@ BTextView::MouseDown(BPoint where)
bigtime_t clickSpeed = 0;
get_click_speed(&clickSpeed);
bool multipleClick = false;
if (clickTime - fClickTime < clickSpeed && fClickOffset == fTrackingMouse->clickOffset)
if (clickTime - fClickTime < clickSpeed
&& fClickOffset == fTrackingMouse->clickOffset) {
multipleClick = true;
}
fWhere = where;
SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS,
B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
if (fSelStart != fSelEnd && !fTrackingMouse->shiftDown && !multipleClick) {
BRegion region;
@ -518,7 +582,8 @@ BTextView::MouseDown(BPoint where)
delete fClickRunner;
BMessenger messenger(this);
fClickRunner = new (nothrow) BMessageRunner(messenger, &message, clickSpeed, 1);
fClickRunner = new (nothrow) BMessageRunner(messenger, &message,
clickSpeed, 1);
}
@ -688,7 +753,8 @@ BTextView::KeyDown(const char *bytes, int32 numBytes)
default:
// if the character is not allowed, bail out.
if (fDisallowedChars
&& fDisallowedChars->HasItem(reinterpret_cast<void *>((uint32)keyPressed))) {
&& fDisallowedChars->HasItem(
reinterpret_cast<void *>((uint32)keyPressed))) {
beep();
return;
}
@ -805,9 +871,10 @@ BTextView::MessageReceived(BMessage *message)
case B_INPUT_METHOD_STARTED:
{
BMessenger messenger;
if (message->FindMessenger("be:reply_to", &messenger) == B_OK) {
if (message->FindMessenger("be:reply_to", &messenger)
== B_OK) {
ASSERT(fInline == NULL);
fInline = new _BInlineInput_(messenger);
fInline = new InlineInput(messenger);
}
break;
}
@ -971,7 +1038,8 @@ BTextView::SetText(const char *inText, const text_run_array *inRuns)
void
BTextView::SetText(const char *inText, int32 inLength, const text_run_array *inRuns)
BTextView::SetText(const char *inText, int32 inLength,
const text_run_array *inRuns)
{
_CancelInputMethod();
@ -1048,7 +1116,7 @@ void
BTextView::Insert(const char *inText, const text_run_array *inRuns)
{
if (inText != NULL)
_DoInsertText(inText, strlen(inText), fSelStart, inRuns, NULL);
_DoInsertText(inText, strlen(inText), fSelStart, inRuns);
}
@ -1058,8 +1126,7 @@ BTextView::Insert(const char *inText, int32 inLength,
{
if (inText != NULL && inLength > 0) {
int32 realLength = strlen(inText);
_DoInsertText(inText, min_c(inLength, realLength), fSelStart, inRuns,
NULL);
_DoInsertText(inText, min_c(inLength, realLength), fSelStart, inRuns);
}
}
@ -1073,7 +1140,7 @@ BTextView::Insert(int32 startOffset, const char *inText, int32 inLength,
// do we really need to do anything?
if (inText != NULL && inLength > 0) {
int32 realLength = strlen(inText);
_DoInsertText(inText, min_c(inLength, realLength), startOffset, inRuns, NULL);
_DoInsertText(inText, min_c(inLength, realLength), startOffset, inRuns);
}
}
@ -1239,8 +1306,8 @@ BTextView::Copy(BClipboard *clipboard)
int32 size;
if (fStylable) {
text_run_array *runArray = RunArray(fSelStart, fSelEnd, &size);
clip->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
runArray, size);
clip->AddData("application/x-vnd.Be-text_run_array",
B_MIME_TYPE, runArray, size);
FreeRunArray(runArray);
}
clipboard->Commit();
@ -1259,35 +1326,38 @@ BTextView::Paste(BClipboard *clipboard)
CALLED();
_CancelInputMethod();
if (clipboard->Lock()) {
BMessage *clip = clipboard->Data();
if (clip != NULL) {
const char *text = NULL;
ssize_t len = 0;
if (!clipboard->Lock())
return;
if (clip->FindData("text/plain", B_MIME_TYPE,
(const void **)&text, &len) == B_OK) {
text_run_array *runArray = NULL;
ssize_t runLen = 0;
BMessage *clip = clipboard->Data();
if (clip != NULL) {
const char *text = NULL;
ssize_t len = 0;
if (fStylable)
clip->FindData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
(const void **)&runArray, &runLen);
if (clip->FindData("text/plain", B_MIME_TYPE,
(const void **)&text, &len) == B_OK) {
text_run_array *runArray = NULL;
ssize_t runLen = 0;
if (fUndo) {
delete fUndo;
fUndo = new _BPasteUndoBuffer_(this, text, len, runArray, runLen);
}
if (fStylable) {
clip->FindData("application/x-vnd.Be-text_run_array",
B_MIME_TYPE, (const void **)&runArray, &runLen);
}
if (fSelStart != fSelEnd)
Delete();
if (fUndo) {
delete fUndo;
fUndo = new _BPasteUndoBuffer_(this, text, len, runArray,
runLen);
}
Insert(text, len, runArray);
}
}
if (fSelStart != fSelEnd)
Delete();
clipboard->Unlock();
Insert(text, len, runArray);
}
}
clipboard->Unlock();
}
@ -1416,8 +1486,10 @@ BTextView::SelectAll()
/*! \brief Gets the current selection.
\param outStart A pointer to an int32 which will contain the selection start's offset.
\param outEnd A pointer to an int32 which will contain the selection end's offset.
\param outStart A pointer to an int32 which will contain the selection
start's offset.
\param outEnd A pointer to an int32 which will contain the selection
end's offset.
*/
void
BTextView::GetSelection(int32 *outStart, int32 *outEnd) const
@ -1437,15 +1509,16 @@ BTextView::GetSelection(int32 *outStart, int32 *outEnd) const
void
BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode, const rgb_color *inColor)
BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode,
const rgb_color *inColor)
{
SetFontAndColor(fSelStart, fSelEnd, inFont, inMode, inColor);
}
void
BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont* font,
uint32 fontMode, const rgb_color* color)
BTextView::SetFontAndColor(int32 startOffset, int32 endOffset,
const BFont* font, uint32 fontMode, const rgb_color* color)
{
CALLED();
@ -1493,21 +1566,25 @@ BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont* font
void
BTextView::GetFontAndColor(int32 inOffset, BFont *outFont, rgb_color *outColor) const
BTextView::GetFontAndColor(int32 inOffset, BFont *outFont,
rgb_color *outColor) const
{
fStyles->GetStyle(inOffset, outFont, outColor);
}
void
BTextView::GetFontAndColor(BFont *outFont, uint32 *outMode, rgb_color *outColor, bool *outEqColor) const
BTextView::GetFontAndColor(BFont *outFont, uint32 *outMode, rgb_color
*outColor, bool *outEqColor) const
{
fStyles->ContinuousGetStyle(outFont, outMode, outColor, outEqColor, fSelStart, fSelEnd);
fStyles->ContinuousGetStyle(outFont, outMode, outColor, outEqColor,
fSelStart, fSelEnd);
}
void
BTextView::SetRunArray(int32 startOffset, int32 endOffset, const text_run_array *inRuns)
BTextView::SetRunArray(int32 startOffset, int32 endOffset,
const text_run_array *inRuns)
{
CALLED();
@ -1532,7 +1609,8 @@ BTextView::SetRunArray(int32 startOffset, int32 endOffset, const text_run_array
text_run_array *
BTextView::RunArray(int32 startOffset, int32 endOffset, int32 *outSize) const
{
STEStyleRange* styleRange = fStyles->GetStyleRange(startOffset, endOffset - 1);
STEStyleRange* styleRange = fStyles->GetStyleRange(startOffset,
endOffset - 1);
if (styleRange == NULL)
return NULL;
@ -1575,8 +1653,8 @@ BTextView::LineAt(BPoint point) const
/*! \brief Returns the location of the character at the given offset.
\param inOffset The offset of the character.
\param outHeight Here the function will put the height of the character at the
given offset.
\param outHeight Here the function will put the height of the character
at the given offset.
\return A BPoint which is the location of the character.
*/
BPoint
@ -1608,7 +1686,8 @@ BTextView::PointAt(int32 inOffset, float *outHeight) const
height = (line + 1)->origin - line->origin;
// special case: go down one line if inOffset is a newline
if (inOffset == textLength && fText->RealCharAt(inOffset - 1) == B_ENTER) {
if (inOffset == textLength && fText->RealCharAt(inOffset - 1)
== B_ENTER) {
result.y += height;
height = LineHeight(CountLines() - 1);
@ -1694,8 +1773,9 @@ BTextView::OffsetAt(BPoint point) const
point.x -= fTextRect.left;
point.x = max_c(point.x, 0.0);
// TODO: The following code isn't very efficient because it always starts from the left end,
// so when the point is near the right end it's very slow.
// TODO: The following code isn't very efficient, because it always starts
// from the left end, so when the point is near the right end it's very
// slow.
int32 offset = line->offset;
const int32 limit = (line + 1)->offset;
float location = 0;
@ -1774,7 +1854,8 @@ BTextView::FindWord(int32 inOffset, int32 *outFromOffset, int32 *outToOffset)
// check to the right
int32 textLen = TextLength();
for (offset = inOffset; offset < textLen; offset = _NextInitialByte(offset)) {
for (offset = inOffset; offset < textLen;
offset = _NextInitialByte(offset)) {
if (_CharClassification(offset) != charType)
break;
}
@ -1784,7 +1865,8 @@ BTextView::FindWord(int32 inOffset, int32 *outFromOffset, int32 *outToOffset)
}
/*! \brief Returns true if the character at the given offset can be the last character in a line.
/*! \brief Returns true if the character at the given offset can be the last
character in a line.
\param offset The offset of the character.
\return true if the character can be the last of a line, false if not.
*/
@ -1899,7 +1981,8 @@ BTextView::GetTextRegion(int32 startOffset, int32 endOffset, BRegion *outRegion)
}
/*! \brief Scrolls the text so that the character at "inOffset" is within the visible range.
/*! \brief Scrolls the text so that the character at "inOffset" is within the
visible range.
\param inOffset The offset of the character.
*/
void
@ -1938,8 +2021,8 @@ BTextView::ScrollToOffset(int32 inOffset)
}
/*! \brief Scrolls the text so that the character which begins the current selection
is within the visible range.
/*! \brief Scrolls the text so that the character which begins the current
selection is within the visible range.
\param inOffset The offset of the character.
*/
void
@ -1969,7 +2052,8 @@ BTextView::Highlight(int32 startOffset, int32 endOffset)
}
/*! \brief Sets the BTextView's text rectangle to be the same as the passed rect.
/*! \brief Sets the BTextView's text rectangle to be the same as the passed
rect.
\param rect A BRect.
*/
void
@ -1996,6 +2080,39 @@ BTextView::TextRect() const
}
/*! \brief Sets the insets from the bounds for the BTextView's text rectangle.
*/
void
BTextView::SetInsets(float _leftInset, float topInset, float rightInset,
float bottomInset)
{
// TODO:
// * store in layout data
// * invalidate layout
// * invalidate view
}
/*! \brief Returns the insets from the bounds for the BTextView's text
rectangle.
*/
void
BTextView::GetInsets(float* _leftInset, float* _topInset, float* _rightInset,
float* _bottomInset) const
{
BRect bounds = Bounds();
if (_leftInset)
*_leftInset = fTextRect.left - bounds.left;
if (_topInset)
*_topInset = fTextRect.top - bounds.top;
if (_rightInset)
*_rightInset = bounds.right - fTextRect.right;
if (_bottomInset)
*_bottomInset = bounds.bottom - fTextRect.bottom;
}
/*! \brief Sets whether the BTextView accepts multiple character styles.
*/
void
@ -2290,12 +2407,14 @@ BTextView::ColorSpace() const
}
/*! \brief Gives to the BTextView the ability to automatically resize itself when needed.
/*! \brief Gives to the BTextView the ability to automatically resize itself
when needed.
\param resize If true, the BTextView will automatically resize itself.
\param resizeView The BTextView's parent view, it's the view which resizes itself.
The resizing mechanism is alternative to the BView resizing. The container view
(the one passed to this function) should not automatically resize itself when the parent is
resized.
\param resizeView The BTextView's parent view, it's the view which resizes
itself.
The resizing mechanism is alternative to the BView resizing. The container
view (the one passed to this function) should not automatically resize
itself when the parent is resized.
*/
void
BTextView::MakeResizable(bool resize, BView *resizeView)
@ -2344,7 +2463,7 @@ void
BTextView::SetDoesUndo(bool undo)
{
if (undo && fUndo == NULL)
fUndo = new _BUndoBuffer_(this, B_UNDO_UNAVAILABLE);
fUndo = new UndoBuffer(this, B_UNDO_UNAVAILABLE);
else if (!undo && fUndo != NULL) {
delete fUndo;
fUndo = NULL;
@ -2491,12 +2610,16 @@ BTextView::FlattenRunArray(const text_run_array* runArray, int32* _size)
array->count = B_HOST_TO_BENDIAN_INT32(runArray->count);
for (int32 i = 0; i < runArray->count; i++) {
array->styles[i].offset = B_HOST_TO_BENDIAN_INT32(runArray->runs[i].offset);
array->styles[i].offset = B_HOST_TO_BENDIAN_INT32(
runArray->runs[i].offset);
runArray->runs[i].font.GetFamilyAndStyle(&array->styles[i].family,
&array->styles[i].style);
array->styles[i].size = B_HOST_TO_BENDIAN_FLOAT(runArray->runs[i].font.Size());
array->styles[i].shear = B_HOST_TO_BENDIAN_FLOAT(runArray->runs[i].font.Shear());
array->styles[i].face = B_HOST_TO_BENDIAN_INT16(runArray->runs[i].font.Face());
array->styles[i].size = B_HOST_TO_BENDIAN_FLOAT(
runArray->runs[i].font.Size());
array->styles[i].shear = B_HOST_TO_BENDIAN_FLOAT(
runArray->runs[i].font.Shear());
array->styles[i].face = B_HOST_TO_BENDIAN_INT16(
runArray->runs[i].font.Face());
array->styles[i].red = runArray->runs[i].color.red;
array->styles[i].green = runArray->runs[i].color.green;
array->styles[i].blue = runArray->runs[i].color.blue;
@ -2519,7 +2642,8 @@ BTextView::UnflattenRunArray(const void* data, int32* _size)
flattened_text_run_array *array = (flattened_text_run_array *)data;
if (B_BENDIAN_TO_HOST_INT32(array->magic) != kFlattenedTextRunArrayMagic
|| B_BENDIAN_TO_HOST_INT32(array->version) != kFlattenedTextRunArrayVersion) {
|| B_BENDIAN_TO_HOST_INT32(array->version)
!= kFlattenedTextRunArrayVersion) {
if (_size)
*_size = 0;
@ -2533,15 +2657,18 @@ BTextView::UnflattenRunArray(const void* data, int32* _size)
return NULL;
for (int32 i = 0; i < count; i++) {
runArray->runs[i].offset = B_BENDIAN_TO_HOST_INT32(array->styles[i].offset);
runArray->runs[i].offset = B_BENDIAN_TO_HOST_INT32(
array->styles[i].offset);
// Set family and style independently from each other, so that
// even if the family doesn't exist, we try to preserve the style
runArray->runs[i].font.SetFamilyAndStyle(array->styles[i].family, NULL);
runArray->runs[i].font.SetFamilyAndStyle(NULL, array->styles[i].style);
runArray->runs[i].font.SetSize(B_BENDIAN_TO_HOST_FLOAT(array->styles[i].size));
runArray->runs[i].font.SetShear(B_BENDIAN_TO_HOST_FLOAT(array->styles[i].shear));
runArray->runs[i].font.SetSize(B_BENDIAN_TO_HOST_FLOAT(
array->styles[i].size));
runArray->runs[i].font.SetShear(B_BENDIAN_TO_HOST_FLOAT(
array->styles[i].shear));
uint16 face = B_BENDIAN_TO_HOST_INT16(array->styles[i].face);
if (face != B_REGULAR_FACE) {
@ -2677,6 +2804,9 @@ void BTextView::_ReservedTextView11() {}
void BTextView::_ReservedTextView12() {}
// #pragma mark -
/*! \brief Inits the BTextView object.
\param textRect The BTextView's text rect.
\param initialFont The font which the BTextView will use.
@ -2697,14 +2827,19 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont,
if (initialColor == NULL)
initialColor = &kBlackColor;
fText = new _BTextGapBuffer_;
fLines = new _BLineBuffer_;
fStyles = new _BStyleBuffer_(&font, initialColor);
fText = new TextGapBuffer;
fLines = new LineBuffer;
fStyles = new StyleBuffer(&font, initialColor);
// We put these here instead of in the constructor initializer list
// to have less code duplication, and a single place where to do changes
// if needed.
fTextRect = textRect;
// NOTE: The only places where text rect is changed:
// * width is possibly adjusted in _AutoResize(),
// * height is adjusted in _RecalculateLineBreaks().
// When used within the layout management framework, the
// text rect is changed to maintain constant insets.
fMinTextRectWidth = fTextRect.Width();
fSelStart = fSelEnd = 0;
fCaretVisible = false;
@ -2733,7 +2868,6 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont,
fDragRunner = NULL;
fClickRunner = NULL;
fTrackingMouse = NULL;
fTextChange = NULL;
}
@ -3022,7 +3156,8 @@ BTextView::_HandleAlphaKey(const char *bytes, int32 numBytes)
{
// TODO: block input if not editable (Andrew)
if (fUndo) {
_BTypingUndoBuffer_ *undoBuffer = dynamic_cast<_BTypingUndoBuffer_ *>(fUndo);
_BTypingUndoBuffer_ *undoBuffer
= dynamic_cast<_BTypingUndoBuffer_ *>(fUndo);
if (!undoBuffer) {
delete fUndo;
fUndo = undoBuffer = new _BTypingUndoBuffer_(this);
@ -3047,12 +3182,12 @@ BTextView::_HandleAlphaKey(const char *bytes, int32 numBytes)
offset++;
if (start != offset)
_DoInsertText(Text() + start, offset - start, fSelStart, NULL, NULL);
_DoInsertText(Text() + start, offset - start, fSelStart, NULL);
_DoInsertText(bytes, numBytes, fSelStart, NULL, NULL);
_DoInsertText(bytes, numBytes, fSelStart, NULL);
} else
_DoInsertText(bytes, numBytes, fSelStart, NULL, NULL);
_DoInsertText(bytes, numBytes, fSelStart, NULL);
fClickOffset = fSelEnd;
@ -3144,7 +3279,8 @@ BTextView::_RecalculateLineBreaks(int32 *startLine, int32 *endLine)
{
// are we insane?
*startLine = (*startLine < 0) ? 0 : *startLine;
*endLine = (*endLine > fLines->NumLines() - 1) ? fLines->NumLines() - 1 : *endLine;
*endLine = (*endLine > fLines->NumLines() - 1) ? fLines->NumLines() - 1
: *endLine;
int32 textLength = fText->Length();
int32 lineIndex = (*startLine > 0) ? *startLine - 1 : 0;
@ -3253,7 +3389,8 @@ BTextView::_FindLineBreak(int32 fromOffset, float *outAscent, float *outDescent,
offset += fromOffset;
offset = (offset < limit) ? offset + 1 : limit;
*ioWidth = _StyledWidth(fromOffset, offset - fromOffset, outAscent, outDescent);
*ioWidth = _StyledWidth(fromOffset, offset - fromOffset, outAscent,
outDescent);
return offset;
}
@ -3393,8 +3530,10 @@ BTextView::_FindLineBreak(int32 fromOffset, float *outAscent, float *outDescent,
/*! \brief Calculate the width of the text within the given limits.
\param fromOffset The offset where to start.
\param length The length of the text to examine.
\param outAscent A pointer to a float which will contain the maximum ascent.
\param outDescent A pointer to a float which will contain the maximum descent.
\param outAscent A pointer to a float which will contain the maximum
ascent.
\param outDescent A pointer to a float which will contain the maximum
descent.
\return The width for the text within the given limits.
*/
float
@ -3418,9 +3557,7 @@ BTextView::_StyledWidth(int32 fromOffset, int32 length, float *outAscent,
#if USE_WIDTHBUFFER
// Use _BWidthBuffer_ if possible
if (sWidths != NULL) {
LockWidthBuffer();
result += sWidths->StringWidth(*fText, fromOffset, numChars, font);
UnlockWidthBuffer();
} else {
#endif
const char* text = fText->GetString(fromOffset, &numChars);
@ -3471,7 +3608,7 @@ BTextView::_ActualTabWidth(float location) const
void
BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset,
const text_run_array *inRuns, _BTextChangeResult_ *outResult)
const text_run_array *inRuns)
{
_CancelInputMethod();
@ -3502,15 +3639,16 @@ BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset,
void
BTextView::_DoDeleteText(int32 fromOffset, int32 toOffset, _BTextChangeResult_ *outResult)
BTextView::_DoDeleteText(int32 fromOffset, int32 toOffset)
{
CALLED();
}
void
BTextView::_DrawLine(BView *view, const int32 &lineNum, const int32 &startOffset,
const bool &erase, BRect &eraseRect, BRegion &inputRegion)
BTextView::_DrawLine(BView *view, const int32 &lineNum,
const int32 &startOffset, const bool &erase, BRect &eraseRect,
BRegion &inputRegion)
{
STELine *line = (*fLines)[lineNum];
float startLeft = fTextRect.left;
@ -3698,13 +3836,16 @@ BTextView::_DrawLines(int32 startLine, int32 endLine, int32 startOffset,
}
BRegion inputRegion;
if (fInline != NULL && fInline->IsActive())
GetTextRegion(fInline->Offset(), fInline->Offset() + fInline->Length(), &inputRegion);
if (fInline != NULL && fInline->IsActive()) {
GetTextRegion(fInline->Offset(), fInline->Offset() + fInline->Length(),
&inputRegion);
}
//BPoint leftTop(startLeft, line->origin);
for (int32 lineNum = startLine; lineNum <= endLine; lineNum++) {
const bool eraseThisLine = erase && lineNum >= startEraseLine;
_DrawLine(view, lineNum, startOffset, eraseThisLine, eraseRect, inputRegion);
_DrawLine(view, lineNum, startOffset, eraseThisLine, eraseRect,
inputRegion);
startOffset = -1;
// Set this to -1 so the next iteration will use the line offset
}
@ -3776,8 +3917,8 @@ BTextView::_InvertCaret()
/*! \brief Place the dragging caret at the given offset.
\param offset The offset (zero based within the object's text) where to place
the dragging caret. If it's -1, hide the caret.
\param offset The offset (zero based within the object's text) where to
place the dragging caret. If it's -1, hide the caret.
*/
void
BTextView::_DragCaret(int32 offset)
@ -3852,13 +3993,16 @@ BTextView::_PerformMouseMoved(BPoint where, uint32 code)
switch (fClickCount) {
case 0:
// triple click, select line by line
fTrackingMouse->selStart = (*fLines)[LineAt(fTrackingMouse->selStart)]->offset;
fTrackingMouse->selEnd = (*fLines)[LineAt(fTrackingMouse->selEnd) + 1]->offset;
fTrackingMouse->selStart
= (*fLines)[LineAt(fTrackingMouse->selStart)]->offset;
fTrackingMouse->selEnd
= (*fLines)[LineAt(fTrackingMouse->selEnd) + 1]->offset;
break;
case 2:
// double click, select word by word
FindWord(currentOffset, &fTrackingMouse->selStart, &fTrackingMouse->selEnd);
FindWord(currentOffset, &fTrackingMouse->selStart,
&fTrackingMouse->selEnd);
break;
default:
@ -3986,16 +4130,18 @@ BTextView::_MessageDropped(BMessage *inMessage, BPoint where, BPoint offset)
ssize_t dataLen = 0;
const char *text = NULL;
if (inMessage->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &dataLen) == B_OK) {
if (inMessage->FindData("text/plain", B_MIME_TYPE, (const void **)&text,
&dataLen) == B_OK) {
text_run_array *runArray = NULL;
ssize_t runLen = 0;
if (fStylable)
inMessage->FindData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
(const void **)&runArray, &runLen);
inMessage->FindData("application/x-vnd.Be-text_run_array",
B_MIME_TYPE, (const void **)&runArray, &runLen);
if (fUndo) {
delete fUndo;
fUndo = new _BDropUndoBuffer_(this, text, dataLen, runArray, runLen, dropOffset, internalDrop);
fUndo = new _BDropUndoBuffer_(this, text, dataLen, runArray,
runLen, dropOffset, internalDrop);
}
if (internalDrop) {
@ -4044,7 +4190,8 @@ BTextView::_PerformAutoScrolling()
// Always scroll vertically line by line or by multiples of that
// based on the distance of the cursor from the border of the view
// TODO: Refine this, I can't even remember how beos works here
scrollBy.y = lineHeight > 0 ? lineHeight * (int32)(floorf(vertDiff) / lineHeight) : 0;
scrollBy.y = lineHeight > 0 ? lineHeight * (int32)(floorf(vertDiff)
/ lineHeight) : 0;
if (bounds.bottom + scrollBy.y > fTextRect.Height())
scrollBy.y = fTextRect.Height() - bounds.bottom;
@ -4112,7 +4259,7 @@ BTextView::_AutoResize(bool redraw)
return;
if (fContainerView != NULL) {
// NOTE: This container view thing is only used by Tracker
// NOTE: This container view thing is only used by Tracker.
// move container view if not left aligned
if (fAlignment == B_ALIGN_CENTER) {
if (fmod(ceilf(newWidth - oldWidth), 2.0) != 0.0)
@ -4132,7 +4279,8 @@ BTextView::_AutoResize(bool redraw)
// erase any potential left over outside the text rect
// (can only be on right hand side)
BRect dirty(fTextRect.right + 1, fTextRect.top, bounds.right, fTextRect.bottom);
BRect dirty(fTextRect.right + 1, fTextRect.top, bounds.right,
fTextRect.bottom);
if (dirty.IsValid()) {
SetLowColor(ViewColor());
FillRect(dirty, B_SOLID_LOW);
@ -4319,7 +4467,8 @@ BTextView::_CharClassification(int32 offset) const
}
/*! \brief Returns the offset of the next UTF8 character within the BTextView's text.
/*! \brief Returns the offset of the next UTF8 character within the BTextView's
text.
\param offset The offset where to start looking.
\return The offset of the next UTF8 character.
*/
@ -4337,7 +4486,8 @@ BTextView::_NextInitialByte(int32 offset) const
}
/*! \brief Returns the offset of the previous UTF8 character within the BTextView's text.
/*! \brief Returns the offset of the previous UTF8 character within the
BTextView's text.
\param offset The offset where to start looking.
\return The offset of the previous UTF8 character.
*/
@ -4359,7 +4509,8 @@ BTextView::_PreviousInitialByte(int32 offset) const
bool
BTextView::_GetProperty(BMessage *specifier, int32 form, const char *property, BMessage *reply)
BTextView::_GetProperty(BMessage *specifier, int32 form, const char *property,
BMessage *reply)
{
CALLED();
if (strcmp(property, "selection") == 0) {
@ -4470,9 +4621,9 @@ BTextView::_HandleInputMethodChanged(BMessage *message)
be_app->ObscureCursor();
// If we find the "be:confirmed" boolean (and the boolean is true),
// it means it's over for now, so the current _BInlineInput_ object
// should become inactive. We will probably receive a B_INPUT_METHOD_STOPPED
// message after this one.
// it means it's over for now, so the current InlineInput object
// should become inactive. We will probably receive a
// B_INPUT_METHOD_STOPPED message after this one.
bool confirmed;
if (message->FindBool("be:confirmed", &confirmed) != B_OK)
confirmed = false;
@ -4495,15 +4646,17 @@ BTextView::_HandleInputMethodChanged(BMessage *message)
if (!confirmed && !fInline->IsActive())
fInline->SetActive(true);
// Get the clauses, and pass them to the _BInlineInput_ object
// TODO: Find out if what we did it's ok, currently we don't consider clauses
// at all, while the bebook says we should; though the visual effect we obtained
// seems correct. Weird.
// Get the clauses, and pass them to the InlineInput object
// TODO: Find out if what we did it's ok, currently we don't consider
// clauses at all, while the bebook says we should; though the visual
// effect we obtained seems correct. Weird.
int32 clauseCount = 0;
int32 clauseStart;
int32 clauseEnd;
while (message->FindInt32("be:clause_start", clauseCount, &clauseStart) == B_OK &&
message->FindInt32("be:clause_end", clauseCount, &clauseEnd) == B_OK) {
while (message->FindInt32("be:clause_start", clauseCount, &clauseStart)
== B_OK
&& message->FindInt32("be:clause_end", clauseCount, &clauseEnd)
== B_OK) {
if (!fInline->AddClause(clauseStart, clauseEnd))
break;
clauseCount++;
@ -4566,11 +4719,12 @@ BTextView::_CancelInputMethod()
if (!fInline)
return;
_BInlineInput_ *inlineInput = fInline;
InlineInput *inlineInput = fInline;
fInline = NULL;
if (inlineInput->IsActive() && Window()) {
_Refresh(inlineInput->Offset(), fText->Length() - inlineInput->Offset(), true, false);
_Refresh(inlineInput->Offset(), fText->Length() - inlineInput->Offset(),
true, false);
BMessage message(B_INPUT_METHOD_EVENT);
message.AddInt32("be:opcode", B_INPUT_METHOD_STOPPED);
@ -4581,30 +4735,10 @@ BTextView::_CancelInputMethod()
}
/*! \brief Locks the static _BWidthBuffer_ object to be able to access it safely.
*/
void
BTextView::LockWidthBuffer()
{
if (atomic_add(&sWidthAtom, 1) > 0) {
while (acquire_sem(sWidthSem) == B_INTERRUPTED)
;
}
}
// #pragma mark - BTextView::TextTrackState
/*! \brief Unlocks the static _BWidthBuffer_ object.
*/
void
BTextView::UnlockWidthBuffer()
{
if (atomic_add(&sWidthAtom, -1) > 1)
release_sem(sWidthSem);
}
// _BTextTrackState_
_BTextTrackState_::_BTextTrackState_(BMessenger messenger)
BTextView::TextTrackState::TextTrackState(BMessenger messenger)
:
clickOffset(0),
shiftDown(false),
@ -4618,14 +4752,14 @@ _BTextTrackState_::_BTextTrackState_(BMessenger messenger)
}
_BTextTrackState_::~_BTextTrackState_()
BTextView::TextTrackState::~TextTrackState()
{
delete fRunner;
}
void
_BTextTrackState_::SimulateMouseMovement(BTextView *textView)
BTextView::TextTrackState::SimulateMouseMovement(BTextView *textView)
{
BPoint where;
ulong buttons;

View File

@ -23,10 +23,10 @@ struct clause
};
/*! \brief Constructs a _BInlineInput_ object.
/*! \brief Constructs a InlineInput object.
\param messenger The BMessenger of the input server method addon.
*/
_BInlineInput_::_BInlineInput_(BMessenger messenger)
BTextView::InlineInput::InlineInput(BMessenger messenger)
:
fMessenger(messenger),
fActive(false),
@ -42,7 +42,7 @@ _BInlineInput_::_BInlineInput_(BMessenger messenger)
/*! \brief Destructs the object, free the allocated memory.
*/
_BInlineInput_::~_BInlineInput_()
BTextView::InlineInput::~InlineInput()
{
ResetClauses();
}
@ -52,21 +52,21 @@ _BInlineInput_::~_BInlineInput_()
which requested the transaction.
*/
const BMessenger *
_BInlineInput_::Method() const
BTextView::InlineInput::Method() const
{
return &fMessenger;
}
bool
_BInlineInput_::IsActive() const
BTextView::InlineInput::IsActive() const
{
return fActive;
}
void
_BInlineInput_::SetActive(bool active)
BTextView::InlineInput::SetActive(bool active)
{
fActive = active;
}
@ -75,7 +75,7 @@ _BInlineInput_::SetActive(bool active)
/*! \brief Return the length of the inputted text.
*/
int32
_BInlineInput_::Length() const
BTextView::InlineInput::Length() const
{
return fLength;
}
@ -86,7 +86,7 @@ _BInlineInput_::Length() const
B_INPUT_METHOD_CHANGED BMessage.
*/
void
_BInlineInput_::SetLength(int32 len)
BTextView::InlineInput::SetLength(int32 len)
{
fLength = len;
}
@ -95,7 +95,7 @@ _BInlineInput_::SetLength(int32 len)
/*! \brief Returns the offset into the BTextView of the text.
*/
int32
_BInlineInput_::Offset() const
BTextView::InlineInput::Offset() const
{
return fOffset;
}
@ -105,7 +105,7 @@ _BInlineInput_::Offset() const
\param offset The offset where the text has been inserted.
*/
void
_BInlineInput_::SetOffset(int32 offset)
BTextView::InlineInput::SetOffset(int32 offset)
{
fOffset = offset;
}
@ -114,7 +114,7 @@ _BInlineInput_::SetOffset(int32 offset)
/*! \brief Returns the length of the selection, if any.
*/
int32
_BInlineInput_::SelectionLength() const
BTextView::InlineInput::SelectionLength() const
{
return fSelectionLength;
}
@ -124,7 +124,7 @@ _BInlineInput_::SelectionLength() const
\param length The length of the selection.
*/
void
_BInlineInput_::SetSelectionLength(int32 length)
BTextView::InlineInput::SetSelectionLength(int32 length)
{
fSelectionLength = length;
}
@ -133,7 +133,7 @@ _BInlineInput_::SetSelectionLength(int32 length)
/*! \brief Returns the offset into the method string of the selection.
*/
int32
_BInlineInput_::SelectionOffset() const
BTextView::InlineInput::SelectionOffset() const
{
return fSelectionOffset;
}
@ -143,7 +143,7 @@ _BInlineInput_::SelectionOffset() const
\param offset The offset where the selection starts.
*/
void
_BInlineInput_::SetSelectionOffset(int32 offset)
BTextView::InlineInput::SetSelectionOffset(int32 offset)
{
fSelectionOffset = offset;
}
@ -154,7 +154,7 @@ _BInlineInput_::SetSelectionOffset(int32 offset)
\param end The offset into the string where the clause finishes.
*/
bool
_BInlineInput_::AddClause(int32 start, int32 end)
BTextView::InlineInput::AddClause(int32 start, int32 end)
{
void *newData = realloc(fClauses, (fNumClauses + 1) * sizeof(clause));
if (newData == NULL)
@ -175,7 +175,7 @@ _BInlineInput_::AddClause(int32 start, int32 end)
\return \c true if the clause exists, \c false if not.
*/
bool
_BInlineInput_::GetClause(int32 index, int32 *start, int32 *end) const
BTextView::InlineInput::GetClause(int32 index, int32 *start, int32 *end) const
{
bool result = false;
if (index >= 0 && index < fNumClauses) {
@ -192,7 +192,7 @@ _BInlineInput_::GetClause(int32 index, int32 *start, int32 *end) const
int32
_BInlineInput_::CountClauses() const
BTextView::InlineInput::CountClauses() const
{
return fNumClauses;
}
@ -201,7 +201,7 @@ _BInlineInput_::CountClauses() const
/*! \brief Deletes any added clause.
*/
void
_BInlineInput_::ResetClauses()
BTextView::InlineInput::ResetClauses()
{
fNumClauses = 0;
free(fClauses);

View File

@ -10,12 +10,14 @@
#define __INLINEINPUT_H
#include <Messenger.h>
#include <TextView.h>
struct clause;
class _BInlineInput_ {
class BTextView::InlineInput {
public:
_BInlineInput_(BMessenger);
~_BInlineInput_();
InlineInput(BMessenger);
~InlineInput();
const BMessenger *Method() const;

View File

@ -9,33 +9,33 @@
#include "LineBuffer.h"
_BLineBuffer_::_BLineBuffer_()
BTextView::LineBuffer::LineBuffer()
: _BTextViewSupportBuffer_<STELine>(20, 2)
{
}
_BLineBuffer_::~_BLineBuffer_()
BTextView::LineBuffer::~LineBuffer()
{
}
void
_BLineBuffer_::InsertLine(STELine *inLine, int32 index)
BTextView::LineBuffer::InsertLine(STELine *inLine, int32 index)
{
InsertItemsAt(1, index, inLine);
}
void
_BLineBuffer_::RemoveLines(int32 index, int32 count)
BTextView::LineBuffer::RemoveLines(int32 index, int32 count)
{
RemoveItemsAt(count, index);
}
void
_BLineBuffer_::RemoveLineRange(int32 fromOffset, int32 toOffset)
BTextView::LineBuffer::RemoveLineRange(int32 fromOffset, int32 toOffset)
{
int32 fromLine = OffsetToLine(fromOffset);
int32 toLine = OffsetToLine(toOffset);
@ -49,7 +49,7 @@ _BLineBuffer_::RemoveLineRange(int32 fromOffset, int32 toOffset)
int32
_BLineBuffer_::OffsetToLine(int32 offset) const
BTextView::LineBuffer::OffsetToLine(int32 offset) const
{
int32 minIndex = 0;
int32 maxIndex = fItemCount - 1;
@ -71,7 +71,7 @@ _BLineBuffer_::OffsetToLine(int32 offset) const
int32
_BLineBuffer_::PixelToLine(float pixel) const
BTextView::LineBuffer::PixelToLine(float pixel) const
{
int32 minIndex = 0;
int32 maxIndex = fItemCount - 1;
@ -93,7 +93,7 @@ _BLineBuffer_::PixelToLine(float pixel) const
void
_BLineBuffer_::BumpOrigin(float delta, long index)
BTextView::LineBuffer::BumpOrigin(float delta, long index)
{
for (long i = index; i < fItemCount; i++)
fBuffer[i].origin += delta;
@ -101,7 +101,7 @@ _BLineBuffer_::BumpOrigin(float delta, long index)
void
_BLineBuffer_::BumpOffset(int32 delta, int32 index)
BTextView::LineBuffer::BumpOffset(int32 delta, int32 index)
{
for (long i = index; i < fItemCount; i++)
fBuffer[i].offset += delta;

View File

@ -7,6 +7,8 @@
*/
#include <SupportDefs.h>
#include <TextView.h>
#include "TextViewSupportBuffer.h"
struct STELine {
@ -17,12 +19,11 @@ struct STELine {
};
// _BLineBuffer_ class ---------------------------------------------------------
class _BLineBuffer_ : public _BTextViewSupportBuffer_<STELine> {
class BTextView::LineBuffer : public _BTextViewSupportBuffer_<STELine> {
public:
_BLineBuffer_();
virtual ~_BLineBuffer_();
LineBuffer();
virtual ~LineBuffer();
void InsertLine(STELine *inLine, int32 index);
void RemoveLines(int32 index, int32 count = 1);
@ -40,14 +41,14 @@ virtual ~_BLineBuffer_();
inline int32
_BLineBuffer_::NumLines() const
BTextView::LineBuffer::NumLines() const
{
return fItemCount - 1;
}
inline STELine *
_BLineBuffer_::operator[](int32 index) const
BTextView::LineBuffer::operator[](int32 index) const
{
return &fBuffer[index];
}

View File

@ -173,7 +173,7 @@ SetStyleFromMode(uint32 mode, const BFont *fromFont, BFont *toFont,
}
_BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor)
BTextView::StyleBuffer::StyleBuffer(const BFont *inFont, const rgb_color *inColor)
:
fValidNullStyle(true)
{
@ -183,21 +183,21 @@ _BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor)
void
_BStyleBuffer_::InvalidateNullStyle()
BTextView::StyleBuffer::InvalidateNullStyle()
{
fValidNullStyle = false;
}
bool
_BStyleBuffer_::IsValidNullStyle() const
BTextView::StyleBuffer::IsValidNullStyle() const
{
return fValidNullStyle;
}
void
_BStyleBuffer_::SyncNullStyle(int32 offset)
BTextView::StyleBuffer::SyncNullStyle(int32 offset)
{
if (fValidNullStyle || fStyleRunDesc.ItemCount() < 1)
return;
@ -210,7 +210,7 @@ _BStyleBuffer_::SyncNullStyle(int32 offset)
void
_BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
BTextView::StyleBuffer::SetNullStyle(uint32 inMode, const BFont *inFont,
const rgb_color *inColor, int32 offset)
{
if (fValidNullStyle || fStyleRunDesc.ItemCount() < 1)
@ -226,7 +226,7 @@ _BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
void
_BStyleBuffer_::GetNullStyle(const BFont **font, const rgb_color **color) const
BTextView::StyleBuffer::GetNullStyle(const BFont **font, const rgb_color **color) const
{
if (font)
*font = &fNullStyle.font;
@ -236,7 +236,7 @@ _BStyleBuffer_::GetNullStyle(const BFont **font, const rgb_color **color) const
STEStyleRange *
_BStyleBuffer_::AllocateStyleRange(const int32 numStyles) const
BTextView::StyleBuffer::AllocateStyleRange(const int32 numStyles) const
{
STEStyleRange* range = (STEStyleRange *)malloc(sizeof(int32) + sizeof(STEStyleRun) * numStyles);
if (range)
@ -246,7 +246,7 @@ _BStyleBuffer_::AllocateStyleRange(const int32 numStyles) const
void
_BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
BTextView::StyleBuffer::SetStyleRange(int32 fromOffset, int32 toOffset,
int32 textLen, uint32 inMode, const BFont *inFont,
const rgb_color *inColor)
{
@ -323,7 +323,7 @@ _BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
void
_BStyleBuffer_::GetStyle(int32 inOffset, BFont *outFont, rgb_color *outColor) const
BTextView::StyleBuffer::GetStyle(int32 inOffset, BFont *outFont, rgb_color *outColor) const
{
if (fStyleRunDesc.ItemCount() < 1) {
if (outFont)
@ -344,7 +344,7 @@ _BStyleBuffer_::GetStyle(int32 inOffset, BFont *outFont, rgb_color *outColor) co
STEStyleRange*
_BStyleBuffer_::GetStyleRange(int32 startOffset, int32 endOffset) const
BTextView::StyleBuffer::GetStyleRange(int32 startOffset, int32 endOffset) const
{
int32 startIndex = OffsetToRun(startOffset);
int32 endIndex = OffsetToRun(endOffset);
@ -371,7 +371,7 @@ _BStyleBuffer_::GetStyleRange(int32 startOffset, int32 endOffset) const
void
_BStyleBuffer_::RemoveStyleRange(int32 fromOffset, int32 toOffset)
BTextView::StyleBuffer::RemoveStyleRange(int32 fromOffset, int32 toOffset)
{
int32 fromIndex = fStyleRunDesc.OffsetToRun(fromOffset);
int32 toIndex = fStyleRunDesc.OffsetToRun(toOffset) - 1;
@ -406,7 +406,7 @@ _BStyleBuffer_::RemoveStyleRange(int32 fromOffset, int32 toOffset)
void
_BStyleBuffer_::RemoveStyles(int32 index, int32 count)
BTextView::StyleBuffer::RemoveStyles(int32 index, int32 count)
{
for (int32 i = index; i < (index + count); i++)
fStyleRecord.RemoveRecord(fStyleRunDesc[i]->index);
@ -416,11 +416,12 @@ _BStyleBuffer_::RemoveStyles(int32 index, int32 count)
int32
_BStyleBuffer_::Iterate(int32 fromOffset, int32 length, _BInlineInput_ *input,
BTextView::StyleBuffer::Iterate(int32 fromOffset, int32 length,
InlineInput *input,
const BFont **outFont, const rgb_color **outColor,
float *outAscent, float *outDescent, uint32 *) const
{
// TODO: Handle the _BInlineInput_ style here in some way
// TODO: Handle the InlineInput style here in some way
int32 numRuns = fStyleRunDesc.ItemCount();
if (length < 1 || numRuns < 1)
return 0;
@ -448,21 +449,21 @@ _BStyleBuffer_::Iterate(int32 fromOffset, int32 length, _BInlineInput_ *input,
int32
_BStyleBuffer_::OffsetToRun(int32 offset) const
BTextView::StyleBuffer::OffsetToRun(int32 offset) const
{
return fStyleRunDesc.OffsetToRun(offset);
}
void
_BStyleBuffer_::BumpOffset(int32 delta, int32 index)
BTextView::StyleBuffer::BumpOffset(int32 delta, int32 index)
{
fStyleRunDesc.BumpOffset(delta, index);
}
STEStyleRun
_BStyleBuffer_::operator[](int32 index) const
BTextView::StyleBuffer::operator[](int32 index) const
{
STEStyleRun run;
@ -506,7 +507,7 @@ FixupMode(const STEStyle &firstStyle, const STEStyle &otherStyle, uint32 &mode,
void
_BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
BTextView::StyleBuffer::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
rgb_color *outColor, bool *sameColor, int32 fromOffset,
int32 toOffset) const
{

View File

@ -11,6 +11,7 @@
#include <Font.h>
#include <InterfaceDefs.h>
#include <SupportDefs.h>
#include <TextView.h>
#include "TextViewSupportBuffer.h"
@ -92,12 +93,10 @@ _BStyleRecordBuffer_::operator[](int32 index) const
}
class _BInlineInput_;
// _BStyleBuffer_ class --------------------------------------------------------
class _BStyleBuffer_ {
// StyleBuffer class --------------------------------------------------------
class BTextView::StyleBuffer {
public:
_BStyleBuffer_(const BFont *inFont,
StyleBuffer(const BFont *inFont,
const rgb_color *inColor);
void InvalidateNullStyle();
@ -123,7 +122,8 @@ class _BStyleBuffer_ {
void RemoveStyleRange(int32 fromOffset, int32 toOffset);
void RemoveStyles(int32 index, int32 count = 1);
int32 Iterate(int32 fromOffset, int32 length, _BInlineInput_ *,
int32 Iterate(int32 fromOffset, int32 length,
InlineInput* input,
const BFont **outFont = NULL,
const rgb_color **outColor = NULL,
float *outAscent = NULL,
@ -147,21 +147,21 @@ class _BStyleBuffer_ {
inline int32
_BStyleBuffer_::NumRuns() const
BTextView::StyleBuffer::NumRuns() const
{
return fStyleRunDesc.ItemCount();
}
inline const _BStyleRunDescBuffer_&
_BStyleBuffer_::RunBuffer() const
BTextView::StyleBuffer::RunBuffer() const
{
return fStyleRunDesc;
}
inline const _BStyleRecordBuffer_&
_BStyleBuffer_::RecordBuffer() const
BTextView::StyleBuffer::RecordBuffer() const
{
return fStyleRecord;
}

View File

@ -19,7 +19,7 @@
#include "TextGapBuffer.h"
_BTextGapBuffer_::_BTextGapBuffer_()
BTextView::TextGapBuffer::TextGapBuffer()
: fExtraCount(2048),
fItemCount(0),
fBuffer(NULL),
@ -35,7 +35,7 @@ _BTextGapBuffer_::_BTextGapBuffer_()
}
_BTextGapBuffer_::~_BTextGapBuffer_()
BTextView::TextGapBuffer::~TextGapBuffer()
{
free(fBuffer);
free(fScratchBuffer);
@ -43,7 +43,7 @@ _BTextGapBuffer_::~_BTextGapBuffer_()
void
_BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
BTextView::TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
{
if (inNumItems < 1)
return;
@ -66,7 +66,7 @@ _BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, int32 inAtInd
void
_BTextGapBuffer_::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 inAtIndex)
BTextView::TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 inAtIndex)
{
off_t fileSize;
@ -102,7 +102,7 @@ _BTextGapBuffer_::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, in
void
_BTextGapBuffer_::RemoveRange(int32 start, int32 end)
BTextView::TextGapBuffer::RemoveRange(int32 start, int32 end)
{
long inAtIndex = start;
long inNumItems = end - start;
@ -124,7 +124,7 @@ _BTextGapBuffer_::RemoveRange(int32 start, int32 end)
void
_BTextGapBuffer_::MoveGapTo(int32 toIndex)
BTextView::TextGapBuffer::MoveGapTo(int32 toIndex)
{
if (toIndex == fGapIndex)
return;
@ -153,7 +153,7 @@ _BTextGapBuffer_::MoveGapTo(int32 toIndex)
void
_BTextGapBuffer_::SizeGapTo(long inCount)
BTextView::TextGapBuffer::SizeGapTo(long inCount)
{
if (inCount == fGapCount)
return;
@ -169,7 +169,7 @@ _BTextGapBuffer_::SizeGapTo(long inCount)
const char *
_BTextGapBuffer_::GetString(int32 fromOffset, int32 *_numBytes)
BTextView::TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
{
char *result = "";
if (_numBytes == NULL)
@ -226,7 +226,7 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 *_numBytes)
bool
_BTextGapBuffer_::FindChar(char inChar, long fromIndex, long *ioDelta)
BTextView::TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta)
{
long numChars = *ioDelta;
for (long i = 0; i < numChars; i++) {
@ -244,7 +244,7 @@ _BTextGapBuffer_::FindChar(char inChar, long fromIndex, long *ioDelta)
const char *
_BTextGapBuffer_::Text()
BTextView::TextGapBuffer::Text()
{
const char *realText = RealText();
@ -273,7 +273,7 @@ _BTextGapBuffer_::Text()
const char *
_BTextGapBuffer_::RealText()
BTextView::TextGapBuffer::RealText()
{
MoveGapTo(fItemCount);
fBuffer[fItemCount] = '\0';
@ -283,7 +283,7 @@ _BTextGapBuffer_::RealText()
void
_BTextGapBuffer_::GetString(int32 offset, int32 length, char *buffer)
BTextView::TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
{
if (buffer == NULL)
return;
@ -324,14 +324,14 @@ _BTextGapBuffer_::GetString(int32 offset, int32 length, char *buffer)
bool
_BTextGapBuffer_::PasswordMode() const
BTextView::TextGapBuffer::PasswordMode() const
{
return fPasswordMode;
}
void
_BTextGapBuffer_::SetPasswordMode(bool state)
BTextView::TextGapBuffer::SetPasswordMode(bool state)
{
fPasswordMode = state;
}

View File

@ -10,17 +10,21 @@
#define __TEXTGAPBUFFER_H
#include <SupportDefs.h>
#include <TextView.h>
class BFile;
class _BTextGapBuffer_ {
class BTextView::TextGapBuffer {
public:
_BTextGapBuffer_();
virtual ~_BTextGapBuffer_();
TextGapBuffer();
virtual ~TextGapBuffer();
void InsertText(const char *inText, int32 inNumItems, int32 inAtIndex);
void InsertText(BFile *file, int32 fileOffset, int32 amount, int32 atIndex);
void InsertText(const char *inText, int32 inNumItems,
int32 inAtIndex);
void InsertText(BFile *file, int32 fileOffset, int32 amount,
int32 atIndex);
void RemoveRange(int32 start, int32 end);
void MoveGapTo(int32 toIndex);
@ -44,11 +48,11 @@ virtual ~_BTextGapBuffer_();
protected:
int32 fExtraCount; // when realloc()-ing
int32 fItemCount; // logical count
char *fBuffer; // allocated memory
int32 fItemCount; // logical count
char *fBuffer; // allocated memory
int32 fBufferCount; // physical count
int32 fGapIndex; // gap position
int32 fGapCount; // gap count
int32 fGapIndex; // gap position
int32 fGapCount; // gap count
char *fScratchBuffer; // for GetString
int32 fScratchSize; // scratch size
bool fPasswordMode;
@ -56,14 +60,14 @@ protected:
inline int32
_BTextGapBuffer_::Length() const
BTextView::TextGapBuffer::Length() const
{
return fItemCount;
}
inline char
_BTextGapBuffer_::RealCharAt(long index) const
BTextView::TextGapBuffer::RealCharAt(long index) const
{
return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];
}

View File

@ -6,7 +6,7 @@
* Stefano Ceccherini (burton666@libero.it)
*/
//! _BUndoBuffer_ and its subclasses handle different types of Undo operations.
//! UndoBuffer and its subclasses handle different types of Undo operations.
#include "UndoBuffer.h"
@ -22,10 +22,10 @@
// TODO: properly document this file
// #pragma mark - _BUndoBuffer_
// #pragma mark - UndoBuffer
_BUndoBuffer_::_BUndoBuffer_(BTextView *textView, undo_state state)
BTextView::UndoBuffer::UndoBuffer(BTextView *textView, undo_state state)
:
fTextView(textView),
fTextData(NULL),
@ -45,7 +45,7 @@ _BUndoBuffer_::_BUndoBuffer_(BTextView *textView, undo_state state)
}
_BUndoBuffer_::~_BUndoBuffer_()
BTextView::UndoBuffer::~UndoBuffer()
{
free(fTextData);
BTextView::FreeRunArray(fRunArray);
@ -53,7 +53,7 @@ _BUndoBuffer_::~_BUndoBuffer_()
void
_BUndoBuffer_::Undo(BClipboard *clipboard)
BTextView::UndoBuffer::Undo(BClipboard *clipboard)
{
fRedo ? RedoSelf(clipboard) : UndoSelf(clipboard);
@ -62,7 +62,7 @@ _BUndoBuffer_::Undo(BClipboard *clipboard)
undo_state
_BUndoBuffer_::State(bool *redo)
BTextView::UndoBuffer::State(bool *redo)
{
*redo = fRedo;
@ -71,7 +71,7 @@ _BUndoBuffer_::State(bool *redo)
void
_BUndoBuffer_::UndoSelf(BClipboard *clipboard)
BTextView::UndoBuffer::UndoSelf(BClipboard *clipboard)
{
fTextView->Select(fStart, fStart);
fTextView->Insert(fTextData, fTextLength, fRunArray);
@ -80,7 +80,7 @@ _BUndoBuffer_::UndoSelf(BClipboard *clipboard)
void
_BUndoBuffer_::RedoSelf(BClipboard *clipboard)
BTextView::UndoBuffer::RedoSelf(BClipboard *clipboard)
{
}
@ -89,7 +89,7 @@ _BUndoBuffer_::RedoSelf(BClipboard *clipboard)
_BCutUndoBuffer_::_BCutUndoBuffer_(BTextView *textView)
: _BUndoBuffer_(textView, B_UNDO_CUT)
: BTextView::UndoBuffer(textView, B_UNDO_CUT)
{
}
@ -125,7 +125,7 @@ _BCutUndoBuffer_::RedoSelf(BClipboard *clipboard)
_BPasteUndoBuffer_::_BPasteUndoBuffer_(BTextView *textView, const char *text,
int32 textLen, text_run_array *runArray, int32 runArrayLen)
: _BUndoBuffer_(textView, B_UNDO_PASTE),
: BTextView::UndoBuffer(textView, B_UNDO_PASTE),
fPasteText(NULL),
fPasteTextLength(textLen),
fPasteRunArray(NULL)
@ -169,7 +169,7 @@ _BPasteUndoBuffer_::RedoSelf(BClipboard *clipboard)
_BClearUndoBuffer_::_BClearUndoBuffer_(BTextView *textView)
: _BUndoBuffer_(textView, B_UNDO_CLEAR)
: BTextView::UndoBuffer(textView, B_UNDO_CLEAR)
{
}
@ -193,7 +193,7 @@ _BClearUndoBuffer_::RedoSelf(BClipboard *clipboard)
_BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text,
int32 textLen, text_run_array *runArray, int32 runArrayLen,
int32 location, bool internalDrop)
: _BUndoBuffer_(textView, B_UNDO_DROP),
: BTextView::UndoBuffer(textView, B_UNDO_DROP),
fDropText(NULL),
fDropTextLength(textLen),
fDropRunArray(NULL)
@ -249,7 +249,7 @@ _BDropUndoBuffer_::RedoSelf(BClipboard *)
_BTypingUndoBuffer_::_BTypingUndoBuffer_(BTextView *textView)
: _BUndoBuffer_(textView, B_UNDO_TYPING),
: BTextView::UndoBuffer(textView, B_UNDO_TYPING),
fTypedText(NULL),
fTypedStart(fStart),
fTypedEnd(fEnd),

View File

@ -14,10 +14,10 @@
class BClipboard;
class _BUndoBuffer_ {
class BTextView::UndoBuffer {
public:
_BUndoBuffer_(BTextView *, undo_state);
virtual ~_BUndoBuffer_();
UndoBuffer(BTextView *, undo_state);
virtual ~UndoBuffer();
void Undo(BClipboard *);
undo_state State(bool *);
@ -43,7 +43,7 @@ private:
// ******** _BCutUndoBuffer_ *******
class _BCutUndoBuffer_ : public _BUndoBuffer_ {
class _BCutUndoBuffer_ : public BTextView::UndoBuffer {
public:
_BCutUndoBuffer_(BTextView *textView);
~_BCutUndoBuffer_();
@ -54,7 +54,7 @@ protected:
// ******** _BPasteUndoBuffer_ *******
class _BPasteUndoBuffer_ : public _BUndoBuffer_ {
class _BPasteUndoBuffer_ : public BTextView::UndoBuffer {
public:
_BPasteUndoBuffer_(BTextView *, const char *, int32, text_run_array *, int32);
~_BPasteUndoBuffer_();
@ -71,7 +71,7 @@ private:
// ******** _BClearUndoBuffer_ *******
class _BClearUndoBuffer_ : public _BUndoBuffer_ {
class _BClearUndoBuffer_ : public BTextView::UndoBuffer {
public:
_BClearUndoBuffer_(BTextView *textView);
~_BClearUndoBuffer_();
@ -82,7 +82,7 @@ protected:
// ******** _BDropUndoBuffer_ ********
class _BDropUndoBuffer_ : public _BUndoBuffer_ {
class _BDropUndoBuffer_ : public BTextView::UndoBuffer {
public:
_BDropUndoBuffer_(BTextView *, char const *, int32, text_run_array *, int32, int32, bool);
~_BDropUndoBuffer_();
@ -102,7 +102,7 @@ private:
// ******** _BTypingUndoBuffer_ ********
class _BTypingUndoBuffer_ : public _BUndoBuffer_ {
class _BTypingUndoBuffer_ : public BTextView::UndoBuffer {
public:
_BTypingUndoBuffer_(BTextView *);
~_BTypingUndoBuffer_();

View File

@ -13,14 +13,17 @@
#include "TextGapBuffer.h"
#include "WidthBuffer.h"
#include <Autolock.h>
#include <Debug.h>
#include <Font.h>
#include <Locker.h>
#include <stdio.h>
const static uint32 kTableCount = 128;
const static uint32 kInvalidCode = 0xFFFFFFFF;
static BLocker sWidthLocker = BLocker("width buffer lock");
struct hashed_escapement {
@ -56,7 +59,7 @@ CharToCode(const char *text, const int32 charLen)
/*! \brief Initializes the object.
*/
_BWidthBuffer_::_BWidthBuffer_()
BTextView::WidthBuffer::WidthBuffer()
:
_BTextViewSupportBuffer_<_width_table_>(1, 0)
{
@ -65,7 +68,7 @@ _BWidthBuffer_::_BWidthBuffer_()
/*! \brief Frees the allocated resources.
*/
_BWidthBuffer_::~_BWidthBuffer_()
BTextView::WidthBuffer::~WidthBuffer()
{
for (int32 x = 0; x < fItemCount; x++)
delete[] (hashed_escapement *)fBuffer[x].widths;
@ -80,12 +83,14 @@ _BWidthBuffer_::~_BWidthBuffer_()
\return The space (in pixels) required to draw the given string.
*/
float
_BWidthBuffer_::StringWidth(const char *inText, int32 fromOffset, int32 length,
const BFont *inStyle)
BTextView::WidthBuffer::StringWidth(const char *inText, int32 fromOffset,
int32 length, const BFont *inStyle)
{
if (inText == NULL || length == 0)
return 0;
BAutolock _(sWidthLocker);
int32 index = 0;
if (!FindTable(inStyle, &index))
index = InsertTable(inStyle);
@ -137,14 +142,14 @@ _BWidthBuffer_::StringWidth(const char *inText, int32 fromOffset, int32 length,
/*! \brief Returns how much room is required to draw a string in the font.
\param inBuffer The _BTextGapBuffer_ to be examined.
\param fromOffset The offset in the _BTextGapBuffer_ where to begin the examination.
\param inBuffer The BTextView::TextGapBuffer to be examined.
\param fromOffset The offset in the BTextView::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
_BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32 length,
BTextView::WidthBuffer::StringWidth(BTextView::TextGapBuffer &inBuffer, int32 fromOffset, int32 length,
const BFont *inStyle)
{
const char* text = inBuffer.GetString(fromOffset, &length);
@ -160,7 +165,7 @@ _BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32
\c false if not.
*/
bool
_BWidthBuffer_::FindTable(const BFont *inStyle, int32 *outIndex)
BTextView::WidthBuffer::FindTable(const BFont *inStyle, int32 *outIndex)
{
if (inStyle == NULL)
return false;
@ -194,7 +199,7 @@ _BWidthBuffer_::FindTable(const BFont *inStyle, int32 *outIndex)
\return The index of the newly created table.
*/
int32
_BWidthBuffer_::InsertTable(const BFont *font)
BTextView::WidthBuffer::InsertTable(const BFont *font)
{
_width_table_ table;
@ -225,7 +230,7 @@ _BWidthBuffer_::InsertTable(const BFont *font)
for the given charachter, \c false if not.
*/
bool
_BWidthBuffer_::GetEscapement(uint32 value, int32 index, float *escapement)
BTextView::WidthBuffer::GetEscapement(uint32 value, int32 index, float *escapement)
{
const _width_table_ &table = fBuffer[index];
const hashed_escapement *widths = static_cast<hashed_escapement *>(table.widths);
@ -251,7 +256,7 @@ _BWidthBuffer_::GetEscapement(uint32 value, int32 index, float *escapement)
uint32
_BWidthBuffer_::Hash(uint32 val)
BTextView::WidthBuffer::Hash(uint32 val)
{
uint32 shifted = val >> 24;
uint32 result = (val >> 15) + (shifted * 3);
@ -275,7 +280,7 @@ _BWidthBuffer_::Hash(uint32 val)
the size of the font).
*/
float
_BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLen,
BTextView::WidthBuffer::HashEscapements(const char *inText, int32 numChars, int32 textLen,
int32 tableIndex, const BFont *inStyle)
{
ASSERT(inText != NULL);

View File

@ -3,7 +3,7 @@ SubDir HAIKU_TOP src kits tracker ;
SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders shared storage tracker ;
UsePrivateHeaders interface shared storage tracker ;
UseLibraryHeaders icon ;

View File

@ -83,11 +83,11 @@ All rights reserved.
#include "InfoWindow.h"
#include "Utilities.h"
#include "Tests.h"
#include "TextViewSupport.h"
#include "Thread.h"
#include "Tracker.h"
#include "TrackerString.h"
#include "WidgetAttributeText.h"
#include "WidthBuffer.h"
using std::min;
@ -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;
_BWidthBuffer_* BPoseView::sWidthBuffer = new _BWidthBuffer_;
BTextView::WidthBuffer* BPoseView::sWidthBuffer = new BTextView::WidthBuffer;
BFont BPoseView::sCurrentFont;
OffscreenBitmap *BPoseView::sOffscreen = new OffscreenBitmap;
char BPoseView::sMatchString[] = "";

View File

@ -63,7 +63,8 @@ class BRefFilter;
class BList;
// TODO: Get rid of this.
class _BWidthBuffer_;
#include <TextView.h>
// for BTextView::WidthBuffer;
namespace BPrivate {
@ -351,7 +352,7 @@ class BPoseView : public BView {
BMessage *specifier, int32 form, const char *property);
virtual status_t GetSupportedSuites(BMessage *);
// string width calls that use local width caches, faster than usin
// string width calls that use local width caches, faster than using
// the general purpose BView::StringWidth
float StringWidth(const char *) const;
float StringWidth(const char *, int32) const;
@ -664,7 +665,7 @@ class BPoseView : public BView {
BRect fDeskbarFrame;
// TODO: Get rid of this.
static _BWidthBuffer_ *sWidthBuffer;
static BTextView::WidthBuffer *sWidthBuffer;
static OffscreenBitmap *sOffscreen;

View File

@ -31,6 +31,9 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "QueryPoseView.h"
#include <new>
#include <Debug.h>
#include <NodeMonitor.h>
@ -47,11 +50,12 @@ All rights reserved.
#include "FSUtils.h"
#include "MimeTypeList.h"
#include "MimeTypes.h"
#include "QueryPoseView.h"
#include "Tracker.h"
#include <fs_attr.h>
using std::nothrow;
// Currently filtering out Trash doesn't node monitor too well - if you
// remove an item from the Trash, it doesn't show up in the query result
// To do this properly, we would have to node monitor everything BQuery
@ -508,7 +512,9 @@ status_t
QueryEntryListCollection::FetchOneQuery(const BQuery *copyThis,
BHandler *target, BObjectList<BQuery> *list, BVolume *volume)
{
BQuery *query = new BQuery;
BQuery *query = new (nothrow) BQuery;
if (query == NULL)
return B_NO_MEMORY;
// have to fake a copy constructor here because BQuery doesn't have
// a copy constructor