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