xref: /haiku/headers/os/interface/Dragger.h (revision b028e77473189065f2baefc6f5e10d451cf591e2)
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 		class Private;
71 
72 	protected:
73 				bool		IsVisibilityChanging() const;
74 
75 	private:
76 		friend class BPrivate::ShelfContainerViewFilter;
77 		friend class BPrivate::replicant_data;
78 		friend class Private;
79 		friend class BShelf;
80 
81 		virtual	void		_ReservedDragger2();
82 		virtual	void		_ReservedDragger3();
83 		virtual	void		_ReservedDragger4();
84 
85 		static	void		_UpdateShowAllDraggers(bool visible);
86 
87 				BDragger&	operator=(const BDragger& other);
88 
89 				void		_AddToList();
90 				void		_RemoveFromList();
91 				status_t	_DetermineRelationship();
92 				status_t	_SetViewToDrag(BView* target);
93 				void		_SetShelf(BShelf* shelf);
94 				void		_SetZombied(bool state);
95 				void		_BuildDefaultPopUp();
96 				void		_ShowPopUp(BView* target, BPoint where);
97 
98 		static	bool		sVisible;
99 		static	bool		sVisibleInitialized;
100 		static	BLocker		sLock;
101 		static	BList		sList;
102 
103 				enum relation {
104 					TARGET_UNKNOWN,
105 					TARGET_IS_CHILD,
106 					TARGET_IS_PARENT,
107 					TARGET_IS_SIBLING
108 				};
109 
110 				BView*		fTarget;
111 				relation	fRelation;
112 				BShelf*		fShelf;
113 				bool		fTransition;
114 				bool		fIsZombie;
115 				char		fErrCount;
116 				BBitmap	*	fBitmap;
117 				BPopUpMenu*	fPopUp;
118 				uint32		_reserved[3];
119 };
120 
121 #endif /* _DRAGGER_H */
122