1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8 Permission is hereby granted, free of charge, to any person obtaining a copy of 9 this software and associated documentation files (the "Software"), to deal in 10 the Software without restriction, including without limitation the rights to 11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 of the Software, and to permit persons to whom the Software is furnished to do 13 so, subject to the following conditions: 14 15 The above copyright notice and this permission notice applies to all licensees 16 and shall be included in all copies or substantial portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25 Except as contained in this notice, the name of Be Incorporated shall not be 26 used in advertising or otherwise to promote the sale, use or other dealings in 27 this Software without prior written authorization from Be Incorporated. 28 29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks 30 of Be Incorporated in the United States and other countries. Other brand product 31 names are registered trademarks or trademarks of their respective holders. 32 All 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 45 class BTextControl; 46 class BFilePanel; 47 class BRefFilter; 48 class BMessenger; 49 class BMenuField; 50 51 namespace BPrivate { 52 53 class BorderedView; 54 class BDirMenu; 55 class AttributeStreamNode; 56 class BFilePanelPoseView; 57 58 class TFilePanel : public BContainerWindow { 59 public: 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 105 // Returns false if RestoreState has not run or if it failed to find 106 // a default state file the last time it ran. 107 bool DefaultStateRestored() const { return fDefaultStateRestored; } 108 109 protected: 110 BPoseView* NewPoseView(Model* model, uint32); 111 virtual void Init(const BMessage* message = NULL); 112 virtual void SaveState(bool hide = true); 113 virtual void SaveState(BMessage &) const; 114 virtual void RestoreState(); 115 virtual void RestoreWindowState(AttributeStreamNode*); 116 virtual void RestoreWindowState(const BMessage&); 117 virtual void RestoreState(const BMessage&); 118 119 virtual void AddFileContextMenus(BMenu*); 120 virtual void AddWindowContextMenus(BMenu*); 121 virtual void AddDropContextMenus(BMenu*); 122 virtual void AddVolumeContextMenus(BMenu*); 123 124 virtual void SetupNavigationMenu(const entry_ref*, BMenu*); 125 virtual void OpenDirectory(); 126 virtual void OpenParent(); 127 virtual void WindowActivated(bool state); 128 129 static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*); 130 static filter_result MessageDropFilter(BMessage*, BHandler**, 131 BMessageFilter*); 132 133 int32 ShowCenteredAlert(const char* text, const char* button1, 134 const char* button2 = NULL, const char* button3 = NULL); 135 136 private: 137 bool SwitchDirToDesktopIfNeeded(entry_ref &ref); 138 bool CanOpenParent() const; 139 void SwitchDirMenuTo(const entry_ref* ref); 140 void AdjustButton(); 141 bool SelectChildInParent(const entry_ref* parent, 142 const node_ref* child); 143 void OpenSelectionCommon(BMessage*); 144 bool IsOpenButtonAlwaysEnabled() const; 145 146 bool fIsSavePanel; 147 uint32 fNodeFlavors; 148 BView* fBackView; 149 BDirMenu* fDirMenu; 150 BMenuField* fDirMenuField; 151 BTextControl* fTextControl; 152 BMessenger fTarget; 153 BFilePanel* fClientObject; 154 int32 fSelectionIterator; 155 BMessage* fMessage; 156 BString fButtonText; 157 bool fHideWhenDone; 158 bool fIsTrackingMenu; 159 bool fDefaultStateRestored; 160 161 typedef BContainerWindow _inherited; 162 }; 163 164 165 class BFilePanelPoseView : public BPoseView { 166 public: 167 BFilePanelPoseView(Model*); 168 169 virtual bool IsFilePanel() const; 170 virtual bool FSNotification(const BMessage*); 171 172 void SetIsDesktop(bool); 173 174 protected: 175 // don't do any volume watching and memtamime watching in file panels 176 // for now 177 virtual void StartWatching(); 178 virtual void StopWatching(); 179 180 virtual void RestoreState(AttributeStreamNode*); 181 virtual void RestoreState(const BMessage &); 182 virtual void SavePoseLocations(BRect* = NULL); 183 184 virtual EntryListBase* InitDirentIterator(const entry_ref*); 185 virtual void AddPosesCompleted(); 186 virtual bool IsDesktopView() const; 187 188 void ShowVolumes(bool visible, bool showShared); 189 190 void AdaptToVolumeChange(BMessage*); 191 void AdaptToDesktopIntegrationChange(BMessage*); 192 193 private: 194 bool fIsDesktop; 195 // This flags makes the distinction between the Desktop as 196 // the root of the world and "/boot/home/Desktop" to which 197 // we might have navigated from the home dir. 198 199 typedef BPoseView _inherited; 200 }; 201 202 203 // inlines follow 204 205 inline bool 206 BFilePanelPoseView::IsFilePanel() const 207 { 208 return true; 209 } 210 211 212 inline bool 213 TFilePanel::IsSavePanel() const 214 { 215 return fIsSavePanel; 216 } 217 218 219 inline const BMessenger* 220 TFilePanel::Target() const 221 { 222 return &fTarget; 223 } 224 225 226 inline void 227 TFilePanel::Refresh() 228 { 229 fPoseView->Refresh(); 230 } 231 232 233 inline bool 234 TFilePanel::HidesWhenDone(void) 235 { 236 return fHideWhenDone; 237 } 238 239 240 inline void 241 TFilePanel::SetHideWhenDone(bool on) 242 { 243 fHideWhenDone = on; 244 } 245 246 247 inline bool 248 TFilePanel::TrackingMenu() const 249 { 250 return fIsTrackingMenu; 251 } 252 253 } // namespace BPrivate 254 255 using namespace BPrivate; 256 257 258 #endif // _FILE_PANEL_PRIV_H 259