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 _SLOW_CONTEXT_POPUP_H
35#define _SLOW_CONTEXT_POPUP_H
36
37
38#include <PopUpMenu.h>
39#include "NavMenu.h"
40
41
42namespace BPrivate {
43
44class BSlowContextMenu : public BPopUpMenu {
45public:
46				BSlowContextMenu(const char* title);
47	virtual		~BSlowContextMenu();
48
49	virtual	void AttachedToWindow();
50	virtual	void DetachedFromWindow();
51
52	void SetNavDir(const entry_ref*);
53
54	void ClearMenu();
55
56	void ForceRebuild();
57	bool NeedsToRebuild() const;
58		// will cause menu to get rebuilt next time it is shown
59
60	void SetTarget(const BMessenger &);
61	const BMessenger Target() const;
62
63	void SetTypesList(const BObjectList<BString>* list);
64	const BObjectList<BString>* TypesList() const;
65
66	static ModelMenuItem* NewModelItem(Model*, const BMessage*,
67		const BMessenger&, bool suppressFolderHierarchy = false,
68		BContainerWindow* = NULL,
69		const BObjectList<BString>* typeslist = NULL,
70		TrackingHookData* hook = NULL);
71
72	TrackingHookData* InitTrackingHook(bool (*)(BMenu*, void*),
73		const BMessenger* target, const BMessage* dragMessage);
74
75	const bool IsShowing() const;
76
77protected:
78	virtual bool AddDynamicItem(add_state state);
79	virtual bool StartBuildingItemList();
80	virtual bool AddNextItem();
81	virtual void DoneBuildingItemList();
82	virtual void ClearMenuBuildingState();
83
84	void BuildVolumeMenu();
85
86	void AddOneItem(Model*);
87	void AddRootItemsIfNeeded();
88	void AddTrashItem();
89	static void SetTrackingHookDeep(BMenu*, bool (*)(BMenu*, void*), void*);
90
91	bool fMenuBuilt;
92
93private:
94	entry_ref fNavDir;
95	BMessage fMessage;
96	BMessenger fMessenger;
97	BWindow* fParentWindow;
98
99	// menu building state
100	bool fVolsOnly;
101	BObjectList<BMenuItem>* fItemList;
102	EntryListBase* fContainer;
103	bool fIteratingDesktop;
104
105	const BObjectList<BString>* fTypesList;
106
107	TrackingHookData fTrackingHook;
108	bool fIsShowing;
109		// see note in AttachedToWindow
110};
111
112
113} // namespace BPrivate
114
115using namespace BPrivate;
116
117
118inline const BObjectList<BString>*
119BSlowContextMenu::TypesList() const
120{
121	return fTypesList;
122}
123
124
125inline const BMessenger
126BSlowContextMenu::Target() const
127{
128	return fMessenger;
129}
130
131
132inline const bool
133BSlowContextMenu::IsShowing() const
134{
135	return fIsShowing;
136}
137
138
139#endif	// _SLOW_CONTEXT_POPUP_H
140