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 struct stat_beos; 18 19 20 class 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 30 enum file_panel_mode { 31 B_OPEN_PANEL, 32 B_SAVE_PANEL 33 }; 34 35 enum file_panel_button { 36 B_CANCEL_BUTTON, 37 B_DEFAULT_BUTTON 38 }; 39 40 41 class 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 71 void SetPanelDirectory(const BEntry* newDirectory); 72 void SetPanelDirectory(const BDirectory* newDirectory); 73 void SetPanelDirectory(const entry_ref* newDirectory); 74 void SetPanelDirectory(const char* newDirectory); 75 void GetPanelDirectory(entry_ref* ref) const; 76 77 void SetHideWhenDone(bool hideWhenDone); 78 bool HidesWhenDone() const; 79 80 void Refresh(); 81 void Rewind(); 82 status_t GetNextSelectedRef(entry_ref* ref); 83 84 private: 85 virtual void _ReservedFilePanel1(); 86 virtual void _ReservedFilePanel2(); 87 virtual void _ReservedFilePanel3(); 88 virtual void _ReservedFilePanel4(); 89 virtual void _ReservedFilePanel5(); 90 virtual void _ReservedFilePanel6(); 91 virtual void _ReservedFilePanel7(); 92 virtual void _ReservedFilePanel8(); 93 94 BWindow* fWindow; 95 uint32 _reserved[10]; 96 }; 97 98 #endif /* _FILE_PANEL_H */ 99