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:
@@ -6,22 +6,15 @@
|
|||||||
#define _TEXTVIEW_H
|
#define _TEXTVIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <BeBuild.h>
|
#include <Locker.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
class BMessageRunner;
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
class BClipboard;
|
class BClipboard;
|
||||||
class BFile;
|
class BFile;
|
||||||
class BList;
|
class BList;
|
||||||
class _BTextGapBuffer_;
|
class BMessageRunner;
|
||||||
class _BLineBuffer_;
|
|
||||||
class _BStyleBuffer_;
|
|
||||||
class _BWidthBuffer_;
|
|
||||||
class _BUndoBuffer_;
|
|
||||||
class _BInlineInput_;
|
|
||||||
class _BTextTrackState_;
|
|
||||||
class _BTextChangeResult_;
|
|
||||||
|
|
||||||
extern "C" status_t _init_interface_kit_();
|
extern "C" status_t _init_interface_kit_();
|
||||||
|
|
||||||
@@ -46,6 +39,7 @@ enum undo_state {
|
|||||||
B_UNDO_DROP
|
B_UNDO_DROP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BTextView : public BView {
|
class BTextView : public BView {
|
||||||
public:
|
public:
|
||||||
BTextView(BRect frame, const char* name,
|
BTextView(BRect frame, const char* name,
|
||||||
@@ -56,6 +50,15 @@ public:
|
|||||||
BRect textRect, const BFont* initialFont,
|
BRect textRect, const BFont* initialFont,
|
||||||
const rgb_color* initialColor,
|
const rgb_color* initialColor,
|
||||||
uint32 resizeMask, uint32 flags);
|
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);
|
BTextView(BMessage* data);
|
||||||
|
|
||||||
virtual ~BTextView();
|
virtual ~BTextView();
|
||||||
@@ -172,6 +175,12 @@ public:
|
|||||||
|
|
||||||
void SetTextRect(BRect rect);
|
void SetTextRect(BRect rect);
|
||||||
BRect TextRect() const;
|
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);
|
void SetStylable(bool stylable);
|
||||||
bool IsStylable() const;
|
bool IsStylable() const;
|
||||||
void SetTabWidth(float width);
|
void SetTabWidth(float width);
|
||||||
@@ -231,8 +240,17 @@ protected:
|
|||||||
BHandler** _handler);
|
BHandler** _handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend status_t _init_interface_kit_();
|
class InlineInput;
|
||||||
friend class _BTextTrackState_;
|
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 _ReservedTextView3();
|
||||||
virtual void _ReservedTextView4();
|
virtual void _ReservedTextView4();
|
||||||
@@ -275,11 +293,9 @@ private:
|
|||||||
|
|
||||||
void _DoInsertText(const char* inText,
|
void _DoInsertText(const char* inText,
|
||||||
int32 inLength, int32 inOffset,
|
int32 inLength, int32 inOffset,
|
||||||
const text_run_array* inRuns,
|
const text_run_array* inRuns);
|
||||||
_BTextChangeResult_* outResult);
|
|
||||||
|
|
||||||
void _DoDeleteText(int32 fromOffset, int32 toOffset,
|
void _DoDeleteText(int32 fromOffset, int32 toOffset);
|
||||||
_BTextChangeResult_* outResult);
|
|
||||||
|
|
||||||
void _DrawLine(BView* view, const int32 &startLine,
|
void _DrawLine(BView* view, const int32 &startLine,
|
||||||
const int32& startOffset, const bool& erase,
|
const int32& startOffset, const bool& erase,
|
||||||
@@ -337,12 +353,9 @@ private:
|
|||||||
void _HandleInputMethodLocationRequest();
|
void _HandleInputMethodLocationRequest();
|
||||||
void _CancelInputMethod();
|
void _CancelInputMethod();
|
||||||
|
|
||||||
static void LockWidthBuffer();
|
TextGapBuffer* fText;
|
||||||
static void UnlockWidthBuffer();
|
LineBuffer* fLines;
|
||||||
|
StyleBuffer* fStyles;
|
||||||
_BTextGapBuffer_* fText;
|
|
||||||
_BLineBuffer_* fLines;
|
|
||||||
_BStyleBuffer_* fStyles;
|
|
||||||
BRect fTextRect;
|
BRect fTextRect;
|
||||||
float fMinTextRectWidth;
|
float fMinTextRectWidth;
|
||||||
int32 fSelStart;
|
int32 fSelStart;
|
||||||
@@ -368,19 +381,16 @@ private:
|
|||||||
color_space fColorSpace;
|
color_space fColorSpace;
|
||||||
bool fResizable;
|
bool fResizable;
|
||||||
BView* fContainerView;
|
BView* fContainerView;
|
||||||
_BUndoBuffer_* fUndo;
|
UndoBuffer* fUndo;
|
||||||
_BInlineInput_* fInline;
|
InlineInput* fInline;
|
||||||
BMessageRunner * fDragRunner;
|
BMessageRunner * fDragRunner;
|
||||||
BMessageRunner * fClickRunner;
|
BMessageRunner * fClickRunner;
|
||||||
BPoint fWhere;
|
BPoint fWhere;
|
||||||
_BTextTrackState_* fTrackingMouse;
|
TextTrackState* fTrackingMouse;
|
||||||
_BTextChangeResult_* fTextChange;
|
|
||||||
|
|
||||||
uint32 _reserved[8];
|
uint32 _reserved[9];
|
||||||
|
|
||||||
static _BWidthBuffer_* sWidths;
|
static WidthBuffer* sWidths;
|
||||||
static sem_id sWidthSem;
|
|
||||||
static int32 sWidthAtom;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _TEXTVIEW_H
|
#endif // _TEXTVIEW_H
|
||||||
|
|||||||
@@ -21,16 +21,20 @@
|
|||||||
*
|
*
|
||||||
* File: WidthBuffer.cpp
|
* File: WidthBuffer.cpp
|
||||||
* Author: Stefano Ceccherini ([email protected])
|
* Author: Stefano Ceccherini ([email protected])
|
||||||
* 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.
|
* to retrieve them without passing through the app server.
|
||||||
* Used by BTextView and OpenTracker.
|
* Used by BTextView and OpenTracker.
|
||||||
*/
|
*/
|
||||||
#ifndef __WIDTHBUFFER_H
|
#ifndef __WIDTHBUFFER_H
|
||||||
#define __WIDTHBUFFER_H
|
#define __WIDTHBUFFER_H
|
||||||
|
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
#include "TextViewSupportBuffer.h"
|
#include "TextViewSupportBuffer.h"
|
||||||
|
|
||||||
class BFont; // forward declaration
|
|
||||||
|
class BFont;
|
||||||
|
|
||||||
|
|
||||||
// TODO: enable this as soon as we are sure opentracker works
|
// 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,
|
// with our libraries, since using a BFont here (as Dano does) is much better,
|
||||||
@@ -50,16 +54,15 @@ struct _width_table_ {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class _BTextGapBuffer_;
|
class BTextView::WidthBuffer : public _BTextViewSupportBuffer_<_width_table_> {
|
||||||
class _BWidthBuffer_ : public _BTextViewSupportBuffer_<_width_table_> {
|
|
||||||
public:
|
public:
|
||||||
_BWidthBuffer_();
|
WidthBuffer();
|
||||||
virtual ~_BWidthBuffer_();
|
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(_BTextGapBuffer_ &gapBuffer, int32 fromOffset, int32 length,
|
float StringWidth(BTextView::TextGapBuffer &gapBuffer, int32 fromOffset,
|
||||||
const BFont *inStyle);
|
int32 length, const BFont *inStyle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool FindTable(const BFont *font, int32 *outIndex);
|
bool FindTable(const BFont *font, int32 *outIndex);
|
||||||
|
|||||||
@@ -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 */
|
|
||||||
@@ -904,12 +904,7 @@ _init_interface_kit_()
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
sem_id widthSem = create_sem(0, "BTextView WidthBuffer Sem");
|
BTextView::sWidths = new BTextView::WidthBuffer;
|
||||||
if (widthSem < 0)
|
|
||||||
return widthSem;
|
|
||||||
BTextView::sWidthSem = widthSem;
|
|
||||||
BTextView::sWidthAtom = 0;
|
|
||||||
BTextView::sWidths = new _BWidthBuffer_;
|
|
||||||
|
|
||||||
_init_global_fonts_();
|
_init_global_fonts_();
|
||||||
|
|
||||||
|
|||||||
+304
-170
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Hiroshi Lockheimer (BTextView is based on his STEEngine)
|
* Hiroshi Lockheimer (BTextView is based on his STEEngine)
|
||||||
* Marc Flerackers ([email protected])
|
* Marc Flerackers ([email protected])
|
||||||
* Stefano Ceccherini ([email protected])
|
* Stefano Ceccherini ([email protected])
|
||||||
|
* Stephan Aßmus <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! BTextView displays and manages styled text. */
|
/*! BTextView displays and manages styled text. */
|
||||||
@@ -15,7 +16,8 @@
|
|||||||
// - Consider using BObjectList instead of BList
|
// - Consider using BObjectList instead of BList
|
||||||
// for disallowed characters (it would remove a lot of reinterpret_casts)
|
// for disallowed characters (it would remove a lot of reinterpret_casts)
|
||||||
// - Check for correctness and possible optimizations the calls to _Refresh(),
|
// - 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:
|
// Known Bugs:
|
||||||
// - Double buffering doesn't work well (disabled by default)
|
// - Double buffering doesn't work well (disabled by default)
|
||||||
@@ -87,30 +89,49 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class _BTextTrackState_ {
|
class BTextView::TextTrackState {
|
||||||
public:
|
public:
|
||||||
_BTextTrackState_(BMessenger messenger);
|
TextTrackState(BMessenger messenger);
|
||||||
~_BTextTrackState_();
|
~TextTrackState();
|
||||||
|
|
||||||
void SimulateMouseMovement(BTextView *view);
|
void SimulateMouseMovement(BTextView* view);
|
||||||
|
|
||||||
int32 clickOffset;
|
public:
|
||||||
bool shiftDown;
|
int32 clickOffset;
|
||||||
BRect selectionRect;
|
bool shiftDown;
|
||||||
|
BRect selectionRect;
|
||||||
int32 anchor;
|
|
||||||
int32 selStart;
|
int32 anchor;
|
||||||
int32 selEnd;
|
int32 selStart;
|
||||||
|
int32 selEnd;
|
||||||
|
|
||||||
private:
|
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
|
// Initialized/finalized by init/fini_interface_kit
|
||||||
_BWidthBuffer_* BTextView::sWidths = NULL;
|
BTextView::WidthBuffer* BTextView::sWidths = NULL;
|
||||||
sem_id BTextView::sWidthSem = B_BAD_SEM_ID;
|
|
||||||
int32 BTextView::sWidthAtom = 0;
|
|
||||||
|
|
||||||
|
|
||||||
const static rgb_color kBlackColor = { 0, 0, 0, 255 };
|
const static rgb_color kBlackColor = { 0, 0, 0, 255 };
|
||||||
@@ -158,14 +179,16 @@ static property_info sPropertyList[] = {
|
|||||||
"text_run_array",
|
"text_run_array",
|
||||||
{ B_GET_PROPERTY, 0 },
|
{ B_GET_PROPERTY, 0 },
|
||||||
{ B_RANGE_SPECIFIER, B_REVERSE_RANGE_SPECIFIER, 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 },
|
{ B_RAW_TYPE, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text_run_array",
|
"text_run_array",
|
||||||
{ B_SET_PROPERTY, 0 },
|
{ B_SET_PROPERTY, 0 },
|
||||||
{ B_RANGE_SPECIFIER, B_REVERSE_RANGE_SPECIFIER, 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 },
|
{ B_RAW_TYPE, 0 },
|
||||||
},
|
},
|
||||||
{ 0 }
|
{ 0 }
|
||||||
@@ -176,7 +199,8 @@ static property_info sPropertyList[] = {
|
|||||||
\param frame The rect which will enclose the BTextView object.
|
\param frame The rect which will enclose the BTextView object.
|
||||||
\param name The name of the object.
|
\param name The name of the object.
|
||||||
\param textRect Determines the area of the text within the BTextView 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.
|
\param flags The flags for the BTextView, passed to the BView constructor.
|
||||||
*/
|
*/
|
||||||
BTextView::BTextView(BRect frame, const char *name, BRect textRect,
|
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 frame The rect which will enclose the BTextView object.
|
||||||
\param name The name of the object.
|
\param name The name of the object.
|
||||||
\param textRect Determines the area of the text within the BTextView 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 initialFont The BTextView will display its text using this font,
|
||||||
\param initialColor The BTextView will display its text using this color, unless otherwise specified.
|
unless otherwise specified.
|
||||||
\param resizeMask The resizing mask for the BTextView, passed to the BView constructor.
|
\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.
|
\param flags The flags for the BTextView, passed to the BView constructor.
|
||||||
*/
|
*/
|
||||||
BTextView::BTextView(BRect frame, const char *name, BRect textRect,
|
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.
|
/*! \brief Creates a BTextView object from the passed BMessage.
|
||||||
\param archive The BMessage from which the object shall be created.
|
\param archive The BMessage from which the object shall be created.
|
||||||
*/
|
*/
|
||||||
@@ -268,15 +324,19 @@ BTextView::BTextView(BMessage *archive)
|
|||||||
|
|
||||||
fDisallowedChars = new BList;
|
fDisallowedChars = new BList;
|
||||||
disallowedCount /= sizeof(int32);
|
disallowedCount /= sizeof(int32);
|
||||||
for (int32 x = 0; x < disallowedCount; x++)
|
for (int32 x = 0; x < disallowedCount; x++) {
|
||||||
fDisallowedChars->AddItem(reinterpret_cast<void *>(disallowedChars[x]));
|
fDisallowedChars->AddItem(
|
||||||
|
reinterpret_cast<void *>(disallowedChars[x]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t runSize = 0;
|
ssize_t runSize = 0;
|
||||||
const void *flattenedRun = NULL;
|
const void *flattenedRun = NULL;
|
||||||
|
|
||||||
if (archive->FindData("_runs", B_RAW_TYPE, &flattenedRun, &runSize) == B_OK) {
|
if (archive->FindData("_runs", B_RAW_TYPE, &flattenedRun, &runSize)
|
||||||
text_run_array *runArray = UnflattenRunArray(flattenedRun, (int32 *)&runSize);
|
== B_OK) {
|
||||||
|
text_run_array *runArray = UnflattenRunArray(flattenedRun,
|
||||||
|
(int32*)&runSize);
|
||||||
if (runArray) {
|
if (runArray) {
|
||||||
SetRunArray(0, TextLength(), runArray);
|
SetRunArray(0, TextLength(), runArray);
|
||||||
FreeRunArray(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.
|
\param archive The BMessage from which the object shall be created.
|
||||||
\return A constructed BTextView as a BArchivable object.
|
\return A constructed BTextView as a BArchivable object.
|
||||||
*/
|
*/
|
||||||
@@ -458,7 +519,7 @@ BTextView::MouseDown(BPoint where)
|
|||||||
_StopMouseTracking();
|
_StopMouseTracking();
|
||||||
|
|
||||||
BMessenger messenger(this);
|
BMessenger messenger(this);
|
||||||
fTrackingMouse = new (nothrow) _BTextTrackState_(messenger);
|
fTrackingMouse = new (nothrow) TextTrackState(messenger);
|
||||||
if (fTrackingMouse == NULL)
|
if (fTrackingMouse == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -477,12 +538,15 @@ BTextView::MouseDown(BPoint where)
|
|||||||
bigtime_t clickSpeed = 0;
|
bigtime_t clickSpeed = 0;
|
||||||
get_click_speed(&clickSpeed);
|
get_click_speed(&clickSpeed);
|
||||||
bool multipleClick = false;
|
bool multipleClick = false;
|
||||||
if (clickTime - fClickTime < clickSpeed && fClickOffset == fTrackingMouse->clickOffset)
|
if (clickTime - fClickTime < clickSpeed
|
||||||
|
&& fClickOffset == fTrackingMouse->clickOffset) {
|
||||||
multipleClick = true;
|
multipleClick = true;
|
||||||
|
}
|
||||||
|
|
||||||
fWhere = where;
|
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) {
|
if (fSelStart != fSelEnd && !fTrackingMouse->shiftDown && !multipleClick) {
|
||||||
BRegion region;
|
BRegion region;
|
||||||
@@ -518,7 +582,8 @@ BTextView::MouseDown(BPoint where)
|
|||||||
delete fClickRunner;
|
delete fClickRunner;
|
||||||
|
|
||||||
BMessenger messenger(this);
|
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:
|
default:
|
||||||
// if the character is not allowed, bail out.
|
// if the character is not allowed, bail out.
|
||||||
if (fDisallowedChars
|
if (fDisallowedChars
|
||||||
&& fDisallowedChars->HasItem(reinterpret_cast<void *>((uint32)keyPressed))) {
|
&& fDisallowedChars->HasItem(
|
||||||
|
reinterpret_cast<void *>((uint32)keyPressed))) {
|
||||||
beep();
|
beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -805,9 +871,10 @@ BTextView::MessageReceived(BMessage *message)
|
|||||||
case B_INPUT_METHOD_STARTED:
|
case B_INPUT_METHOD_STARTED:
|
||||||
{
|
{
|
||||||
BMessenger messenger;
|
BMessenger messenger;
|
||||||
if (message->FindMessenger("be:reply_to", &messenger) == B_OK) {
|
if (message->FindMessenger("be:reply_to", &messenger)
|
||||||
|
== B_OK) {
|
||||||
ASSERT(fInline == NULL);
|
ASSERT(fInline == NULL);
|
||||||
fInline = new _BInlineInput_(messenger);
|
fInline = new InlineInput(messenger);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -971,7 +1038,8 @@ BTextView::SetText(const char *inText, const text_run_array *inRuns)
|
|||||||
|
|
||||||
|
|
||||||
void
|
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();
|
_CancelInputMethod();
|
||||||
|
|
||||||
@@ -1048,7 +1116,7 @@ void
|
|||||||
BTextView::Insert(const char *inText, const text_run_array *inRuns)
|
BTextView::Insert(const char *inText, const text_run_array *inRuns)
|
||||||
{
|
{
|
||||||
if (inText != NULL)
|
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) {
|
if (inText != NULL && inLength > 0) {
|
||||||
int32 realLength = strlen(inText);
|
int32 realLength = strlen(inText);
|
||||||
_DoInsertText(inText, min_c(inLength, realLength), fSelStart, inRuns,
|
_DoInsertText(inText, min_c(inLength, realLength), fSelStart, inRuns);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1073,7 +1140,7 @@ BTextView::Insert(int32 startOffset, const char *inText, int32 inLength,
|
|||||||
// do we really need to do anything?
|
// do we really need to do anything?
|
||||||
if (inText != NULL && inLength > 0) {
|
if (inText != NULL && inLength > 0) {
|
||||||
int32 realLength = strlen(inText);
|
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;
|
int32 size;
|
||||||
if (fStylable) {
|
if (fStylable) {
|
||||||
text_run_array *runArray = RunArray(fSelStart, fSelEnd, &size);
|
text_run_array *runArray = RunArray(fSelStart, fSelEnd, &size);
|
||||||
clip->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
|
clip->AddData("application/x-vnd.Be-text_run_array",
|
||||||
runArray, size);
|
B_MIME_TYPE, runArray, size);
|
||||||
FreeRunArray(runArray);
|
FreeRunArray(runArray);
|
||||||
}
|
}
|
||||||
clipboard->Commit();
|
clipboard->Commit();
|
||||||
@@ -1259,35 +1326,38 @@ BTextView::Paste(BClipboard *clipboard)
|
|||||||
CALLED();
|
CALLED();
|
||||||
_CancelInputMethod();
|
_CancelInputMethod();
|
||||||
|
|
||||||
if (clipboard->Lock()) {
|
if (!clipboard->Lock())
|
||||||
BMessage *clip = clipboard->Data();
|
return;
|
||||||
if (clip != NULL) {
|
|
||||||
const char *text = NULL;
|
|
||||||
ssize_t len = 0;
|
|
||||||
|
|
||||||
if (clip->FindData("text/plain", B_MIME_TYPE,
|
BMessage *clip = clipboard->Data();
|
||||||
(const void **)&text, &len) == B_OK) {
|
if (clip != NULL) {
|
||||||
text_run_array *runArray = NULL;
|
const char *text = NULL;
|
||||||
ssize_t runLen = 0;
|
ssize_t len = 0;
|
||||||
|
|
||||||
if (fStylable)
|
if (clip->FindData("text/plain", B_MIME_TYPE,
|
||||||
clip->FindData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
|
(const void **)&text, &len) == B_OK) {
|
||||||
(const void **)&runArray, &runLen);
|
text_run_array *runArray = NULL;
|
||||||
|
ssize_t runLen = 0;
|
||||||
|
|
||||||
if (fUndo) {
|
if (fStylable) {
|
||||||
delete fUndo;
|
clip->FindData("application/x-vnd.Be-text_run_array",
|
||||||
fUndo = new _BPasteUndoBuffer_(this, text, len, runArray, runLen);
|
B_MIME_TYPE, (const void **)&runArray, &runLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fSelStart != fSelEnd)
|
if (fUndo) {
|
||||||
Delete();
|
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.
|
/*! \brief Gets the current selection.
|
||||||
\param outStart A pointer to an int32 which will contain the selection start's offset.
|
\param outStart A pointer to an int32 which will contain the selection
|
||||||
\param outEnd A pointer to an int32 which will contain the selection end's offset.
|
start's offset.
|
||||||
|
\param outEnd A pointer to an int32 which will contain the selection
|
||||||
|
end's offset.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BTextView::GetSelection(int32 *outStart, int32 *outEnd) const
|
BTextView::GetSelection(int32 *outStart, int32 *outEnd) const
|
||||||
@@ -1437,15 +1509,16 @@ BTextView::GetSelection(int32 *outStart, int32 *outEnd) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
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);
|
SetFontAndColor(fSelStart, fSelEnd, inFont, inMode, inColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont* font,
|
BTextView::SetFontAndColor(int32 startOffset, int32 endOffset,
|
||||||
uint32 fontMode, const rgb_color* color)
|
const BFont* font, uint32 fontMode, const rgb_color* color)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -1493,21 +1566,25 @@ BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont* font
|
|||||||
|
|
||||||
|
|
||||||
void
|
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);
|
fStyles->GetStyle(inOffset, outFont, outColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
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
|
void
|
||||||
BTextView::SetRunArray(int32 startOffset, int32 endOffset, const text_run_array *inRuns)
|
BTextView::SetRunArray(int32 startOffset, int32 endOffset,
|
||||||
|
const text_run_array *inRuns)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -1532,7 +1609,8 @@ BTextView::SetRunArray(int32 startOffset, int32 endOffset, const text_run_array
|
|||||||
text_run_array *
|
text_run_array *
|
||||||
BTextView::RunArray(int32 startOffset, int32 endOffset, int32 *outSize) const
|
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)
|
if (styleRange == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1575,8 +1653,8 @@ BTextView::LineAt(BPoint point) const
|
|||||||
|
|
||||||
/*! \brief Returns the location of the character at the given offset.
|
/*! \brief Returns the location of the character at the given offset.
|
||||||
\param inOffset The offset of the character.
|
\param inOffset The offset of the character.
|
||||||
\param outHeight Here the function will put the height of the character at the
|
\param outHeight Here the function will put the height of the character
|
||||||
given offset.
|
at the given offset.
|
||||||
\return A BPoint which is the location of the character.
|
\return A BPoint which is the location of the character.
|
||||||
*/
|
*/
|
||||||
BPoint
|
BPoint
|
||||||
@@ -1608,7 +1686,8 @@ BTextView::PointAt(int32 inOffset, float *outHeight) const
|
|||||||
height = (line + 1)->origin - line->origin;
|
height = (line + 1)->origin - line->origin;
|
||||||
|
|
||||||
// special case: go down one line if inOffset is a newline
|
// 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;
|
result.y += height;
|
||||||
height = LineHeight(CountLines() - 1);
|
height = LineHeight(CountLines() - 1);
|
||||||
|
|
||||||
@@ -1694,8 +1773,9 @@ BTextView::OffsetAt(BPoint point) const
|
|||||||
point.x -= fTextRect.left;
|
point.x -= fTextRect.left;
|
||||||
point.x = max_c(point.x, 0.0);
|
point.x = max_c(point.x, 0.0);
|
||||||
|
|
||||||
// TODO: The following code isn't very efficient because it always starts from the left end,
|
// TODO: The following code isn't very efficient, because it always starts
|
||||||
// so when the point is near the right end it's very slow.
|
// from the left end, so when the point is near the right end it's very
|
||||||
|
// slow.
|
||||||
int32 offset = line->offset;
|
int32 offset = line->offset;
|
||||||
const int32 limit = (line + 1)->offset;
|
const int32 limit = (line + 1)->offset;
|
||||||
float location = 0;
|
float location = 0;
|
||||||
@@ -1774,7 +1854,8 @@ BTextView::FindWord(int32 inOffset, int32 *outFromOffset, int32 *outToOffset)
|
|||||||
|
|
||||||
// check to the right
|
// check to the right
|
||||||
int32 textLen = TextLength();
|
int32 textLen = TextLength();
|
||||||
for (offset = inOffset; offset < textLen; offset = _NextInitialByte(offset)) {
|
for (offset = inOffset; offset < textLen;
|
||||||
|
offset = _NextInitialByte(offset)) {
|
||||||
if (_CharClassification(offset) != charType)
|
if (_CharClassification(offset) != charType)
|
||||||
break;
|
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.
|
\param offset The offset of the character.
|
||||||
\return true if the character can be the last of a line, false if not.
|
\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.
|
\param inOffset The offset of the character.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@@ -1938,8 +2021,8 @@ BTextView::ScrollToOffset(int32 inOffset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Scrolls the text so that the character which begins the current selection
|
/*! \brief Scrolls the text so that the character which begins the current
|
||||||
is within the visible range.
|
selection is within the visible range.
|
||||||
\param inOffset The offset of the character.
|
\param inOffset The offset of the character.
|
||||||
*/
|
*/
|
||||||
void
|
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.
|
\param rect A BRect.
|
||||||
*/
|
*/
|
||||||
void
|
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.
|
/*! \brief Sets whether the BTextView accepts multiple character styles.
|
||||||
*/
|
*/
|
||||||
void
|
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 resize If true, the BTextView will automatically resize itself.
|
||||||
\param resizeView The BTextView's parent view, it's the view which resizes itself.
|
\param resizeView The BTextView's parent view, it's the view which resizes
|
||||||
The resizing mechanism is alternative to the BView resizing. The container view
|
itself.
|
||||||
(the one passed to this function) should not automatically resize itself when the parent is
|
The resizing mechanism is alternative to the BView resizing. The container
|
||||||
resized.
|
view (the one passed to this function) should not automatically resize
|
||||||
|
itself when the parent is resized.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BTextView::MakeResizable(bool resize, BView *resizeView)
|
BTextView::MakeResizable(bool resize, BView *resizeView)
|
||||||
@@ -2344,7 +2463,7 @@ void
|
|||||||
BTextView::SetDoesUndo(bool undo)
|
BTextView::SetDoesUndo(bool undo)
|
||||||
{
|
{
|
||||||
if (undo && fUndo == NULL)
|
if (undo && fUndo == NULL)
|
||||||
fUndo = new _BUndoBuffer_(this, B_UNDO_UNAVAILABLE);
|
fUndo = new UndoBuffer(this, B_UNDO_UNAVAILABLE);
|
||||||
else if (!undo && fUndo != NULL) {
|
else if (!undo && fUndo != NULL) {
|
||||||
delete fUndo;
|
delete fUndo;
|
||||||
fUndo = NULL;
|
fUndo = NULL;
|
||||||
@@ -2491,12 +2610,16 @@ BTextView::FlattenRunArray(const text_run_array* runArray, int32* _size)
|
|||||||
array->count = B_HOST_TO_BENDIAN_INT32(runArray->count);
|
array->count = B_HOST_TO_BENDIAN_INT32(runArray->count);
|
||||||
|
|
||||||
for (int32 i = 0; i < runArray->count; i++) {
|
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,
|
runArray->runs[i].font.GetFamilyAndStyle(&array->styles[i].family,
|
||||||
&array->styles[i].style);
|
&array->styles[i].style);
|
||||||
array->styles[i].size = B_HOST_TO_BENDIAN_FLOAT(runArray->runs[i].font.Size());
|
array->styles[i].size = B_HOST_TO_BENDIAN_FLOAT(
|
||||||
array->styles[i].shear = B_HOST_TO_BENDIAN_FLOAT(runArray->runs[i].font.Shear());
|
runArray->runs[i].font.Size());
|
||||||
array->styles[i].face = B_HOST_TO_BENDIAN_INT16(runArray->runs[i].font.Face());
|
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].red = runArray->runs[i].color.red;
|
||||||
array->styles[i].green = runArray->runs[i].color.green;
|
array->styles[i].green = runArray->runs[i].color.green;
|
||||||
array->styles[i].blue = runArray->runs[i].color.blue;
|
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;
|
flattened_text_run_array *array = (flattened_text_run_array *)data;
|
||||||
|
|
||||||
if (B_BENDIAN_TO_HOST_INT32(array->magic) != kFlattenedTextRunArrayMagic
|
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)
|
if (_size)
|
||||||
*_size = 0;
|
*_size = 0;
|
||||||
|
|
||||||
@@ -2533,15 +2657,18 @@ BTextView::UnflattenRunArray(const void* data, int32* _size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (int32 i = 0; i < count; i++) {
|
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
|
// Set family and style independently from each other, so that
|
||||||
// even if the family doesn't exist, we try to preserve the style
|
// 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(array->styles[i].family, NULL);
|
||||||
runArray->runs[i].font.SetFamilyAndStyle(NULL, array->styles[i].style);
|
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.SetSize(B_BENDIAN_TO_HOST_FLOAT(
|
||||||
runArray->runs[i].font.SetShear(B_BENDIAN_TO_HOST_FLOAT(array->styles[i].shear));
|
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);
|
uint16 face = B_BENDIAN_TO_HOST_INT16(array->styles[i].face);
|
||||||
if (face != B_REGULAR_FACE) {
|
if (face != B_REGULAR_FACE) {
|
||||||
@@ -2677,6 +2804,9 @@ void BTextView::_ReservedTextView11() {}
|
|||||||
void BTextView::_ReservedTextView12() {}
|
void BTextView::_ReservedTextView12() {}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Inits the BTextView object.
|
/*! \brief Inits the BTextView object.
|
||||||
\param textRect The BTextView's text rect.
|
\param textRect The BTextView's text rect.
|
||||||
\param initialFont The font which the BTextView will use.
|
\param initialFont The font which the BTextView will use.
|
||||||
@@ -2697,14 +2827,19 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont,
|
|||||||
if (initialColor == NULL)
|
if (initialColor == NULL)
|
||||||
initialColor = &kBlackColor;
|
initialColor = &kBlackColor;
|
||||||
|
|
||||||
fText = new _BTextGapBuffer_;
|
fText = new TextGapBuffer;
|
||||||
fLines = new _BLineBuffer_;
|
fLines = new LineBuffer;
|
||||||
fStyles = new _BStyleBuffer_(&font, initialColor);
|
fStyles = new StyleBuffer(&font, initialColor);
|
||||||
|
|
||||||
// We put these here instead of in the constructor initializer list
|
// We put these here instead of in the constructor initializer list
|
||||||
// to have less code duplication, and a single place where to do changes
|
// to have less code duplication, and a single place where to do changes
|
||||||
// if needed.
|
// if needed.
|
||||||
fTextRect = textRect;
|
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();
|
fMinTextRectWidth = fTextRect.Width();
|
||||||
fSelStart = fSelEnd = 0;
|
fSelStart = fSelEnd = 0;
|
||||||
fCaretVisible = false;
|
fCaretVisible = false;
|
||||||
@@ -2733,7 +2868,6 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont,
|
|||||||
fDragRunner = NULL;
|
fDragRunner = NULL;
|
||||||
fClickRunner = NULL;
|
fClickRunner = NULL;
|
||||||
fTrackingMouse = NULL;
|
fTrackingMouse = NULL;
|
||||||
fTextChange = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3022,7 +3156,8 @@ BTextView::_HandleAlphaKey(const char *bytes, int32 numBytes)
|
|||||||
{
|
{
|
||||||
// TODO: block input if not editable (Andrew)
|
// TODO: block input if not editable (Andrew)
|
||||||
if (fUndo) {
|
if (fUndo) {
|
||||||
_BTypingUndoBuffer_ *undoBuffer = dynamic_cast<_BTypingUndoBuffer_ *>(fUndo);
|
_BTypingUndoBuffer_ *undoBuffer
|
||||||
|
= dynamic_cast<_BTypingUndoBuffer_ *>(fUndo);
|
||||||
if (!undoBuffer) {
|
if (!undoBuffer) {
|
||||||
delete fUndo;
|
delete fUndo;
|
||||||
fUndo = undoBuffer = new _BTypingUndoBuffer_(this);
|
fUndo = undoBuffer = new _BTypingUndoBuffer_(this);
|
||||||
@@ -3047,12 +3182,12 @@ BTextView::_HandleAlphaKey(const char *bytes, int32 numBytes)
|
|||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
if (start != 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
|
} else
|
||||||
_DoInsertText(bytes, numBytes, fSelStart, NULL, NULL);
|
_DoInsertText(bytes, numBytes, fSelStart, NULL);
|
||||||
|
|
||||||
fClickOffset = fSelEnd;
|
fClickOffset = fSelEnd;
|
||||||
|
|
||||||
@@ -3144,7 +3279,8 @@ BTextView::_RecalculateLineBreaks(int32 *startLine, int32 *endLine)
|
|||||||
{
|
{
|
||||||
// are we insane?
|
// are we insane?
|
||||||
*startLine = (*startLine < 0) ? 0 : *startLine;
|
*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 textLength = fText->Length();
|
||||||
int32 lineIndex = (*startLine > 0) ? *startLine - 1 : 0;
|
int32 lineIndex = (*startLine > 0) ? *startLine - 1 : 0;
|
||||||
@@ -3253,7 +3389,8 @@ BTextView::_FindLineBreak(int32 fromOffset, float *outAscent, float *outDescent,
|
|||||||
offset += fromOffset;
|
offset += fromOffset;
|
||||||
offset = (offset < limit) ? offset + 1 : limit;
|
offset = (offset < limit) ? offset + 1 : limit;
|
||||||
|
|
||||||
*ioWidth = _StyledWidth(fromOffset, offset - fromOffset, outAscent, outDescent);
|
*ioWidth = _StyledWidth(fromOffset, offset - fromOffset, outAscent,
|
||||||
|
outDescent);
|
||||||
|
|
||||||
return offset;
|
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.
|
/*! \brief Calculate the width of the text within the given limits.
|
||||||
\param fromOffset The offset where to start.
|
\param fromOffset The offset where to start.
|
||||||
\param length The length of the text to examine.
|
\param length The length of the text to examine.
|
||||||
\param outAscent A pointer to a float which will contain the maximum ascent.
|
\param outAscent A pointer to a float which will contain the maximum
|
||||||
\param outDescent A pointer to a float which will contain the maximum descent.
|
ascent.
|
||||||
|
\param outDescent A pointer to a float which will contain the maximum
|
||||||
|
descent.
|
||||||
\return The width for the text within the given limits.
|
\return The width for the text within the given limits.
|
||||||
*/
|
*/
|
||||||
float
|
float
|
||||||
@@ -3418,9 +3557,7 @@ BTextView::_StyledWidth(int32 fromOffset, int32 length, float *outAscent,
|
|||||||
#if USE_WIDTHBUFFER
|
#if USE_WIDTHBUFFER
|
||||||
// Use _BWidthBuffer_ if possible
|
// Use _BWidthBuffer_ if possible
|
||||||
if (sWidths != NULL) {
|
if (sWidths != NULL) {
|
||||||
LockWidthBuffer();
|
|
||||||
result += sWidths->StringWidth(*fText, fromOffset, numChars, font);
|
result += sWidths->StringWidth(*fText, fromOffset, numChars, font);
|
||||||
UnlockWidthBuffer();
|
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
const char* text = fText->GetString(fromOffset, &numChars);
|
const char* text = fText->GetString(fromOffset, &numChars);
|
||||||
@@ -3471,7 +3608,7 @@ BTextView::_ActualTabWidth(float location) const
|
|||||||
|
|
||||||
void
|
void
|
||||||
BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset,
|
BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset,
|
||||||
const text_run_array *inRuns, _BTextChangeResult_ *outResult)
|
const text_run_array *inRuns)
|
||||||
{
|
{
|
||||||
_CancelInputMethod();
|
_CancelInputMethod();
|
||||||
|
|
||||||
@@ -3502,15 +3639,16 @@ BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextView::_DoDeleteText(int32 fromOffset, int32 toOffset, _BTextChangeResult_ *outResult)
|
BTextView::_DoDeleteText(int32 fromOffset, int32 toOffset)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextView::_DrawLine(BView *view, const int32 &lineNum, const int32 &startOffset,
|
BTextView::_DrawLine(BView *view, const int32 &lineNum,
|
||||||
const bool &erase, BRect &eraseRect, BRegion &inputRegion)
|
const int32 &startOffset, const bool &erase, BRect &eraseRect,
|
||||||
|
BRegion &inputRegion)
|
||||||
{
|
{
|
||||||
STELine *line = (*fLines)[lineNum];
|
STELine *line = (*fLines)[lineNum];
|
||||||
float startLeft = fTextRect.left;
|
float startLeft = fTextRect.left;
|
||||||
@@ -3698,13 +3836,16 @@ BTextView::_DrawLines(int32 startLine, int32 endLine, int32 startOffset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BRegion inputRegion;
|
BRegion inputRegion;
|
||||||
if (fInline != NULL && fInline->IsActive())
|
if (fInline != NULL && fInline->IsActive()) {
|
||||||
GetTextRegion(fInline->Offset(), fInline->Offset() + fInline->Length(), &inputRegion);
|
GetTextRegion(fInline->Offset(), fInline->Offset() + fInline->Length(),
|
||||||
|
&inputRegion);
|
||||||
|
}
|
||||||
|
|
||||||
//BPoint leftTop(startLeft, line->origin);
|
//BPoint leftTop(startLeft, line->origin);
|
||||||
for (int32 lineNum = startLine; lineNum <= endLine; lineNum++) {
|
for (int32 lineNum = startLine; lineNum <= endLine; lineNum++) {
|
||||||
const bool eraseThisLine = erase && lineNum >= startEraseLine;
|
const bool eraseThisLine = erase && lineNum >= startEraseLine;
|
||||||
_DrawLine(view, lineNum, startOffset, eraseThisLine, eraseRect, inputRegion);
|
_DrawLine(view, lineNum, startOffset, eraseThisLine, eraseRect,
|
||||||
|
inputRegion);
|
||||||
startOffset = -1;
|
startOffset = -1;
|
||||||
// Set this to -1 so the next iteration will use the line offset
|
// 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.
|
/*! \brief Place the dragging caret at the given offset.
|
||||||
\param offset The offset (zero based within the object's text) where to place
|
\param offset The offset (zero based within the object's text) where to
|
||||||
the dragging caret. If it's -1, hide the caret.
|
place the dragging caret. If it's -1, hide the caret.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BTextView::_DragCaret(int32 offset)
|
BTextView::_DragCaret(int32 offset)
|
||||||
@@ -3852,13 +3993,16 @@ BTextView::_PerformMouseMoved(BPoint where, uint32 code)
|
|||||||
switch (fClickCount) {
|
switch (fClickCount) {
|
||||||
case 0:
|
case 0:
|
||||||
// triple click, select line by line
|
// triple click, select line by line
|
||||||
fTrackingMouse->selStart = (*fLines)[LineAt(fTrackingMouse->selStart)]->offset;
|
fTrackingMouse->selStart
|
||||||
fTrackingMouse->selEnd = (*fLines)[LineAt(fTrackingMouse->selEnd) + 1]->offset;
|
= (*fLines)[LineAt(fTrackingMouse->selStart)]->offset;
|
||||||
|
fTrackingMouse->selEnd
|
||||||
|
= (*fLines)[LineAt(fTrackingMouse->selEnd) + 1]->offset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// double click, select word by word
|
// double click, select word by word
|
||||||
FindWord(currentOffset, &fTrackingMouse->selStart, &fTrackingMouse->selEnd);
|
FindWord(currentOffset, &fTrackingMouse->selStart,
|
||||||
|
&fTrackingMouse->selEnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -3986,16 +4130,18 @@ BTextView::_MessageDropped(BMessage *inMessage, BPoint where, BPoint offset)
|
|||||||
|
|
||||||
ssize_t dataLen = 0;
|
ssize_t dataLen = 0;
|
||||||
const char *text = NULL;
|
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;
|
text_run_array *runArray = NULL;
|
||||||
ssize_t runLen = 0;
|
ssize_t runLen = 0;
|
||||||
if (fStylable)
|
if (fStylable)
|
||||||
inMessage->FindData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
|
inMessage->FindData("application/x-vnd.Be-text_run_array",
|
||||||
(const void **)&runArray, &runLen);
|
B_MIME_TYPE, (const void **)&runArray, &runLen);
|
||||||
|
|
||||||
if (fUndo) {
|
if (fUndo) {
|
||||||
delete 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) {
|
if (internalDrop) {
|
||||||
@@ -4044,7 +4190,8 @@ BTextView::_PerformAutoScrolling()
|
|||||||
// Always scroll vertically line by line or by multiples of that
|
// Always scroll vertically line by line or by multiples of that
|
||||||
// based on the distance of the cursor from the border of the view
|
// 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
|
// 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())
|
if (bounds.bottom + scrollBy.y > fTextRect.Height())
|
||||||
scrollBy.y = fTextRect.Height() - bounds.bottom;
|
scrollBy.y = fTextRect.Height() - bounds.bottom;
|
||||||
@@ -4112,7 +4259,7 @@ BTextView::_AutoResize(bool redraw)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (fContainerView != NULL) {
|
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
|
// move container view if not left aligned
|
||||||
if (fAlignment == B_ALIGN_CENTER) {
|
if (fAlignment == B_ALIGN_CENTER) {
|
||||||
if (fmod(ceilf(newWidth - oldWidth), 2.0) != 0.0)
|
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
|
// erase any potential left over outside the text rect
|
||||||
// (can only be on right hand side)
|
// (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()) {
|
if (dirty.IsValid()) {
|
||||||
SetLowColor(ViewColor());
|
SetLowColor(ViewColor());
|
||||||
FillRect(dirty, B_SOLID_LOW);
|
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.
|
\param offset The offset where to start looking.
|
||||||
\return The offset of the next UTF8 character.
|
\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.
|
\param offset The offset where to start looking.
|
||||||
\return The offset of the previous UTF8 character.
|
\return The offset of the previous UTF8 character.
|
||||||
*/
|
*/
|
||||||
@@ -4359,7 +4509,8 @@ BTextView::_PreviousInitialByte(int32 offset) const
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BTextView::_GetProperty(BMessage *specifier, int32 form, const char *property, BMessage *reply)
|
BTextView::_GetProperty(BMessage *specifier, int32 form, const char *property,
|
||||||
|
BMessage *reply)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (strcmp(property, "selection") == 0) {
|
if (strcmp(property, "selection") == 0) {
|
||||||
@@ -4470,9 +4621,9 @@ BTextView::_HandleInputMethodChanged(BMessage *message)
|
|||||||
be_app->ObscureCursor();
|
be_app->ObscureCursor();
|
||||||
|
|
||||||
// If we find the "be:confirmed" boolean (and the boolean is true),
|
// If we find the "be:confirmed" boolean (and the boolean is true),
|
||||||
// it means it's over for now, so the current _BInlineInput_ object
|
// it means it's over for now, so the current InlineInput object
|
||||||
// should become inactive. We will probably receive a B_INPUT_METHOD_STOPPED
|
// should become inactive. We will probably receive a
|
||||||
// message after this one.
|
// B_INPUT_METHOD_STOPPED message after this one.
|
||||||
bool confirmed;
|
bool confirmed;
|
||||||
if (message->FindBool("be:confirmed", &confirmed) != B_OK)
|
if (message->FindBool("be:confirmed", &confirmed) != B_OK)
|
||||||
confirmed = false;
|
confirmed = false;
|
||||||
@@ -4495,15 +4646,17 @@ BTextView::_HandleInputMethodChanged(BMessage *message)
|
|||||||
if (!confirmed && !fInline->IsActive())
|
if (!confirmed && !fInline->IsActive())
|
||||||
fInline->SetActive(true);
|
fInline->SetActive(true);
|
||||||
|
|
||||||
// Get the clauses, and pass them to the _BInlineInput_ object
|
// 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
|
// TODO: Find out if what we did it's ok, currently we don't consider
|
||||||
// at all, while the bebook says we should; though the visual effect we obtained
|
// clauses at all, while the bebook says we should; though the visual
|
||||||
// seems correct. Weird.
|
// effect we obtained seems correct. Weird.
|
||||||
int32 clauseCount = 0;
|
int32 clauseCount = 0;
|
||||||
int32 clauseStart;
|
int32 clauseStart;
|
||||||
int32 clauseEnd;
|
int32 clauseEnd;
|
||||||
while (message->FindInt32("be:clause_start", clauseCount, &clauseStart) == B_OK &&
|
while (message->FindInt32("be:clause_start", clauseCount, &clauseStart)
|
||||||
message->FindInt32("be:clause_end", clauseCount, &clauseEnd) == B_OK) {
|
== B_OK
|
||||||
|
&& message->FindInt32("be:clause_end", clauseCount, &clauseEnd)
|
||||||
|
== B_OK) {
|
||||||
if (!fInline->AddClause(clauseStart, clauseEnd))
|
if (!fInline->AddClause(clauseStart, clauseEnd))
|
||||||
break;
|
break;
|
||||||
clauseCount++;
|
clauseCount++;
|
||||||
@@ -4566,11 +4719,12 @@ BTextView::_CancelInputMethod()
|
|||||||
if (!fInline)
|
if (!fInline)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_BInlineInput_ *inlineInput = fInline;
|
InlineInput *inlineInput = fInline;
|
||||||
fInline = NULL;
|
fInline = NULL;
|
||||||
|
|
||||||
if (inlineInput->IsActive() && Window()) {
|
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);
|
BMessage message(B_INPUT_METHOD_EVENT);
|
||||||
message.AddInt32("be:opcode", B_INPUT_METHOD_STOPPED);
|
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.
|
// #pragma mark - BTextView::TextTrackState
|
||||||
*/
|
|
||||||
void
|
|
||||||
BTextView::LockWidthBuffer()
|
|
||||||
{
|
|
||||||
if (atomic_add(&sWidthAtom, 1) > 0) {
|
|
||||||
while (acquire_sem(sWidthSem) == B_INTERRUPTED)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Unlocks the static _BWidthBuffer_ object.
|
BTextView::TextTrackState::TextTrackState(BMessenger messenger)
|
||||||
*/
|
|
||||||
void
|
|
||||||
BTextView::UnlockWidthBuffer()
|
|
||||||
{
|
|
||||||
if (atomic_add(&sWidthAtom, -1) > 1)
|
|
||||||
release_sem(sWidthSem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// _BTextTrackState_
|
|
||||||
_BTextTrackState_::_BTextTrackState_(BMessenger messenger)
|
|
||||||
:
|
:
|
||||||
clickOffset(0),
|
clickOffset(0),
|
||||||
shiftDown(false),
|
shiftDown(false),
|
||||||
@@ -4618,14 +4752,14 @@ _BTextTrackState_::_BTextTrackState_(BMessenger messenger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_BTextTrackState_::~_BTextTrackState_()
|
BTextView::TextTrackState::~TextTrackState()
|
||||||
{
|
{
|
||||||
delete fRunner;
|
delete fRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BTextTrackState_::SimulateMouseMovement(BTextView *textView)
|
BTextView::TextTrackState::SimulateMouseMovement(BTextView *textView)
|
||||||
{
|
{
|
||||||
BPoint where;
|
BPoint where;
|
||||||
ulong buttons;
|
ulong buttons;
|
||||||
|
|||||||
@@ -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.
|
\param messenger The BMessenger of the input server method addon.
|
||||||
*/
|
*/
|
||||||
_BInlineInput_::_BInlineInput_(BMessenger messenger)
|
BTextView::InlineInput::InlineInput(BMessenger messenger)
|
||||||
:
|
:
|
||||||
fMessenger(messenger),
|
fMessenger(messenger),
|
||||||
fActive(false),
|
fActive(false),
|
||||||
@@ -42,7 +42,7 @@ _BInlineInput_::_BInlineInput_(BMessenger messenger)
|
|||||||
|
|
||||||
/*! \brief Destructs the object, free the allocated memory.
|
/*! \brief Destructs the object, free the allocated memory.
|
||||||
*/
|
*/
|
||||||
_BInlineInput_::~_BInlineInput_()
|
BTextView::InlineInput::~InlineInput()
|
||||||
{
|
{
|
||||||
ResetClauses();
|
ResetClauses();
|
||||||
}
|
}
|
||||||
@@ -52,21 +52,21 @@ _BInlineInput_::~_BInlineInput_()
|
|||||||
which requested the transaction.
|
which requested the transaction.
|
||||||
*/
|
*/
|
||||||
const BMessenger *
|
const BMessenger *
|
||||||
_BInlineInput_::Method() const
|
BTextView::InlineInput::Method() const
|
||||||
{
|
{
|
||||||
return &fMessenger;
|
return &fMessenger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_BInlineInput_::IsActive() const
|
BTextView::InlineInput::IsActive() const
|
||||||
{
|
{
|
||||||
return fActive;
|
return fActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BInlineInput_::SetActive(bool active)
|
BTextView::InlineInput::SetActive(bool active)
|
||||||
{
|
{
|
||||||
fActive = active;
|
fActive = active;
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ _BInlineInput_::SetActive(bool active)
|
|||||||
/*! \brief Return the length of the inputted text.
|
/*! \brief Return the length of the inputted text.
|
||||||
*/
|
*/
|
||||||
int32
|
int32
|
||||||
_BInlineInput_::Length() const
|
BTextView::InlineInput::Length() const
|
||||||
{
|
{
|
||||||
return fLength;
|
return fLength;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ _BInlineInput_::Length() const
|
|||||||
B_INPUT_METHOD_CHANGED BMessage.
|
B_INPUT_METHOD_CHANGED BMessage.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_BInlineInput_::SetLength(int32 len)
|
BTextView::InlineInput::SetLength(int32 len)
|
||||||
{
|
{
|
||||||
fLength = len;
|
fLength = len;
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ _BInlineInput_::SetLength(int32 len)
|
|||||||
/*! \brief Returns the offset into the BTextView of the text.
|
/*! \brief Returns the offset into the BTextView of the text.
|
||||||
*/
|
*/
|
||||||
int32
|
int32
|
||||||
_BInlineInput_::Offset() const
|
BTextView::InlineInput::Offset() const
|
||||||
{
|
{
|
||||||
return fOffset;
|
return fOffset;
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ _BInlineInput_::Offset() const
|
|||||||
\param offset The offset where the text has been inserted.
|
\param offset The offset where the text has been inserted.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_BInlineInput_::SetOffset(int32 offset)
|
BTextView::InlineInput::SetOffset(int32 offset)
|
||||||
{
|
{
|
||||||
fOffset = offset;
|
fOffset = offset;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ _BInlineInput_::SetOffset(int32 offset)
|
|||||||
/*! \brief Returns the length of the selection, if any.
|
/*! \brief Returns the length of the selection, if any.
|
||||||
*/
|
*/
|
||||||
int32
|
int32
|
||||||
_BInlineInput_::SelectionLength() const
|
BTextView::InlineInput::SelectionLength() const
|
||||||
{
|
{
|
||||||
return fSelectionLength;
|
return fSelectionLength;
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ _BInlineInput_::SelectionLength() const
|
|||||||
\param length The length of the selection.
|
\param length The length of the selection.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_BInlineInput_::SetSelectionLength(int32 length)
|
BTextView::InlineInput::SetSelectionLength(int32 length)
|
||||||
{
|
{
|
||||||
fSelectionLength = length;
|
fSelectionLength = length;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ _BInlineInput_::SetSelectionLength(int32 length)
|
|||||||
/*! \brief Returns the offset into the method string of the selection.
|
/*! \brief Returns the offset into the method string of the selection.
|
||||||
*/
|
*/
|
||||||
int32
|
int32
|
||||||
_BInlineInput_::SelectionOffset() const
|
BTextView::InlineInput::SelectionOffset() const
|
||||||
{
|
{
|
||||||
return fSelectionOffset;
|
return fSelectionOffset;
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ _BInlineInput_::SelectionOffset() const
|
|||||||
\param offset The offset where the selection starts.
|
\param offset The offset where the selection starts.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_BInlineInput_::SetSelectionOffset(int32 offset)
|
BTextView::InlineInput::SetSelectionOffset(int32 offset)
|
||||||
{
|
{
|
||||||
fSelectionOffset = offset;
|
fSelectionOffset = offset;
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ _BInlineInput_::SetSelectionOffset(int32 offset)
|
|||||||
\param end The offset into the string where the clause finishes.
|
\param end The offset into the string where the clause finishes.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
_BInlineInput_::AddClause(int32 start, int32 end)
|
BTextView::InlineInput::AddClause(int32 start, int32 end)
|
||||||
{
|
{
|
||||||
void *newData = realloc(fClauses, (fNumClauses + 1) * sizeof(clause));
|
void *newData = realloc(fClauses, (fNumClauses + 1) * sizeof(clause));
|
||||||
if (newData == NULL)
|
if (newData == NULL)
|
||||||
@@ -175,7 +175,7 @@ _BInlineInput_::AddClause(int32 start, int32 end)
|
|||||||
\return \c true if the clause exists, \c false if not.
|
\return \c true if the clause exists, \c false if not.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
_BInlineInput_::GetClause(int32 index, int32 *start, int32 *end) const
|
BTextView::InlineInput::GetClause(int32 index, int32 *start, int32 *end) const
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (index >= 0 && index < fNumClauses) {
|
if (index >= 0 && index < fNumClauses) {
|
||||||
@@ -192,7 +192,7 @@ _BInlineInput_::GetClause(int32 index, int32 *start, int32 *end) const
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
_BInlineInput_::CountClauses() const
|
BTextView::InlineInput::CountClauses() const
|
||||||
{
|
{
|
||||||
return fNumClauses;
|
return fNumClauses;
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ _BInlineInput_::CountClauses() const
|
|||||||
/*! \brief Deletes any added clause.
|
/*! \brief Deletes any added clause.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_BInlineInput_::ResetClauses()
|
BTextView::InlineInput::ResetClauses()
|
||||||
{
|
{
|
||||||
fNumClauses = 0;
|
fNumClauses = 0;
|
||||||
free(fClauses);
|
free(fClauses);
|
||||||
|
|||||||
@@ -10,12 +10,14 @@
|
|||||||
#define __INLINEINPUT_H
|
#define __INLINEINPUT_H
|
||||||
|
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
struct clause;
|
struct clause;
|
||||||
class _BInlineInput_ {
|
|
||||||
|
class BTextView::InlineInput {
|
||||||
public:
|
public:
|
||||||
_BInlineInput_(BMessenger);
|
InlineInput(BMessenger);
|
||||||
~_BInlineInput_();
|
~InlineInput();
|
||||||
|
|
||||||
const BMessenger *Method() const;
|
const BMessenger *Method() const;
|
||||||
|
|
||||||
|
|||||||
@@ -9,33 +9,33 @@
|
|||||||
#include "LineBuffer.h"
|
#include "LineBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
_BLineBuffer_::_BLineBuffer_()
|
BTextView::LineBuffer::LineBuffer()
|
||||||
: _BTextViewSupportBuffer_<STELine>(20, 2)
|
: _BTextViewSupportBuffer_<STELine>(20, 2)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_BLineBuffer_::~_BLineBuffer_()
|
BTextView::LineBuffer::~LineBuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BLineBuffer_::InsertLine(STELine *inLine, int32 index)
|
BTextView::LineBuffer::InsertLine(STELine *inLine, int32 index)
|
||||||
{
|
{
|
||||||
InsertItemsAt(1, index, inLine);
|
InsertItemsAt(1, index, inLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BLineBuffer_::RemoveLines(int32 index, int32 count)
|
BTextView::LineBuffer::RemoveLines(int32 index, int32 count)
|
||||||
{
|
{
|
||||||
RemoveItemsAt(count, index);
|
RemoveItemsAt(count, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BLineBuffer_::RemoveLineRange(int32 fromOffset, int32 toOffset)
|
BTextView::LineBuffer::RemoveLineRange(int32 fromOffset, int32 toOffset)
|
||||||
{
|
{
|
||||||
int32 fromLine = OffsetToLine(fromOffset);
|
int32 fromLine = OffsetToLine(fromOffset);
|
||||||
int32 toLine = OffsetToLine(toOffset);
|
int32 toLine = OffsetToLine(toOffset);
|
||||||
@@ -49,7 +49,7 @@ _BLineBuffer_::RemoveLineRange(int32 fromOffset, int32 toOffset)
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
_BLineBuffer_::OffsetToLine(int32 offset) const
|
BTextView::LineBuffer::OffsetToLine(int32 offset) const
|
||||||
{
|
{
|
||||||
int32 minIndex = 0;
|
int32 minIndex = 0;
|
||||||
int32 maxIndex = fItemCount - 1;
|
int32 maxIndex = fItemCount - 1;
|
||||||
@@ -71,7 +71,7 @@ _BLineBuffer_::OffsetToLine(int32 offset) const
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
_BLineBuffer_::PixelToLine(float pixel) const
|
BTextView::LineBuffer::PixelToLine(float pixel) const
|
||||||
{
|
{
|
||||||
int32 minIndex = 0;
|
int32 minIndex = 0;
|
||||||
int32 maxIndex = fItemCount - 1;
|
int32 maxIndex = fItemCount - 1;
|
||||||
@@ -93,7 +93,7 @@ _BLineBuffer_::PixelToLine(float pixel) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BLineBuffer_::BumpOrigin(float delta, long index)
|
BTextView::LineBuffer::BumpOrigin(float delta, long index)
|
||||||
{
|
{
|
||||||
for (long i = index; i < fItemCount; i++)
|
for (long i = index; i < fItemCount; i++)
|
||||||
fBuffer[i].origin += delta;
|
fBuffer[i].origin += delta;
|
||||||
@@ -101,7 +101,7 @@ _BLineBuffer_::BumpOrigin(float delta, long index)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BLineBuffer_::BumpOffset(int32 delta, int32 index)
|
BTextView::LineBuffer::BumpOffset(int32 delta, int32 index)
|
||||||
{
|
{
|
||||||
for (long i = index; i < fItemCount; i++)
|
for (long i = index; i < fItemCount; i++)
|
||||||
fBuffer[i].offset += delta;
|
fBuffer[i].offset += delta;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
#include "TextViewSupportBuffer.h"
|
#include "TextViewSupportBuffer.h"
|
||||||
|
|
||||||
struct STELine {
|
struct STELine {
|
||||||
@@ -17,12 +19,11 @@ struct STELine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// _BLineBuffer_ class ---------------------------------------------------------
|
class BTextView::LineBuffer : public _BTextViewSupportBuffer_<STELine> {
|
||||||
class _BLineBuffer_ : public _BTextViewSupportBuffer_<STELine> {
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_BLineBuffer_();
|
LineBuffer();
|
||||||
virtual ~_BLineBuffer_();
|
virtual ~LineBuffer();
|
||||||
|
|
||||||
void InsertLine(STELine *inLine, int32 index);
|
void InsertLine(STELine *inLine, int32 index);
|
||||||
void RemoveLines(int32 index, int32 count = 1);
|
void RemoveLines(int32 index, int32 count = 1);
|
||||||
@@ -40,14 +41,14 @@ virtual ~_BLineBuffer_();
|
|||||||
|
|
||||||
|
|
||||||
inline int32
|
inline int32
|
||||||
_BLineBuffer_::NumLines() const
|
BTextView::LineBuffer::NumLines() const
|
||||||
{
|
{
|
||||||
return fItemCount - 1;
|
return fItemCount - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline STELine *
|
inline STELine *
|
||||||
_BLineBuffer_::operator[](int32 index) const
|
BTextView::LineBuffer::operator[](int32 index) const
|
||||||
{
|
{
|
||||||
return &fBuffer[index];
|
return &fBuffer[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
fValidNullStyle(true)
|
||||||
{
|
{
|
||||||
@@ -183,21 +183,21 @@ _BStyleBuffer_::_BStyleBuffer_(const BFont *inFont, const rgb_color *inColor)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::InvalidateNullStyle()
|
BTextView::StyleBuffer::InvalidateNullStyle()
|
||||||
{
|
{
|
||||||
fValidNullStyle = false;
|
fValidNullStyle = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_BStyleBuffer_::IsValidNullStyle() const
|
BTextView::StyleBuffer::IsValidNullStyle() const
|
||||||
{
|
{
|
||||||
return fValidNullStyle;
|
return fValidNullStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::SyncNullStyle(int32 offset)
|
BTextView::StyleBuffer::SyncNullStyle(int32 offset)
|
||||||
{
|
{
|
||||||
if (fValidNullStyle || fStyleRunDesc.ItemCount() < 1)
|
if (fValidNullStyle || fStyleRunDesc.ItemCount() < 1)
|
||||||
return;
|
return;
|
||||||
@@ -210,7 +210,7 @@ _BStyleBuffer_::SyncNullStyle(int32 offset)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
|
BTextView::StyleBuffer::SetNullStyle(uint32 inMode, const BFont *inFont,
|
||||||
const rgb_color *inColor, int32 offset)
|
const rgb_color *inColor, int32 offset)
|
||||||
{
|
{
|
||||||
if (fValidNullStyle || fStyleRunDesc.ItemCount() < 1)
|
if (fValidNullStyle || fStyleRunDesc.ItemCount() < 1)
|
||||||
@@ -226,7 +226,7 @@ _BStyleBuffer_::SetNullStyle(uint32 inMode, const BFont *inFont,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::GetNullStyle(const BFont **font, const rgb_color **color) const
|
BTextView::StyleBuffer::GetNullStyle(const BFont **font, const rgb_color **color) const
|
||||||
{
|
{
|
||||||
if (font)
|
if (font)
|
||||||
*font = &fNullStyle.font;
|
*font = &fNullStyle.font;
|
||||||
@@ -236,7 +236,7 @@ _BStyleBuffer_::GetNullStyle(const BFont **font, const rgb_color **color) const
|
|||||||
|
|
||||||
|
|
||||||
STEStyleRange *
|
STEStyleRange *
|
||||||
_BStyleBuffer_::AllocateStyleRange(const int32 numStyles) const
|
BTextView::StyleBuffer::AllocateStyleRange(const int32 numStyles) const
|
||||||
{
|
{
|
||||||
STEStyleRange* range = (STEStyleRange *)malloc(sizeof(int32) + sizeof(STEStyleRun) * numStyles);
|
STEStyleRange* range = (STEStyleRange *)malloc(sizeof(int32) + sizeof(STEStyleRun) * numStyles);
|
||||||
if (range)
|
if (range)
|
||||||
@@ -246,7 +246,7 @@ _BStyleBuffer_::AllocateStyleRange(const int32 numStyles) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
BTextView::StyleBuffer::SetStyleRange(int32 fromOffset, int32 toOffset,
|
||||||
int32 textLen, uint32 inMode, const BFont *inFont,
|
int32 textLen, uint32 inMode, const BFont *inFont,
|
||||||
const rgb_color *inColor)
|
const rgb_color *inColor)
|
||||||
{
|
{
|
||||||
@@ -323,7 +323,7 @@ _BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
|||||||
|
|
||||||
|
|
||||||
void
|
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 (fStyleRunDesc.ItemCount() < 1) {
|
||||||
if (outFont)
|
if (outFont)
|
||||||
@@ -344,7 +344,7 @@ _BStyleBuffer_::GetStyle(int32 inOffset, BFont *outFont, rgb_color *outColor) co
|
|||||||
|
|
||||||
|
|
||||||
STEStyleRange*
|
STEStyleRange*
|
||||||
_BStyleBuffer_::GetStyleRange(int32 startOffset, int32 endOffset) const
|
BTextView::StyleBuffer::GetStyleRange(int32 startOffset, int32 endOffset) const
|
||||||
{
|
{
|
||||||
int32 startIndex = OffsetToRun(startOffset);
|
int32 startIndex = OffsetToRun(startOffset);
|
||||||
int32 endIndex = OffsetToRun(endOffset);
|
int32 endIndex = OffsetToRun(endOffset);
|
||||||
@@ -371,7 +371,7 @@ _BStyleBuffer_::GetStyleRange(int32 startOffset, int32 endOffset) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::RemoveStyleRange(int32 fromOffset, int32 toOffset)
|
BTextView::StyleBuffer::RemoveStyleRange(int32 fromOffset, int32 toOffset)
|
||||||
{
|
{
|
||||||
int32 fromIndex = fStyleRunDesc.OffsetToRun(fromOffset);
|
int32 fromIndex = fStyleRunDesc.OffsetToRun(fromOffset);
|
||||||
int32 toIndex = fStyleRunDesc.OffsetToRun(toOffset) - 1;
|
int32 toIndex = fStyleRunDesc.OffsetToRun(toOffset) - 1;
|
||||||
@@ -406,7 +406,7 @@ _BStyleBuffer_::RemoveStyleRange(int32 fromOffset, int32 toOffset)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::RemoveStyles(int32 index, int32 count)
|
BTextView::StyleBuffer::RemoveStyles(int32 index, int32 count)
|
||||||
{
|
{
|
||||||
for (int32 i = index; i < (index + count); i++)
|
for (int32 i = index; i < (index + count); i++)
|
||||||
fStyleRecord.RemoveRecord(fStyleRunDesc[i]->index);
|
fStyleRecord.RemoveRecord(fStyleRunDesc[i]->index);
|
||||||
@@ -416,11 +416,12 @@ _BStyleBuffer_::RemoveStyles(int32 index, int32 count)
|
|||||||
|
|
||||||
|
|
||||||
int32
|
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,
|
const BFont **outFont, const rgb_color **outColor,
|
||||||
float *outAscent, float *outDescent, uint32 *) const
|
float *outAscent, float *outDescent, uint32 *) const
|
||||||
{
|
{
|
||||||
// TODO: Handle the _BInlineInput_ style here in some way
|
// TODO: Handle the InlineInput style here in some way
|
||||||
int32 numRuns = fStyleRunDesc.ItemCount();
|
int32 numRuns = fStyleRunDesc.ItemCount();
|
||||||
if (length < 1 || numRuns < 1)
|
if (length < 1 || numRuns < 1)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -448,21 +449,21 @@ _BStyleBuffer_::Iterate(int32 fromOffset, int32 length, _BInlineInput_ *input,
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
_BStyleBuffer_::OffsetToRun(int32 offset) const
|
BTextView::StyleBuffer::OffsetToRun(int32 offset) const
|
||||||
{
|
{
|
||||||
return fStyleRunDesc.OffsetToRun(offset);
|
return fStyleRunDesc.OffsetToRun(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::BumpOffset(int32 delta, int32 index)
|
BTextView::StyleBuffer::BumpOffset(int32 delta, int32 index)
|
||||||
{
|
{
|
||||||
fStyleRunDesc.BumpOffset(delta, index);
|
fStyleRunDesc.BumpOffset(delta, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STEStyleRun
|
STEStyleRun
|
||||||
_BStyleBuffer_::operator[](int32 index) const
|
BTextView::StyleBuffer::operator[](int32 index) const
|
||||||
{
|
{
|
||||||
STEStyleRun run;
|
STEStyleRun run;
|
||||||
|
|
||||||
@@ -506,7 +507,7 @@ FixupMode(const STEStyle &firstStyle, const STEStyle &otherStyle, uint32 &mode,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
BTextView::StyleBuffer::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
||||||
rgb_color *outColor, bool *sameColor, int32 fromOffset,
|
rgb_color *outColor, bool *sameColor, int32 fromOffset,
|
||||||
int32 toOffset) const
|
int32 toOffset) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
#include "TextViewSupportBuffer.h"
|
#include "TextViewSupportBuffer.h"
|
||||||
|
|
||||||
@@ -92,12 +93,10 @@ _BStyleRecordBuffer_::operator[](int32 index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _BInlineInput_;
|
// StyleBuffer class --------------------------------------------------------
|
||||||
|
class BTextView::StyleBuffer {
|
||||||
// _BStyleBuffer_ class --------------------------------------------------------
|
|
||||||
class _BStyleBuffer_ {
|
|
||||||
public:
|
public:
|
||||||
_BStyleBuffer_(const BFont *inFont,
|
StyleBuffer(const BFont *inFont,
|
||||||
const rgb_color *inColor);
|
const rgb_color *inColor);
|
||||||
|
|
||||||
void InvalidateNullStyle();
|
void InvalidateNullStyle();
|
||||||
@@ -123,7 +122,8 @@ class _BStyleBuffer_ {
|
|||||||
void RemoveStyleRange(int32 fromOffset, int32 toOffset);
|
void RemoveStyleRange(int32 fromOffset, int32 toOffset);
|
||||||
void RemoveStyles(int32 index, int32 count = 1);
|
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 BFont **outFont = NULL,
|
||||||
const rgb_color **outColor = NULL,
|
const rgb_color **outColor = NULL,
|
||||||
float *outAscent = NULL,
|
float *outAscent = NULL,
|
||||||
@@ -147,21 +147,21 @@ class _BStyleBuffer_ {
|
|||||||
|
|
||||||
|
|
||||||
inline int32
|
inline int32
|
||||||
_BStyleBuffer_::NumRuns() const
|
BTextView::StyleBuffer::NumRuns() const
|
||||||
{
|
{
|
||||||
return fStyleRunDesc.ItemCount();
|
return fStyleRunDesc.ItemCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const _BStyleRunDescBuffer_&
|
inline const _BStyleRunDescBuffer_&
|
||||||
_BStyleBuffer_::RunBuffer() const
|
BTextView::StyleBuffer::RunBuffer() const
|
||||||
{
|
{
|
||||||
return fStyleRunDesc;
|
return fStyleRunDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const _BStyleRecordBuffer_&
|
inline const _BStyleRecordBuffer_&
|
||||||
_BStyleBuffer_::RecordBuffer() const
|
BTextView::StyleBuffer::RecordBuffer() const
|
||||||
{
|
{
|
||||||
return fStyleRecord;
|
return fStyleRecord;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "TextGapBuffer.h"
|
#include "TextGapBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
_BTextGapBuffer_::_BTextGapBuffer_()
|
BTextView::TextGapBuffer::TextGapBuffer()
|
||||||
: fExtraCount(2048),
|
: fExtraCount(2048),
|
||||||
fItemCount(0),
|
fItemCount(0),
|
||||||
fBuffer(NULL),
|
fBuffer(NULL),
|
||||||
@@ -35,7 +35,7 @@ _BTextGapBuffer_::_BTextGapBuffer_()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_BTextGapBuffer_::~_BTextGapBuffer_()
|
BTextView::TextGapBuffer::~TextGapBuffer()
|
||||||
{
|
{
|
||||||
free(fBuffer);
|
free(fBuffer);
|
||||||
free(fScratchBuffer);
|
free(fScratchBuffer);
|
||||||
@@ -43,7 +43,7 @@ _BTextGapBuffer_::~_BTextGapBuffer_()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
|
BTextView::TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
|
||||||
{
|
{
|
||||||
if (inNumItems < 1)
|
if (inNumItems < 1)
|
||||||
return;
|
return;
|
||||||
@@ -66,7 +66,7 @@ _BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, int32 inAtInd
|
|||||||
|
|
||||||
|
|
||||||
void
|
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;
|
off_t fileSize;
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ _BTextGapBuffer_::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, in
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BTextGapBuffer_::RemoveRange(int32 start, int32 end)
|
BTextView::TextGapBuffer::RemoveRange(int32 start, int32 end)
|
||||||
{
|
{
|
||||||
long inAtIndex = start;
|
long inAtIndex = start;
|
||||||
long inNumItems = end - start;
|
long inNumItems = end - start;
|
||||||
@@ -124,7 +124,7 @@ _BTextGapBuffer_::RemoveRange(int32 start, int32 end)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BTextGapBuffer_::MoveGapTo(int32 toIndex)
|
BTextView::TextGapBuffer::MoveGapTo(int32 toIndex)
|
||||||
{
|
{
|
||||||
if (toIndex == fGapIndex)
|
if (toIndex == fGapIndex)
|
||||||
return;
|
return;
|
||||||
@@ -153,7 +153,7 @@ _BTextGapBuffer_::MoveGapTo(int32 toIndex)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BTextGapBuffer_::SizeGapTo(long inCount)
|
BTextView::TextGapBuffer::SizeGapTo(long inCount)
|
||||||
{
|
{
|
||||||
if (inCount == fGapCount)
|
if (inCount == fGapCount)
|
||||||
return;
|
return;
|
||||||
@@ -169,7 +169,7 @@ _BTextGapBuffer_::SizeGapTo(long inCount)
|
|||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
_BTextGapBuffer_::GetString(int32 fromOffset, int32 *_numBytes)
|
BTextView::TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
||||||
{
|
{
|
||||||
char *result = "";
|
char *result = "";
|
||||||
if (_numBytes == NULL)
|
if (_numBytes == NULL)
|
||||||
@@ -226,7 +226,7 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 *_numBytes)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_BTextGapBuffer_::FindChar(char inChar, long fromIndex, long *ioDelta)
|
BTextView::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 +244,7 @@ _BTextGapBuffer_::FindChar(char inChar, long fromIndex, long *ioDelta)
|
|||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
_BTextGapBuffer_::Text()
|
BTextView::TextGapBuffer::Text()
|
||||||
{
|
{
|
||||||
const char *realText = RealText();
|
const char *realText = RealText();
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ _BTextGapBuffer_::Text()
|
|||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
_BTextGapBuffer_::RealText()
|
BTextView::TextGapBuffer::RealText()
|
||||||
{
|
{
|
||||||
MoveGapTo(fItemCount);
|
MoveGapTo(fItemCount);
|
||||||
fBuffer[fItemCount] = '\0';
|
fBuffer[fItemCount] = '\0';
|
||||||
@@ -283,7 +283,7 @@ _BTextGapBuffer_::RealText()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BTextGapBuffer_::GetString(int32 offset, int32 length, char *buffer)
|
BTextView::TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
|
||||||
{
|
{
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -324,14 +324,14 @@ _BTextGapBuffer_::GetString(int32 offset, int32 length, char *buffer)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_BTextGapBuffer_::PasswordMode() const
|
BTextView::TextGapBuffer::PasswordMode() const
|
||||||
{
|
{
|
||||||
return fPasswordMode;
|
return fPasswordMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BTextGapBuffer_::SetPasswordMode(bool state)
|
BTextView::TextGapBuffer::SetPasswordMode(bool state)
|
||||||
{
|
{
|
||||||
fPasswordMode = state;
|
fPasswordMode = state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,17 +10,21 @@
|
|||||||
#define __TEXTGAPBUFFER_H
|
#define __TEXTGAPBUFFER_H
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
|
|
||||||
class BFile;
|
class BFile;
|
||||||
class _BTextGapBuffer_ {
|
|
||||||
|
|
||||||
|
|
||||||
|
class BTextView::TextGapBuffer {
|
||||||
public:
|
public:
|
||||||
_BTextGapBuffer_();
|
TextGapBuffer();
|
||||||
virtual ~_BTextGapBuffer_();
|
virtual ~TextGapBuffer();
|
||||||
|
|
||||||
void InsertText(const char *inText, int32 inNumItems, int32 inAtIndex);
|
void InsertText(const char *inText, int32 inNumItems,
|
||||||
void InsertText(BFile *file, int32 fileOffset, int32 amount, int32 atIndex);
|
int32 inAtIndex);
|
||||||
|
void InsertText(BFile *file, int32 fileOffset, int32 amount,
|
||||||
|
int32 atIndex);
|
||||||
void RemoveRange(int32 start, int32 end);
|
void RemoveRange(int32 start, int32 end);
|
||||||
|
|
||||||
void MoveGapTo(int32 toIndex);
|
void MoveGapTo(int32 toIndex);
|
||||||
@@ -44,11 +48,11 @@ virtual ~_BTextGapBuffer_();
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32 fExtraCount; // when realloc()-ing
|
int32 fExtraCount; // when realloc()-ing
|
||||||
int32 fItemCount; // logical count
|
int32 fItemCount; // logical count
|
||||||
char *fBuffer; // allocated memory
|
char *fBuffer; // allocated memory
|
||||||
int32 fBufferCount; // physical count
|
int32 fBufferCount; // physical count
|
||||||
int32 fGapIndex; // gap position
|
int32 fGapIndex; // gap position
|
||||||
int32 fGapCount; // gap count
|
int32 fGapCount; // gap count
|
||||||
char *fScratchBuffer; // for GetString
|
char *fScratchBuffer; // for GetString
|
||||||
int32 fScratchSize; // scratch size
|
int32 fScratchSize; // scratch size
|
||||||
bool fPasswordMode;
|
bool fPasswordMode;
|
||||||
@@ -56,14 +60,14 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
inline int32
|
inline int32
|
||||||
_BTextGapBuffer_::Length() const
|
BTextView::TextGapBuffer::Length() const
|
||||||
{
|
{
|
||||||
return fItemCount;
|
return fItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline char
|
inline char
|
||||||
_BTextGapBuffer_::RealCharAt(long index) const
|
BTextView::TextGapBuffer::RealCharAt(long index) const
|
||||||
{
|
{
|
||||||
return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];
|
return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* Stefano Ceccherini (burton666@libero.it)
|
* 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"
|
#include "UndoBuffer.h"
|
||||||
@@ -22,10 +22,10 @@
|
|||||||
// TODO: properly document this file
|
// 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),
|
fTextView(textView),
|
||||||
fTextData(NULL),
|
fTextData(NULL),
|
||||||
@@ -45,7 +45,7 @@ _BUndoBuffer_::_BUndoBuffer_(BTextView *textView, undo_state state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_BUndoBuffer_::~_BUndoBuffer_()
|
BTextView::UndoBuffer::~UndoBuffer()
|
||||||
{
|
{
|
||||||
free(fTextData);
|
free(fTextData);
|
||||||
BTextView::FreeRunArray(fRunArray);
|
BTextView::FreeRunArray(fRunArray);
|
||||||
@@ -53,7 +53,7 @@ _BUndoBuffer_::~_BUndoBuffer_()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BUndoBuffer_::Undo(BClipboard *clipboard)
|
BTextView::UndoBuffer::Undo(BClipboard *clipboard)
|
||||||
{
|
{
|
||||||
fRedo ? RedoSelf(clipboard) : UndoSelf(clipboard);
|
fRedo ? RedoSelf(clipboard) : UndoSelf(clipboard);
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ _BUndoBuffer_::Undo(BClipboard *clipboard)
|
|||||||
|
|
||||||
|
|
||||||
undo_state
|
undo_state
|
||||||
_BUndoBuffer_::State(bool *redo)
|
BTextView::UndoBuffer::State(bool *redo)
|
||||||
{
|
{
|
||||||
*redo = fRedo;
|
*redo = fRedo;
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ _BUndoBuffer_::State(bool *redo)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BUndoBuffer_::UndoSelf(BClipboard *clipboard)
|
BTextView::UndoBuffer::UndoSelf(BClipboard *clipboard)
|
||||||
{
|
{
|
||||||
fTextView->Select(fStart, fStart);
|
fTextView->Select(fStart, fStart);
|
||||||
fTextView->Insert(fTextData, fTextLength, fRunArray);
|
fTextView->Insert(fTextData, fTextLength, fRunArray);
|
||||||
@@ -80,7 +80,7 @@ _BUndoBuffer_::UndoSelf(BClipboard *clipboard)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BUndoBuffer_::RedoSelf(BClipboard *clipboard)
|
BTextView::UndoBuffer::RedoSelf(BClipboard *clipboard)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ _BUndoBuffer_::RedoSelf(BClipboard *clipboard)
|
|||||||
|
|
||||||
|
|
||||||
_BCutUndoBuffer_::_BCutUndoBuffer_(BTextView *textView)
|
_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,
|
_BPasteUndoBuffer_::_BPasteUndoBuffer_(BTextView *textView, const char *text,
|
||||||
int32 textLen, text_run_array *runArray, int32 runArrayLen)
|
int32 textLen, text_run_array *runArray, int32 runArrayLen)
|
||||||
: _BUndoBuffer_(textView, B_UNDO_PASTE),
|
: BTextView::UndoBuffer(textView, B_UNDO_PASTE),
|
||||||
fPasteText(NULL),
|
fPasteText(NULL),
|
||||||
fPasteTextLength(textLen),
|
fPasteTextLength(textLen),
|
||||||
fPasteRunArray(NULL)
|
fPasteRunArray(NULL)
|
||||||
@@ -169,7 +169,7 @@ _BPasteUndoBuffer_::RedoSelf(BClipboard *clipboard)
|
|||||||
|
|
||||||
|
|
||||||
_BClearUndoBuffer_::_BClearUndoBuffer_(BTextView *textView)
|
_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,
|
_BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text,
|
||||||
int32 textLen, text_run_array *runArray, int32 runArrayLen,
|
int32 textLen, text_run_array *runArray, int32 runArrayLen,
|
||||||
int32 location, bool internalDrop)
|
int32 location, bool internalDrop)
|
||||||
: _BUndoBuffer_(textView, B_UNDO_DROP),
|
: BTextView::UndoBuffer(textView, B_UNDO_DROP),
|
||||||
fDropText(NULL),
|
fDropText(NULL),
|
||||||
fDropTextLength(textLen),
|
fDropTextLength(textLen),
|
||||||
fDropRunArray(NULL)
|
fDropRunArray(NULL)
|
||||||
@@ -249,7 +249,7 @@ _BDropUndoBuffer_::RedoSelf(BClipboard *)
|
|||||||
|
|
||||||
|
|
||||||
_BTypingUndoBuffer_::_BTypingUndoBuffer_(BTextView *textView)
|
_BTypingUndoBuffer_::_BTypingUndoBuffer_(BTextView *textView)
|
||||||
: _BUndoBuffer_(textView, B_UNDO_TYPING),
|
: BTextView::UndoBuffer(textView, B_UNDO_TYPING),
|
||||||
fTypedText(NULL),
|
fTypedText(NULL),
|
||||||
fTypedStart(fStart),
|
fTypedStart(fStart),
|
||||||
fTypedEnd(fEnd),
|
fTypedEnd(fEnd),
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
class BClipboard;
|
class BClipboard;
|
||||||
|
|
||||||
class _BUndoBuffer_ {
|
class BTextView::UndoBuffer {
|
||||||
public:
|
public:
|
||||||
_BUndoBuffer_(BTextView *, undo_state);
|
UndoBuffer(BTextView *, undo_state);
|
||||||
virtual ~_BUndoBuffer_();
|
virtual ~UndoBuffer();
|
||||||
|
|
||||||
void Undo(BClipboard *);
|
void Undo(BClipboard *);
|
||||||
undo_state State(bool *);
|
undo_state State(bool *);
|
||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// ******** _BCutUndoBuffer_ *******
|
// ******** _BCutUndoBuffer_ *******
|
||||||
class _BCutUndoBuffer_ : public _BUndoBuffer_ {
|
class _BCutUndoBuffer_ : public BTextView::UndoBuffer {
|
||||||
public:
|
public:
|
||||||
_BCutUndoBuffer_(BTextView *textView);
|
_BCutUndoBuffer_(BTextView *textView);
|
||||||
~_BCutUndoBuffer_();
|
~_BCutUndoBuffer_();
|
||||||
@@ -54,7 +54,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
// ******** _BPasteUndoBuffer_ *******
|
// ******** _BPasteUndoBuffer_ *******
|
||||||
class _BPasteUndoBuffer_ : public _BUndoBuffer_ {
|
class _BPasteUndoBuffer_ : public BTextView::UndoBuffer {
|
||||||
public:
|
public:
|
||||||
_BPasteUndoBuffer_(BTextView *, const char *, int32, text_run_array *, int32);
|
_BPasteUndoBuffer_(BTextView *, const char *, int32, text_run_array *, int32);
|
||||||
~_BPasteUndoBuffer_();
|
~_BPasteUndoBuffer_();
|
||||||
@@ -71,7 +71,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// ******** _BClearUndoBuffer_ *******
|
// ******** _BClearUndoBuffer_ *******
|
||||||
class _BClearUndoBuffer_ : public _BUndoBuffer_ {
|
class _BClearUndoBuffer_ : public BTextView::UndoBuffer {
|
||||||
public:
|
public:
|
||||||
_BClearUndoBuffer_(BTextView *textView);
|
_BClearUndoBuffer_(BTextView *textView);
|
||||||
~_BClearUndoBuffer_();
|
~_BClearUndoBuffer_();
|
||||||
@@ -82,7 +82,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
// ******** _BDropUndoBuffer_ ********
|
// ******** _BDropUndoBuffer_ ********
|
||||||
class _BDropUndoBuffer_ : public _BUndoBuffer_ {
|
class _BDropUndoBuffer_ : public BTextView::UndoBuffer {
|
||||||
public:
|
public:
|
||||||
_BDropUndoBuffer_(BTextView *, char const *, int32, text_run_array *, int32, int32, bool);
|
_BDropUndoBuffer_(BTextView *, char const *, int32, text_run_array *, int32, int32, bool);
|
||||||
~_BDropUndoBuffer_();
|
~_BDropUndoBuffer_();
|
||||||
@@ -102,7 +102,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// ******** _BTypingUndoBuffer_ ********
|
// ******** _BTypingUndoBuffer_ ********
|
||||||
class _BTypingUndoBuffer_ : public _BUndoBuffer_ {
|
class _BTypingUndoBuffer_ : public BTextView::UndoBuffer {
|
||||||
public:
|
public:
|
||||||
_BTypingUndoBuffer_(BTextView *);
|
_BTypingUndoBuffer_(BTextView *);
|
||||||
~_BTypingUndoBuffer_();
|
~_BTypingUndoBuffer_();
|
||||||
|
|||||||
@@ -13,14 +13,17 @@
|
|||||||
#include "TextGapBuffer.h"
|
#include "TextGapBuffer.h"
|
||||||
#include "WidthBuffer.h"
|
#include "WidthBuffer.h"
|
||||||
|
|
||||||
|
#include <Autolock.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
|
#include <Locker.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
const static uint32 kTableCount = 128;
|
const static uint32 kTableCount = 128;
|
||||||
const static uint32 kInvalidCode = 0xFFFFFFFF;
|
const static uint32 kInvalidCode = 0xFFFFFFFF;
|
||||||
|
static BLocker sWidthLocker = BLocker("width buffer lock");
|
||||||
|
|
||||||
|
|
||||||
struct hashed_escapement {
|
struct hashed_escapement {
|
||||||
@@ -56,7 +59,7 @@ CharToCode(const char *text, const int32 charLen)
|
|||||||
|
|
||||||
/*! \brief Initializes the object.
|
/*! \brief Initializes the object.
|
||||||
*/
|
*/
|
||||||
_BWidthBuffer_::_BWidthBuffer_()
|
BTextView::WidthBuffer::WidthBuffer()
|
||||||
:
|
:
|
||||||
_BTextViewSupportBuffer_<_width_table_>(1, 0)
|
_BTextViewSupportBuffer_<_width_table_>(1, 0)
|
||||||
{
|
{
|
||||||
@@ -65,7 +68,7 @@ _BWidthBuffer_::_BWidthBuffer_()
|
|||||||
|
|
||||||
/*! \brief Frees the allocated resources.
|
/*! \brief Frees the allocated resources.
|
||||||
*/
|
*/
|
||||||
_BWidthBuffer_::~_BWidthBuffer_()
|
BTextView::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;
|
||||||
@@ -80,12 +83,14 @@ _BWidthBuffer_::~_BWidthBuffer_()
|
|||||||
\return The space (in pixels) required to draw the given string.
|
\return The space (in pixels) required to draw the given string.
|
||||||
*/
|
*/
|
||||||
float
|
float
|
||||||
_BWidthBuffer_::StringWidth(const char *inText, int32 fromOffset, int32 length,
|
BTextView::WidthBuffer::StringWidth(const char *inText, int32 fromOffset,
|
||||||
const BFont *inStyle)
|
int32 length, const BFont *inStyle)
|
||||||
{
|
{
|
||||||
if (inText == NULL || length == 0)
|
if (inText == NULL || length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
BAutolock _(sWidthLocker);
|
||||||
|
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
if (!FindTable(inStyle, &index))
|
if (!FindTable(inStyle, &index))
|
||||||
index = InsertTable(inStyle);
|
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.
|
/*! \brief Returns how much room is required to draw a string in the font.
|
||||||
\param inBuffer The _BTextGapBuffer_ to be examined.
|
\param inBuffer The BTextView::TextGapBuffer to be examined.
|
||||||
\param fromOffset The offset in the _BTextGapBuffer_ where to begin the examination.
|
\param fromOffset The offset in the BTextView::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
|
||||||
_BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32 length,
|
BTextView::WidthBuffer::StringWidth(BTextView::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);
|
||||||
@@ -160,7 +165,7 @@ _BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32
|
|||||||
\c false if not.
|
\c false if not.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
_BWidthBuffer_::FindTable(const BFont *inStyle, int32 *outIndex)
|
BTextView::WidthBuffer::FindTable(const BFont *inStyle, int32 *outIndex)
|
||||||
{
|
{
|
||||||
if (inStyle == NULL)
|
if (inStyle == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -194,7 +199,7 @@ _BWidthBuffer_::FindTable(const BFont *inStyle, int32 *outIndex)
|
|||||||
\return The index of the newly created table.
|
\return The index of the newly created table.
|
||||||
*/
|
*/
|
||||||
int32
|
int32
|
||||||
_BWidthBuffer_::InsertTable(const BFont *font)
|
BTextView::WidthBuffer::InsertTable(const BFont *font)
|
||||||
{
|
{
|
||||||
_width_table_ table;
|
_width_table_ table;
|
||||||
|
|
||||||
@@ -225,7 +230,7 @@ _BWidthBuffer_::InsertTable(const BFont *font)
|
|||||||
for the given charachter, \c false if not.
|
for the given charachter, \c false if not.
|
||||||
*/
|
*/
|
||||||
bool
|
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 _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);
|
||||||
@@ -251,7 +256,7 @@ _BWidthBuffer_::GetEscapement(uint32 value, int32 index, float *escapement)
|
|||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
_BWidthBuffer_::Hash(uint32 val)
|
BTextView::WidthBuffer::Hash(uint32 val)
|
||||||
{
|
{
|
||||||
uint32 shifted = val >> 24;
|
uint32 shifted = val >> 24;
|
||||||
uint32 result = (val >> 15) + (shifted * 3);
|
uint32 result = (val >> 15) + (shifted * 3);
|
||||||
@@ -275,7 +280,7 @@ _BWidthBuffer_::Hash(uint32 val)
|
|||||||
the size of the font).
|
the size of the font).
|
||||||
*/
|
*/
|
||||||
float
|
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)
|
int32 tableIndex, const BFont *inStyle)
|
||||||
{
|
{
|
||||||
ASSERT(inText != NULL);
|
ASSERT(inText != NULL);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ SubDir HAIKU_TOP src kits tracker ;
|
|||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
AddSubDirSupportedPlatforms libbe_test ;
|
AddSubDirSupportedPlatforms libbe_test ;
|
||||||
|
|
||||||
UsePrivateHeaders shared storage tracker ;
|
UsePrivateHeaders interface shared storage tracker ;
|
||||||
|
|
||||||
UseLibraryHeaders icon ;
|
UseLibraryHeaders icon ;
|
||||||
|
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ All rights reserved.
|
|||||||
#include "InfoWindow.h"
|
#include "InfoWindow.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "Tests.h"
|
#include "Tests.h"
|
||||||
#include "TextViewSupport.h"
|
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "Tracker.h"
|
#include "Tracker.h"
|
||||||
#include "TrackerString.h"
|
#include "TrackerString.h"
|
||||||
#include "WidgetAttributeText.h"
|
#include "WidgetAttributeText.h"
|
||||||
|
#include "WidthBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
using std::min;
|
using std::min;
|
||||||
@@ -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;
|
||||||
_BWidthBuffer_* BPoseView::sWidthBuffer = new _BWidthBuffer_;
|
BTextView::WidthBuffer* BPoseView::sWidthBuffer = new BTextView::WidthBuffer;
|
||||||
BFont BPoseView::sCurrentFont;
|
BFont BPoseView::sCurrentFont;
|
||||||
OffscreenBitmap *BPoseView::sOffscreen = new OffscreenBitmap;
|
OffscreenBitmap *BPoseView::sOffscreen = new OffscreenBitmap;
|
||||||
char BPoseView::sMatchString[] = "";
|
char BPoseView::sMatchString[] = "";
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ class BRefFilter;
|
|||||||
class BList;
|
class BList;
|
||||||
|
|
||||||
// TODO: Get rid of this.
|
// TODO: Get rid of this.
|
||||||
class _BWidthBuffer_;
|
#include <TextView.h>
|
||||||
|
// for BTextView::WidthBuffer;
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
@@ -351,7 +352,7 @@ class BPoseView : public BView {
|
|||||||
BMessage *specifier, int32 form, const char *property);
|
BMessage *specifier, int32 form, const char *property);
|
||||||
virtual status_t GetSupportedSuites(BMessage *);
|
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
|
// the general purpose BView::StringWidth
|
||||||
float StringWidth(const char *) const;
|
float StringWidth(const char *) const;
|
||||||
float StringWidth(const char *, int32) const;
|
float StringWidth(const char *, int32) const;
|
||||||
@@ -664,7 +665,7 @@ class BPoseView : public BView {
|
|||||||
BRect fDeskbarFrame;
|
BRect fDeskbarFrame;
|
||||||
|
|
||||||
// TODO: Get rid of this.
|
// TODO: Get rid of this.
|
||||||
static _BWidthBuffer_ *sWidthBuffer;
|
static BTextView::WidthBuffer *sWidthBuffer;
|
||||||
|
|
||||||
static OffscreenBitmap *sOffscreen;
|
static OffscreenBitmap *sOffscreen;
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
#include "QueryPoseView.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
@@ -47,11 +50,12 @@ All rights reserved.
|
|||||||
#include "FSUtils.h"
|
#include "FSUtils.h"
|
||||||
#include "MimeTypeList.h"
|
#include "MimeTypeList.h"
|
||||||
#include "MimeTypes.h"
|
#include "MimeTypes.h"
|
||||||
#include "QueryPoseView.h"
|
|
||||||
#include "Tracker.h"
|
#include "Tracker.h"
|
||||||
|
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
|
|
||||||
|
using std::nothrow;
|
||||||
|
|
||||||
// Currently filtering out Trash doesn't node monitor too well - if you
|
// 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
|
// 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
|
// To do this properly, we would have to node monitor everything BQuery
|
||||||
@@ -508,7 +512,9 @@ status_t
|
|||||||
QueryEntryListCollection::FetchOneQuery(const BQuery *copyThis,
|
QueryEntryListCollection::FetchOneQuery(const BQuery *copyThis,
|
||||||
BHandler *target, BObjectList<BQuery> *list, BVolume *volume)
|
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
|
// have to fake a copy constructor here because BQuery doesn't have
|
||||||
// a copy constructor
|
// a copy constructor
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user