xref: /haiku/headers/os/interface/Dragger.h (revision 73ad2473e7874b3702cf5b0fdf4c81b747812ed9)
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 frame, BView* target,
27 									uint32 resizingMode = 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				_InitData();
93 			void				_AddToList();
94 			void				_RemoveFromList();
95 			status_t			_DetermineRelationship();
96 			status_t			_SetViewToDrag(BView* target);
97 			void				_SetShelf(BShelf* shelf);
98 			void				_SetZombied(bool state);
99 			void				_BuildDefaultPopUp();
100 			void				_ShowPopUp(BView* target, BPoint where);
101 
102 			enum relation {
103 				TARGET_UNKNOWN,
104 				TARGET_IS_CHILD,
105 				TARGET_IS_PARENT,
106 				TARGET_IS_SIBLING
107 			};
108 
109 			BView*				fTarget;
110 			relation			fRelation;
111 			BShelf*				fShelf;
112 			bool				fTransition;
113 			bool				fIsZombie;
114 			char				fErrCount;
115 			bool				fPopUpIsCustom;
116 			BBitmap*			fBitmap;
117 			BPopUpMenu*			fPopUp;
118 			uint32				_reserved[3];
119 };
120 
121 #endif /* _DRAGGER_H */
122