Moved BTextView::UndoBuffer derivatives into the BTextView class as well,

hopefully fixing the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27660 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-09-21 08:42:02 +00:00
parent 5c4cde5afa
commit 8ab8c63d26
3 changed files with 142 additions and 134 deletions
+21 -23
View File
@@ -1279,7 +1279,7 @@ BTextView::Cut(BClipboard *clipboard)
_CancelInputMethod();
if (fUndo) {
delete fUndo;
fUndo = new _BCutUndoBuffer_(this);
fUndo = new CutUndoBuffer(this);
}
Copy(clipboard);
Delete();
@@ -1346,7 +1346,7 @@ BTextView::Paste(BClipboard *clipboard)
if (fUndo) {
delete fUndo;
fUndo = new _BPasteUndoBuffer_(this, text, len, runArray,
fUndo = new PasteUndoBuffer(this, text, len, runArray,
runLen);
}
@@ -1370,7 +1370,7 @@ BTextView::Clear()
// because when fUndo is NULL, undo is deactivated.
if (fUndo) {
delete fUndo;
fUndo = new _BClearUndoBuffer_(this);
fUndo = new ClearUndoBuffer(this);
}
Delete();
@@ -2083,8 +2083,7 @@ 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)
BTextView::SetInsets(float left, float top, float right, float bottom)
{
// TODO:
// * store in layout data
@@ -2097,19 +2096,19 @@ BTextView::SetInsets(float _leftInset, float topInset, float rightInset,
rectangle.
*/
void
BTextView::GetInsets(float* _leftInset, float* _topInset, float* _rightInset,
float* _bottomInset) const
BTextView::GetInsets(float* _left, float* _top, float* _right,
float* _bottom) 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;
if (_left)
*_left = fTextRect.left - bounds.left;
if (_top)
*_top = fTextRect.top - bounds.top;
if (_right)
*_right = bounds.right - fTextRect.right;
if (_bottom)
*_bottom = bounds.bottom - fTextRect.bottom;
}
@@ -2877,11 +2876,11 @@ void
BTextView::_HandleBackspace()
{
if (fUndo) {
_BTypingUndoBuffer_ *undoBuffer = dynamic_cast<_BTypingUndoBuffer_ *>(
TypingUndoBuffer *undoBuffer = dynamic_cast<TypingUndoBuffer*>(
fUndo);
if (!undoBuffer) {
delete fUndo;
fUndo = undoBuffer = new _BTypingUndoBuffer_(this);
fUndo = undoBuffer = new TypingUndoBuffer(this);
}
undoBuffer->BackwardErase();
}
@@ -3012,11 +3011,11 @@ void
BTextView::_HandleDelete()
{
if (fUndo) {
_BTypingUndoBuffer_ *undoBuffer = dynamic_cast<_BTypingUndoBuffer_ *>(
TypingUndoBuffer *undoBuffer = dynamic_cast<TypingUndoBuffer*>(
fUndo);
if (!undoBuffer) {
delete fUndo;
fUndo = undoBuffer = new _BTypingUndoBuffer_(this);
fUndo = undoBuffer = new TypingUndoBuffer(this);
}
undoBuffer->ForwardErase();
}
@@ -3156,11 +3155,10 @@ BTextView::_HandleAlphaKey(const char *bytes, int32 numBytes)
{
// TODO: block input if not editable (Andrew)
if (fUndo) {
_BTypingUndoBuffer_ *undoBuffer
= dynamic_cast<_BTypingUndoBuffer_ *>(fUndo);
TypingUndoBuffer *undoBuffer = dynamic_cast<TypingUndoBuffer*>(fUndo);
if (!undoBuffer) {
delete fUndo;
fUndo = undoBuffer = new _BTypingUndoBuffer_(this);
fUndo = undoBuffer = new TypingUndoBuffer(this);
}
undoBuffer->InputCharacter(numBytes);
}
@@ -4140,7 +4138,7 @@ BTextView::_MessageDropped(BMessage *inMessage, BPoint where, BPoint offset)
if (fUndo) {
delete fUndo;
fUndo = new _BDropUndoBuffer_(this, text, dataLen, runArray,
fUndo = new DropUndoBuffer(this, text, dataLen, runArray,
runLen, dropOffset, internalDrop);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2007, Haiku, Inc.
* Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -62,9 +62,9 @@ BTextView::UndoBuffer::Undo(BClipboard *clipboard)
undo_state
BTextView::UndoBuffer::State(bool *redo)
BTextView::UndoBuffer::State(bool* _isRedo) const
{
*redo = fRedo;
*_isRedo = fRedo;
return fState;
}
@@ -85,22 +85,22 @@ BTextView::UndoBuffer::RedoSelf(BClipboard *clipboard)
}
// #pragma mark - _BCutUndoBuffer_
// #pragma mark - CutUndoBuffer
_BCutUndoBuffer_::_BCutUndoBuffer_(BTextView *textView)
BTextView::CutUndoBuffer::CutUndoBuffer(BTextView* textView)
: BTextView::UndoBuffer(textView, B_UNDO_CUT)
{
}
_BCutUndoBuffer_::~_BCutUndoBuffer_()
BTextView::CutUndoBuffer::~CutUndoBuffer()
{
}
void
_BCutUndoBuffer_::RedoSelf(BClipboard *clipboard)
BTextView::CutUndoBuffer::RedoSelf(BClipboard* clipboard)
{
BMessage* clip = NULL;
@@ -120,11 +120,12 @@ _BCutUndoBuffer_::RedoSelf(BClipboard *clipboard)
}
// #pragma mark - _BPasteUndoBuffer_
// #pragma mark - PasteUndoBuffer
_BPasteUndoBuffer_::_BPasteUndoBuffer_(BTextView *textView, const char *text,
int32 textLen, text_run_array *runArray, int32 runArrayLen)
BTextView::PasteUndoBuffer::PasteUndoBuffer(BTextView* textView,
const char* text, int32 textLen, text_run_array* runArray,
int32 runArrayLen)
: BTextView::UndoBuffer(textView, B_UNDO_PASTE),
fPasteText(NULL),
fPasteTextLength(textLen),
@@ -138,7 +139,7 @@ _BPasteUndoBuffer_::_BPasteUndoBuffer_(BTextView *textView, const char *text,
}
_BPasteUndoBuffer_::~_BPasteUndoBuffer_()
BTextView::PasteUndoBuffer::~PasteUndoBuffer()
{
free(fPasteText);
BTextView::FreeRunArray(fPasteRunArray);
@@ -146,7 +147,7 @@ _BPasteUndoBuffer_::~_BPasteUndoBuffer_()
void
_BPasteUndoBuffer_::UndoSelf(BClipboard *clipboard)
BTextView::PasteUndoBuffer::UndoSelf(BClipboard* clipboard)
{
fTextView->Select(fStart, fStart);
fTextView->Delete(fStart, fStart + fPasteTextLength);
@@ -156,7 +157,7 @@ _BPasteUndoBuffer_::UndoSelf(BClipboard *clipboard)
void
_BPasteUndoBuffer_::RedoSelf(BClipboard *clipboard)
BTextView::PasteUndoBuffer::RedoSelf(BClipboard* clipboard)
{
fTextView->Select(fStart, fStart);
fTextView->Delete(fStart, fEnd);
@@ -165,34 +166,34 @@ _BPasteUndoBuffer_::RedoSelf(BClipboard *clipboard)
}
// #pragma mark - _BClearUndoBuffer_
// #pragma mark - ClearUndoBuffer
_BClearUndoBuffer_::_BClearUndoBuffer_(BTextView *textView)
BTextView::ClearUndoBuffer::ClearUndoBuffer(BTextView* textView)
: BTextView::UndoBuffer(textView, B_UNDO_CLEAR)
{
}
_BClearUndoBuffer_::~_BClearUndoBuffer_()
BTextView::ClearUndoBuffer::~ClearUndoBuffer()
{
}
void
_BClearUndoBuffer_::RedoSelf(BClipboard *clipboard)
BTextView::ClearUndoBuffer::RedoSelf(BClipboard* clipboard)
{
fTextView->Select(fStart, fStart);
fTextView->Delete(fStart, fEnd);
}
// #pragma mark - _BDropUndoBuffer_
// #pragma mark - DropUndoBuffer
_BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text,
int32 textLen, text_run_array *runArray, int32 runArrayLen,
int32 location, bool internalDrop)
BTextView::DropUndoBuffer::DropUndoBuffer(BTextView* textView,
char const* text, int32 textLen, text_run_array* runArray,
int32 runArrayLen, int32 location, bool internalDrop)
: BTextView::UndoBuffer(textView, B_UNDO_DROP),
fDropText(NULL),
fDropTextLength(textLen),
@@ -212,7 +213,7 @@ _BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text,
}
_BDropUndoBuffer_::~_BDropUndoBuffer_()
BTextView::DropUndoBuffer::~DropUndoBuffer()
{
free(fDropText);
BTextView::FreeRunArray(fDropRunArray);
@@ -220,7 +221,7 @@ _BDropUndoBuffer_::~_BDropUndoBuffer_()
void
_BDropUndoBuffer_::UndoSelf(BClipboard *)
BTextView::DropUndoBuffer::UndoSelf(BClipboard* )
{
fTextView->Select(fDropLocation, fDropLocation);
fTextView->Delete(fDropLocation, fDropLocation + fDropTextLength);
@@ -233,7 +234,7 @@ _BDropUndoBuffer_::UndoSelf(BClipboard *)
void
_BDropUndoBuffer_::RedoSelf(BClipboard *)
BTextView::DropUndoBuffer::RedoSelf(BClipboard* )
{
if (fInternalDrop) {
fTextView->Select(fStart, fStart);
@@ -245,10 +246,10 @@ _BDropUndoBuffer_::RedoSelf(BClipboard *)
}
// #pragma mark - _BTypingUndoBuffer_
// #pragma mark - TypingUndoBuffer
_BTypingUndoBuffer_::_BTypingUndoBuffer_(BTextView *textView)
BTextView::TypingUndoBuffer::TypingUndoBuffer(BTextView* textView)
: BTextView::UndoBuffer(textView, B_UNDO_TYPING),
fTypedText(NULL),
fTypedStart(fStart),
@@ -258,14 +259,14 @@ _BTypingUndoBuffer_::_BTypingUndoBuffer_(BTextView *textView)
}
_BTypingUndoBuffer_::~_BTypingUndoBuffer_()
BTextView::TypingUndoBuffer::~TypingUndoBuffer()
{
free(fTypedText);
}
void
_BTypingUndoBuffer_::UndoSelf(BClipboard *clipboard)
BTextView::TypingUndoBuffer::UndoSelf(BClipboard* clipboard)
{
int32 len = fTypedEnd - fTypedStart;
@@ -283,7 +284,7 @@ _BTypingUndoBuffer_::UndoSelf(BClipboard *clipboard)
void
_BTypingUndoBuffer_::RedoSelf(BClipboard *clipboard)
BTextView::TypingUndoBuffer::RedoSelf(BClipboard* clipboard)
{
fTextView->Select(fTypedStart, fTypedStart);
fTextView->Delete(fTypedStart, fTypedStart + fTextLength);
@@ -293,20 +294,20 @@ _BTypingUndoBuffer_::RedoSelf(BClipboard *clipboard)
void
_BTypingUndoBuffer_::InputCharacter(int32 len)
BTextView::TypingUndoBuffer::InputCharacter(int32 len)
{
int32 start, end;
fTextView->GetSelection(&start, &end);
if (start != fTypedEnd || end != fTypedEnd)
Reset();
_Reset();
fTypedEnd += len;
}
void
_BTypingUndoBuffer_::Reset()
BTextView::TypingUndoBuffer::_Reset()
{
free(fTextData);
fTextView->GetSelection(&fStart, &fEnd);
@@ -325,7 +326,7 @@ _BTypingUndoBuffer_::Reset()
void
_BTypingUndoBuffer_::BackwardErase()
BTextView::TypingUndoBuffer::BackwardErase()
{
int32 start, end;
fTextView->GetSelection(&start, &end);
@@ -334,7 +335,7 @@ _BTypingUndoBuffer_::BackwardErase()
int32 charLen = UTF8PreviousCharLen(text + start, text);
if (start != fTypedEnd || end != fTypedEnd) {
Reset();
_Reset();
// if we've got a selection, we're already done
if (start != end)
return;
@@ -356,7 +357,7 @@ _BTypingUndoBuffer_::BackwardErase()
void
_BTypingUndoBuffer_::ForwardErase()
BTextView::TypingUndoBuffer::ForwardErase()
{
// TODO: Cleanup
int32 start, end;
@@ -366,7 +367,7 @@ _BTypingUndoBuffer_::ForwardErase()
int32 charLen = UTF8NextCharLen(fTextView->Text() + start);
if (start != fTypedEnd || end != fTypedEnd || fUndone > 0) {
Reset();
_Reset();
// if we've got a selection, we're already done
if (fStart == fEnd) {
free(fTextData);
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -14,17 +14,19 @@
class BClipboard;
// UndoBuffer
class BTextView::UndoBuffer {
public:
UndoBuffer(BTextView *, undo_state);
UndoBuffer(BTextView* view, undo_state state);
virtual ~UndoBuffer();
void Undo(BClipboard *);
undo_state State(bool *);
void Undo(BClipboard* clipboard);
undo_state State(bool* _isRedo) const;
protected:
virtual void UndoSelf(BClipboard *);
virtual void RedoSelf(BClipboard *);
virtual void UndoSelf(BClipboard* clipboard);
virtual void RedoSelf(BClipboard* clipboard);
BTextView* fTextView;
int32 fStart;
@@ -42,26 +44,29 @@ private:
};
// ******** _BCutUndoBuffer_ *******
class _BCutUndoBuffer_ : public BTextView::UndoBuffer {
// CutUndoBuffer
class BTextView::CutUndoBuffer : public BTextView::UndoBuffer {
public:
_BCutUndoBuffer_(BTextView *textView);
~_BCutUndoBuffer_();
CutUndoBuffer(BTextView* textView);
virtual ~CutUndoBuffer();
protected:
virtual void RedoSelf(BClipboard *);
virtual void RedoSelf(BClipboard* clipboard);
};
// ******** _BPasteUndoBuffer_ *******
class _BPasteUndoBuffer_ : public BTextView::UndoBuffer {
// PasteUndoBuffer
class BTextView::PasteUndoBuffer : public BTextView::UndoBuffer {
public:
_BPasteUndoBuffer_(BTextView *, const char *, int32, text_run_array *, int32);
~_BPasteUndoBuffer_();
PasteUndoBuffer(BTextView* textView,
const char* text, int32 textLength,
text_run_array* runArray,
int32 runArrayLen);
virtual ~PasteUndoBuffer();
protected:
virtual void UndoSelf(BClipboard *);
virtual void RedoSelf(BClipboard *);
virtual void UndoSelf(BClipboard* clipboard);
virtual void RedoSelf(BClipboard* clipboard);
private:
char* fPasteText;
@@ -70,26 +75,30 @@ private:
};
// ******** _BClearUndoBuffer_ *******
class _BClearUndoBuffer_ : public BTextView::UndoBuffer {
// ClearUndoBuffer
class BTextView::ClearUndoBuffer : public BTextView::UndoBuffer {
public:
_BClearUndoBuffer_(BTextView *textView);
~_BClearUndoBuffer_();
ClearUndoBuffer(BTextView* textView);
virtual ~ClearUndoBuffer();
protected:
virtual void RedoSelf(BClipboard *);
virtual void RedoSelf(BClipboard* clipboard);
};
// ******** _BDropUndoBuffer_ ********
class _BDropUndoBuffer_ : public BTextView::UndoBuffer {
// DropUndoBuffer
class BTextView::DropUndoBuffer : public BTextView::UndoBuffer {
public:
_BDropUndoBuffer_(BTextView *, char const *, int32, text_run_array *, int32, int32, bool);
~_BDropUndoBuffer_();
DropUndoBuffer(BTextView* textView,
char const* text, int32 textLength,
text_run_array* runArray,
int32 runArrayLength, int32 location,
bool internalDrop);
virtual ~DropUndoBuffer();
protected:
virtual void UndoSelf(BClipboard *);
virtual void RedoSelf(BClipboard *);
virtual void UndoSelf(BClipboard* clipboard);
virtual void RedoSelf(BClipboard* clipboard);
private:
char* fDropText;
@@ -101,22 +110,22 @@ private:
};
// ******** _BTypingUndoBuffer_ ********
class _BTypingUndoBuffer_ : public BTextView::UndoBuffer {
// TypingUndoBuffer
class BTextView::TypingUndoBuffer : public BTextView::UndoBuffer {
public:
_BTypingUndoBuffer_(BTextView *);
~_BTypingUndoBuffer_();
TypingUndoBuffer(BTextView* textView);
virtual ~TypingUndoBuffer();
void InputCharacter(int32);
void InputCharacter(int32 length);
void BackwardErase();
void ForwardErase();
protected:
virtual void RedoSelf(BClipboard *);
virtual void UndoSelf(BClipboard *);
virtual void RedoSelf(BClipboard* clipboard);
virtual void UndoSelf(BClipboard* clipboard);
private:
void Reset();
void _Reset();
char* fTypedText;
int32 fTypedStart;