xref: /haiku/src/kits/tracker/PoseView.h (revision fef6144999c2fa611f59ee6ffe6dd7999501385c)
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 //
36 //	BPoseView is a container for poses, handling all of the interaction, drawing,
37 //	etc. The three different view modes are handled here.
38 //
39 //	this is by far the fattest Tracker class and over time will undergo a lot of
40 //	trimming
41 
42 #ifndef	_POSE_VIEW_H
43 #define _POSE_VIEW_H
44 
45 #include "AttributeStream.h"
46 #include "ContainerWindow.h"
47 #include "Model.h"
48 #include "PendingNodeMonitorCache.h"
49 #include "Pose.h"
50 #include "PoseList.h"
51 #include "TitleView.h"
52 #include "Utilities.h"
53 #include "ViewState.h"
54 
55 #include <Directory.h>
56 #include <FilePanel.h>
57 #include <MessageRunner.h>
58 #include <String.h>
59 #include <ScrollBar.h>
60 #include <View.h>
61 #include <set>
62 
63 class BRefFilter;
64 class BList;
65 
66 // TODO: Get rid of this.
67 class _BWidthBuffer_;
68 
69 namespace BPrivate {
70 
71 class BCountView;
72 class BContainerWindow;
73 class BHScrollBar;
74 class EntryListBase;
75 
76 const int32 kSmallStep = 10;
77 const int32 kListOffset = 20;
78 
79 const uint32 kMiniIconMode = 'Tmic';
80 const uint32 kIconMode = 'Ticn';
81 const uint32 kListMode = 'Tlst';
82 
83 const uint32 kCheckTypeahead = 'Tcty';
84 
85 class BPoseView : public BView {
86 	public:
87 		BPoseView(Model *, BRect, uint32 viewMode, uint32 resizeMask = B_FOLLOW_ALL);
88 		virtual ~BPoseView();
89 
90 		// setup, teardown
91 		virtual void Init(AttributeStreamNode *);
92 		virtual void Init(const BMessage &);
93 		void InitCommon();
94 		virtual	void DetachedFromWindow();
95 
96 		// Returns true if for instance, node ref is a remote desktop directory and
97 		// this is a desktop pose view.
98 		virtual bool Represents(const node_ref *) const;
99 		virtual bool Represents(const entry_ref *) const;
100 
101 		BContainerWindow *ContainerWindow() const;
102 		Model *TargetModel() const;
103 
104 		virtual bool IsFilePanel() const;
105 		bool IsDesktopWindow() const;
106 		virtual bool IsDesktopView() const;
107 
108 		// state saving/restoring
109 		virtual	void SaveState(AttributeStreamNode *node);
110 		virtual void RestoreState(AttributeStreamNode *);
111 		virtual void RestoreColumnState(AttributeStreamNode *);
112 		void AddColumnList(BObjectList<BColumn> *list);
113 		virtual void SaveColumnState(AttributeStreamNode *);
114 		virtual void SavePoseLocations(BRect *frameIfDesktop = 0);
115 		void DisableSaveLocation();
116 
117 		virtual	void SaveState(BMessage &) const;
118 		virtual void RestoreState(const BMessage &);
119 		virtual void RestoreColumnState(const BMessage &);
120 		virtual void SaveColumnState(BMessage &) const;
121 
122 		bool StateNeedsSaving();
123 
124 		// switch between mini icon mode, icon mode and list mode
125 		virtual void SetViewMode(uint32 mode);
126 		uint32 ViewMode() const;
127 
128 		// re-use the pose view for a new directory
129 	 	virtual void SwitchDir(const entry_ref *, AttributeStreamNode *node = 0);
130 
131 		// in the rare cases where a pose view needs to be explicitly refreshed
132 		// (for instance in a query window with a dynamic date query), this is
133 		// used
134 		virtual void Refresh();
135 
136 		// callbacks
137 		virtual	void MessageReceived(BMessage *);
138 		virtual	void AttachedToWindow();
139 		virtual void WindowActivated(bool);
140 		virtual void MakeFocus(bool = true);
141 		virtual void MouseMoved(BPoint, uint32, const BMessage *);
142 		virtual	void Draw(BRect update_rect);
143 		virtual	void MouseDown(BPoint where);
144 		virtual	void KeyDown(const char *, int32);
145 		virtual void Pulse();
146 		virtual void MoveBy(float, float);
147 
148 		// misc. mode setters
149 		void SetMultipleSelection(bool);
150 		void SetDragEnabled(bool);
151 		void SetDropEnabled(bool);
152 		void SetSelectionRectEnabled(bool);
153 		void SetAlwaysAutoPlace(bool);
154 		void SetSelectionChangedHook(bool);
155 		void SetShowHideSelection(bool);
156 		void SetEnsurePosesVisible(bool);
157 		void SetIconMapping(bool);
158 		void SetAutoScroll(bool);
159 		void SetPoseEditing(bool);
160 
161 		void UpdateVolumeIcon(dev_t device, bool forceUpdate = false);
162 		void UpdateVolumeIcons();
163 
164 		// file change notification handler
165 		virtual bool FSNotification(const BMessage *);
166 
167 		// scrollbars
168 		virtual void UpdateScrollRange();
169 		virtual	void SetScrollBarsTo(BPoint);
170 		virtual void AddScrollBars();
171 		BHScrollBar *HScrollBar() const;
172 		BScrollBar *VScrollBar() const ;
173 		void DisableScrollBars();
174 		void EnableScrollBars();
175 
176 		// sorting
177 		virtual void SortPoses();
178 		void SetPrimarySort(uint32 attrHash);
179 		void SetSecondarySort(uint32 attrHash);
180 		void SetReverseSort(bool reverse);
181 		uint32 PrimarySort() const;
182 		uint32 PrimarySortType() const;
183 		uint32 SecondarySort() const;
184 		uint32 SecondarySortType() const;
185 		bool ReverseSort() const;
186 		void CheckPoseSortOrder(BPose *, int32 index);
187 		void CheckPoseVisibility(BRect * = NULL);
188 			// make sure pose fits the screen and/or window bounds if needed
189 
190 		// view metrics
191 		font_height	FontInfo() const;
192 			// returns height, descent, etc.
193 		float FontHeight() const;
194 		float ListElemHeight() const;
195 
196 		void SetIconPoseHeight();
197 		float IconPoseHeight() const;
198 
199 		BRect Extent() const;
200 		void GetLayoutInfo(uint32 viewMode, BPoint *grid, BPoint *offset) const;
201 
202 		int32 CountItems() const;
203 		void UpdateCount();
204 
205 		rgb_color DeskTextColor() const;
206 		rgb_color DeskTextBackColor() const;
207 
208 		bool EraseWidgetTextBackground() const;
209 		void SetEraseWidgetTextBackground(bool);
210 			// used to not erase when we have a background image and
211 			// invalidate instead
212 
213 		// column handling
214 		void ColumnRedraw(BRect updateRect);
215 		bool AddColumn(BColumn *, const BColumn *after = NULL);
216 		bool RemoveColumn(BColumn *column, bool runAlert);
217 		void MoveColumnTo(BColumn *src, BColumn *dest);
218 		bool ResizeColumnToWidest(BColumn *column);
219 		BPoint ResizeColumn(BColumn *, float, float *lastLineDrawPos = NULL,
220 			void (*drawLineFunc)(BPoseView *, BPoint, BPoint) = 0,
221 			void (*undrawLineFunc)(BPoseView *, BPoint, BPoint) = 0);
222 			// returns the bottom right of the last pose drawn or bottom right of
223 			// bounds
224 
225 		BColumn *ColumnAt(int32 index) const;
226 		BColumn *ColumnFor(uint32 attribute_hash) const;
227 		BColumn *FirstColumn() const;
228 		BColumn *LastColumn() const;
229 		int32 IndexOfColumn(const BColumn *) const;
230 		int32 CountColumns() const;
231 
232 		// pose access
233 		int32 IndexOfPose(const BPose *) const;
234 		BPose *PoseAtIndex(int32 index) const;
235 
236 		BPose *FindPose(BPoint where, int32 *index = NULL) const;
237 			// return pose at location h, v (search list starting from bottom so
238 			// drawing and hit detection reflect the same pose ordering)
239 		BPose *FindPose(const Model *, int32 *index = NULL) const;
240 		BPose *FindPose(const node_ref *, int32 *index = NULL) const;
241 		BPose *FindPose(const entry_ref *, int32 *index = NULL) const;
242 		BPose *FindPose(const entry_ref *, int32 specifierForm, int32 *index) const;
243 			// special form of FindPose used for scripting, <specifierForm> may
244 			// ask for previous or next pose
245 		BPose *DeepFindPose(const node_ref *node, int32 *index = NULL) const;
246 			// same as FindPose, node can be a target of the actual
247 			// pose if the pose is a symlink
248 
249 		void OpenInfoWindows();
250 		void SetDefaultPrinter();
251 
252 		void IdentifySelection();
253 		void UnmountSelectedVolumes();
254 		virtual void OpenParent();
255 
256 		virtual void OpenSelection(BPose *clicked_pose = NULL, int32 *index = NULL);
257 		void OpenSelectionUsing(BPose *clicked_pose = NULL, int32 *index = NULL);
258 			// launches the open with window
259 		virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow *);
260 		void DuplicateSelection(BPoint *dropStart = NULL, BPoint *dropEnd = NULL);
261 
262 		// Move to trash calls try to select the next pose in the view when they
263 		// are dones
264 		virtual void MoveSelectionToTrash(bool selectNext = true);
265 		virtual void DeleteSelection(bool selectNext = true, bool askUser = true);
266 		virtual void MoveEntryToTrash(const entry_ref *, bool selectNext = true);
267 
268 		void RestoreSelectionFromTrash(bool selectNext = true);
269 
270 		// selection
271 		PoseList *SelectionList() const;
272 		void SelectAll();
273 		void InvertSelection();
274 		int32 SelectMatchingEntries(const BMessage *);
275 		void ShowSelectionWindow();
276 		void ClearSelection();
277 		void ShowSelection(bool);
278 		void AddRemovePoseFromSelection(BPose *pose, int32 index, bool select);
279 
280 		BLooper *SelectionHandler();
281 		void SetSelectionHandler(BLooper *);
282 
283 		BObjectList<BString> *MimeTypesInSelection();
284 
285 		// pose selection
286 		void SelectPose(BPose *, int32 index, bool scrollIntoView = true);
287 		void AddPoseToSelection(BPose *, int32 index, bool scrollIntoView = true);
288 		void RemovePoseFromSelection(BPose *);
289 		void SelectPoseAtLocation(BPoint);
290 		void SelectPoses(int32 start, int32 end);
291 
292 		// pose handling
293 		void ScrollIntoView(BPose *pose, int32 index, bool drawOnly = false);
294 		void SetActivePose(BPose *);
295 		BPose *ActivePose() const;
296 		void CommitActivePose(bool saveChanges = true);
297 		static bool PoseVisible(const Model *, const PoseInfo *, bool inFilePanel);
298 		bool FrameForPose(BPose *targetpose, bool convert, BRect *poseRect);
299 		bool CreateSymlinkPoseTarget(Model *symlink);
300 			// used to complete a symlink pose; returns true if
301 			// target symlink should not be shown
302 		void ResetPosePlacementHint();
303 		void PlaceFolder(const entry_ref *, const BMessage *);
304 
305 		// clipboard handling for poses
306 		bool HasPosesInClipboard();
307 		void SetHasPosesInClipboard(bool hasPoses);
308 		void SetPosesClipboardMode(uint32 clipboardMode);
309 		void UpdatePosesClipboardModeFromClipboard(BMessage *clipboardReport = NULL);
310 
311 		// filtering
312 		void SetRefFilter(BRefFilter *);
313 		BRefFilter *RefFilter() const;
314 
315 		// access for mime types represented in the pose view
316 		const char *MimeTypeAt(int32);
317 		int32 CountMimeTypes();
318 	 	void RefreshMimeTypeList();
319 
320 		// drag&drop handling
321 		virtual bool HandleMessageDropped(BMessage *);
322 		static bool HandleDropCommon(BMessage *dragMessage, Model *target, BPose *,
323 			BView *view, BPoint dropPt);
324 			// used by pose views and info windows
325 		static bool CanHandleDragSelection(const Model *target,
326 			const BMessage *dragMessage, bool ignoreTypes);
327 		virtual	void DragSelectedPoses(const BPose *clickedPose, BPoint);
328 		virtual	void DragSelectionRect(BPoint, bool extendSelection);
329 
330 		void MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow,
331 			bool forceCopy, bool createLink = false, bool relativeLink = false);
332 		static void MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow,
333 			BContainerWindow *destWindow, uint32 buttons, BPoint loc,
334 			bool forceCopy, bool createLink = false, bool relativeLink = false);
335 
336 		bool UpdateDropTarget(BPoint, const BMessage *, bool trackingContextMenu);
337 			// return true if drop target changed
338 		void HiliteDropTarget(bool hiliteState);
339 
340 		void DragStop();
341 			// throw away cached up structures
342 
343 		static bool MenuTrackingHook(BMenu *menu, void *castToThis);
344 			// hook for spring loaded nav-menus
345 
346 		// scripting
347 		virtual BHandler *ResolveSpecifier(BMessage	*message, int32 index,
348 			BMessage *specifier, int32 form, const char	*property);
349 		virtual status_t GetSupportedSuites(BMessage *);
350 
351 		// string width calls that use local width caches, faster than usin
352 		// the general purpose BView::StringWidth
353 		float StringWidth(const char *) const;
354 		float StringWidth(const char *, int32) const;
355 			// deliberately hide the BView StringWidth here - this makes it
356 			// easy to have the right StringWidth picked up by
357 			// template instantiation, as used by WidgetAttributeText
358 
359 		// show/hide barberpole while a background task is filling up the view, etc.
360 		void ShowBarberPole();
361 		void HideBarberPole();
362 
363 		bool fShowSelectionWhenInactive;
364 		bool fTransparentSelection;
365 		bool fIsDrawingSelectionRect;
366 
367 		bool IsWatchingDateFormatChange();
368 		void StartWatchDateFormatChange();
369 		void StopWatchDateFormatChange();
370 
371 		void UpdateDateColumns(BMessage *);
372 		virtual void AdaptToVolumeChange(BMessage *);
373 		virtual void AdaptToDesktopIntegrationChange(BMessage *);
374 
375 	protected:
376 		// view setup
377 		virtual void SetUpDefaultColumnsIfNeeded();
378 
379 		virtual EntryListBase *InitDirentIterator(const entry_ref *);
380 			// sets up an entry iterator for _add_poses_
381 			// overriden by QueryPoseView, etc. to provide different iteration
382 
383 		void Cleanup(bool doAll = false);
384 			// clean up poses
385 		void NewFolder(const BMessage *);
386 			// create a new folder, optionally specify a location
387 
388 		void NewFileFromTemplate(const BMessage *);
389 			// create a new file based on a template, optionally specify a location
390 
391 		void ShowContextMenu(BPoint);
392 
393 		// scripting handlers
394 		virtual bool HandleScriptingMessage(BMessage *message);
395 		bool SetProperty(BMessage *message, BMessage *specifier, int32 form,
396 			const char *property, BMessage *reply);
397 		bool GetProperty(BMessage *, int32, const char *, BMessage *);
398 		bool CreateProperty(BMessage *message, BMessage *specifier, int32,
399 			const char *, BMessage *reply);
400 		bool ExecuteProperty(BMessage *specifier, int32, const char *, BMessage *reply);
401 		bool CountProperty(BMessage *, int32, const char *, BMessage *);
402 		bool DeleteProperty(BMessage *, int32, const char *, BMessage *);
403 
404 		void ClearPoses();
405 			// remove all the current poses from the view
406 
407 		// pose info read/write calls
408 		void ReadPoseInfo(Model *, PoseInfo *);
409 		ExtendedPoseInfo *ReadExtendedPoseInfo(Model *);
410 
411 		// pose creation
412 		BPose *EntryCreated(const node_ref *, const node_ref *, const char *, int32 *index = 0);
413 
414 		BPose *CreatePose(Model *, PoseInfo *, bool insertionSort = true,
415 			int32 *index = 0, BRect *boundsPtr = 0, bool forceDraw = true);
416 		virtual void CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
417 			BPose **resultingPoses, bool insertionSort = true, int32 *lastPoseIndexPtr = 0,
418 			BRect *boundsPtr = 0, bool forceDraw = false);
419 		virtual bool ShouldShowPose(const Model *, const PoseInfo *);
420 			// filter, subclasses override to control which poses show up
421 			// subclasses should always call inherited
422 		void CreateVolumePose(BVolume *, bool watchIndividually);
423 
424 		virtual bool AddPosesThreadValid(const entry_ref *) const;
425 			// verifies whether or not the current set of AddPoses threads
426 			// are valid and allowed to be adding poses -- returns false
427 			// in the case where the directory has been switched while populating
428 			// the view
429 
430 		virtual void AddPoses(Model *model = NULL);
431 			// if <model> is zero, PoseView has other means of iterating through all
432 			// the entries that it adds
433 		virtual void AddRootPoses(bool watchIndividually, bool mountShared);
434 			// watchIndividually is used when placing a volume pose onto the Desktop
435 			// where unlike in the Root window it will not be watched by the folder
436 			// representing root. If set, each volume will therefore be watched
437 			// individually
438 		virtual void RemoveRootPoses();
439 		virtual void AddTrashPoses();
440 
441 		virtual bool DeletePose(const node_ref *, BPose *pose = NULL, int32 index = 0);
442 		virtual void DeleteSymLinkPoseTarget(const node_ref *itemNode, BPose *pose,
443 			int32 index);
444 			// the pose itself wasn't deleted but it's target node was - the
445 			// pose must be a symlink
446 		static void PoseHandleDeviceUnmounted(BPose *pose, Model *model, int32 index,
447 			BPoseView *poseView, dev_t device);
448 		static void RemoveNonBootDesktopModels(BPose *, Model *model, int32,
449 			BPoseView *poseView, dev_t);
450 
451 		// pose placement
452 		void CheckAutoPlacedPoses();
453 			// find poses that need placing and place them in a new spot
454 		void PlacePose(BPose *, BRect &);
455 			// find a new place for a pose, starting at fHintLocation and place it
456 		bool SlotOccupied(BRect poseRect, BRect viewBounds) const;
457 		void NextSlot(BPose *, BRect &poseRect, BRect viewBounds);
458 		void TrySettingPoseLocation(BNode *node, BPoint point);
459 		BPoint PinToGrid(BPoint, BPoint grid, BPoint offset) const;
460 
461 		// zombie pose handling
462 		Model *FindZombie(const node_ref *, int32 *index = 0);
463 		BPose *ConvertZombieToPose(Model *zombie, int32 index);
464 
465 		// pose handling
466 		BRect CalcPoseRect(BPose *, int32 index, bool minimal = false) const;
467 		void DrawPose(BPose *, int32 index, bool fullDraw = true);
468 		void DrawViewCommon(BRect, bool recalculateText = false);
469 
470 		// pose list handling
471 		int32 BSearchList(const BPose *, int32 *index);
472 		void InsertPoseAfter(BPose *pose, int32 *index, int32 orientation,
473 			BRect *invalidRect);
474 			// does a CopyBits to scroll poses making room for a new pose,
475 			// returns rectangle that needs invalidating
476 		void CloseGapInList(BRect *invalidRect);
477 		int32 FirstIndexAtOrBelow(int32 y, bool constrainIndex = true) const;
478 		void AddToVSList(BPose *);
479 		int32 RemoveFromVSList(const BPose *);
480 		BPose *FindNearbyPose(char arrow, int32 *index);
481 		BPose *FindBestMatch(int32 *index);
482 		BPose *FindNextMatch(int32 *index, bool reverse = false);
483 
484 		// node monitoring calls
485 		virtual void StartWatching();
486 		virtual void StopWatching();
487 
488 		status_t WatchNewNode(const node_ref *item);
489 			// the above would ideally be the only call of these three and it would
490 			// be a virtual, overriding the specific watch mask in query pose view, etc.
491 			// however we need to call WatchNewNode from inside AddPosesTask while
492 			// the window is unlocked - we have to use the static and a cached
493 			// messenger and masks.
494 		static status_t WatchNewNode(const node_ref *, uint32, BMessenger);
495 		virtual uint32 WatchNewNodeMask();
496 			// override to change different watch modes for query pose view, etc.
497 
498 		// drag&drop handling
499 		static bool EachItemInDraggedSelection(const BMessage *message,
500 			bool (*)(BPose *, BPoseView *, void *), BPoseView *poseView,
501 			void * = NULL);
502 			// iterates through each pose in current selectiond in the source
503 			// window of the current drag message; locks the window
504 			// add const version
505 		BRect GetDragRect(int32 clickedPoseIndex);
506 		BBitmap *MakeDragBitmap(BRect dragRect, BPoint clickedPoint, int32 clickedPoseIndex, BPoint &offset);
507 		static bool FindDragNDropAction(const BMessage *dragMessage, bool &canCopy,
508 			bool &canMove, bool &canLink, bool &canErase);
509 
510 		static bool CanTrashForeignDrag(const Model *);
511 		static bool CanCopyOrMoveForeignDrag(const Model *, const BMessage *);
512 		static bool DragSelectionContains(const BPose *target, const BMessage *dragMessage);
513 		static status_t CreateClippingFile(BPoseView *poseView, BFile &result,
514 			char *resultingName, BDirectory *dir, BMessage *message, const char *fallbackName,
515 			bool setLocation = false, BPoint dropPoint = BPoint(0, 0));
516 
517 		// opening files, lanunching
518 		void OpenSelectionCommon(BPose *, int32 *, bool);
519 			// used by OpenSelection and OpenSelectionUsing
520 		static void LaunchAppWithSelection(Model *, const BMessage *, bool checkTypes = true);
521 
522 		// node monitoring calls
523 		virtual bool EntryMoved(const BMessage *);
524 		virtual bool AttributeChanged(const BMessage *);
525 		virtual bool NoticeMetaMimeChanged(const BMessage *);
526 		virtual void MetaMimeChanged(const char *, const char *);
527 
528 		// click handling
529 		bool WasDoubleClick(const BPose *, BPoint);
530 		bool WasClickInPath(const BPose *, int32 index, BPoint) const;
531 		int32 WaitForMouseUpOrDrag(BPoint start);
532 
533 		// selection
534 		void SelectPosesListMode(BRect, BList **);
535 		void SelectPosesIconMode(BRect, BList **);
536 		void AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose *);
537 
538 		// view drawing
539 		void SynchronousUpdate(BRect, bool clip = false);
540 
541 		// scrolling
542 		void HandleAutoScroll();
543 		bool CheckAutoScroll(BPoint mouseLoc, bool shouldScroll, bool selectionScrolling = false);
544 
545 		// view extent handling
546 		void RecalcExtent();
547 		void AddToExtent(const BRect &);
548 		void ClearExtent();
549 		void RemoveFromExtent(const BRect &);
550 
551 		virtual void EditQueries();
552 		virtual void AddCountView();
553 
554 		void AddMimeType(const char *);
555 		void HandleAttrMenuItemSelected(BMessage *);
556 		void TryUpdatingBrokenLinks();
557 			// ran a little after a volume gets mounted
558 
559 		void MapToNewIconMode(BPose *, BPoint oldGrid, BPoint oldOffset);
560 		void ResetOrigin();
561 		void PinPointToValidRange(BPoint &);
562 			// used to ensure pose locations make sense after getting them
563 			// in pose info from attributes, etc.
564 
565 		void FinishPendingScroll(float &listViewScrollBy, BRect bounds);
566 			// utility call for CreatePoses
567 
568 		// background AddPoses task calls
569 		static status_t AddPosesTask(void *);
570 		virtual void AddPosesCompleted();
571 		bool IsValidAddPosesThread(thread_id) const;
572 
573 		// misc
574 		BList *GetDropPointList(BPoint dropPoint, BPoint startPoint, const PoseList *,
575 			bool sourceInListMode, bool dropOnGrid) const;
576 		void SendSelectionAsRefs(uint32 what, bool onlyQueries = false);
577 		void MoveListToTrash(BObjectList<entry_ref> *, bool selectNext, bool deleteDirectly);
578 		void Delete(BObjectList<entry_ref> *, bool selectNext, bool askUser);
579 		void Delete(const entry_ref &ref, bool selectNext, bool askUser);
580 		void RestoreItemsFromTrash(BObjectList<entry_ref> *, bool selectNext);
581 
582 		static bool ShouldIntegrateDesktop(const BVolume &volume);
583 
584 	private:
585 		void DrawOpenAnimation(BRect);
586 
587 		void MoveSelectionOrEntryToTrash(const entry_ref *ref, bool selectNext);
588 
589 	protected:
590 		BHScrollBar *fHScrollBar;
591 		BScrollBar *fVScrollBar;
592 		Model *fModel;
593 		BPose *fActivePose;
594 		BRect fExtent;
595 		// the following should probably be just member lists, not pointers
596 		PoseList *fPoseList;
597 		PoseList *fVSPoseList;
598 		PoseList *fSelectionList;
599 		BObjectList<BString> fMimeTypesInSelectionCache;
600 			// used for mime string based icon highliting during a drag
601 		BObjectList<Model> *fZombieList;
602 		PendingNodeMonitorCache pendingNodeMonitorCache;
603 		BObjectList<BColumn> *fColumnList;
604 		BObjectList<BString> *fMimeTypeList;
605 	  	bool fMimeTypeListIsDirty;
606 		BViewState *fViewState;
607 		bool fStateNeedsSaving;
608 		BCountView *fCountView;
609 		float fListElemHeight;
610 		float fIconPoseHeight;
611 		BRegion *fUpdateRegion;
612 		BPose *fDropTarget;
613 		bool fDropTargetWasSelected;
614 		BLooper *fSelectionHandler;
615 		BPoint fLastClickPt;
616 		bigtime_t fLastClickTime;
617 		const BPose *fLastClickedPose;
618 		BPoint fLastLeftTop;
619 		BRect fLastExtent;
620 		BTitleView *fTitleView;
621 		BRefFilter *fRefFilter;
622 		BPoint fGrid;
623 		BPoint fOffset;
624 		BPoint fHintLocation;
625 		float fAutoScrollInc;
626 		int32 fAutoScrollState;
627 		std::set<thread_id> fAddPosesThreads;
628 		bool fEraseWidgetBackground;
629 		const BPose *fSelectionPivotPose;
630 		const BPose *fRealPivotPose;
631 		BMessageRunner *fKeyRunner;
632 
633 		bool fSelectionVisible : 1;
634 		bool fMultipleSelection : 1;
635 		bool fDragEnabled : 1;
636 		bool fDropEnabled : 1;
637 		bool fSelectionRectEnabled : 1;
638 		bool fAlwaysAutoPlace : 1;
639 		bool fAllowPoseEditing : 1;
640 		bool fSelectionChangedHook : 1;	// get rid of this
641 		bool fSavePoseLocations : 1;
642 		bool fShowHideSelection : 1;
643 		bool fOkToMapIcons : 1;
644 		bool fEnsurePosesVisible : 1;
645 		bool fShouldAutoScroll : 1;
646 		bool fIsDesktopWindow : 1;
647 		bool fIsWatchingDateFormatChange : 1;
648 		bool fHasPosesInClipboard : 1;
649 
650 		BRect fStartFrame;
651 		BRect fSelectionRect;
652 
653 		static float fFontHeight;
654 		static font_height fFontInfo;
655 		static BFont fCurrentFont;
656 		static bigtime_t fLastKeyTime;
657 		static char fMatchString[B_FILE_NAME_LENGTH];
658 			// used for typeahead - should be replaced by a typeahead state
659 
660 		// TODO: Get rid of this.
661 		static _BWidthBuffer_ *fWidthBuf;
662 
663 		static OffscreenBitmap *fOffscreen;
664 
665 		typedef BView _inherited;
666 };
667 
668 
669 class BHScrollBar : public BScrollBar {
670 	public:
671 		BHScrollBar(BRect, const char *, BView *);
672 		void SetTitleView(BView *);
673 
674 		// BScrollBar overrides
675 		virtual	void ValueChanged(float);
676 
677 	private:
678 		BView *fTitleView;
679 
680 		typedef BScrollBar _inherited;
681 };
682 
683 
684 class TPoseViewFilter : public BMessageFilter {
685 	public:
686 		TPoseViewFilter(BPoseView *pose);
687 		~TPoseViewFilter();
688 
689 		filter_result Filter(BMessage *, BHandler **);
690 
691 	private:
692 		filter_result ObjectDropFilter(BMessage *, BHandler **);
693 
694 		BPoseView *fPoseView;
695 };
696 
697 
698 extern bool
699 ClearViewOriginOne(const char *name, uint32 type, off_t size, void *data, void *params);
700 
701 // inlines follow
702 
703 inline BContainerWindow *
704 BPoseView::ContainerWindow() const
705 {
706 	return dynamic_cast<BContainerWindow *>(Window());
707 }
708 
709 inline Model *
710 BPoseView::TargetModel() const
711 {
712 	return fModel;
713 }
714 
715 inline float
716 BPoseView::ListElemHeight() const
717 {
718 	return fListElemHeight;
719 }
720 
721 inline float
722 BPoseView::IconPoseHeight() const
723 {
724 	return fIconPoseHeight;
725 }
726 
727 inline PoseList *
728 BPoseView::SelectionList() const
729 {
730 	return fSelectionList;
731 }
732 
733 inline BObjectList<BString> *
734 BPoseView::MimeTypesInSelection()
735 {
736 	return &fMimeTypesInSelectionCache;
737 }
738 
739 inline BHScrollBar*
740 BPoseView::HScrollBar() const
741 {
742 	return fHScrollBar;
743 }
744 
745 inline BScrollBar*
746 BPoseView::VScrollBar() const
747 {
748 	return fVScrollBar;
749 }
750 
751 inline bool
752 BPoseView::StateNeedsSaving()
753 {
754 	return fStateNeedsSaving || fViewState->StateNeedsSaving();
755 }
756 
757 inline uint32
758 BPoseView::ViewMode() const
759 {
760 	return fViewState->ViewMode();
761 }
762 
763 inline font_height
764 BPoseView::FontInfo() const
765 {
766 	return fFontInfo;
767 }
768 
769 inline float
770 BPoseView::FontHeight() const
771 {
772 	return fFontHeight;
773 }
774 
775 inline BPose *
776 BPoseView::ActivePose() const
777 {
778 	return fActivePose;
779 }
780 
781 inline void
782 BPoseView::DisableSaveLocation()
783 {
784 	fSavePoseLocations = false;
785 }
786 
787 inline bool
788 BPoseView::IsFilePanel() const
789 {
790 	return false;
791 }
792 
793 inline bool
794 BPoseView::IsDesktopWindow() const
795 {
796 	return fIsDesktopWindow;
797 }
798 
799 inline bool
800 BPoseView::IsDesktopView() const
801 {
802 	return false;
803 }
804 
805 inline uint32
806 BPoseView::PrimarySort() const
807 {
808 	return fViewState->PrimarySort();
809 }
810 
811 inline uint32
812 BPoseView::PrimarySortType() const
813 {
814 	return fViewState->PrimarySortType();
815 }
816 
817 inline uint32
818 BPoseView::SecondarySort() const
819 {
820 	return fViewState->SecondarySort();
821 }
822 
823 inline uint32
824 BPoseView::SecondarySortType() const
825 {
826 	return fViewState->SecondarySortType();
827 }
828 
829 inline bool
830 BPoseView::ReverseSort() const
831 {
832 	return fViewState->ReverseSort();
833 }
834 
835 inline void
836 BPoseView::SetShowHideSelection(bool on)
837 {
838 	fShowHideSelection = on;
839 }
840 
841 inline void
842 BPoseView::SetIconMapping(bool on)
843 {
844 	fOkToMapIcons = on;
845 }
846 
847 inline void
848 BPoseView::AddToExtent(const BRect &rect)
849 {
850 	fExtent = fExtent | rect;
851 }
852 
853 inline void
854 BPoseView::ClearExtent()
855 {
856 	fExtent.Set(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN);
857 }
858 
859 inline int32
860 BPoseView::CountColumns() const
861 {
862 	return fColumnList->CountItems();
863 }
864 
865 inline int32
866 BPoseView::IndexOfColumn(const BColumn* column) const
867 {
868 	return fColumnList->IndexOf(const_cast<BColumn *>(column));
869 }
870 
871 inline int32
872 BPoseView::IndexOfPose(const BPose *pose) const
873 {
874 	return fPoseList->IndexOf(pose);
875 }
876 
877 inline BPose *
878 BPoseView::PoseAtIndex(int32 index) const
879 {
880 	return fPoseList->ItemAt(index);
881 }
882 
883 inline BColumn *
884 BPoseView::ColumnAt(int32 index) const
885 {
886 	return fColumnList->ItemAt(index);
887 }
888 
889 inline BColumn *
890 BPoseView::FirstColumn() const
891 {
892 	return fColumnList->FirstItem();
893 }
894 
895 inline BColumn *
896 BPoseView::LastColumn() const
897 {
898 	return fColumnList->LastItem();
899 }
900 
901 inline int32
902 BPoseView::CountItems() const
903 {
904 	return fPoseList->CountItems();
905 }
906 
907 inline void
908 BPoseView::SetMultipleSelection(bool state)
909 {
910 	fMultipleSelection = state;
911 }
912 
913 inline void
914 BPoseView::SetSelectionChangedHook(bool state)
915 {
916 	fSelectionChangedHook = state;
917 }
918 
919 inline void
920 BPoseView::SetAutoScroll(bool state)
921 {
922 	fShouldAutoScroll = state;
923 }
924 
925 inline void
926 BPoseView::SetPoseEditing(bool state)
927 {
928 	fAllowPoseEditing = state;
929 }
930 
931 inline void
932 BPoseView::SetDragEnabled(bool state)
933 {
934 	fDragEnabled = state;
935 }
936 
937 inline void
938 BPoseView::SetDropEnabled(bool state)
939 {
940 	fDropEnabled = state;
941 }
942 
943 inline void
944 BPoseView::SetSelectionRectEnabled(bool state)
945 {
946 	fSelectionRectEnabled = state;
947 }
948 
949 inline void
950 BPoseView::SetAlwaysAutoPlace(bool state)
951 {
952 	fAlwaysAutoPlace = state;
953 }
954 
955 inline void
956 BPoseView::SetEnsurePosesVisible(bool state)
957 {
958 	fEnsurePosesVisible = state;
959 }
960 
961 inline void
962 BPoseView::SetSelectionHandler(BLooper *looper)
963 {
964 	fSelectionHandler = looper;
965 }
966 
967 inline void
968 BPoseView::SetRefFilter(BRefFilter *filter)
969 {
970 	fRefFilter = filter;
971 }
972 
973 inline BRefFilter *
974 BPoseView::RefFilter() const
975 {
976 	return fRefFilter;
977 }
978 
979 inline void
980 BHScrollBar::SetTitleView(BView *view)
981 {
982 	fTitleView = view;
983 }
984 
985 inline BPose *
986 BPoseView::FindPose(const Model *model, int32 *index) const
987 {
988 	return fPoseList->FindPose(model, index);
989 }
990 
991 inline BPose *
992 BPoseView::FindPose(const node_ref *node, int32 *index) const
993 {
994 	return fPoseList->FindPose(node, index);
995 }
996 
997 inline BPose *
998 BPoseView::FindPose(const entry_ref *entry, int32 *index) const
999 {
1000 	return fPoseList->FindPose(entry, index);
1001 }
1002 
1003 
1004 } // namespace BPrivate
1005 
1006 using namespace BPrivate;
1007 
1008 #endif	/* _POSE_VIEW_H */
1009