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