Made constants static, coding style cleanup.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Copyright 2001-2012, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -8,6 +8,7 @@
|
||||
* Alexandre Deckner ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
//! BDragger represents a replicant "handle".
|
||||
|
||||
|
||||
@@ -45,10 +46,10 @@ using BPrivate::gSystemCatalog;
|
||||
#define B_TRANSLATE(str) \
|
||||
gSystemCatalog.GetString(B_TRANSLATE_MARK(str), "Dragger")
|
||||
|
||||
const uint32 kMsgDragStarted = 'Drgs';
|
||||
|
||||
const unsigned char
|
||||
kHandBitmap[] = {
|
||||
static const uint32 kMsgDragStarted = 'Drgs';
|
||||
|
||||
static const unsigned char kHandBitmap[] = {
|
||||
255, 255, 0, 0, 0, 255, 255, 255,
|
||||
255, 255, 0, 131, 131, 0, 255, 255,
|
||||
0, 0, 0, 0, 131, 131, 0, 0,
|
||||
@@ -112,8 +113,9 @@ DraggerManager* DraggerManager::sDefaultInstance = NULL;
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags)
|
||||
: BView(bounds, "_dragger_", rmask, flags),
|
||||
BDragger::BDragger(BRect bounds, BView* target, uint32 resizeMask, uint32 flags)
|
||||
:
|
||||
BView(bounds, "_dragger_", resizeMask, flags),
|
||||
fTarget(target),
|
||||
fRelation(TARGET_UNKNOWN),
|
||||
fShelf(NULL),
|
||||
@@ -128,7 +130,8 @@ BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags)
|
||||
|
||||
|
||||
BDragger::BDragger(BMessage* data)
|
||||
: BView(data),
|
||||
:
|
||||
BView(data),
|
||||
fTarget(NULL),
|
||||
fRelation(TARGET_UNKNOWN),
|
||||
fShelf(NULL),
|
||||
@@ -179,15 +182,16 @@ BDragger::Archive(BMessage *data, bool deep) const
|
||||
|
||||
BMessage popupMsg;
|
||||
|
||||
if (fPopUp && fPopUpIsCustom) {
|
||||
if (fPopUp != NULL && fPopUpIsCustom) {
|
||||
bool windowLocked = fPopUp->Window()->Lock();
|
||||
|
||||
ret = fPopUp->Archive(&popupMsg, deep);
|
||||
|
||||
if (windowLocked)
|
||||
if (windowLocked) {
|
||||
fPopUp->Window()->Unlock();
|
||||
// TODO: Investigate, in some (rare) occasions the menu window
|
||||
// has already been unlocked
|
||||
}
|
||||
|
||||
if (ret == B_OK)
|
||||
ret = data->AddMessage("_popup", &popupMsg);
|
||||
@@ -229,8 +233,8 @@ BDragger::Draw(BRect update)
|
||||
{
|
||||
BRect bounds(Bounds());
|
||||
|
||||
if (AreDraggersDrawn() && (!fShelf || fShelf->AllowsDragging())) {
|
||||
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) == 0) {
|
||||
if (AreDraggersDrawn() && (fShelf == NULL || fShelf->AllowsDragging())) {
|
||||
if (Parent() != NULL && (Parent()->Flags() & B_DRAW_ON_CHILDREN) == 0) {
|
||||
uint32 flags = Parent()->Flags();
|
||||
Parent()->SetFlags(flags | B_DRAW_ON_CHILDREN);
|
||||
Parent()->Draw(Frame() & ConvertToParent(update));
|
||||
@@ -248,7 +252,7 @@ BDragger::Draw(BRect update)
|
||||
// TODO: should draw it differently ?
|
||||
}
|
||||
} else if (IsVisibilityChanging()) {
|
||||
if (Parent()) {
|
||||
if (Parent() != NULL) {
|
||||
if ((Parent()->Flags() & B_DRAW_ON_CHILDREN) == 0) {
|
||||
uint32 flags = Parent()->Flags();
|
||||
Parent()->SetFlags(flags | B_DRAW_ON_CHILDREN);
|
||||
@@ -266,13 +270,13 @@ BDragger::Draw(BRect update)
|
||||
void
|
||||
BDragger::MouseDown(BPoint where)
|
||||
{
|
||||
if (!fTarget || !AreDraggersDrawn())
|
||||
if (fTarget == NULL || !AreDraggersDrawn())
|
||||
return;
|
||||
|
||||
uint32 buttons;
|
||||
Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
|
||||
|
||||
if (fShelf != NULL && (buttons & B_SECONDARY_MOUSE_BUTTON))
|
||||
if (fShelf != NULL && (buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
|
||||
_ShowPopUp(fTarget, where);
|
||||
}
|
||||
|
||||
@@ -316,7 +320,8 @@ BDragger::MessageReceived(BMessage *msg)
|
||||
Flush();
|
||||
fTransition = false;
|
||||
} else {
|
||||
if ((fShelf && (fShelf->AllowsDragging() && AreDraggersDrawn()))
|
||||
if ((fShelf != NULL && fShelf->AllowsDragging()
|
||||
&& AreDraggersDrawn())
|
||||
|| AreDraggersDrawn()) {
|
||||
Show();
|
||||
} else
|
||||
@@ -332,14 +337,12 @@ BDragger::MessageReceived(BMessage *msg)
|
||||
fTarget->Archive(&archive);
|
||||
else if (fRelation == TARGET_IS_CHILD)
|
||||
Archive(&archive);
|
||||
else {
|
||||
if (fTarget->Archive(&archive)) {
|
||||
else if (fTarget->Archive(&archive)) {
|
||||
BMessage archivedSelf(B_ARCHIVED_OBJECT);
|
||||
|
||||
if (Archive(&archivedSelf))
|
||||
archive.AddMessage("__widget", &archivedSelf);
|
||||
}
|
||||
}
|
||||
|
||||
archive.AddInt32("be:actions", B_TRASH_TARGET);
|
||||
BPoint offset;
|
||||
@@ -348,9 +351,8 @@ BDragger::MessageReceived(BMessage *msg)
|
||||
if (bitmap != NULL)
|
||||
DragMessage(&archive, bitmap, mode, offset, this);
|
||||
else {
|
||||
DragMessage(&archive,
|
||||
ConvertFromScreen(fTarget->ConvertToScreen(fTarget->Bounds())),
|
||||
this);
|
||||
DragMessage(&archive, ConvertFromScreen(
|
||||
fTarget->ConvertToScreen(fTarget->Bounds())), this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -663,7 +665,7 @@ BDragger::_RemoveFromList()
|
||||
status_t
|
||||
BDragger::_DetermineRelationship()
|
||||
{
|
||||
if (fTarget) {
|
||||
if (fTarget != NULL) {
|
||||
if (fTarget == Parent())
|
||||
fRelation = TARGET_IS_PARENT;
|
||||
else if (fTarget == ChildAt(0))
|
||||
@@ -682,10 +684,11 @@ BDragger::_DetermineRelationship()
|
||||
if (fRelation == TARGET_IS_PARENT) {
|
||||
BRect bounds(Frame());
|
||||
BRect parentBounds(Parent()->Bounds());
|
||||
if (!parentBounds.Contains(bounds))
|
||||
if (!parentBounds.Contains(bounds)) {
|
||||
MoveTo(parentBounds.right - bounds.Width(),
|
||||
parentBounds.bottom - bounds.Height());
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -699,7 +702,7 @@ BDragger::_SetViewToDrag(BView *target)
|
||||
|
||||
fTarget = target;
|
||||
|
||||
if (Window())
|
||||
if (Window() != NULL)
|
||||
_DetermineRelationship();
|
||||
|
||||
return B_OK;
|
||||
@@ -734,7 +737,7 @@ BDragger::_BuildDefaultPopUp()
|
||||
BMessage* msg = new BMessage(B_ABOUT_REQUESTED);
|
||||
|
||||
const char* name = fTarget->Name();
|
||||
if (name)
|
||||
if (name != NULL)
|
||||
msg->AddString("target", name);
|
||||
|
||||
BString about(B_TRANSLATE("About %app" B_UTF8_ELLIPSIS));
|
||||
@@ -752,7 +755,7 @@ BDragger::_ShowPopUp(BView *target, BPoint where)
|
||||
{
|
||||
BPoint point = ConvertToScreen(where);
|
||||
|
||||
if (!fPopUp && fTarget)
|
||||
if (fPopUp == NULL && fTarget != NULL)
|
||||
_BuildDefaultPopUp();
|
||||
|
||||
fPopUp->SetTargetForItems(fTarget);
|
||||
|
||||
Reference in New Issue
Block a user