* Fixed a memory leak when creating the drag bitmap.

* Added an optional modification message that is triggered whenever the
  view adopts a new icon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28178 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-10-16 19:26:19 +00:00
parent 21f11263f6
commit 20ca748ade
2 changed files with 26 additions and 3 deletions
+23 -2
View File
@@ -525,6 +525,7 @@ Icon::AllocateBitmap(int32 size, int32 space)
IconView::IconView(BRect rect, const char* name, uint32 resizeMode, uint32 flags)
: BControl(rect, name, NULL, NULL, resizeMode, B_WILL_DRAW | flags),
fModificationMessage(NULL),
fIconSize(B_LARGE_ICON),
fIcon(NULL),
fHeapIcon(NULL),
@@ -542,6 +543,7 @@ IconView::IconView(BRect rect, const char* name, uint32 resizeMode, uint32 flags
IconView::~IconView()
{
delete fIcon;
delete fModificationMessage;
}
@@ -864,6 +866,9 @@ IconView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
icon->CopyTo(message);
if (icon != fIconData)
delete icon;
BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
dragBitmap->Lock();
BView *view = new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
@@ -1111,9 +1116,22 @@ IconView::SetTarget(const BMessenger& target)
void
IconView::Invoke()
IconView::SetModificationMessage(BMessage* message)
{
fTarget.SendMessage(kMsgIconInvoked);
delete fModificationMessage;
fModificationMessage = message;
}
void
IconView::Invoke(const BMessage* _message)
{
if (_message == NULL)
fTarget.SendMessage(kMsgIconInvoked);
else {
BMessage message(*_message);
fTarget.SendMessage(&message);
}
}
@@ -1238,6 +1256,9 @@ IconView::_SetIcon(BBitmap* large, BBitmap* mini, const uint8* data, size_t size
}
Invalidate();
}
if (fModificationMessage)
Invoke(fModificationMessage);
}
+3 -1
View File
@@ -93,7 +93,8 @@ class IconView : public BControl {
void ShowIconHeap(bool show);
void ShowEmptyFrame(bool show);
void SetTarget(const BMessenger& target);
void Invoke();
void SetModificationMessage(BMessage* message);
void Invoke(const BMessage* message = NULL);
::Icon* Icon();
int32 IconSize() const { return fIconSize; }
@@ -116,6 +117,7 @@ class IconView : public BControl {
void _StopWatching();
BMessenger fTarget;
BMessage* fModificationMessage;
int32 fIconSize;
BBitmap* fIcon;
BBitmap* fHeapIcon;