btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / tracker / NavMenu.h
blobe1c45d1475a538ceea8e0ccab9a586eaec42f0a8
1 /*
2 Open Tracker License
4 Terms and Conditions
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
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:
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.
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.
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.
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.
35 // NavMenu is a hierarchical menu of volumes, folders, files and queries
36 // displays icons, uses the SlowMenu API for full interruptability
38 #ifndef NAV_MENU_H
39 #define NAV_MENU_H
42 #include <Messenger.h>
43 #include <StorageDefs.h>
44 #include <Entry.h>
46 #include "SlowMenu.h"
49 template<class T> class BObjectList;
50 class BMenuItem;
53 namespace BPrivate {
55 class Model;
56 class BContainerWindow;
57 class ModelMenuItem;
58 class EntryListBase;
61 struct TrackingHookData {
62 TrackingHookData()
64 fTrackingHook(NULL),
65 fDragMessage(NULL)
69 bool (*fTrackingHook)(BMenu*, void*);
70 BMessenger fTarget;
71 const BMessage* fDragMessage;
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
84 virtual ~BNavMenu();
86 virtual void AttachedToWindow();
87 virtual void DetachedFromWindow();
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
94 virtual void ResetTargets();
95 void SetTarget(const BMessenger&);
96 BMessenger Target();
98 void SetTypesList(const BObjectList<BString>* list);
99 const BObjectList<BString>* TypesList() const;
101 void AddNavDir(const Model* model, uint32 what, BHandler* target,
102 bool populateSubmenu);
104 void AddNavParentDir(const char* name, const Model* model, uint32 what,
105 BHandler* target);
106 void AddNavParentDir(const Model* model, uint32 what, BHandler* target);
107 void SetShowParent(bool show);
109 static int32 GetMaxMenuWidth();
111 static int CompareFolderNamesFirstOne(const BMenuItem*, const BMenuItem*);
112 static int CompareOne(const BMenuItem*, const BMenuItem*);
114 static ModelMenuItem* NewModelItem(Model*, const BMessage*,
115 const BMessenger&, bool suppressFolderHierarchy = false,
116 BContainerWindow* = NULL, const BObjectList<BString>* typeslist = NULL,
117 TrackingHookData* hook = NULL);
119 TrackingHookData* InitTrackingHook(bool (*hookfunction)(BMenu*, void*),
120 const BMessenger* target, const BMessage* dragMessage);
122 protected:
123 virtual bool StartBuildingItemList();
124 virtual bool AddNextItem();
125 virtual void DoneBuildingItemList();
126 virtual void ClearMenuBuildingState();
128 void BuildVolumeMenu();
130 void AddOneItem(Model*);
131 void AddRootItemsIfNeeded();
132 void AddTrashItem();
133 static void SetTrackingHookDeep(BMenu*, bool (*)(BMenu*, void*), void*);
135 entry_ref fNavDir;
136 BMessage fMessage;
137 BMessenger fMessenger;
138 BWindow* fParentWindow;
140 // menu building state
141 uint8 fFlags;
142 BObjectList<BMenuItem>* fItemList;
143 EntryListBase* fContainer;
144 bool fIteratingDesktop;
146 BObjectList<BString>* fTypesList;
148 TrackingHookData fTrackingHook;
151 // Spring Loaded Folder convenience routines
152 // used in both Tracker and Deskbar
153 #ifndef _IMPEXP_TRACKER
154 # define _IMPEXP_TRACKER
155 #endif
156 _IMPEXP_TRACKER bool SpringLoadedFolderCompareMessages(const BMessage *incoming,
157 const BMessage *dragmessage);
158 _IMPEXP_TRACKER void SpringLoadedFolderSetMenuStates(const BMenu *menu,
159 const BObjectList<BString> *typeslist);
160 _IMPEXP_TRACKER void SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref,
161 BObjectList<BString> *typeslist);
162 _IMPEXP_TRACKER void SpringLoadedFolderCacheDragData(const BMessage *incoming,
163 BMessage **, BObjectList<BString> **typeslist);
165 } // namespace BPrivate
167 using namespace BPrivate;
170 #endif // NAV_MENU_H