xref: /haiku/headers/os/be_apps/Tracker/RecentItems.h (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
1 /*
2 Open Tracker License
3 
4 Terms and Conditions
5 
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
28 
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
32 All rights reserved.
33 */
34 
35 #ifndef __RECENT_ITEMS_LIST__
36 #define __RECENT_ITEMS_LIST__
37 
38 #include <Entry.h>
39 #include <Message.h>
40 #include <String.h>
41 
42 /* BRecentItemsList classes allow creating an entire menu with
43  * recent files, folders, apps. If the user wishes to add items to
44  * their own menu, they can instead use the GetNextMenuItem call to
45  * get one menu at a time to add it to their app.
46  */
47 
48 class BMenuItem;
49 class BMenu;
50 
51 class BRecentItemsList {
52 public:
53 	BRecentItemsList(int32 maxItems, bool navMenuFolders);
54 		/* if <navMenuFolders> passed, folder items get NavMenu-style
55 		 * subdirectories attached to them
56 		 */
57 
58 	virtual ~BRecentItemsList() {}
59 
60 	virtual void Rewind();
61 		/* resets the iteration */
62 
63 	virtual BMenuItem *GetNextMenuItem(const BMessage *fileOpenMessage = NULL,
64 		const BMessage *containerOpenMessage = NULL,
65 		BHandler *target = NULL, entry_ref *currentItemRef = NULL);
66 		/* if <fileOpenMessage> specified, the item for a file gets a copy with
67 		 * the item ref attached as "refs", otherwise a default B_REFS_RECEIVED
68 		 * message message gets attached
69 		 * if <containerOpenMessage> specified, the item for a folder, volume or query
70 		 * gets a copy with the item ref attached as "refs", otherwise a default
71 		 * B_REFS_RECEIVED message message gets attached
72 		 * if <currentItemRef> gets passed, the caller gets to look at the
73 		 * entry_ref corresponding to the item
74 		 */
75 
76 	virtual status_t GetNextRef(entry_ref *);
77 
78 protected:
79 	BMessage fItems;
80 	int32 fIndex;
81 	int32 fMaxItems;
82 	bool fNavMenuFolders;
83 
84 private:
85 
86 	virtual	void _r1();
87 	virtual	void _r2();
88 	virtual	void _r3();
89 	virtual	void _r4();
90 	virtual	void _r5();
91 	virtual	void _r6();
92 	virtual	void _r7();
93 	virtual	void _r8();
94 	virtual	void _r9();
95 	virtual	void _r10();
96 
97 	uint32 _reserved[20];
98 };
99 
100 class BRecentFilesList : public BRecentItemsList {
101 public:
102 
103 	/* use one of the two constructors to set up next item iteration */
104 	BRecentFilesList(int32 maxItems = 10, bool navMenuFolders = false,
105 		const char *ofType = NULL, const char *openedByAppSig = NULL);
106 	BRecentFilesList(int32 maxItems, bool navMenuFolders, const char *ofTypeList[],
107 		int32 ofTypeListCount, const char *openedByAppSig = NULL);
108 	virtual ~BRecentFilesList();
109 
110 	/* use one of the two NewFileListMenu calls to get an entire menu */
111 	static BMenu *NewFileListMenu(const char *title,
112 		BMessage *openFileMessage = NULL, BMessage *openFolderMessage = NULL,
113 		BHandler *target = NULL,
114 		int32 maxItems = 10, bool navMenuFolders = false,
115 		const char *ofType = NULL, const char *openedByAppSig = NULL);
116 
117 	static BMenu *NewFileListMenu(const char *title,
118 		BMessage *openFileMessage, BMessage *openFolderMessage,
119 		BHandler *target,
120 		int32 maxItems, bool navMenuFolders,
121 		const char *ofTypeList[], int32 ofTypeListCount,
122 		const char *openedByAppSig);
123 
124 	virtual status_t GetNextRef(entry_ref *);
125 
126 protected:
127 
128 	BString fType;
129 	char **fTypes;
130 	int32 fTypeCount;
131 	BString fAppSig;
132 
133 private:
134 	virtual	void _r11();
135 	virtual	void _r12();
136 	virtual	void _r13();
137 	virtual	void _r14();
138 	virtual	void _r15();
139 	virtual	void _r16();
140 	virtual	void _r17();
141 	virtual	void _r18();
142 	virtual	void _r19();
143 	virtual	void _r110();
144 
145 	uint32 _reserved[20];
146 };
147 
148 class BRecentFoldersList : public BRecentItemsList {
149 public:
150 	/* use the constructor to set up next item iteration */
151 	BRecentFoldersList(int32 maxItems, bool navMenuFolders = false,
152 		const char *openedByAppSig = NULL);
153 
154 	/* use NewFolderListMenu to get an entire menu */
155 	static BMenu *NewFolderListMenu(const char *title,
156 		BMessage *openMessage = NULL, BHandler *target = NULL,
157 		int32 maxItems = 10, bool navMenuFolders = false,
158 		const char *openedByAppSig = NULL);
159 
160 	virtual status_t GetNextRef(entry_ref *);
161 
162 protected:
163 	BString fAppSig;
164 
165 private:
166 	virtual	void _r21();
167 	virtual	void _r22();
168 	virtual	void _r23();
169 	virtual	void _r24();
170 	virtual	void _r25();
171 	virtual	void _r26();
172 	virtual	void _r27();
173 	virtual	void _r28();
174 	virtual	void _r29();
175 	virtual	void _r210();
176 
177 	uint32 _reserved[20];
178 };
179 
180 class BRecentAppsList : public BRecentItemsList {
181 public:
182 	/* use the constructor to set up next item iteration */
183 	BRecentAppsList(int32 maxItems);
184 
185 	/* use NewFolderListMenu to get an entire menu */
186 	static BMenu *NewAppListMenu(const char *title,
187 		BMessage *openMessage = NULL, BHandler *target = NULL,
188 		int32 maxItems = 10);
189 
190 	virtual status_t GetNextRef(entry_ref *);
191 
192 private:
193 	virtual	void _r31();
194 	virtual	void _r32();
195 	virtual	void _r33();
196 	virtual	void _r34();
197 	virtual	void _r35();
198 	virtual	void _r36();
199 	virtual	void _r37();
200 	virtual	void _r38();
201 	virtual	void _r39();
202 	virtual	void _r310();
203 
204 	uint32 _reserved[20];
205 };
206 
207 #endif
208