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