xref: /haiku/headers/os/interface/Shelf.h (revision f23596149e0d173463f70629581aa10cc305d32e)
1 /*
2  * Copyright 2001-2006, Haiku Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _SHELF_H
6 #define _SHELF_H
7 
8 
9 #include <Handler.h>
10 #include <List.h>
11 
12 class BDataIO;
13 class BView;
14 class BEntry;
15 struct entry_ref;
16 
17 namespace BPrivate {
18 	class replicant_data;
19 	class ShelfContainerViewFilter;
20 };
21 
22 
23 class BShelf : public BHandler {
24 	public:
25 		BShelf(BView* view, bool allowDrags = true, const char* shelfType = NULL);
26 		BShelf(const entry_ref* ref, BView* view, bool allowDrags = true,
27 				const char* shelfType = NULL);
28 		BShelf(BDataIO* stream, BView* view, bool allowDrags = true,
29 				const char* shelfType = NULL);
30 		BShelf(BMessage *data);
31 		virtual	~BShelf();
32 
33 		virtual	status_t	Archive(BMessage* data, bool deep = true) const;
34 		static BArchivable*	Instantiate(BMessage* archive);
35 
36 		virtual	void		MessageReceived(BMessage *msg);
37 		status_t			Save();
38 		virtual	void		SetDirty(bool state);
39 		bool				IsDirty() const;
40 
41 		virtual BHandler*	ResolveSpecifier(BMessage *msg,
42 								int32 index, BMessage *specifier,
43 								int32 form, const char *property);
44 		virtual status_t	GetSupportedSuites(BMessage* data);
45 
46 		virtual status_t	Perform(perform_code d, void *arg);
47 		bool				AllowsDragging() const;
48 		void				SetAllowsDragging(bool state);
49 		bool				AllowsZombies() const;
50 		void				SetAllowsZombies(bool state);
51 		bool				DisplaysZombies() const;
52 		void				SetDisplaysZombies(bool state);
53 		bool				IsTypeEnforced() const;
54 		void				SetTypeEnforced(bool state);
55 
56 		status_t			SetSaveLocation(BDataIO *data_io);
57 		status_t			SetSaveLocation(const entry_ref *ref);
58 		BDataIO*			SaveLocation(entry_ref *ref) const;
59 
60 		status_t			AddReplicant(BMessage *data, BPoint location);
61 		status_t			DeleteReplicant(BView *replicant);
62 		status_t			DeleteReplicant(BMessage *data);
63 		status_t			DeleteReplicant(int32 index);
64 		int32				CountReplicants() const;
65 		BMessage*			ReplicantAt(int32 index,
66 								BView **view = NULL,
67 								uint32 *uid = NULL,
68 								status_t *perr = NULL) const;
69 		int32				IndexOf(const BView *replicantView) const;
70 		int32				IndexOf(const BMessage *archive) const;
71 		int32				IndexOf(uint32 id) const;
72 
73 	protected:
74 		virtual bool		CanAcceptReplicantMessage(BMessage*) const;
75 		virtual bool		CanAcceptReplicantView(BRect, BView*, BMessage*) const;
76 		virtual BPoint		AdjustReplicantBy(BRect, BMessage*) const;
77 
78 		virtual	void		ReplicantDeleted(int32 index, const BMessage *archive,
79 								const BView *replicant);
80 
81 	private:
82 		friend class BPrivate::ShelfContainerViewFilter;
83 
84 		virtual	void		_ReservedShelf2();
85 		virtual	void		_ReservedShelf3();
86 		virtual	void		_ReservedShelf4();
87 		virtual	void		_ReservedShelf5();
88 		virtual	void		_ReservedShelf6();
89 		virtual	void		_ReservedShelf7();
90 		virtual	void		_ReservedShelf8();
91 
92 							BShelf(const BShelf& other);
93 		BShelf&				operator=(const BShelf& other);
94 
95 		status_t			_Archive(BMessage* data) const;
96 		void				_InitData(BEntry* entry, BDataIO* stream,
97 								BView* view, bool allowDrags);
98 		status_t			_DeleteReplicant(BPrivate::replicant_data* replicant);
99 		status_t			_AddReplicant(BMessage* data,
100 								BPoint* location, uint32 uniqueID);
101 		status_t			_GetProperty(BMessage* message, BMessage* reply);
102 
103 	private:
104 		BView*				fContainerView;
105 		BDataIO*			fStream;
106 		BEntry*				fEntry;
107 		BList				fReplicants;
108 		BPrivate::ShelfContainerViewFilter* fFilter;
109 		uint32				fGenCount;
110 		bool				fAllowDragging;
111 		bool				fDirty;
112 		bool				fDisplayZombies;
113 		bool				fAllowZombies;
114 		bool				fTypeEnforced;
115 
116 		uint32				_reserved[8];
117 };
118 
119 #endif	/* _SHELF_H */
120