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.
34 #ifndef _CONTAINER_WINDOW_H
35 #define _CONTAINER_WINDOW_H
38 #include <GroupView.h>
39 #include <StringList.h>
42 #include "LockingList.h"
44 #include "SlowContextPopup.h"
58 class DraggableContainerIcon
;
60 class AttributeStreamNode
;
61 class BackgroundImage
;
63 class ModelNodeLazyOpener
;
65 class SelectionWindow
;
68 #define kDefaultFolderTemplate "DefaultFolderTemplate"
71 extern const char* kAddOnsMenuName
;
75 // flags that describe opening of the window
76 kRestoreWorkspace
= 0x1,
78 // set when opening a window during initial Tracker start
83 struct AddonShortcut
{
91 class BContainerWindow
: public BWindow
{
93 BContainerWindow(LockingList
<BWindow
>* windowList
,
94 uint32 containerWindowFlags
,
95 window_look look
= B_DOCUMENT_WINDOW_LOOK
,
96 window_feel feel
= B_NORMAL_WINDOW_FEEL
,
97 uint32 flags
= B_WILL_ACCEPT_FIRST_CLICK
| B_NO_WORKSPACE_ACTIVATION
,
98 uint32 workspace
= B_CURRENT_WORKSPACE
, bool useLayouts
= true,
99 bool isDeskWindow
= false);
101 virtual ~BContainerWindow();
103 virtual void Init(const BMessage
* message
= NULL
);
104 virtual void InitLayout();
106 static BRect
InitialWindowRect(window_feel
);
108 virtual void Minimize(bool minimize
);
110 virtual bool QuitRequested();
112 virtual void UpdateIfTrash(Model
*);
114 virtual void CreatePoseView(Model
*);
116 virtual void ShowContextMenu(BPoint
, const entry_ref
*, BView
*);
117 virtual uint32
ShowDropContextMenu(BPoint
);
118 virtual void MenusBeginning();
119 virtual void MenusEnded();
120 virtual void MessageReceived(BMessage
*);
121 virtual void FrameResized(float, float);
122 virtual void FrameMoved(BPoint
);
123 virtual void Zoom(BPoint
, float, float);
124 virtual void WorkspacesChanged(uint32
, uint32
);
126 // virtuals that control setup of window
127 virtual bool ShouldAddMenus() const;
128 virtual bool ShouldAddScrollBars() const;
130 virtual void CheckScreenIntersect();
132 bool IsTrash() const;
133 bool InTrash() const;
134 bool IsPrintersDir() const;
136 virtual bool IsShowing(const node_ref
*) const;
137 virtual bool IsShowing(const entry_ref
*) const;
141 Model
* TargetModel() const;
142 BPoseView
* PoseView() const;
143 BNavigator
* Navigator() const;
145 virtual void SelectionChanged();
146 virtual void ViewModeChanged(uint32 oldMode
, uint32 newMode
);
148 virtual void RestoreState();
149 virtual void RestoreState(const BMessage
&);
150 void RestoreStateCommon();
151 virtual void SaveState(bool hide
= true);
152 virtual void SaveState(BMessage
&) const;
155 bool StateNeedsSaving() const;
156 bool SaveStateIsEnabled() const;
157 void SetSaveStateEnabled(bool);
159 void UpdateBackgroundImage();
161 static status_t
GetLayoutState(BNode
*, BMessage
*);
162 static status_t
SetLayoutState(BNode
*, const BMessage
*);
163 // calls for inheriting window size, attribute layout, etc.
166 virtual void AddMimeTypesToMenu(BMenu
*);
167 void AddMimeTypesToMenu();
168 virtual void MarkAttributeMenu(BMenu
*);
169 void MarkAttributeMenu();
170 void MarkArrangeByMenu(BMenu
*);
171 BMenuItem
* NewAttributeMenuItem(const char* label
, const char* name
,
172 int32 type
, float width
, int32 align
, bool editable
,
174 BMenuItem
* NewAttributeMenuItem(const char* label
, const char* name
,
175 int32 type
, const char* displayAs
, float width
, int32 align
,
176 bool editable
, bool statField
);
177 virtual void NewAttributeMenu(BMenu
*);
179 void HideAttributeMenu();
180 void ShowAttributeMenu();
181 PiggybackTaskLoop
* DelayedTaskLoop();
182 // use for RunLater queueing
183 void PulseTaskLoop();
184 // called by some view that has pulse, either BackgroundView
187 static bool DefaultStateSourceNode(const char* name
, BNode
* result
,
188 bool createNew
= false, bool createFolder
= true);
191 void EachAddon(bool (*)(const Model
*, const char*, uint32 shortcut
,
192 uint32 modifiers
, bool primary
, void*), void*, BStringList
&);
194 BPopUpMenu
* ContextMenu();
197 status_t
DragStart(const BMessage
*);
199 bool Dragging() const;
200 BMessage
* DragMessage() const;
202 void ShowSelectionWindow();
204 void ShowNavigator(bool);
205 void SetSingleWindowBrowseShortcuts(bool);
207 void SetPathWatchingEnabled(bool);
208 bool IsPathWatchingEnabled(void) const;
211 virtual BPoseView
* NewPoseView(Model
*, uint32
);
212 // instantiate a different flavor of BPoseView for different
215 virtual void RestoreWindowState(AttributeStreamNode
*);
216 virtual void RestoreWindowState(const BMessage
&);
217 virtual void SaveWindowState(AttributeStreamNode
*);
218 virtual void SaveWindowState(BMessage
&) const;
220 virtual bool NeedsDefaultStateSetup();
221 virtual void SetUpDefaultState();
222 // these two virtuals control setting up a new folder that
223 // does not have any state settings yet with the default
225 virtual void AddMenus();
226 virtual void AddShortcuts();
227 // add equivalents of the menu shortcuts to the menuless
229 virtual void AddFileMenu(BMenu
* menu
);
230 virtual void AddWindowMenu(BMenu
* menu
);
232 virtual void AddContextMenus();
234 virtual void AddFileContextMenus(BMenu
*);
235 virtual void AddWindowContextMenus(BMenu
*);
236 virtual void AddVolumeContextMenus(BMenu
*);
237 virtual void AddDropContextMenus(BMenu
*);
238 virtual void AddTrashContextMenus(BMenu
*);
240 virtual void RepopulateMenus();
241 void PopulateArrangeByMenu(BMenu
*);
243 virtual void SetCutItem(BMenu
*);
244 virtual void SetCopyItem(BMenu
*);
245 virtual void SetPasteItem(BMenu
*);
246 virtual void SetArrangeMenu(BMenu
*);
247 virtual void SetCloseItem(BMenu
*);
248 virtual void SetupNavigationMenu(const entry_ref
*, BMenu
*);
249 virtual void SetupMoveCopyMenus(const entry_ref
*, BMenu
*);
250 virtual void PopulateMoveCopyNavMenu(BNavMenu
*, uint32
,
251 const entry_ref
*, bool);
253 virtual void SetupOpenWithMenu(BMenu
*);
254 virtual void SetUpEditQueryItem(BMenu
*);
255 virtual void SetUpDiskMenu(BMenu
*);
257 virtual void BuildAddOnMenu(BMenu
*);
258 void BuildMimeTypeList(BStringList
& mimeTypes
);
260 enum UpdateMenuContext
{
266 virtual void UpdateMenu(BMenu
* menu
, UpdateMenuContext context
);
268 BMenu
* AddMimeMenu(const BMimeType
& mimeType
, bool isSuperType
,
269 BMenu
* menu
, int32 start
);
271 BHandler
* ResolveSpecifier(BMessage
*, int32
, BMessage
*, int32
,
274 bool EachAddon(BPath
&path
,
275 bool (*)(const Model
*, const char*, uint32
, bool, void*),
276 BObjectList
<Model
>*, void*, BStringList
&);
277 void LoadAddOn(BMessage
*);
280 BGroupLayout
* fRootLayout
;
281 BGroupView
* fMenuContainer
;
282 BGridView
* fPoseContainer
;
283 BorderedView
* fBorderedView
;
284 BGroupView
* fVScrollBarContainer
;
285 BGroupView
* fCountContainer
;
287 BPopUpMenu
* fFileContextMenu
;
288 BPopUpMenu
* fWindowContextMenu
;
289 BPopUpMenu
* fDropContextMenu
;
290 BPopUpMenu
* fVolumeContextMenu
;
291 BPopUpMenu
* fTrashContextMenu
;
292 BSlowContextMenu
* fDragContextMenu
;
293 BMenuItem
* fMoveToItem
;
294 BMenuItem
* fCopyToItem
;
295 BMenuItem
* fCreateLinkItem
;
296 BMenuItem
* fOpenWithItem
;
297 ModelMenuItem
* fNavigationItem
;
299 DraggableContainerIcon
* fDraggableIcon
;
300 BNavigator
* fNavigator
;
301 BPoseView
* fPoseView
;
302 LockingList
<BWindow
>* fWindowList
;
306 BMenu
* fArrangeByMenu
;
308 SelectionWindow
* fSelectionWindow
;
310 PiggybackTaskLoop
* fTaskLoop
;
317 uint32 fContainerWindowFlags
;
318 BackgroundImage
* fBackgroundImage
;
320 static LockingList
<struct AddonShortcut
>* fAddonsList
;
323 BRect fSavedZoomRect
;
324 BRect fPreviousBounds
;
326 static BRect sNewWindRect
;
328 BPopUpMenu
* fContextMenu
;
329 BMessage
* fDragMessage
;
330 BObjectList
<BString
>* fCachedTypesList
;
331 bool fWaitingForRefs
;
333 bool fStateNeedsSaving
;
334 bool fSaveStateIsEnabled
;
336 bool fIsWatchingPath
;
338 typedef BWindow _inherited
;
340 friend int32
show_context_menu(void*);
341 friend class BackgroundView
;
343 void _UpdateSelectionMIMEInfo();
344 void _AddFolderIcon();
348 class WindowStateNodeOpener
{
349 // this class manages opening and closing the proper node for
350 // state restoring / saving; the constructor knows how to decide whether
351 // to use a special directory for root, etc.
352 // setter calls used when no attributes can be read from a node and
353 // defaults are to be substituted
355 WindowStateNodeOpener(BContainerWindow
* window
, bool forWriting
);
356 virtual ~WindowStateNodeOpener();
358 void SetTo(const BDirectory
*);
359 void SetTo(const BEntry
* entry
, bool forWriting
);
360 void SetTo(Model
*, bool forWriting
);
362 AttributeStreamNode
* StreamNode() const;
366 ModelNodeLazyOpener
* fModelOpener
;
368 AttributeStreamNode
* fStreamNode
;
372 class BorderedView
: public BGroupView
{
376 void PoseViewFocused(bool);
377 virtual void Pulse();
379 void EnableBorderHighlight(bool);
382 virtual void WindowActivated(bool);
385 bool fEnableBorderHighlight
;
387 typedef BGroupView _inherited
;
391 int CompareLabels(const BMenuItem
*, const BMenuItem
*);
397 BContainerWindow::Navigator() const
404 BContainerWindow::PoseView() const
411 BContainerWindow::IsTrash() const
418 BContainerWindow::InTrash() const
425 BContainerWindow::IsPrintersDir() const
432 BContainerWindow::SetUpDiskMenu(BMenu
*)
434 // nothing at this level
439 BContainerWindow::ContextMenu()
446 BContainerWindow::Dragging() const
448 return fDragMessage
&& fCachedTypesList
;
453 BContainerWindow::DragMessage() const
460 BContainerWindow::SaveStateIsEnabled() const
462 return fSaveStateIsEnabled
;
467 BContainerWindow::SetSaveStateEnabled(bool value
)
469 fSaveStateIsEnabled
= value
;
474 BContainerWindow::IsPathWatchingEnabled() const
476 return fIsWatchingPath
;
480 filter_result
ActivateWindowFilter(BMessage
* message
, BHandler
** target
,
481 BMessageFilter
* messageFilter
);
483 } // namespace BPrivate
485 using namespace BPrivate
;
488 #endif // _CONTAINER_WINDOW_H