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