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