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 _FILE_PANEL_PRIV_H
35#define _FILE_PANEL_PRIV_H
36
37
38#include <FilePanel.h>
39
40#include "ContainerWindow.h"
41#include "PoseView.h"
42#include "TaskLoop.h"
43
44
45class BTextControl;
46class BFilePanel;
47class BRefFilter;
48class BMessenger;
49class BMenuField;
50
51namespace BPrivate {
52
53class BorderedView;
54class BDirMenu;
55class AttributeStreamNode;
56class BFilePanelPoseView;
57
58class TFilePanel : public BContainerWindow {
59public:
60	TFilePanel(file_panel_mode = B_OPEN_PANEL,
61		BMessenger* target = NULL, const BEntry* startDirectory = NULL,
62		uint32 nodeFlavors = B_FILE_NODE | B_SYMLINK_NODE,
63		bool multipleSelection = true, BMessage* = NULL, BRefFilter* = NULL,
64		uint32 containerWindowFlags = 0,
65		window_look look = B_DOCUMENT_WINDOW_LOOK,
66		window_feel feel = B_NORMAL_WINDOW_FEEL,
67		bool hideWhenDone = true);
68
69	virtual ~TFilePanel();
70
71	BFilePanelPoseView* PoseView() const;
72
73	virtual bool QuitRequested();
74	virtual void MenusBeginning();
75	virtual void MenusEnded();
76	virtual void DispatchMessage(BMessage* message, BHandler* handler);
77	virtual void ShowContextMenu(BPoint, const entry_ref*, BView*);
78
79	void SetClientObject(BFilePanel*);
80	void SetRefFilter(BRefFilter*);
81	void SetNodeFlavors(uint32 nodeFlavors) { fNodeFlavors = nodeFlavors; }
82	void SetSaveText(const char* text);
83	void SetButtonLabel(file_panel_button, const char* text);
84	void SetTo(const entry_ref* ref);
85	virtual void SelectionChanged();
86	void HandleOpenButton();
87	void HandleSaveButton();
88	void Rewind();
89	bool IsSavePanel() const;
90	void Refresh();
91	const BMessenger* Target() const;
92	BRefFilter* Filter() const;
93
94	void SetTarget(BMessenger);
95	void SetMessage(BMessage* message);
96
97	virtual status_t GetNextEntryRef(entry_ref*);
98	virtual void MessageReceived(BMessage*);
99
100	void SetHideWhenDone(bool);
101	bool HidesWhenDone(void);
102
103	bool TrackingMenu() const;
104
105protected:
106	BPoseView* NewPoseView(Model* model, uint32);
107	virtual	void Init(const BMessage* message = NULL);
108	virtual	void SaveState(bool hide = true);
109	virtual	void SaveState(BMessage &) const;
110	virtual void RestoreState();
111	virtual void RestoreWindowState(AttributeStreamNode*);
112	virtual void RestoreWindowState(const BMessage&);
113	virtual void RestoreState(const BMessage&);
114
115	virtual void AddFileContextMenus(BMenu*);
116	virtual void AddWindowContextMenus(BMenu*);
117	virtual void AddDropContextMenus(BMenu*);
118	virtual void AddVolumeContextMenus(BMenu*);
119
120	virtual void SetupNavigationMenu(const entry_ref*, BMenu*);
121	virtual void OpenDirectory();
122	virtual void OpenParent();
123	virtual void WindowActivated(bool state);
124
125	static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*);
126	static filter_result MessageDropFilter(BMessage*, BHandler**,
127		BMessageFilter*);
128
129	int32 ShowCenteredAlert(const char* text, const char* button1,
130		const char* button2 = NULL, const char* button3 = NULL);
131
132private:
133	bool SwitchDirToDesktopIfNeeded(entry_ref &ref);
134	bool CanOpenParent() const;
135	void SwitchDirMenuTo(const entry_ref* ref);
136	void AdjustButton();
137	bool SelectChildInParent(const entry_ref* parent,
138		const node_ref* child);
139	void OpenSelectionCommon(BMessage*);
140	bool IsOpenButtonAlwaysEnabled() const;
141
142	bool fIsSavePanel;
143	uint32 fNodeFlavors;
144	BView* fBackView;
145	BDirMenu* fDirMenu;
146	BMenuField* fDirMenuField;
147	BTextControl* fTextControl;
148	BMessenger fTarget;
149	BFilePanel* fClientObject;
150	int32 fSelectionIterator;
151	BMessage* fMessage;
152	BString fButtonText;
153	bool fHideWhenDone;
154	bool fIsTrackingMenu;
155
156	typedef BContainerWindow _inherited;
157};
158
159
160class BFilePanelPoseView : public BPoseView {
161public:
162	BFilePanelPoseView(Model*);
163
164	virtual bool IsFilePanel() const;
165	virtual bool FSNotification(const BMessage*);
166
167	void SetIsDesktop(bool);
168
169protected:
170	// don't do any volume watching and memtamime watching in file panels
171	// for now
172	virtual void StartWatching();
173	virtual void StopWatching();
174
175	virtual void RestoreState(AttributeStreamNode*);
176	virtual void RestoreState(const BMessage &);
177	virtual void SavePoseLocations(BRect* = NULL);
178
179	virtual EntryListBase* InitDirentIterator(const entry_ref*);
180	virtual void AddPosesCompleted();
181	virtual bool IsDesktopView() const;
182
183	void ShowVolumes(bool visible, bool showShared);
184
185	void AdaptToVolumeChange(BMessage*);
186	void AdaptToDesktopIntegrationChange(BMessage*);
187
188private:
189	bool fIsDesktop;
190		// This flags makes the distinction between the Desktop as
191		// the root of the world and "/boot/home/Desktop" to which
192		// we might have navigated from the home dir.
193
194	typedef BPoseView _inherited;
195};
196
197
198// inlines follow
199
200inline bool
201BFilePanelPoseView::IsFilePanel() const
202{
203	return true;
204}
205
206
207inline bool
208TFilePanel::IsSavePanel() const
209{
210	return fIsSavePanel;
211}
212
213
214inline const BMessenger*
215TFilePanel::Target() const
216{
217	return &fTarget;
218}
219
220
221inline void
222TFilePanel::Refresh()
223{
224	fPoseView->Refresh();
225}
226
227
228inline bool
229TFilePanel::HidesWhenDone(void)
230{
231	return fHideWhenDone;
232}
233
234
235inline void
236TFilePanel::SetHideWhenDone(bool on)
237{
238	fHideWhenDone = on;
239}
240
241
242inline bool
243TFilePanel::TrackingMenu() const
244{
245	return fIsTrackingMenu;
246}
247
248} // namespace BPrivate
249
250using namespace BPrivate;
251
252
253#endif	// _FILE_PANEL_PRIV_H
254