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 35 // NavMenu is a hierarchical menu of volumes, folders, files and queries 36 // displays icons, uses the SlowMenu API for full interruptability 37 38 #ifndef NAV_MENU_H 39 #define NAV_MENU_H 40 41 42 #include <Messenger.h> 43 #include <StorageDefs.h> 44 #include <Entry.h> 45 46 #include "SlowMenu.h" 47 48 49 template<class T> class BObjectList; 50 class BMenuItem; 51 52 namespace BPrivate { 53 54 class Model; 55 class BContainerWindow; 56 class ModelMenuItem; 57 class EntryListBase; 58 59 60 class TrackingHookData { 61 public: 62 TrackingHookData() 63 : 64 fTrackingHook(NULL), 65 fDragMessage(NULL) 66 { 67 } 68 69 bool (*fTrackingHook)(BMenu *, void *); 70 BMessenger fTarget; 71 const BMessage *fDragMessage; 72 }; 73 74 75 class BNavMenu : public BSlowMenu { 76 public: 77 BNavMenu(const char* title, uint32 message, const BHandler *, 78 BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL); 79 BNavMenu(const char* title, uint32 message, const BMessenger &, 80 BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL); 81 // parentWindow, if specified, will be closed if nav menu item invoked 82 // with option held down 83 84 virtual ~BNavMenu(); 85 86 virtual void AttachedToWindow(); 87 virtual void DetachedFromWindow(); 88 89 void SetNavDir(const entry_ref *); 90 void ForceRebuild(); 91 bool NeedsToRebuild() const; 92 // will cause menu to get rebuilt next time it is shown 93 94 virtual void ResetTargets(); 95 void SetTarget(const BMessenger &); 96 BMessenger Target(); 97 98 void SetTypesList(const BObjectList<BString> *list); 99 const BObjectList<BString> *TypesList() const; 100 101 void AddNavDir(const Model *model, uint32 what, BHandler *target, 102 bool populateSubmenu); 103 104 void AddNavParentDir(const char *name, const Model *model, uint32 what, BHandler *target); 105 void AddNavParentDir(const Model *model, uint32 what, BHandler *target); 106 void SetShowParent(bool show); 107 108 static int32 GetMaxMenuWidth(); 109 110 static int CompareFolderNamesFirstOne(const BMenuItem *, const BMenuItem *); 111 static int CompareOne(const BMenuItem *, const BMenuItem *); 112 113 static ModelMenuItem *NewModelItem(Model *, const BMessage *, const BMessenger &, 114 bool suppressFolderHierarchy=false, BContainerWindow * = NULL, 115 const BObjectList<BString> *typeslist = NULL, 116 TrackingHookData *hook = NULL); 117 118 TrackingHookData *InitTrackingHook(bool (*hookfunction)(BMenu *, void *), 119 const BMessenger *target, const BMessage *dragMessage); 120 121 protected: 122 virtual bool StartBuildingItemList(); 123 virtual bool AddNextItem(); 124 virtual void DoneBuildingItemList(); 125 virtual void ClearMenuBuildingState(); 126 127 void BuildVolumeMenu(); 128 129 void AddOneItem(Model *); 130 void AddRootItemsIfNeeded(); 131 void AddTrashItem(); 132 static void SetTrackingHookDeep(BMenu *, bool (*)(BMenu *, void *), void *); 133 134 entry_ref fNavDir; 135 BMessage fMessage; 136 BMessenger fMessenger; 137 BWindow *fParentWindow; 138 139 // menu building state 140 uint8 fFlags; 141 BObjectList<BMenuItem> *fItemList; 142 EntryListBase *fContainer; 143 bool fIteratingDesktop; 144 145 BObjectList<BString> *fTypesList; 146 147 TrackingHookData fTrackingHook; 148 }; 149 150 // Spring Loaded Folder convenience routines 151 // used in both Tracker and Deskbar 152 #ifndef _IMPEXP_TRACKER 153 # define _IMPEXP_TRACKER 154 #endif 155 _IMPEXP_TRACKER bool SpringLoadedFolderCompareMessages(const BMessage *incoming, 156 const BMessage *dragmessage); 157 _IMPEXP_TRACKER void SpringLoadedFolderSetMenuStates(const BMenu *menu, 158 const BObjectList<BString> *typeslist); 159 _IMPEXP_TRACKER void SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref, 160 BObjectList<BString> *typeslist); 161 _IMPEXP_TRACKER void SpringLoadedFolderCacheDragData(const BMessage *incoming, 162 BMessage **, BObjectList<BString> **typeslist); 163 164 } // namespace BPrivate 165 166 using namespace BPrivate; 167 168 #endif // NAV_MENU_H 169