Fixed Edit-->Clear to leave behind a white box if the selection box is not moved after it is made, added Undo capability for Cut and Clear actions

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5719 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2003-12-21 19:44:13 +00:00
parent 0552c71396
commit 75238186d7
2 changed files with 32 additions and 14 deletions
+31 -14
View File
@@ -1594,19 +1594,37 @@ ShowImageView::AddWhiteRect(BRect &rect)
delete bitmap; delete bitmap;
} }
void
ShowImageView::RemoveSelection(bool bToClipboard)
{
if (HasSelection()) {
BRect rect = fSelectionRect;
bool bCutBackground = (fSelBitmap) ? false : true;
BBitmap *selection, *restore = NULL;
selection = CopySelection();
if (bToClipboard)
CopySelectionToClipboard();
SetHasSelection(false);
if (bCutBackground) {
// If the user hasn't dragged the selection,
// paint a white rectangle where the selection was
restore = CopyFromRect(rect);
AddWhiteRect(rect);
}
fUndo.SetTo(rect, restore, selection);
Invalidate();
}
}
void void
ShowImageView::Cut() ShowImageView::Cut()
{ {
BRect rect = fSelectionRect; // Copy the selection to the clipboard,
bool bCutBackground = (fSelBitmap) ? false : true; // then remove it
RemoveSelection(true);
CopySelectionToClipboard();
ClearSelection();
if (bCutBackground)
// If the user hasn't dragged the selection,
// paint a white rectangle where the selection was
AddWhiteRect(rect);
} }
void void
@@ -1661,10 +1679,9 @@ ShowImageView::SelectAll()
void void
ShowImageView::ClearSelection() ShowImageView::ClearSelection()
{ {
if (HasSelection()) { // Remove the selection,
SetHasSelection(false); // DON'T copy it to the clipboard
Invalidate(); RemoveSelection(false);
}
} }
void void
+1
View File
@@ -129,6 +129,7 @@ private:
}; };
void InitPatterns(); void InitPatterns();
void RotatePatterns(); void RotatePatterns();
void RemoveSelection(bool bToClipboard);
bool HasSelection() { return fHasSelection; } bool HasSelection() { return fHasSelection; }
void SetHasSelection(bool bHasSelection); void SetHasSelection(bool bHasSelection);
void AnimateSelection(bool a); void AnimateSelection(bool a);