1/* 2Open Tracker License 3 4Terms and Conditions 5 6Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8Permission is hereby granted, free of charge, to any person obtaining a copy of 9this software and associated documentation files (the "Software"), to deal in 10the Software without restriction, including without limitation the rights to 11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12of the Software, and to permit persons to whom the Software is furnished to do 13so, subject to the following conditions: 14 15The above copyright notice and this permission notice applies to all licensees 16and shall be included in all copies or substantial portions of the Software. 17 18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25Except as contained in this notice, the name of Be Incorporated shall not be 26used in advertising or otherwise to promote the sale, use or other dealings in 27this Software without prior written authorization from Be Incorporated. 28 29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks 30of Be Incorporated in the United States and other countries. Other brand product 31names are registered trademarks or trademarks of their respective holders. 32All rights reserved. 33*/ 34#ifndef __FAVORITES_MENU__ 35#define __FAVORITES_MENU__ 36 37 38#include <vector> 39 40#include "NavMenu.h" 41#include "ObjectList.h" 42 43 44class BRefFilter; 45 46namespace BPrivate { 47 48class EntryListBase; 49 50#define kGoDirectory "Tracker/Go" 51 52 53class FavoritesMenu : public BSlowMenu { 54 // FavoritesMenu is used in the FilePanel - 55 // displays recent files, recent folders and favorites items 56 public: 57 FavoritesMenu(const char* title, BMessage* openFolderMessage, 58 BMessage* openFileMessage, const BMessenger &, 59 bool isSavePanel, BRefFilter* filter = NULL); 60 virtual ~FavoritesMenu(); 61 62 void SetRefFilter(BRefFilter* filter); 63 64 private: 65 // override the necessary SlowMenu hooks 66 virtual bool StartBuildingItemList(); 67 virtual bool AddNextItem(); 68 virtual void DoneBuildingItemList(); 69 virtual void ClearMenuBuildingState(); 70 71 bool ShouldShowModel(const Model* model); 72 73 BMessage* fOpenFolderMessage; 74 BMessage* fOpenFileMessage; 75 BMessenger fTarget; 76 77 enum State { 78 kStart, 79 kAddingFavorites, 80 kAddingFiles, 81 kAddingFolders, 82 kDone 83 }; 84 85 State fState; 86 87 int32 fIndex; 88 int32 fSectionItemCount; 89 bool fAddedSeparatorForSection; 90 // keeps track whether a separator will be needed before the 91 // next inserted item 92 BMessage fItems; 93 94 EntryListBase* fContainer; 95 BObjectList<BMenuItem>* fItemList; 96 int32 fInitialItemCount; 97 std::vector<entry_ref> fUniqueRefCheck; 98 bool fIsSavePanel; 99 BRefFilter* fRefFilter; 100 101 typedef BSlowMenu _inherited; 102}; 103 104 105enum recent_type { 106 kRecentDocuments = 0, 107 kRecentApplications = 1, 108 kRecentFolders = 2 109}; 110 111 112class RecentsMenu : public BNavMenu { 113 public: 114 RecentsMenu(const char* name, int32 which, uint32 what, 115 BHandler* target); 116 117 void DetachedFromWindow(); 118 119 int32 RecentsCount(); 120 121 private: 122 virtual bool StartBuildingItemList(); 123 virtual bool AddNextItem(); 124 bool AddRecents(int32 count); 125 virtual void DoneBuildingItemList(); 126 virtual void ClearMenuBuildingState(); 127 128 private: 129 int32 fWhich; 130 int32 fRecentsCount; 131 132 int32 fItemIndex; 133 BMessage fRecentList; 134}; 135 136} // namespace BPrivate 137 138using namespace BPrivate; 139 140#endif 141