1 /* 2 * Copyright 2006, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _DRAGGER_H 6 #define _DRAGGER_H 7 8 9 #include <Locker.h> 10 #include <List.h> 11 #include <View.h> 12 13 class BBitmap; 14 class BMessage; 15 class BShelf; 16 17 namespace BPrivate { 18 class replicant_data; 19 class ShelfContainerViewFilter; 20 }; 21 22 23 class BDragger : public BView { 24 public: 25 BDragger(BRect bounds, BView* target, 26 uint32 resizingMask = B_FOLLOW_NONE, 27 uint32 flags = B_WILL_DRAW); 28 BDragger(BMessage* data); 29 virtual ~BDragger(); 30 31 static BArchivable* Instantiate(BMessage* data); 32 virtual status_t Archive(BMessage* data, bool deep = true) const; 33 34 virtual void AttachedToWindow(); 35 virtual void DetachedFromWindow(); 36 37 virtual void Draw(BRect updateRect); 38 virtual void MouseDown(BPoint where); 39 virtual void MouseUp(BPoint where); 40 virtual void MouseMoved(BPoint where, uint32 transit, 41 const BMessage* dragMessage); 42 virtual void MessageReceived(BMessage* message); 43 virtual void FrameMoved(BPoint newPosition); 44 virtual void FrameResized(float newWidth, float newHeight); 45 46 static status_t ShowAllDraggers(); 47 static status_t HideAllDraggers(); 48 static bool AreDraggersDrawn(); 49 50 virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, 51 BMessage* specifier, int32 form, 52 const char* property); 53 virtual status_t GetSupportedSuites(BMessage* data); 54 virtual status_t Perform(perform_code d, void* arg); 55 56 virtual void ResizeToPreferred(); 57 virtual void GetPreferredSize(float* _width, float* _height); 58 virtual void MakeFocus(bool focus = true); 59 virtual void AllAttached(); 60 virtual void AllDetached(); 61 62 status_t SetPopUp(BPopUpMenu* contextMenu); 63 BPopUpMenu* PopUp() const; 64 65 bool InShelf() const; 66 BView* Target() const; 67 68 virtual BBitmap* DragBitmap(BPoint* offset, drawing_mode *mode); 69 70 protected: 71 bool IsVisibilityChanging() const; 72 73 private: 74 friend class BPrivate::ShelfContainerViewFilter; 75 friend class BPrivate::replicant_data; 76 friend class BShelf; 77 78 virtual void _ReservedDragger2(); 79 virtual void _ReservedDragger3(); 80 virtual void _ReservedDragger4(); 81 82 BDragger& operator=(const BDragger& other); 83 84 void _AddToList(); 85 void _RemoveFromList(); 86 status_t _DetermineRelationship(); 87 status_t _SetViewToDrag(BView* target); 88 void _SetShelf(BShelf* shelf); 89 void _SetZombied(bool state); 90 void _BuildDefaultPopUp(); 91 void _ShowPopUp(BView* target, BPoint where); 92 93 static bool sVisible; 94 static bool sVisibleInitialized; 95 static BLocker sLock; 96 static BList sList; 97 98 enum relation { 99 TARGET_UNKNOWN, 100 TARGET_IS_CHILD, 101 TARGET_IS_PARENT, 102 TARGET_IS_SIBLING 103 }; 104 105 BView* fTarget; 106 relation fRelation; 107 BShelf* fShelf; 108 bool fTransition; 109 bool fIsZombie; 110 char fErrCount; 111 BBitmap * fBitmap; 112 BPopUpMenu* fPopUp; 113 uint32 _reserved[3]; 114 }; 115 116 #endif /* _DRAGGER_H */ 117