From 6e0e4ca6b2ab01f0f1bc7fd198e262481063fd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 11 Aug 2006 19:26:37 +0000 Subject: [PATCH] * Fixed bug that let the dragger not hide in the Deskbar (was in ListManage(), now in _AddToList()). * Cleaned up BDragger and BShelf a bit, moved private classes into the BPrivate namespace, renamed private methods to have the '_' prefix. * Rewrote Dragger.h. * Is that static dragger list needed at all? And if so, for what?` git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18487 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Dragger.h | 212 ++++++++++++++++----------------- headers/os/interface/Shelf.h | 15 ++- src/kits/interface/Dragger.cpp | 124 ++++++++++--------- src/kits/interface/Shelf.cpp | 202 +++++++++++++++---------------- 4 files changed, 278 insertions(+), 275 deletions(-) diff --git a/headers/os/interface/Dragger.h b/headers/os/interface/Dragger.h index 8dff6e04d6..c33aee3880 100644 --- a/headers/os/interface/Dragger.h +++ b/headers/os/interface/Dragger.h @@ -1,17 +1,11 @@ -/******************************************************************************* -/ -/ File: Dragger.h -/ -/ Description: BDragger represents a replicant "handle." -/ -/ Copyright 1997-98, Be Incorporated, All Rights Reserved -/ -*******************************************************************************/ - +/* + * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _DRAGGER_H #define _DRAGGER_H -#include + #include #include #include @@ -20,107 +14,103 @@ class BBitmap; class BMessage; class BShelf; -/*----------------------------------------------------------------*/ -/*----- BDragger class -------------------------------------------*/ - -class BDragger : public BView { -public: - BDragger(BRect bounds, - BView *target, - uint32 rmask = B_FOLLOW_NONE, - uint32 flags = B_WILL_DRAW); - BDragger(BMessage *data); - -virtual ~BDragger(); -static BArchivable *Instantiate(BMessage *data); -virtual status_t Archive(BMessage *data, bool deep = true) const; - -virtual void AttachedToWindow(); -virtual void DetachedFromWindow(); -virtual void Draw(BRect update); -virtual void MouseDown(BPoint where); -virtual void MouseUp(BPoint pt); -virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg); -virtual void MessageReceived(BMessage *msg); -virtual void FrameMoved(BPoint new_position); -virtual void FrameResized(float new_width, float new_height); - -static status_t ShowAllDraggers(); /* system wide!*/ -static status_t HideAllDraggers(); /* system wide!*/ -static bool AreDraggersDrawn(); - -virtual BHandler *ResolveSpecifier(BMessage *msg, - int32 index, - BMessage *specifier, - int32 form, - const char *property); -virtual status_t GetSupportedSuites(BMessage *data); -virtual status_t Perform(perform_code d, void *arg); - -virtual void ResizeToPreferred(); -virtual void GetPreferredSize(float *width, float *height); -virtual void MakeFocus(bool state = true); -virtual void AllAttached(); -virtual void AllDetached(); - - status_t SetPopUp(BPopUpMenu *context_menu); - BPopUpMenu *PopUp() const; - - bool InShelf() const; - BView *Target() const; - -virtual BBitmap *DragBitmap(BPoint *offset, drawing_mode *mode); - -protected: - bool IsVisibilityChanging() const; - -/*----- Private or reserved -----------------------------------------*/ -private: - -friend class _TContainerViewFilter_; -friend class _rep_data_; -friend class BShelf; -friend void _toggle_handles_(bool); - -//+virtual void _ReservedDragger1(); -virtual void _ReservedDragger2(); -virtual void _ReservedDragger3(); -virtual void _ReservedDragger4(); - - BDragger &operator=(const BDragger &); - - void ListManage(bool); - status_t determine_relationship(); - status_t SetViewToDrag(BView *target); - void SetShelf(BShelf *); - void SetZombied(bool state); - void BuildDefaultPopUp(); - void ShowPopUp(BView *target, BPoint where); -static bool sVisible; -static bool sInited; -static BLocker sLock; -static BList sList; - - enum relation { - TARGET_UNKNOWN, - TARGET_IS_CHILD, - TARGET_IS_PARENT, - TARGET_IS_SIBLING - }; - - BView *fTarget; - relation fRelation; - BShelf *fShelf; - bool fTransition; - bool fIsZombie; - char fErrCount; - bool _unused2; - BBitmap *fBitmap; - BPopUpMenu *fPopUp; - uint32 _reserved[3]; /* was 4 */ +namespace BPrivate { + class replicant_data; + class ShelfContainerViewFilter; }; -/*-------------------------------------------------------------*/ -/*-------------------------------------------------------------*/ + +class BDragger : public BView { + public: + BDragger(BRect bounds, BView* target, + uint32 resizingMask = B_FOLLOW_NONE, + uint32 flags = B_WILL_DRAW); + BDragger(BMessage* data); + virtual ~BDragger(); + + static BArchivable* Instantiate(BMessage* data); + virtual status_t Archive(BMessage* data, bool deep = true) const; + + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + + virtual void Draw(BRect updateRect); + virtual void MouseDown(BPoint where); + virtual void MouseUp(BPoint where); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* dragMessage); + virtual void MessageReceived(BMessage* message); + virtual void FrameMoved(BPoint newPosition); + virtual void FrameResized(float newWidth, float newHeight); + + static status_t ShowAllDraggers(); + static status_t HideAllDraggers(); + static bool AreDraggersDrawn(); + + virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 form, + const char* property); + virtual status_t GetSupportedSuites(BMessage* data); + virtual status_t Perform(perform_code d, void* arg); + + virtual void ResizeToPreferred(); + virtual void GetPreferredSize(float* _width, float* _height); + virtual void MakeFocus(bool focus = true); + virtual void AllAttached(); + virtual void AllDetached(); + + status_t SetPopUp(BPopUpMenu* contextMenu); + BPopUpMenu* PopUp() const; + + bool InShelf() const; + BView* Target() const; + + virtual BBitmap* DragBitmap(BPoint* offset, drawing_mode *mode); + + protected: + bool IsVisibilityChanging() const; + + private: + friend class BPrivate::ShelfContainerViewFilter; + friend class BPrivate::replicant_data; + friend class BShelf; + + virtual void _ReservedDragger2(); + virtual void _ReservedDragger3(); + virtual void _ReservedDragger4(); + + BDragger& operator=(const BDragger& other); + + void _AddToList(); + void _RemoveFromList(); + status_t _DetermineRelationship(); + status_t _SetViewToDrag(BView* target); + void _SetShelf(BShelf* shelf); + void _SetZombied(bool state); + void _BuildDefaultPopUp(); + void _ShowPopUp(BView* target, BPoint where); + + static bool sVisible; + static bool sVisibleInitialized; + static BLocker sLock; + static BList sList; + + enum relation { + TARGET_UNKNOWN, + TARGET_IS_CHILD, + TARGET_IS_PARENT, + TARGET_IS_SIBLING + }; + + BView* fTarget; + relation fRelation; + BShelf* fShelf; + bool fTransition; + bool fIsZombie; + char fErrCount; + BBitmap * fBitmap; + BPopUpMenu* fPopUp; + uint32 _reserved[3]; +}; #endif /* _DRAGGER_H */ diff --git a/headers/os/interface/Shelf.h b/headers/os/interface/Shelf.h index 791c0b05d0..cd068f8c3a 100644 --- a/headers/os/interface/Shelf.h +++ b/headers/os/interface/Shelf.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku Inc. + * Copyright 2001-2006, Haiku Inc. * Distributed under the terms of the MIT License. */ #ifndef _SHELF_H @@ -14,8 +14,11 @@ class BView; class BEntry; struct entry_ref; -class _rep_data_; -class _TContainerViewFilter_; +namespace BPrivate { + class replicant_data; + class ShelfContainerViewFilter; +}; + class BShelf : public BHandler { public: @@ -76,7 +79,7 @@ class BShelf : public BHandler { const BView *replicant); private: - friend class _TContainerViewFilter_; + friend class BPrivate::ShelfContainerViewFilter; virtual void _ReservedShelf2(); virtual void _ReservedShelf3(); @@ -92,7 +95,7 @@ class BShelf : public BHandler { status_t _Archive(BMessage* data) const; void _InitData(BEntry* entry, BDataIO* stream, BView* view, bool allowDrags); - status_t _DeleteReplicant(_rep_data_* replicant); + status_t _DeleteReplicant(BPrivate::replicant_data* replicant); status_t _AddReplicant(BMessage* data, BPoint* location, uint32 uniqueID); status_t _GetProperty(BMessage* message, BMessage* reply); @@ -102,7 +105,7 @@ class BShelf : public BHandler { BDataIO* fStream; BEntry* fEntry; BList fReplicants; - _TContainerViewFilter_* fFilter; + BPrivate::ShelfContainerViewFilter* fFilter; uint32 fGenCount; bool fAllowDragging; bool fDirty; diff --git a/src/kits/interface/Dragger.cpp b/src/kits/interface/Dragger.cpp index d9a246ac3d..945ec39e05 100644 --- a/src/kits/interface/Dragger.cpp +++ b/src/kits/interface/Dragger.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -25,8 +26,8 @@ bool BDragger::sVisible; -bool BDragger::sInited; -BLocker BDragger::sLock("BDragger_sLock"); +bool BDragger::sVisibleInitialized; +BLocker BDragger::sLock("BDragger static"); BList BDragger::sList; const static rgb_color kZombieColor = {220, 220, 220, 255}; @@ -133,15 +134,15 @@ BDragger::AttachedToWindow() SetViewColor(B_TRANSPARENT_COLOR); } - determine_relationship(); - ListManage(true); + _DetermineRelationship(); + _AddToList(); } void BDragger::DetachedFromWindow() { - ListManage(false); + _RemoveFromList(); } @@ -186,8 +187,7 @@ BDragger::MouseDown(BPoint where) return; } - ShowPopUp(fTarget, where); - + _ShowPopUp(fTarget, where); } else { bigtime_t time = system_time(); bigtime_t clickSpeed = 0; @@ -199,10 +199,10 @@ BDragger::MouseDown(BPoint where) while (true) { BPoint mousePoint; GetMouse(&mousePoint, &buttons); - + if (!buttons || system_time() > time + clickSpeed) break; - + if (mousePoint != where) { drag = true; break; @@ -228,18 +228,19 @@ BDragger::MouseDown(BPoint where) } archive.AddInt32("be:actions", B_TRASH_TARGET); - + BPoint offset; drawing_mode mode; BBitmap *bitmap = DragBitmap(&offset, &mode); - if (bitmap) + if (bitmap != NULL) DragMessage(&archive, bitmap, mode, offset, this); - else + else { DragMessage(&archive, ConvertFromScreen(fTarget->ConvertToScreen(fTarget->Bounds())), this); + } } else - ShowPopUp(fTarget, where); + _ShowPopUp(fTarget, where); } } @@ -262,20 +263,20 @@ void BDragger::MessageReceived(BMessage *msg) { if (msg->what == B_TRASH_TARGET) { - if (fShelf) + if (fShelf != NULL) Window()->PostMessage(kDeleteReplicant, fTarget, NULL); - else + else { (new BAlert("??", "Can't delete this replicant from its original application. Life goes on.", "OK", NULL, NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT))->Go(NULL); - + } } else if (msg->what == B_SCREEN_CHANGED) { + // TODO: this code is to be called whenever the "are draggers drawn" option is changed if (fRelation == TARGET_IS_CHILD) { fTransition = true; Invalidate(); Flush(); fTransition = false; - } else { if ((fShelf && (fShelf->AllowsDragging() && AreDraggersDrawn())) || AreDraggersDrawn()) @@ -321,28 +322,34 @@ BDragger::HideAllDraggers() bool BDragger::AreDraggersDrawn() { - // TODO: Implement. Should ask the registrar or the app server - return true; + BAutolock _(sLock); + + if (!sVisibleInitialized) { + // TODO: Implement. Should ask the registrar or the app server + sVisible = true; + sVisibleInitialized = true; + } + return sVisible; } -BHandler * -BDragger::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, - int32 form, const char *property) +BHandler* +BDragger::ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, + int32 form, const char* property) { - return BView::ResolveSpecifier(msg, index, specifier, form, property); + return BView::ResolveSpecifier(message, index, specifier, form, property); } status_t -BDragger::GetSupportedSuites(BMessage *data) +BDragger::GetSupportedSuites(BMessage* data) { return BView::GetSupportedSuites(data); } status_t -BDragger::Perform(perform_code d, void *arg) +BDragger::Perform(perform_code d, void* arg) { return BView::Perform(d, arg); } @@ -356,9 +363,9 @@ BDragger::ResizeToPreferred() void -BDragger::GetPreferredSize(float *width, float *height) +BDragger::GetPreferredSize(float* _width, float* _height) { - BView::GetPreferredSize(width, height); + BView::GetPreferredSize(_width, _height); } @@ -386,7 +393,7 @@ BDragger::AllDetached() status_t BDragger::SetPopUp(BPopUpMenu *menu) { - if (fPopUp != NULL && fPopUp != menu) + if (fPopUp != menu) delete fPopUp; fPopUp = menu; @@ -397,9 +404,9 @@ BDragger::SetPopUp(BPopUpMenu *menu) BPopUpMenu * BDragger::PopUp() const { - if (!fPopUp && fTarget) - const_cast(this)->BuildDefaultPopUp(); - + if (fPopUp == NULL && fTarget) + const_cast(this)->_BuildDefaultPopUp(); + return fPopUp; } @@ -445,33 +452,35 @@ BDragger::operator=(const BDragger &) void -BDragger::ListManage(bool add) +BDragger::_AddToList() { - if (sLock.Lock()) { - bool drawn = AreDraggersDrawn(); + BAutolock _(sLock); + sList.AddItem(this); - if (add) { - bool dragging = true; + bool allowsDragging = true; + if (fShelf) + allowsDragging = fShelf->AllowsDragging(); - sList.AddItem(this); - - if (fShelf) - dragging = fShelf->AllowsDragging(); - - if (!drawn && !dragging) { - if (fRelation != TARGET_IS_CHILD) - Hide(); - } - } else - sList.RemoveItem(this); - - sLock.Unlock(); + if (!AreDraggersDrawn() || !allowsDragging) { + // The dragger is not shown - but we can't hide us in case we're the + // parent of the actual target view (because then you couldn't see + // it anymore). + if (fRelation != TARGET_IS_CHILD) + Hide(); } } +void +BDragger::_RemoveFromList() +{ + BAutolock _(sLock); + sList.RemoveItem(this); +} + + status_t -BDragger::determine_relationship() +BDragger::_DetermineRelationship() { status_t err = B_OK; @@ -496,7 +505,7 @@ BDragger::determine_relationship() status_t -BDragger::SetViewToDrag(BView *target) +BDragger::_SetViewToDrag(BView *target) { if (target->Window() != Window()) return B_ERROR; @@ -504,21 +513,21 @@ BDragger::SetViewToDrag(BView *target) fTarget = target; if (Window()) - determine_relationship(); + _DetermineRelationship(); return B_OK; } void -BDragger::SetShelf(BShelf *shelf) +BDragger::_SetShelf(BShelf *shelf) { fShelf = shelf; } void -BDragger::SetZombied(bool state) +BDragger::_SetZombied(bool state) { fIsZombie = state; @@ -530,7 +539,7 @@ BDragger::SetZombied(bool state) void -BDragger::BuildDefaultPopUp() +BDragger::_BuildDefaultPopUp() { fPopUp = new BPopUpMenu("Shelf", false, false, B_ITEMS_IN_COLUMN); @@ -538,7 +547,6 @@ BDragger::BuildDefaultPopUp() BMessage *msg = new BMessage(B_ABOUT_REQUESTED); const char *name = fTarget->Name(); - if (name) msg->AddString("target", name); @@ -552,12 +560,12 @@ BDragger::BuildDefaultPopUp() void -BDragger::ShowPopUp(BView *target, BPoint where) +BDragger::_ShowPopUp(BView *target, BPoint where) { BPoint point = ConvertToScreen(where); if (!fPopUp && fTarget) - BuildDefaultPopUp(); + _BuildDefaultPopUp(); fPopUp->SetTargetForItems(fTarget); diff --git a/src/kits/interface/Shelf.cpp b/src/kits/interface/Shelf.cpp index 1e5292b424..c5e27716a9 100644 --- a/src/kits/interface/Shelf.cpp +++ b/src/kits/interface/Shelf.cpp @@ -101,17 +101,19 @@ extern "C" void _ReservedShelf1__6BShelfFv(BShelf *const, int32, const BMessage*, const BView*); -class _rep_data_ { +namespace BPrivate { + +class replicant_data { private: friend class BShelf; - _rep_data_(BMessage *message, BView *view, BDragger *dragger, + replicant_data(BMessage *message, BView *view, BDragger *dragger, BDragger::relation relation, unsigned long id, image_id image); - _rep_data_(); + replicant_data(); - static _rep_data_* find(BList const *list, BMessage const *msg); - static _rep_data_* find(BList const *list, BView const *view, bool allowZombie); - static _rep_data_* find(BList const *list, unsigned long id); + static replicant_data* find(BList const *list, BMessage const *msg); + static replicant_data* find(BList const *list, BView const *view, bool allowZombie); + static replicant_data* find(BList const *list, unsigned long id); static int32 index_of(BList const *list, BMessage const *msg); static int32 index_of(BList const *list, BView const *view, bool allowZombie); @@ -127,20 +129,37 @@ class _rep_data_ { BView *fZombieView; }; - -class _TContainerViewFilter_ : public BMessageFilter { +class ShelfContainerViewFilter : public BMessageFilter { public: - _TContainerViewFilter_(BShelf *shelf, BView *view); - virtual ~_TContainerViewFilter_(); + ShelfContainerViewFilter(BShelf *shelf, BView *view); filter_result Filter(BMessage *msg, BHandler **handler); - filter_result ObjectDropFilter(BMessage *msg, BHandler **handler); - protected: + private: + filter_result _ObjectDropFilter(BMessage *msg, BHandler **handler); + BShelf *fShelf; BView *fView; }; +class ReplicantViewFilter : public BMessageFilter { + public: + ReplicantViewFilter(BShelf *shelf, BView *view); + + filter_result Filter(BMessage *message, BHandler **handler); + + private: + BShelf *fShelf; + BView *fView; +}; + +} // namespace BPrivate + + +using BPrivate::replicant_data; +using BPrivate::ReplicantViewFilter; +using BPrivate::ShelfContainerViewFilter; + // #pragma mark - @@ -164,7 +183,7 @@ send_reply(BMessage* message, status_t status, uint32 uniqueID) // #pragma mark - -_rep_data_::_rep_data_(BMessage *message, BView *view, BDragger *dragger, +replicant_data::replicant_data(BMessage *message, BView *view, BDragger *dragger, BDragger::relation relation, unsigned long id, image_id image) : fMessage(message), @@ -179,7 +198,7 @@ _rep_data_::_rep_data_(BMessage *message, BView *view, BDragger *dragger, } -_rep_data_::_rep_data_() +replicant_data::replicant_data() : fMessage(NULL), fView(NULL), @@ -194,12 +213,12 @@ _rep_data_::_rep_data_() //static -_rep_data_ * -_rep_data_::find(BList const *list, BMessage const *msg) +replicant_data * +replicant_data::find(BList const *list, BMessage const *msg) { int32 i = 0; - _rep_data_ *item; - while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) { + replicant_data *item; + while ((item = (replicant_data*)list->ItemAt(i++)) != NULL) { if (item->fMessage == msg) return item; } @@ -209,12 +228,12 @@ _rep_data_::find(BList const *list, BMessage const *msg) //static -_rep_data_ * -_rep_data_::find(BList const *list, BView const *view, bool allowZombie) +replicant_data * +replicant_data::find(BList const *list, BView const *view, bool allowZombie) { int32 i = 0; - _rep_data_ *item; - while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) { + replicant_data *item; + while ((item = (replicant_data*)list->ItemAt(i++)) != NULL) { if (item->fView == view) return item; @@ -227,12 +246,12 @@ _rep_data_::find(BList const *list, BView const *view, bool allowZombie) //static -_rep_data_ * -_rep_data_::find(BList const *list, unsigned long id) +replicant_data * +replicant_data::find(BList const *list, unsigned long id) { int32 i = 0; - _rep_data_ *item; - while ((item = (_rep_data_*)list->ItemAt(i++)) != NULL) { + replicant_data *item; + while ((item = (replicant_data*)list->ItemAt(i++)) != NULL) { if (item->fId == id) return item; } @@ -243,11 +262,11 @@ _rep_data_::find(BList const *list, unsigned long id) //static int32 -_rep_data_::index_of(BList const *list, BMessage const *msg) +replicant_data::index_of(BList const *list, BMessage const *msg) { int32 i = 0; - _rep_data_ *item; - while ((item = (_rep_data_*)list->ItemAt(i)) != NULL) { + replicant_data *item; + while ((item = (replicant_data*)list->ItemAt(i)) != NULL) { if (item->fMessage == msg) return i; i++; @@ -259,11 +278,11 @@ _rep_data_::index_of(BList const *list, BMessage const *msg) //static int32 -_rep_data_::index_of(BList const *list, BView const *view, bool allowZombie) +replicant_data::index_of(BList const *list, BView const *view, bool allowZombie) { int32 i = 0; - _rep_data_ *item; - while ((item = (_rep_data_*)list->ItemAt(i)) != NULL) { + replicant_data *item; + while ((item = (replicant_data*)list->ItemAt(i)) != NULL) { if (item->fView == view) return i; @@ -278,11 +297,11 @@ _rep_data_::index_of(BList const *list, BView const *view, bool allowZombie) //static int32 -_rep_data_::index_of(BList const *list, unsigned long id) +replicant_data::index_of(BList const *list, unsigned long id) { int32 i = 0; - _rep_data_ *item; - while ((item = (_rep_data_*)list->ItemAt(i)) != NULL) { + replicant_data *item; + while ((item = (replicant_data*)list->ItemAt(i)) != NULL) { if (item->fId == id) return i; i++; @@ -295,34 +314,29 @@ _rep_data_::index_of(BList const *list, unsigned long id) // #pragma mark - -_TContainerViewFilter_::_TContainerViewFilter_(BShelf *shelf, BView *view) - : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), +ShelfContainerViewFilter::ShelfContainerViewFilter(BShelf *shelf, BView *view) + : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), fShelf(shelf), fView(view) { } -_TContainerViewFilter_::~_TContainerViewFilter_() -{ -} - - filter_result -_TContainerViewFilter_::Filter(BMessage *msg, BHandler **handler) +ShelfContainerViewFilter::Filter(BMessage *msg, BHandler **handler) { filter_result filter = B_DISPATCH_MESSAGE; - if (msg->what == B_ARCHIVED_OBJECT || - msg->what == B_ABOUT_REQUESTED) - return ObjectDropFilter(msg, handler); + if (msg->what == B_ARCHIVED_OBJECT + || msg->what == B_ABOUT_REQUESTED) + return _ObjectDropFilter(msg, handler); return filter; } filter_result -_TContainerViewFilter_::ObjectDropFilter(BMessage *msg, BHandler **_handler) +ShelfContainerViewFilter::_ObjectDropFilter(BMessage *msg, BHandler **_handler) { BView *mouseView = NULL; if (*_handler) @@ -380,35 +394,24 @@ _TContainerViewFilter_::ObjectDropFilter(BMessage *msg, BHandler **_handler) // #pragma mark - -class _TReplicantViewFilter_ : public BMessageFilter { - public: - _TReplicantViewFilter_(BShelf *shelf, BView *view) - : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), - fShelf(shelf), - fView(view) - { - } - - virtual ~_TReplicantViewFilter_() - { - } - - filter_result Filter(BMessage *message, BHandler **handler) - { - if (message->what == kDeleteReplicant) { - if (handler != NULL) - *handler = fShelf; - message->AddPointer("_target", fView); - } - return B_DISPATCH_MESSAGE; - } - - private: - BShelf *fShelf; - BView *fView; -}; +ReplicantViewFilter::ReplicantViewFilter(BShelf *shelf, BView *view) + : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), + fShelf(shelf), + fView(view) +{ +} +filter_result +ReplicantViewFilter::Filter(BMessage *message, BHandler **handler) +{ + if (message->what == kDeleteReplicant) { + if (handler != NULL) + *handler = fShelf; + message->AddPointer("_target", fView); + } + return B_DISPATCH_MESSAGE; +} // #pragma mark - @@ -836,9 +839,9 @@ BShelf::AddReplicant(BMessage *data, BPoint location) status_t BShelf::DeleteReplicant(BView *replicant) { - int32 index = _rep_data_::index_of(&fReplicants, replicant, true); + int32 index = replicant_data::index_of(&fReplicants, replicant, true); - _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); + replicant_data *item = (replicant_data*)fReplicants.ItemAt(index); if (item == NULL) return B_BAD_VALUE; @@ -849,9 +852,9 @@ BShelf::DeleteReplicant(BView *replicant) status_t BShelf::DeleteReplicant(BMessage *data) { - int32 index = _rep_data_::index_of(&fReplicants, data); + int32 index = replicant_data::index_of(&fReplicants, data); - _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); + replicant_data *item = (replicant_data*)fReplicants.ItemAt(index); if (!item) return B_BAD_VALUE; @@ -862,7 +865,7 @@ BShelf::DeleteReplicant(BMessage *data) status_t BShelf::DeleteReplicant(int32 index) { - _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); + replicant_data *item = (replicant_data*)fReplicants.ItemAt(index); if (!item) return B_BAD_INDEX; @@ -881,7 +884,7 @@ BMessage * BShelf::ReplicantAt(int32 index, BView **_view, uint32 *_uniqueID, status_t *_error) const { - _rep_data_ *item = (_rep_data_*)fReplicants.ItemAt(index); + replicant_data *item = (replicant_data*)fReplicants.ItemAt(index); if (item == NULL) { // no replicant found if (_view) @@ -908,21 +911,21 @@ BShelf::ReplicantAt(int32 index, BView **_view, uint32 *_uniqueID, int32 BShelf::IndexOf(const BView *replicant_view) const { - return _rep_data_::index_of(&fReplicants, replicant_view, false); + return replicant_data::index_of(&fReplicants, replicant_view, false); } int32 BShelf::IndexOf(const BMessage *archive) const { - return _rep_data_::index_of(&fReplicants, archive); + return replicant_data::index_of(&fReplicants, archive); } int32 BShelf::IndexOf(uint32 id) const { - return _rep_data_::index_of(&fReplicants, id); + return replicant_data::index_of(&fReplicants, id); } @@ -949,14 +952,13 @@ BShelf::AdjustReplicantBy(BRect, BMessage*) const void BShelf::ReplicantDeleted(int32 index, const BMessage *archive, - const BView *replicant) + const BView *replicant) { } void -_ReservedShelf1__6BShelfFv(BShelf *const, int32, const BMessage*, - const BView*) +_ReservedShelf1__6BShelfFv(BShelf *const, int32, const BMessage*, const BView*) { } @@ -1019,7 +1021,7 @@ BShelf::_InitData(BEntry *entry, BDataIO *stream, BView *view, else fStream = stream; - fFilter = new _TContainerViewFilter_(this, fContainerView); + fFilter = new ShelfContainerViewFilter(this, fContainerView); fContainerView->AddFilter(fFilter); fContainerView->_SetShelf(this); @@ -1050,7 +1052,7 @@ BShelf::_InitData(BEntry *entry, BDataIO *stream, BView *view, status_t -BShelf::_DeleteReplicant(_rep_data_* item) +BShelf::_DeleteReplicant(replicant_data* item) { bool loadedImage = item->fMessage->FindBool(""); @@ -1064,7 +1066,7 @@ BShelf::_DeleteReplicant(_rep_data_* item) if (item->fDragger) item->fDragger->RemoveSelf(); - int32 index = _rep_data_::index_of(&fReplicants, item->fMessage); + int32 index = replicant_data::index_of(&fReplicants, item->fMessage); // TODO: Test if it's ok here ReplicantDeleted(index, item->fMessage, view); @@ -1114,11 +1116,11 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) if (data->FindString("class", &_class) == B_OK && data->FindString("add_on", &add_on) == B_OK) { int32 i = 0; - _rep_data_ *item; + replicant_data *item; const char *rep_class = NULL; const char *rep_add_on = NULL; - while ((item = (_rep_data_*)fReplicants.ItemAt(i++)) != NULL) { + while ((item = (replicant_data*)fReplicants.ItemAt(i++)) != NULL) { if (item->fMessage->FindString("class", &rep_class) == B_OK && item->fMessage->FindString("add_on", &rep_add_on) == B_OK && !strcmp(_class, rep_class) && add_on && rep_add_on @@ -1158,14 +1160,14 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) dragger = dynamic_cast(instantiate_object(&widget, &draggerImage)); if (dragger != NULL) { // Replicant is either a sibling or unknown - dragger->SetViewToDrag(replicant); + dragger->_SetViewToDrag(replicant); relation = BDragger::TARGET_IS_SIBLING; } } else { // Replicant is child of the dragger if ((dragger = dynamic_cast(view)) != NULL) { replicant = dragger->ChildAt(0); - dragger->SetViewToDrag(replicant); + dragger->_SetViewToDrag(replicant); relation = BDragger::TARGET_IS_CHILD; } else { // Replicant is parent of the dragger @@ -1173,14 +1175,14 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) dragger = dynamic_cast(replicant->FindView("_dragger_")); if (dragger) - dragger->SetViewToDrag(replicant); + dragger->_SetViewToDrag(replicant); relation = BDragger::TARGET_IS_PARENT; } } if (dragger != NULL) - dragger->SetShelf(this); + dragger->_SetShelf(this); BRect frame; if (relation != BDragger::TARGET_IS_CHILD) { @@ -1211,7 +1213,7 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) if (relation == BDragger::TARGET_IS_SIBLING || relation == BDragger::TARGET_IS_CHILD) fContainerView->AddChild(dragger); - replicant->AddFilter(new _TReplicantViewFilter_(this, replicant)); + replicant->AddFilter(new ReplicantViewFilter(this, replicant)); } else if (fDisplayZombies && fAllowZombies) { // TODO: the zombies must be adjusted and moved as well! BRect frame; @@ -1230,12 +1232,12 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) frame.OffsetTo(B_ORIGIN); dragger = new BDragger(frame, zombie); - dragger->SetShelf(this); - dragger->SetZombied(true); + dragger->_SetShelf(this); + dragger->_SetZombied(true); zombie->AddChild(dragger); zombie->SetArchive(data); - zombie->AddFilter(new _TReplicantViewFilter_(this, zombie)); + zombie->AddFilter(new ReplicantViewFilter(this, zombie)); fContainerView->AddChild(zombie); } @@ -1244,7 +1246,7 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) data->RemoveName("_drop_point_"); data->RemoveName("_drop_offset_"); - _rep_data_ *item = new _rep_data_(data, replicant, dragger, relation, + replicant_data *item = new replicant_data(data, replicant, dragger, relation, uniqueID, image); item->fError = B_OK;