1/*
2Open Tracker License
3
4Terms and Conditions
5
6Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy of
9this software and associated documentation files (the "Software"), to deal in
10the Software without restriction, including without limitation the rights to
11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12of the Software, and to permit persons to whom the Software is furnished to do
13so, subject to the following conditions:
14
15The above copyright notice and this permission notice applies to all licensees
16and shall be included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25Except as contained in this notice, the name of Be Incorporated shall not be
26used in advertising or otherwise to promote the sale, use or other dealings in
27this Software without prior written authorization from Be Incorporated.
28
29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30of Be Incorporated in the United States and other countries. Other brand product
31names are registered trademarks or trademarks of their respective holders.
32All rights reserved.
33*/
34#ifndef _FAVORITES_MENU_H
35#define _FAVORITES_MENU_H
36
37
38#include <vector>
39
40#include <ObjectList.h>
41
42#include "NavMenu.h"
43
44
45class BRefFilter;
46
47namespace BPrivate {
48
49class EntryListBase;
50
51#define kGoDirectory "Tracker/Go"
52
53
54class FavoritesMenu : public BSlowMenu {
55	// FavoritesMenu is used in the FilePanel -
56	// displays recent files, recent folders and favorites items
57	public:
58		FavoritesMenu(const char* title, BMessage* openFolderMessage,
59			BMessage* openFileMessage, const BMessenger &,
60			bool isSavePanel, BRefFilter* filter = NULL);
61		virtual ~FavoritesMenu();
62
63		void SetRefFilter(BRefFilter* filter);
64
65	private:
66		// override the necessary SlowMenu hooks
67		virtual bool StartBuildingItemList();
68		virtual bool AddNextItem();
69		virtual void DoneBuildingItemList();
70		virtual void ClearMenuBuildingState();
71
72		bool ShouldShowModel(const Model* model);
73
74		BMessage* fOpenFolderMessage;
75		BMessage* fOpenFileMessage;
76		BMessenger fTarget;
77
78		enum State {
79			kStart,
80			kAddingFavorites,
81			kAddingFiles,
82			kAddingFolders,
83			kDone
84		};
85
86		State fState;
87
88		int32 fIndex;
89		int32 fSectionItemCount;
90		bool fAddedSeparatorForSection;
91			// keeps track whether a separator will be needed before the
92			// next inserted item
93		BMessage fItems;
94
95		EntryListBase* fContainer;
96		BObjectList<BMenuItem>* fItemList;
97		int32 fInitialItemCount;
98		std::vector<entry_ref> fUniqueRefCheck;
99		bool fIsSavePanel;
100		BRefFilter* fRefFilter;
101
102		typedef BSlowMenu _inherited;
103};
104
105
106enum recent_type {
107	kRecentDocuments = 0,
108	kRecentApplications = 1,
109	kRecentFolders = 2
110};
111
112
113class RecentsMenu : public BNavMenu {
114	public:
115		RecentsMenu(const char* name, int32 which, uint32 what,
116			BHandler* target);
117
118		void			DetachedFromWindow();
119
120		int32			RecentsCount();
121
122	private:
123		virtual	bool	StartBuildingItemList();
124		virtual	bool	AddNextItem();
125				bool	AddRecents(int32 count);
126		virtual	void	DoneBuildingItemList();
127		virtual	void	ClearMenuBuildingState();
128
129	private:
130		int32			fWhich;
131		int32			fRecentsCount;
132
133		int32 			fItemIndex;
134		BMessage		fRecentList;
135};
136
137} // namespace BPrivate
138
139using namespace BPrivate;
140
141
142#endif	// _FAVORITES_MENU_H
143