Implemented the BRect version of DragMessage(). This just creates a drag bitmap with the rect. We may want to switch to a less heavy implementation later on though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17115 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2006-04-12 20:26:56 +00:00
parent 7008829b0f
commit 34ff238b88
+27 -40
View File
@@ -1235,56 +1235,43 @@ BView::DragMessage(BMessage *message, BRect dragRect, BHandler *replyTo)
if (!message || !dragRect.IsValid()) if (!message || !dragRect.IsValid())
return; return;
if (replyTo == NULL)
replyTo = this;
if (replyTo->Looper() == NULL)
debugger("DragMessage: warning - the Handler needs a looper");
do_owner_check_no_pick(); do_owner_check_no_pick();
// calculate the offset
BPoint offset; BPoint offset;
uint32 buttons;
BMessage *current = fOwner->CurrentMessage();
if (!current || current->FindPoint("be:view_where", &offset) != B_OK)
GetMouse(&offset, &buttons, false);
offset -= dragRect.LeftTop();
if (!message->HasInt32("buttons")) { // create a drag bitmap for the rect
BMessage *msg = fOwner->CurrentMessage(); BBitmap *bitmap = new BBitmap(dragRect, B_RGBA32);
uint32 buttons; uint32 *bits = (uint32*)bitmap->Bits();
uint32 bytesPerRow = bitmap->BytesPerRow();
uint32 width = dragRect.IntegerWidth() + 1;
uint32 height = dragRect.IntegerHeight() + 1;
uint32 lastRow = (height - 1) * width;
if (msg) { memset(bits, 0x00, height * bytesPerRow);
if (msg->FindInt32("buttons", (int32 *)&buttons) != B_OK) {
BPoint point;
GetMouse(&point, &buttons, false);
}
BPoint point; // top
if (msg->FindPoint("be:view_where", &point) == B_OK) for (uint32 i = 0; i < width; i += 2)
offset = point - dragRect.LeftTop(); bits[i] = 0xff000000;
} else {
BPoint point;
GetMouse(&point, &buttons, false);
}
message->AddInt32("buttons", buttons); // bottom
} for (uint32 i = (height % 2 == 0 ? 1 : 0); i < width; i += 2)
bits[lastRow + i] = 0xff000000;
BMessage::Private privateMessage(message); // left
privateMessage.SetReply(BMessenger(replyTo, replyTo->Looper())); for (uint32 i = 0; i < lastRow; i += width * 2)
bits[i] = 0xff000000;
int32 bufferSize = privateMessage.NativeFlattenedSize(); // right
char* buffer = new (nothrow) char[bufferSize]; for (uint32 i = (width % 2 == 0 ? width : 0); i < lastRow; i += width * 2)
if (buffer) { bits[width - 1 + i] = 0xff000000;
privateMessage.NativeFlatten(buffer, bufferSize);
fOwner->fLink->StartMessage(AS_LAYER_DRAG_RECT); DragMessage(message, bitmap, B_OP_BLEND, offset, replyTo);
fOwner->fLink->Attach<BRect>(dragRect);
fOwner->fLink->Attach<BPoint>(offset);
fOwner->fLink->Attach<int32>(bufferSize);
fOwner->fLink->Attach(buffer, bufferSize);
fOwner->fLink->Flush();
delete [] buffer;
} else {
fprintf(stderr, "BView::DragMessage() - no memory to flatten drag message\n");
}
} }