Fixed a couple of infinite loops, small style changes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10520 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2004-12-23 13:27:14 +00:00
parent 0e0eb256d8
commit 3a15790e0f
+34 -38
View File
@@ -23,7 +23,6 @@
// Author: Marc Flerackers ([email protected]) // Author: Marc Flerackers ([email protected])
// Description: BDragger represents a replicant "handle". // Description: BDragger represents a replicant "handle".
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <Alert.h> #include <Alert.h>
#include <Beep.h> #include <Beep.h>
#include <Bitmap.h> #include <Bitmap.h>
@@ -37,22 +36,25 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
// Globals ---------------------------------------------------------------------
bool BDragger::sVisible; bool BDragger::sVisible;
bool BDragger::sInited; bool BDragger::sInited;
BLocker BDragger::sLock; BLocker BDragger::sLock;
BList BDragger::sList; BList BDragger::sList;
static rgb_color kZombieColor = {220, 220, 220, 255}; const static rgb_color kZombieColor = {220, 220, 220, 255};
const unsigned char kHandBitmap[] = { 255, 255, 0, 0, 0, 255, 255, 255, const unsigned char
255, 255, 0, 131, 131, 0, 255, 255, kHandBitmap[] = {
0, 0, 0, 0, 131, 131, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255,
0, 131, 0, 0, 131, 131, 0, 0, 255, 255, 0, 131, 131, 0, 255, 255,
0, 131, 131, 131, 131, 131, 0, 0, 0, 0, 0, 0, 131, 131, 0, 0,
255, 0, 131, 131, 131, 131, 0, 0, 0, 131, 0, 0, 131, 131, 0, 0,
255, 255, 0, 0, 0, 0, 0, 0, 0, 131, 131, 131, 131, 131, 0, 0,
255, 255, 255, 255, 255, 255, 0, 0}; 255, 0, 131, 131, 131, 131, 0, 0,
255, 255, 0, 0, 0, 0, 0, 0,
255, 255, 255, 255, 255, 255, 0, 0
};
BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags) BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags)
@@ -80,7 +82,7 @@ BDragger::BDragger(BMessage *data)
fErrCount(0), fErrCount(0),
fPopUp(NULL) fPopUp(NULL)
{ {
data->FindInt32("_rel", (int32*)&fRelation); data->FindInt32("_rel", (int32 *)&fRelation);
fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false); fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false);
fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8); fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8);
@@ -91,7 +93,7 @@ BDragger::BDragger(BMessage *data)
BArchivable *archivable = instantiate_object(&popupMsg); BArchivable *archivable = instantiate_object(&popupMsg);
if (archivable) if (archivable)
fPopUp = dynamic_cast<BPopUpMenu*>(archivable); fPopUp = dynamic_cast<BPopUpMenu *>(archivable);
} }
} }
@@ -207,15 +209,15 @@ BDragger::MouseDown(BPoint where)
bool drag = false; bool drag = false;
while (true) { while (true) {
BPoint where2; BPoint mousePoint;
uint32 buttons; uint32 buttons;
GetMouse(&where2, &buttons); GetMouse(&mousePoint, &buttons);
if (!buttons) if (!buttons)
break; break;
if (where2 != where) { if (mousePoint != where) {
drag = true; drag = true;
break; break;
} }
@@ -240,7 +242,6 @@ BDragger::MouseDown(BPoint where)
} }
archive.AddInt32("be:actions", B_TRASH_TARGET); archive.AddInt32("be:actions", B_TRASH_TARGET);
BPoint offset; BPoint offset;
drawing_mode mode; drawing_mode mode;
@@ -258,16 +259,16 @@ BDragger::MouseDown(BPoint where)
void void
BDragger::MouseUp(BPoint pt) BDragger::MouseUp(BPoint point)
{ {
BView::MouseUp(pt); BView::MouseUp(point);
} }
void void
BDragger::MouseMoved(BPoint pt, uint32 code, const BMessage *msg) BDragger::MouseMoved(BPoint point, uint32 code, const BMessage *msg)
{ {
BView::MouseMoved(pt, code, msg); BView::MouseMoved(point, code, msg);
} }
@@ -276,7 +277,7 @@ BDragger::MessageReceived(BMessage *msg)
{ {
if (msg->what == B_TRASH_TARGET) { if (msg->what == B_TRASH_TARGET) {
if (fShelf) if (fShelf)
Window()->PostMessage('JAHA', fTarget, NULL); Window()->PostMessage('JAHA', fTarget, NULL); // TODO: 'JAHA' ? What's that ?
else else
(new BAlert("??", (new BAlert("??",
"Can't delete this replicant from its original application. Life goes on.", "Can't delete this replicant from its original application. Life goes on.",
@@ -301,16 +302,16 @@ BDragger::MessageReceived(BMessage *msg)
void void
BDragger::FrameMoved(BPoint new_position) BDragger::FrameMoved(BPoint newPosition)
{ {
BView::FrameMoved(new_position); BView::FrameMoved(newPosition);
} }
void void
BDragger::FrameResized(float new_width, float new_height) BDragger::FrameResized(float newWidth, float newHeight)
{ {
BView::FrameResized(new_width, new_height); BView::FrameResized(newWidth, newHeight);
} }
@@ -349,14 +350,14 @@ BHandler *BDragger::ResolveSpecifier(BMessage *msg, int32 index,
status_t status_t
BDragger::GetSupportedSuites(BMessage *data) BDragger::GetSupportedSuites(BMessage *data)
{ {
return GetSupportedSuites(data); return BView::GetSupportedSuites(data);
} }
status_t status_t
BDragger::Perform(perform_code d, void *arg) BDragger::Perform(perform_code d, void *arg)
{ {
return Perform(d, arg); return BView::Perform(d, arg);
} }
@@ -410,7 +411,7 @@ BPopUpMenu *
BDragger::PopUp() const BDragger::PopUp() const
{ {
if (!fPopUp && fTarget) if (!fPopUp && fTarget)
const_cast<BDragger*>(this)->BuildDefaultPopUp(); const_cast<BDragger *>(this)->BuildDefaultPopUp();
return fPopUp; return fPopUp;
} }
@@ -552,21 +553,16 @@ BDragger::BuildDefaultPopUp()
if (name) if (name)
msg->AddString("target", name); msg->AddString("target", name);
// TODO: Fix this char about[B_OS_NAME_LENGTH];
char *about = (char*)malloc(6 + (name ? strlen(name) : 0) + 1); snprintf(about, B_OS_NAME_LENGTH, "About %s", name);
sprintf(about, "About %s", name);
fPopUp->AddItem(new BMenuItem(about, msg)); fPopUp->AddItem(new BMenuItem(about, msg));
free(about); // Separator
// Seperator
fPopUp->AddItem(new BSeparatorItem()); fPopUp->AddItem(new BSeparatorItem());
// Delete // Delete
msg = new BMessage('JAHA'); fPopUp->AddItem(new BMenuItem("Delete", new BMessage('JAHA')));
fPopUp->AddItem(new BMenuItem("Delete", msg));
} }