xref: /haiku/headers/os/interface/Shelf.h (revision 7120e97489acbf17d86d3f33e3b2e68974fd4b23)
1 /*******************************************************************************
2 /
3 /	File:			Shelf.h
4 /
5 /   Description:    BShelf stores replicant views that are dropped onto it
6 /
7 /	Copyright 1996-98, Be Incorporated, All Rights Reserved
8 /
9 *******************************************************************************/
10 
11 #ifndef _SHELF_H
12 #define _SHELF_H
13 
14 #include <BeBuild.h>
15 #include <Handler.h>
16 #include <List.h>
17 
18 class BDataIO;
19 class BView;
20 
21 class BEntry;
22 extern "C" void  _ReservedShelf1__6BShelfFv(BShelf *const, int32,
23 	const BMessage*, const BView*);
24 
25 /*----------------------------------------------------------------*/
26 /*----- BShelf class ---------------------------------------------*/
27 
28 class BShelf : public BHandler {
29 public:
30 						BShelf(BView *view,
31 								bool allow_drags = true,
32 								const char *shelf_type = NULL);
33 						BShelf(const entry_ref *ref,
34 								BView *view,
35 								bool allow_drags = true,
36 								const char *shelf_type = NULL);
37 						BShelf(BDataIO *stream,
38 								BView *view,
39 								bool allow_drags = true,
40 								const char *shelf_type = NULL);
41 						BShelf(BMessage *data);
42 virtual					~BShelf();
43 
44 virtual	status_t		Archive(BMessage *data, bool deep = true) const;
45 static	BArchivable		*Instantiate(BMessage *data);
46 
47 virtual	void			MessageReceived(BMessage *msg);
48 		status_t		Save();
49 virtual	void			SetDirty(bool state);
50 		bool			IsDirty() const;
51 
52 virtual BHandler		*ResolveSpecifier(BMessage *msg,
53 										int32 index,
54 										BMessage *specifier,
55 										int32 form,
56 										const char *property);
57 virtual status_t		GetSupportedSuites(BMessage *data);
58 
59 virtual status_t		Perform(perform_code d, void *arg);
60 		bool			AllowsDragging() const;
61 		void			SetAllowsDragging(bool state);
62 		bool			AllowsZombies() const;
63 		void			SetAllowsZombies(bool state);
64 		bool			DisplaysZombies() const;
65 		void			SetDisplaysZombies(bool state);
66 		bool			IsTypeEnforced() const;
67 		void			SetTypeEnforced(bool state);
68 
69 		status_t		SetSaveLocation(BDataIO *data_io);
70 		status_t		SetSaveLocation(const entry_ref *ref);
71 		BDataIO			*SaveLocation(entry_ref *ref) const;
72 
73 		status_t		AddReplicant(BMessage *data, BPoint location);
74 		status_t		DeleteReplicant(BView *replicant);
75 		status_t		DeleteReplicant(BMessage *data);
76 		status_t		DeleteReplicant(int32 index);
77 		int32			CountReplicants() const;
78 		BMessage		*ReplicantAt(int32 index,
79 									BView **view = NULL,
80 									uint32 *uid = NULL,
81 									status_t *perr = NULL) const;
82 		int32			IndexOf(const BView *replicant_view) const;
83 		int32			IndexOf(const BMessage *archive) const;
84 		int32			IndexOf(uint32 id) const;
85 
86 protected:
87 virtual bool 			CanAcceptReplicantMessage(BMessage*) const;
88 virtual bool 			CanAcceptReplicantView(BRect, BView*, BMessage*) const;
89 virtual BPoint 			AdjustReplicantBy(BRect, BMessage*) const;
90 
91 virtual	void			ReplicantDeleted(int32 index,
92 										const BMessage *archive,
93 										const BView *replicant);
94 
95 /*----- Private or reserved -----------------------------------------*/
96 private:
97 friend class _TContainerViewFilter_;
98 friend void  _ReservedShelf1__6BShelfFv(BShelf *const, int32,
99 				const BMessage*, const BView*);
100 
101 virtual	void			_ReservedShelf2();
102 virtual	void			_ReservedShelf3();
103 virtual	void			_ReservedShelf4();
104 virtual	void			_ReservedShelf5();
105 
106 #if !_PR3_COMPATIBLE_
107 virtual	void			_ReservedShelf6();
108 virtual	void			_ReservedShelf7();
109 virtual	void			_ReservedShelf8();
110 #endif
111 						BShelf(const BShelf&);
112 		BShelf			&operator=(const BShelf &);
113 
114 		status_t		_Archive(BMessage *data) const;
115 		void			InitData(BEntry *entry,
116 								BDataIO *stream,
117 								BView *view,
118 								bool allow_drags);
119 		status_t		RealAddReplicant(BMessage *data,
120 										BPoint *loc,
121 										uint32 uid);
122 		status_t		GetProperty(BMessage *msg, BMessage *reply);
123 
124 		BView			*fContainerView;
125 		BDataIO			*fStream;
126 		BEntry			*fEntry;
127 		BList			fReplicants;
128 		_TContainerViewFilter_	*fFilter;
129 		uint32			fGenCount;
130 		bool			fAllowDragging;
131 		bool			fDirty;
132 		bool			fDisplayZombies;
133 		bool			fAllowZombies;
134 		bool			fTypeEnforced;
135 
136 		uint32			_reserved[3];	/* was 5 */
137 #if !_PR3_COMPATIBLE_
138 		uint32			_more_reserved[5];
139 #endif
140 };
141 
142 /*-------------------------------------------------------------*/
143 /*-------------------------------------------------------------*/
144 
145 #endif /* _SHELF_H */
146