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(); _CancelInputMethod();
if (fUndo) { if (fUndo) {
delete fUndo; delete fUndo;
fUndo = new _BCutUndoBuffer_(this); fUndo = new CutUndoBuffer(this);
} }
Copy(clipboard); Copy(clipboard);
Delete(); Delete();
@@ -1346,7 +1346,7 @@ BTextView::Paste(BClipboard *clipboard)
if (fUndo) { if (fUndo) {
delete fUndo; delete fUndo;
fUndo = new _BPasteUndoBuffer_(this, text, len, runArray, fUndo = new PasteUndoBuffer(this, text, len, runArray,
runLen); runLen);
} }
@@ -1370,7 +1370,7 @@ BTextView::Clear()
// because when fUndo is NULL, undo is deactivated. // because when fUndo is NULL, undo is deactivated.
if (fUndo) { if (fUndo) {
delete fUndo; delete fUndo;
fUndo = new _BClearUndoBuffer_(this); fUndo = new ClearUndoBuffer(this);
} }
Delete(); Delete();
@@ -2083,8 +2083,7 @@ BTextView::TextRect() const
/*! \brief Sets the insets from the bounds for the BTextView's text rectangle. /*! \brief Sets the insets from the bounds for the BTextView's text rectangle.
*/ */
void void
BTextView::SetInsets(float _leftInset, float topInset, float rightInset, BTextView::SetInsets(float left, float top, float right, float bottom)
float bottomInset)
{ {
// TODO: // TODO:
// * store in layout data // * store in layout data
@@ -2097,19 +2096,19 @@ BTextView::SetInsets(float _leftInset, float topInset, float rightInset,
rectangle. rectangle.
*/ */
void void
BTextView::GetInsets(float* _leftInset, float* _topInset, float* _rightInset, BTextView::GetInsets(float* _left, float* _top, float* _right,
float* _bottomInset) const float* _bottom) const
{ {
BRect bounds = Bounds(); BRect bounds = Bounds();
if (_leftInset) if (_left)
*_leftInset = fTextRect.left - bounds.left; *_left = fTextRect.left - bounds.left;
if (_topInset) if (_top)
*_topInset = fTextRect.top - bounds.top; *_top = fTextRect.top - bounds.top;
if (_rightInset) if (_right)
*_rightInset = bounds.right - fTextRect.right; *_right = bounds.right - fTextRect.right;
if (_bottomInset) if (_bottom)
*_bottomInset = bounds.bottom - fTextRect.bottom; *_bottom = bounds.bottom - fTextRect.bottom;
} }
@@ -2877,11 +2876,11 @@ void
BTextView::_HandleBackspace() BTextView::_HandleBackspace()
{ {
if (fUndo) { if (fUndo) {
_BTypingUndoBuffer_ *undoBuffer = dynamic_cast<_BTypingUndoBuffer_ *>( TypingUndoBuffer *undoBuffer = dynamic_cast<TypingUndoBuffer*>(
fUndo); fUndo);
if (!undoBuffer) { if (!undoBuffer) {
delete fUndo; delete fUndo;
fUndo = undoBuffer = new _BTypingUndoBuffer_(this); fUndo = undoBuffer = new TypingUndoBuffer(this);
} }
undoBuffer->BackwardErase(); undoBuffer->BackwardErase();
} }
@@ -3012,11 +3011,11 @@ void
BTextView::_HandleDelete() BTextView::_HandleDelete()
{ {
if (fUndo) { if (fUndo) {
_BTypingUndoBuffer_ *undoBuffer = dynamic_cast<_BTypingUndoBuffer_ *>( TypingUndoBuffer *undoBuffer = dynamic_cast<TypingUndoBuffer*>(
fUndo); fUndo);
if (!undoBuffer) { if (!undoBuffer) {
delete fUndo; delete fUndo;
fUndo = undoBuffer = new _BTypingUndoBuffer_(this); fUndo = undoBuffer = new TypingUndoBuffer(this);
} }
undoBuffer->ForwardErase(); undoBuffer->ForwardErase();
} }
@@ -3156,11 +3155,10 @@ 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 TypingUndoBuffer *undoBuffer = dynamic_cast<TypingUndoBuffer*>(fUndo);
= dynamic_cast<_BTypingUndoBuffer_ *>(fUndo);
if (!undoBuffer) { if (!undoBuffer) {
delete fUndo; delete fUndo;
fUndo = undoBuffer = new _BTypingUndoBuffer_(this); fUndo = undoBuffer = new TypingUndoBuffer(this);
} }
undoBuffer->InputCharacter(numBytes); undoBuffer->InputCharacter(numBytes);
} }
@@ -4140,7 +4138,7 @@ BTextView::_MessageDropped(BMessage *inMessage, BPoint where, BPoint offset)
if (fUndo) { if (fUndo) {
delete fUndo; delete fUndo;
fUndo = new _BDropUndoBuffer_(this, text, dataLen, runArray, fUndo = new DropUndoBuffer(this, text, dataLen, runArray,
runLen, dropOffset, internalDrop); 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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -62,9 +62,9 @@ BTextView::UndoBuffer::Undo(BClipboard *clipboard)
undo_state undo_state
BTextView::UndoBuffer::State(bool *redo) BTextView::UndoBuffer::State(bool* _isRedo) const
{ {
*redo = fRedo; *_isRedo = fRedo;
return fState; 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) : BTextView::UndoBuffer(textView, B_UNDO_CUT)
{ {
} }
_BCutUndoBuffer_::~_BCutUndoBuffer_() BTextView::CutUndoBuffer::~CutUndoBuffer()
{ {
} }
void void
_BCutUndoBuffer_::RedoSelf(BClipboard *clipboard) BTextView::CutUndoBuffer::RedoSelf(BClipboard* clipboard)
{ {
BMessage* clip = NULL; BMessage* clip = NULL;
@@ -120,11 +120,12 @@ _BCutUndoBuffer_::RedoSelf(BClipboard *clipboard)
} }
// #pragma mark - _BPasteUndoBuffer_ // #pragma mark - PasteUndoBuffer
_BPasteUndoBuffer_::_BPasteUndoBuffer_(BTextView *textView, const char *text, BTextView::PasteUndoBuffer::PasteUndoBuffer(BTextView* textView,
int32 textLen, text_run_array *runArray, int32 runArrayLen) const char* text, int32 textLen, text_run_array* runArray,
int32 runArrayLen)
: BTextView::UndoBuffer(textView, B_UNDO_PASTE), : BTextView::UndoBuffer(textView, B_UNDO_PASTE),
fPasteText(NULL), fPasteText(NULL),
fPasteTextLength(textLen), fPasteTextLength(textLen),
@@ -138,7 +139,7 @@ _BPasteUndoBuffer_::_BPasteUndoBuffer_(BTextView *textView, const char *text,
} }
_BPasteUndoBuffer_::~_BPasteUndoBuffer_() BTextView::PasteUndoBuffer::~PasteUndoBuffer()
{ {
free(fPasteText); free(fPasteText);
BTextView::FreeRunArray(fPasteRunArray); BTextView::FreeRunArray(fPasteRunArray);
@@ -146,7 +147,7 @@ _BPasteUndoBuffer_::~_BPasteUndoBuffer_()
void void
_BPasteUndoBuffer_::UndoSelf(BClipboard *clipboard) BTextView::PasteUndoBuffer::UndoSelf(BClipboard* clipboard)
{ {
fTextView->Select(fStart, fStart); fTextView->Select(fStart, fStart);
fTextView->Delete(fStart, fStart + fPasteTextLength); fTextView->Delete(fStart, fStart + fPasteTextLength);
@@ -156,7 +157,7 @@ _BPasteUndoBuffer_::UndoSelf(BClipboard *clipboard)
void void
_BPasteUndoBuffer_::RedoSelf(BClipboard *clipboard) BTextView::PasteUndoBuffer::RedoSelf(BClipboard* clipboard)
{ {
fTextView->Select(fStart, fStart); fTextView->Select(fStart, fStart);
fTextView->Delete(fStart, fEnd); 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) : BTextView::UndoBuffer(textView, B_UNDO_CLEAR)
{ {
} }
_BClearUndoBuffer_::~_BClearUndoBuffer_() BTextView::ClearUndoBuffer::~ClearUndoBuffer()
{ {
} }
void void
_BClearUndoBuffer_::RedoSelf(BClipboard *clipboard) BTextView::ClearUndoBuffer::RedoSelf(BClipboard* clipboard)
{ {
fTextView->Select(fStart, fStart); fTextView->Select(fStart, fStart);
fTextView->Delete(fStart, fEnd); fTextView->Delete(fStart, fEnd);
} }
// #pragma mark - _BDropUndoBuffer_ // #pragma mark - DropUndoBuffer
_BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text, BTextView::DropUndoBuffer::DropUndoBuffer(BTextView* textView,
int32 textLen, text_run_array *runArray, int32 runArrayLen, char const* text, int32 textLen, text_run_array* runArray,
int32 location, bool internalDrop) int32 runArrayLen, int32 location, bool internalDrop)
: BTextView::UndoBuffer(textView, B_UNDO_DROP), : BTextView::UndoBuffer(textView, B_UNDO_DROP),
fDropText(NULL), fDropText(NULL),
fDropTextLength(textLen), fDropTextLength(textLen),
@@ -212,7 +213,7 @@ _BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text,
} }
_BDropUndoBuffer_::~_BDropUndoBuffer_() BTextView::DropUndoBuffer::~DropUndoBuffer()
{ {
free(fDropText); free(fDropText);
BTextView::FreeRunArray(fDropRunArray); BTextView::FreeRunArray(fDropRunArray);
@@ -220,7 +221,7 @@ _BDropUndoBuffer_::~_BDropUndoBuffer_()
void void
_BDropUndoBuffer_::UndoSelf(BClipboard *) BTextView::DropUndoBuffer::UndoSelf(BClipboard* )
{ {
fTextView->Select(fDropLocation, fDropLocation); fTextView->Select(fDropLocation, fDropLocation);
fTextView->Delete(fDropLocation, fDropLocation + fDropTextLength); fTextView->Delete(fDropLocation, fDropLocation + fDropTextLength);
@@ -233,7 +234,7 @@ _BDropUndoBuffer_::UndoSelf(BClipboard *)
void void
_BDropUndoBuffer_::RedoSelf(BClipboard *) BTextView::DropUndoBuffer::RedoSelf(BClipboard* )
{ {
if (fInternalDrop) { if (fInternalDrop) {
fTextView->Select(fStart, fStart); 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), : BTextView::UndoBuffer(textView, B_UNDO_TYPING),
fTypedText(NULL), fTypedText(NULL),
fTypedStart(fStart), fTypedStart(fStart),
@@ -258,14 +259,14 @@ _BTypingUndoBuffer_::_BTypingUndoBuffer_(BTextView *textView)
} }
_BTypingUndoBuffer_::~_BTypingUndoBuffer_() BTextView::TypingUndoBuffer::~TypingUndoBuffer()
{ {
free(fTypedText); free(fTypedText);
} }
void void
_BTypingUndoBuffer_::UndoSelf(BClipboard *clipboard) BTextView::TypingUndoBuffer::UndoSelf(BClipboard* clipboard)
{ {
int32 len = fTypedEnd - fTypedStart; int32 len = fTypedEnd - fTypedStart;
@@ -283,7 +284,7 @@ _BTypingUndoBuffer_::UndoSelf(BClipboard *clipboard)
void void
_BTypingUndoBuffer_::RedoSelf(BClipboard *clipboard) BTextView::TypingUndoBuffer::RedoSelf(BClipboard* clipboard)
{ {
fTextView->Select(fTypedStart, fTypedStart); fTextView->Select(fTypedStart, fTypedStart);
fTextView->Delete(fTypedStart, fTypedStart + fTextLength); fTextView->Delete(fTypedStart, fTypedStart + fTextLength);
@@ -293,20 +294,20 @@ _BTypingUndoBuffer_::RedoSelf(BClipboard *clipboard)
void void
_BTypingUndoBuffer_::InputCharacter(int32 len) BTextView::TypingUndoBuffer::InputCharacter(int32 len)
{ {
int32 start, end; int32 start, end;
fTextView->GetSelection(&start, &end); fTextView->GetSelection(&start, &end);
if (start != fTypedEnd || end != fTypedEnd) if (start != fTypedEnd || end != fTypedEnd)
Reset(); _Reset();
fTypedEnd += len; fTypedEnd += len;
} }
void void
_BTypingUndoBuffer_::Reset() BTextView::TypingUndoBuffer::_Reset()
{ {
free(fTextData); free(fTextData);
fTextView->GetSelection(&fStart, &fEnd); fTextView->GetSelection(&fStart, &fEnd);
@@ -325,7 +326,7 @@ _BTypingUndoBuffer_::Reset()
void void
_BTypingUndoBuffer_::BackwardErase() BTextView::TypingUndoBuffer::BackwardErase()
{ {
int32 start, end; int32 start, end;
fTextView->GetSelection(&start, &end); fTextView->GetSelection(&start, &end);
@@ -334,7 +335,7 @@ _BTypingUndoBuffer_::BackwardErase()
int32 charLen = UTF8PreviousCharLen(text + start, text); int32 charLen = UTF8PreviousCharLen(text + start, text);
if (start != fTypedEnd || end != fTypedEnd) { if (start != fTypedEnd || end != fTypedEnd) {
Reset(); _Reset();
// if we've got a selection, we're already done // if we've got a selection, we're already done
if (start != end) if (start != end)
return; return;
@@ -356,7 +357,7 @@ _BTypingUndoBuffer_::BackwardErase()
void void
_BTypingUndoBuffer_::ForwardErase() BTextView::TypingUndoBuffer::ForwardErase()
{ {
// TODO: Cleanup // TODO: Cleanup
int32 start, end; int32 start, end;
@@ -366,7 +367,7 @@ _BTypingUndoBuffer_::ForwardErase()
int32 charLen = UTF8NextCharLen(fTextView->Text() + start); int32 charLen = UTF8NextCharLen(fTextView->Text() + start);
if (start != fTypedEnd || end != fTypedEnd || fUndone > 0) { if (start != fTypedEnd || end != fTypedEnd || fUndone > 0) {
Reset(); _Reset();
// if we've got a selection, we're already done // if we've got a selection, we're already done
if (fStart == fEnd) { if (fStart == fEnd) {
free(fTextData); 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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -14,17 +14,19 @@
class BClipboard; class BClipboard;
// UndoBuffer
class BTextView::UndoBuffer { class BTextView::UndoBuffer {
public: public:
UndoBuffer(BTextView *, undo_state); UndoBuffer(BTextView* view, undo_state state);
virtual ~UndoBuffer(); virtual ~UndoBuffer();
void Undo(BClipboard *); void Undo(BClipboard* clipboard);
undo_state State(bool *); undo_state State(bool* _isRedo) const;
protected: protected:
virtual void UndoSelf(BClipboard *); virtual void UndoSelf(BClipboard* clipboard);
virtual void RedoSelf(BClipboard *); virtual void RedoSelf(BClipboard* clipboard);
BTextView* fTextView; BTextView* fTextView;
int32 fStart; int32 fStart;
@@ -42,26 +44,29 @@ private:
}; };
// ******** _BCutUndoBuffer_ ******* // CutUndoBuffer
class _BCutUndoBuffer_ : public BTextView::UndoBuffer { class BTextView::CutUndoBuffer : public BTextView::UndoBuffer {
public: public:
_BCutUndoBuffer_(BTextView *textView); CutUndoBuffer(BTextView* textView);
~_BCutUndoBuffer_(); virtual ~CutUndoBuffer();
protected: protected:
virtual void RedoSelf(BClipboard *); virtual void RedoSelf(BClipboard* clipboard);
}; };
// ******** _BPasteUndoBuffer_ ******* // PasteUndoBuffer
class _BPasteUndoBuffer_ : public BTextView::UndoBuffer { class BTextView::PasteUndoBuffer : public BTextView::UndoBuffer {
public: public:
_BPasteUndoBuffer_(BTextView *, const char *, int32, text_run_array *, int32); PasteUndoBuffer(BTextView* textView,
~_BPasteUndoBuffer_(); const char* text, int32 textLength,
text_run_array* runArray,
int32 runArrayLen);
virtual ~PasteUndoBuffer();
protected: protected:
virtual void UndoSelf(BClipboard *); virtual void UndoSelf(BClipboard* clipboard);
virtual void RedoSelf(BClipboard *); virtual void RedoSelf(BClipboard* clipboard);
private: private:
char* fPasteText; char* fPasteText;
@@ -70,26 +75,30 @@ private:
}; };
// ******** _BClearUndoBuffer_ ******* // ClearUndoBuffer
class _BClearUndoBuffer_ : public BTextView::UndoBuffer { class BTextView::ClearUndoBuffer : public BTextView::UndoBuffer {
public: public:
_BClearUndoBuffer_(BTextView *textView); ClearUndoBuffer(BTextView* textView);
~_BClearUndoBuffer_(); virtual ~ClearUndoBuffer();
protected: protected:
virtual void RedoSelf(BClipboard *); virtual void RedoSelf(BClipboard* clipboard);
}; };
// ******** _BDropUndoBuffer_ ******** // DropUndoBuffer
class _BDropUndoBuffer_ : public BTextView::UndoBuffer { class BTextView::DropUndoBuffer : public BTextView::UndoBuffer {
public: public:
_BDropUndoBuffer_(BTextView *, char const *, int32, text_run_array *, int32, int32, bool); DropUndoBuffer(BTextView* textView,
~_BDropUndoBuffer_(); char const* text, int32 textLength,
text_run_array* runArray,
int32 runArrayLength, int32 location,
bool internalDrop);
virtual ~DropUndoBuffer();
protected: protected:
virtual void UndoSelf(BClipboard *); virtual void UndoSelf(BClipboard* clipboard);
virtual void RedoSelf(BClipboard *); virtual void RedoSelf(BClipboard* clipboard);
private: private:
char* fDropText; char* fDropText;
@@ -101,22 +110,22 @@ private:
}; };
// ******** _BTypingUndoBuffer_ ******** // TypingUndoBuffer
class _BTypingUndoBuffer_ : public BTextView::UndoBuffer { class BTextView::TypingUndoBuffer : public BTextView::UndoBuffer {
public: public:
_BTypingUndoBuffer_(BTextView *); TypingUndoBuffer(BTextView* textView);
~_BTypingUndoBuffer_(); virtual ~TypingUndoBuffer();
void InputCharacter(int32); void InputCharacter(int32 length);
void BackwardErase(); void BackwardErase();
void ForwardErase(); void ForwardErase();
protected: protected:
virtual void RedoSelf(BClipboard *); virtual void RedoSelf(BClipboard* clipboard);
virtual void UndoSelf(BClipboard *); virtual void UndoSelf(BClipboard* clipboard);
private: private:
void Reset(); void _Reset();
char* fTypedText; char* fTypedText;
int32 fTypedStart; int32 fTypedStart;