* 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:
@@ -525,6 +525,7 @@ Icon::AllocateBitmap(int32 size, int32 space)
|
|||||||
|
|
||||||
IconView::IconView(BRect rect, const char* name, uint32 resizeMode, uint32 flags)
|
IconView::IconView(BRect rect, const char* name, uint32 resizeMode, uint32 flags)
|
||||||
: BControl(rect, name, NULL, NULL, resizeMode, B_WILL_DRAW | flags),
|
: BControl(rect, name, NULL, NULL, resizeMode, B_WILL_DRAW | flags),
|
||||||
|
fModificationMessage(NULL),
|
||||||
fIconSize(B_LARGE_ICON),
|
fIconSize(B_LARGE_ICON),
|
||||||
fIcon(NULL),
|
fIcon(NULL),
|
||||||
fHeapIcon(NULL),
|
fHeapIcon(NULL),
|
||||||
@@ -542,6 +543,7 @@ IconView::IconView(BRect rect, const char* name, uint32 resizeMode, uint32 flags
|
|||||||
IconView::~IconView()
|
IconView::~IconView()
|
||||||
{
|
{
|
||||||
delete fIcon;
|
delete fIcon;
|
||||||
|
delete fModificationMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -864,6 +866,9 @@ IconView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
|||||||
|
|
||||||
icon->CopyTo(message);
|
icon->CopyTo(message);
|
||||||
|
|
||||||
|
if (icon != fIconData)
|
||||||
|
delete icon;
|
||||||
|
|
||||||
BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
|
BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
|
||||||
dragBitmap->Lock();
|
dragBitmap->Lock();
|
||||||
BView *view = new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
|
BView *view = new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
|
||||||
@@ -1111,9 +1116,22 @@ IconView::SetTarget(const BMessenger& target)
|
|||||||
|
|
||||||
|
|
||||||
void
|
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();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fModificationMessage)
|
||||||
|
Invoke(fModificationMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ class IconView : public BControl {
|
|||||||
void ShowIconHeap(bool show);
|
void ShowIconHeap(bool show);
|
||||||
void ShowEmptyFrame(bool show);
|
void ShowEmptyFrame(bool show);
|
||||||
void SetTarget(const BMessenger& target);
|
void SetTarget(const BMessenger& target);
|
||||||
void Invoke();
|
void SetModificationMessage(BMessage* message);
|
||||||
|
void Invoke(const BMessage* message = NULL);
|
||||||
|
|
||||||
::Icon* Icon();
|
::Icon* Icon();
|
||||||
int32 IconSize() const { return fIconSize; }
|
int32 IconSize() const { return fIconSize; }
|
||||||
@@ -116,6 +117,7 @@ class IconView : public BControl {
|
|||||||
void _StopWatching();
|
void _StopWatching();
|
||||||
|
|
||||||
BMessenger fTarget;
|
BMessenger fTarget;
|
||||||
|
BMessage* fModificationMessage;
|
||||||
int32 fIconSize;
|
int32 fIconSize;
|
||||||
BBitmap* fIcon;
|
BBitmap* fIcon;
|
||||||
BBitmap* fHeapIcon;
|
BBitmap* fHeapIcon;
|
||||||
|
|||||||
Reference in New Issue
Block a user