1/*
2 * Copyright 2005, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef	_FILE_PANEL_H
6#define _FILE_PANEL_H
7
8
9#include <Directory.h>
10#include <Entry.h>
11#include <Node.h>
12
13class BMessage;
14class BMessenger;
15class BWindow;
16struct stat;
17struct stat_beos;
18
19
20class BRefFilter {
21	public:
22#if __GNUC__ > 2
23		virtual		 ~BRefFilter() {};
24#endif
25		virtual	bool Filter(const entry_ref* ref, BNode* node,
26						struct stat_beos* stat, const char* mimeType) = 0;
27};
28
29
30enum file_panel_mode {
31	B_OPEN_PANEL,
32	B_SAVE_PANEL
33};
34
35enum file_panel_button {
36	B_CANCEL_BUTTON,
37	B_DEFAULT_BUTTON
38};
39
40
41class BFilePanel {
42	public:
43		BFilePanel(file_panel_mode mode = B_OPEN_PANEL,
44			BMessenger* target = NULL, const entry_ref* directory = NULL,
45			uint32 nodeFlavors = 0, bool allowMultipleSelection = true,
46			BMessage* message = NULL, BRefFilter* refFilter = NULL,
47			bool modal = false, bool hideWhenDone = true);
48		virtual	~BFilePanel();
49
50		void			Show();
51		void			Hide();
52		bool			IsShowing() const;
53
54		virtual	void	WasHidden();
55		virtual	void	SelectionChanged();
56		virtual	void	SendMessage(const BMessenger* target, BMessage* message);
57
58		BWindow*		Window() const;
59		BMessenger		Messenger() const;
60		BRefFilter*		RefFilter() const;
61
62		file_panel_mode	PanelMode() const;
63
64		void			SetTarget(BMessenger target);
65		void			SetMessage(BMessage* message);
66
67		void			SetRefFilter(BRefFilter* filter);
68		void			SetSaveText(const char* text);
69		void			SetButtonLabel(file_panel_button button, const char* label);
70		void			SetNodeFlavors(uint32 flavors);
71
72		void			SetPanelDirectory(const BEntry* newDirectory);
73		void			SetPanelDirectory(const BDirectory* newDirectory);
74		void			SetPanelDirectory(const entry_ref* newDirectory);
75		void			SetPanelDirectory(const char* newDirectory);
76		void			GetPanelDirectory(entry_ref* ref) const;
77
78		void			SetHideWhenDone(bool hideWhenDone);
79		bool			HidesWhenDone() const;
80
81		void			Refresh();
82		void			Rewind();
83		status_t		GetNextSelectedRef(entry_ref* ref);
84
85	private:
86		virtual	void	_ReservedFilePanel1();
87		virtual	void	_ReservedFilePanel2();
88		virtual	void	_ReservedFilePanel3();
89		virtual	void	_ReservedFilePanel4();
90		virtual	void	_ReservedFilePanel5();
91		virtual	void	_ReservedFilePanel6();
92		virtual	void	_ReservedFilePanel7();
93		virtual	void	_ReservedFilePanel8();
94
95		BWindow*		fWindow;
96		uint32			_reserved[10];
97};
98
99#endif	/* _FILE_PANEL_H */
100