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.
38 // BPoseView is a container for poses, handling all of the interaction, drawing,
39 // etc. The three different view modes are handled here.
41 // this is by far the fattest Tracker class and over time will undergo a lot of
45 #include "AttributeStream.h"
46 #include "ContainerWindow.h"
48 #include "PendingNodeMonitorCache.h"
50 #include "TitleView.h"
51 #include "Utilities.h"
52 #include "ViewState.h"
54 #include <Directory.h>
55 #include <FilePanel.h>
56 #include <MessageRunner.h>
58 #include <ScrollBar.h>
73 struct std::hash
<node_ref
>
77 operator()(node_ref ref
) const
83 } // namespace __gnu_cxx
84 typedef __gnu_cxx::hash_set
<node_ref
, __gnu_cxx::hash
<node_ref
> > NodeSet
;
86 typedef std::hash_set
<node_ref
, std::hash
<node_ref
> > NodeSet
;
93 class BContainerWindow
;
98 const int32 kSmallStep
= 10;
99 const int32 kListOffset
= 20;
101 const uint32 kMiniIconMode
= 'Tmic';
102 const uint32 kIconMode
= 'Ticn';
103 const uint32 kListMode
= 'Tlst';
105 const uint32 kCheckTypeahead
= 'Tcty';
107 class BPoseView
: public BView
{
109 BPoseView(Model
*, uint32 viewMode
);
110 virtual ~BPoseView();
113 virtual void Init(AttributeStreamNode
*);
114 virtual void Init(const BMessage
&);
116 virtual void DetachedFromWindow();
118 // Returns true if for instance, node ref is a remote desktop
119 // directory and this is a desktop pose view.
120 virtual bool Represents(const node_ref
*) const;
121 virtual bool Represents(const entry_ref
*) const;
123 BContainerWindow
* ContainerWindow() const;
124 const char* ViewStateAttributeName() const;
125 const char* ForeignViewStateAttributeName() const;
126 Model
* TargetModel() const;
128 virtual bool IsFilePanel() const;
129 bool IsDesktopWindow() const;
130 virtual bool IsDesktopView() const;
132 // state saving/restoring
133 virtual void SaveState(AttributeStreamNode
* node
);
134 virtual void RestoreState(AttributeStreamNode
*);
135 virtual void RestoreColumnState(AttributeStreamNode
*);
136 void AddColumnList(BObjectList
<BColumn
>*list
);
137 virtual void SaveColumnState(AttributeStreamNode
*);
138 virtual void SavePoseLocations(BRect
* frameIfDesktop
= NULL
);
139 void DisableSaveLocation();
141 virtual void SaveState(BMessage
&) const;
142 virtual void RestoreState(const BMessage
&);
143 virtual void RestoreColumnState(const BMessage
&);
144 virtual void SaveColumnState(BMessage
&) const;
146 bool StateNeedsSaving();
148 // switch between mini icon mode, icon mode and list mode
149 virtual void SetViewMode(uint32 mode
);
150 uint32
ViewMode() const;
152 // re-use the pose view for a new directory
153 virtual void SwitchDir(const entry_ref
*,
154 AttributeStreamNode
* node
= NULL
);
156 // in the rare cases where a pose view needs to be explicitly
157 // refreshed (for instance in a query window with a dynamic
158 // date query), this is used
159 virtual void Refresh();
162 virtual void MessageReceived(BMessage
* message
);
163 virtual void AttachedToWindow();
164 virtual void WindowActivated(bool active
);
165 virtual void MakeFocus(bool = true);
166 virtual BSize
MinSize();
167 virtual void Draw(BRect update_rect
);
168 virtual void DrawAfterChildren(BRect update_rect
);
169 virtual void MouseMoved(BPoint
, uint32
, const BMessage
*);
170 virtual void MouseDown(BPoint where
);
171 virtual void MouseUp(BPoint where
);
172 virtual void MouseDragged(const BMessage
*);
173 virtual void MouseLongDown(const BMessage
*);
174 virtual void MouseIdle(const BMessage
*);
175 virtual void KeyDown(const char*, int32
);
176 virtual void Pulse();
177 virtual void ScrollTo(BPoint
);
179 // misc. mode setters
180 void SetMultipleSelection(bool);
181 void SetDragEnabled(bool);
182 void SetDropEnabled(bool);
183 void SetSelectionRectEnabled(bool);
184 void SetAlwaysAutoPlace(bool);
185 void SetSelectionChangedHook(bool);
186 void SetShowHideSelection(bool);
187 void SetEnsurePosesVisible(bool);
188 void SetIconMapping(bool);
189 void SetAutoScroll(bool);
190 void SetPoseEditing(bool);
192 void UpdateIcon(BPose
* pose
);
194 // file change notification handler
195 virtual bool FSNotification(const BMessage
*);
198 virtual void UpdateScrollRange();
199 virtual void SetScrollBarsTo(BPoint
);
200 virtual void AddScrollBars();
201 BScrollBar
* HScrollBar() const;
202 BScrollBar
* VScrollBar() const ;
203 BCountView
* CountView() const;
204 BTitleView
* TitleView() const;
205 void DisableScrollBars();
206 void EnableScrollBars();
209 virtual void SortPoses();
210 void SetPrimarySort(uint32 attrHash
);
211 void SetSecondarySort(uint32 attrHash
);
212 void SetReverseSort(bool reverse
);
213 uint32
PrimarySort() const;
214 uint32
PrimarySortType() const;
215 uint32
SecondarySort() const;
216 uint32
SecondarySortType() const;
217 bool ReverseSort() const;
218 void CheckPoseSortOrder(BPose
*, int32 index
);
219 void CheckPoseVisibility(BRect
* = NULL
);
220 // make sure pose fits the screen and/or window bounds if needed
223 font_height
FontInfo() const;
224 // returns height, descent, etc.
225 float FontHeight() const;
226 float ListElemHeight() const;
227 void SetListElemHeight();
229 void SetIconPoseHeight();
230 float IconPoseHeight() const;
231 uint32
IconSizeInt() const;
232 icon_size
IconSize() const;
234 BRect
Extent() const;
235 void GetLayoutInfo(uint32 viewMode
, BPoint
* grid
,
236 BPoint
* offset
) const;
238 int32
CountItems() const;
241 rgb_color
DeskTextColor() const;
242 rgb_color
DeskTextBackColor() const;
244 bool WidgetTextOutline() const;
245 void SetWidgetTextOutline(bool);
246 // used to not erase when we have a background image and
247 // invalidate instead
249 void ScrollView(int32 type
);
252 void ColumnRedraw(BRect updateRect
);
253 bool AddColumn(BColumn
*, const BColumn
* after
= NULL
);
254 bool RemoveColumn(BColumn
* column
, bool runAlert
);
255 void MoveColumnTo(BColumn
* src
, BColumn
* dest
);
256 bool ResizeColumnToWidest(BColumn
* column
);
257 BPoint
ResizeColumn(BColumn
*, float, float* lastLineDrawPos
= NULL
,
258 void (*drawLineFunc
)(BPoseView
*, BPoint
, BPoint
) = 0,
259 void (*undrawLineFunc
)(BPoseView
*, BPoint
, BPoint
) = 0);
260 // returns the bottom right of the last pose drawn or
261 // the bottom right of bounds
263 BColumn
* ColumnAt(int32 index
) const;
264 BColumn
* ColumnFor(uint32 attribute_hash
) const;
265 BColumn
* FirstColumn() const;
266 BColumn
* LastColumn() const;
267 int32
IndexOfColumn(const BColumn
*) const;
268 int32
CountColumns() const;
270 // Where to start the first column
271 float StartOffset() const;
274 int32
IndexOfPose(const BPose
*) const;
275 BPose
* PoseAtIndex(int32 index
) const;
277 BPose
* FindPose(BPoint where
, int32
* index
= NULL
) const;
278 // return pose at location h, v (search list starting from
279 // bottom so drawing and hit detection reflect the same pose
281 BPose
* FindPose(const Model
*, int32
* index
= NULL
) const;
282 BPose
* FindPose(const node_ref
*, int32
* index
= NULL
) const;
283 BPose
* FindPose(const entry_ref
*, int32
* index
= NULL
) const;
284 BPose
* FindPose(const entry_ref
*, int32 specifierForm
,
286 // special form of FindPose used for scripting,
287 // <specifierForm> may ask for previous or next pose
288 BPose
* DeepFindPose(const node_ref
* node
, int32
* index
= NULL
) const;
289 // same as FindPose, node can be a target of the actual
290 // pose if the pose is a symlink
291 BPose
* FirstVisiblePose(int32
* _index
= NULL
) const;
292 BPose
* LastVisiblePose(int32
* _index
= NULL
) const;
294 void OpenInfoWindows();
295 void SetDefaultPrinter();
297 void IdentifySelection(bool force
= false);
298 void UnmountSelectedVolumes();
299 virtual void OpenParent();
301 virtual void OpenSelection(BPose
* clicked_pose
= NULL
,
302 int32
* index
= NULL
);
303 void OpenSelectionUsing(BPose
* clicked_pose
= NULL
,
304 int32
* index
= NULL
);
305 // launches the open with window
306 virtual void MoveSelectionTo(BPoint
, BPoint
, BContainerWindow
*);
307 void DuplicateSelection(BPoint
* dropStart
= NULL
,
308 BPoint
* dropEnd
= NULL
);
310 // Move to trash calls try to select the next pose in the view
311 // when they are dones
312 virtual void MoveSelectionToTrash(bool selectNext
= true);
313 virtual void DeleteSelection(bool selectNext
= true,
314 bool askUser
= true);
315 virtual void MoveEntryToTrash(const entry_ref
*,
316 bool selectNext
= true);
318 void RestoreSelectionFromTrash(bool selectNext
= true);
321 PoseList
* SelectionList() const;
323 void InvertSelection();
324 int32
SelectMatchingEntries(const BMessage
*);
325 void ShowSelectionWindow();
326 void ClearSelection();
327 void ShowSelection(bool);
328 void AddRemovePoseFromSelection(BPose
* pose
, int32 index
,
331 BLooper
* SelectionHandler();
332 void SetSelectionHandler(BLooper
*);
334 BObjectList
<BString
>*MimeTypesInSelection();
337 void SelectPose(BPose
*, int32 index
, bool scrollIntoView
= true);
338 void AddPoseToSelection(BPose
*, int32 index
,
339 bool scrollIntoView
= true);
340 void RemovePoseFromSelection(BPose
*);
341 void SelectPoseAtLocation(BPoint
);
342 void SelectPoses(int32 start
, int32 end
);
343 void MoveOrChangePoseSelection(int32 to
);
346 void ScrollIntoView(BPose
* pose
, int32 index
);
347 void ScrollIntoView(BRect poseRect
);
348 void SetActivePose(BPose
*);
349 BPose
* ActivePose() const;
350 void CommitActivePose(bool saveChanges
= true);
351 static bool PoseVisible(const Model
*, const PoseInfo
*);
352 bool FrameForPose(BPose
* targetPose
, bool convert
, BRect
* poseRect
);
353 bool CreateSymlinkPoseTarget(Model
* symlink
);
354 // used to complete a symlink pose; returns true if
355 // target symlink should not be shown
356 void ResetPosePlacementHint();
357 void PlaceFolder(const entry_ref
*, const BMessage
*);
359 // clipboard handling for poses
360 inline bool HasPosesInClipboard();
361 inline void SetHasPosesInClipboard(bool hasPoses
);
362 void SetPosesClipboardMode(uint32 clipboardMode
);
363 void UpdatePosesClipboardModeFromClipboard(
364 BMessage
* clipboardReport
= NULL
);
367 void SetRefFilter(BRefFilter
*);
368 BRefFilter
* RefFilter() const;
370 // access for mime types represented in the pose view
371 void AddMimeType(const char* mimeType
);
372 const char* MimeTypeAt(int32 index
);
373 int32
CountMimeTypes();
374 void RefreshMimeTypeList();
376 // drag&drop handling
377 virtual bool HandleMessageDropped(BMessage
*);
378 static bool HandleDropCommon(BMessage
* dragMessage
, Model
* target
,
379 BPose
*, BView
* view
, BPoint dropPoint
);
380 // used by pose views and info windows
381 static bool CanHandleDragSelection(const Model
* target
,
382 const BMessage
* dragMessage
, bool ignoreTypes
);
383 virtual void DragSelectedPoses(const BPose
* clickedPose
, BPoint
);
385 void MoveSelectionInto(Model
* destFolder
, BContainerWindow
* srcWindow
,
386 bool forceCopy
, bool forceMove
= false, bool createLink
= false,
387 bool relativeLink
= false);
388 static void MoveSelectionInto(Model
* destFolder
,
389 BContainerWindow
* srcWindow
, BContainerWindow
* destWindow
,
390 uint32 buttons
, BPoint loc
, bool forceCopy
,
391 bool forceMove
= false, bool createLink
= false,
392 bool relativeLink
= false, BPoint clickPoint
= BPoint(0, 0),
393 bool pinToGrid
= false);
395 bool UpdateDropTarget(BPoint
, const BMessage
*,
396 bool trackingContextMenu
);
397 // return true if drop target changed
398 void HiliteDropTarget(bool hiliteState
);
401 // throw away cached up structures
403 static bool MenuTrackingHook(BMenu
* menu
, void* castToThis
);
404 // hook for spring loaded nav-menus
407 virtual BHandler
* ResolveSpecifier(BMessage
* message
, int32 index
,
408 BMessage
* specifier
, int32 form
, const char* property
);
409 virtual status_t
GetSupportedSuites(BMessage
*);
411 // string width calls that use local width caches, faster than using
412 // the general purpose BView::StringWidth
413 float StringWidth(const char*) const;
414 float StringWidth(const char*, int32
) const;
415 // deliberately hide the BView StringWidth here - this makes it
416 // easy to have the right StringWidth picked up by
417 // template instantiation, as used by WidgetAttributeText
419 // show/hide barberpole while a background task is filling
421 void ShowBarberPole();
422 void HideBarberPole();
424 bool fShowSelectionWhenInactive
;
425 bool fTransparentSelection
;
426 bool fIsDrawingSelectionRect
;
428 bool IsWatchingDateFormatChange();
429 void StartWatchDateFormatChange();
430 void StopWatchDateFormatChange();
432 // type ahead filtering
433 bool IsFiltering() const;
435 void UpdateDateColumns(BMessage
*);
436 virtual void AdaptToVolumeChange(BMessage
*);
437 virtual void AdaptToDesktopIntegrationChange(BMessage
*);
439 void SetTextWidgetToCheck(BTextWidget
*, BTextWidget
* = NULL
);
443 virtual void SetUpDefaultColumnsIfNeeded();
445 virtual EntryListBase
* InitDirentIterator(const entry_ref
*);
446 // sets up an entry iterator for _add_poses_
447 // overriden by QueryPoseView, etc. to provide different iteration
448 virtual void ReturnDirentIterator(EntryListBase
* iterator
);
449 // returns the entry iterator after _add_poses_ is done
451 void Cleanup(bool doAll
= false);
453 void NewFolder(const BMessage
*);
454 // create a new folder, optionally specify a location
456 void NewFileFromTemplate(const BMessage
*);
457 // create a new file based on a template, optionally specify
460 void ShowContextMenu(BPoint
);
462 // scripting handlers
463 virtual bool HandleScriptingMessage(BMessage
* message
);
464 bool SetProperty(BMessage
* message
, BMessage
* specifier
, int32 form
,
465 const char* property
, BMessage
* reply
);
466 bool GetProperty(BMessage
*, int32
, const char*, BMessage
*);
467 bool CreateProperty(BMessage
* message
, BMessage
* specifier
, int32
,
468 const char*, BMessage
* reply
);
469 bool ExecuteProperty(BMessage
* specifier
, int32
, const char*,
471 bool CountProperty(BMessage
*, int32
, const char*, BMessage
*);
472 bool DeleteProperty(BMessage
*, int32
, const char*, BMessage
*);
475 // remove all the current poses from the view
477 // pose info read/write calls
478 void ReadPoseInfo(Model
*, PoseInfo
*);
479 ExtendedPoseInfo
* ReadExtendedPoseInfo(Model
*);
481 void _CheckPoseSortOrder(PoseList
* list
, BPose
*, int32 index
);
484 BPose
* EntryCreated(const node_ref
*, const node_ref
*, const char*,
487 void AddPoseToList(PoseList
* list
, bool visibleList
,
488 bool insertionSort
, BPose
* pose
, BRect
&viewBounds
,
489 float& listViewScrollBy
, bool forceDraw
, int32
* indexPtr
= NULL
);
490 BPose
* CreatePose(Model
*, PoseInfo
*, bool insertionSort
= true,
491 int32
* index
= 0, BRect
* boundsPointer
= 0, bool forceDraw
= true);
492 virtual void CreatePoses(Model
**models
, PoseInfo
* poseInfoArray
,
493 int32 count
, BPose
** resultingPoses
, bool insertionSort
= true,
494 int32
* lastPoseIndexPointer
= 0, BRect
* boundsPointer
= 0,
495 bool forceDraw
= false);
496 virtual bool ShouldShowPose(const Model
*, const PoseInfo
*);
497 // filter, subclasses override to control which poses show up
498 // subclasses should always call inherited
499 void CreateVolumePose(BVolume
*, bool watchIndividually
);
501 void CreateTrashPose();
503 virtual bool AddPosesThreadValid(const entry_ref
*) const;
504 // verifies whether or not the current set of AddPoses threads
505 // are valid and allowed to be adding poses -- returns false
506 // in the case where the directory has been switched while
507 // populating the view
509 virtual void AddPoses(Model
* model
= NULL
);
510 // if <model> is zero, PoseView has other means of iterating
511 // through all the entries thaat it adds
513 virtual void AddRootPoses(bool watchIndividually
, bool mountShared
);
514 // watchIndividually is used when placing a volume pose onto
515 // the Desktop where unlike in the Root window it will not be
516 // watched by the folder representing root. If set, each volume
517 // will therefore be watched individually
518 virtual void RemoveRootPoses();
519 virtual void AddTrashPoses();
521 virtual bool DeletePose(const node_ref
*, BPose
* pose
= NULL
,
523 virtual void DeleteSymLinkPoseTarget(const node_ref
* itemNode
,
524 BPose
* pose
, int32 index
);
525 // the pose itself wasn't deleted but it's target node was - the
526 // pose must be a symlink
527 static void PoseHandleDeviceUnmounted(BPose
* pose
, Model
* model
,
528 int32 index
, BPoseView
* poseView
, dev_t device
);
529 static void RemoveNonBootDesktopModels(BPose
*, Model
* model
, int32
,
530 BPoseView
* poseView
, dev_t
);
533 void CheckAutoPlacedPoses();
534 // find poses that need placing and place them in a new spot
535 void PlacePose(BPose
*, BRect
&);
536 // find a new place for a pose, starting at fHintLocation
538 bool IsValidLocation(const BPose
* pose
);
539 bool IsValidLocation(const BRect
& rect
);
540 status_t
GetDeskbarFrame(BRect
* frame
);
541 bool SlotOccupied(BRect poseRect
, BRect viewBounds
) const;
542 void NextSlot(BPose
*, BRect
&poseRect
, BRect viewBounds
);
543 void TrySettingPoseLocation(BNode
* node
, BPoint point
);
544 BPoint
PinToGrid(BPoint
, BPoint grid
, BPoint offset
) const;
546 // zombie pose handling
547 Model
* FindZombie(const node_ref
*, int32
* index
= 0);
548 BPose
* ConvertZombieToPose(Model
* zombie
, int32 index
);
551 BRect
CalcPoseRect(const BPose
*, int32 index
,
552 bool firstColumnOnly
= false) const;
553 BRect
CalcPoseRectIcon(const BPose
*) const;
554 BRect
CalcPoseRectList(const BPose
*, int32 index
,
555 bool firstColumnOnly
= false) const;
556 void DrawPose(BPose
*, int32 index
, bool fullDraw
= true);
557 void DrawViewCommon(const BRect
&updateRect
);
559 // pose list handling
560 int32
BSearchList(PoseList
* poseList
, const BPose
*, int32
* index
,
562 void InsertPoseAfter(BPose
* pose
, int32
* index
, int32 orientation
,
564 // does a CopyBits to scroll poses making room for a new pose,
565 // returns rectangle that needs invalidating
566 void CloseGapInList(BRect
* invalidRect
);
567 int32
FirstIndexAtOrBelow(int32 y
, bool constrainIndex
= true) const;
568 void AddToVSList(BPose
*);
569 int32
RemoveFromVSList(const BPose
*);
570 BPose
* FindNearbyPose(char arrow
, int32
* index
);
571 BPose
* FindBestMatch(int32
* index
);
572 BPose
* FindNextMatch(int32
* index
, bool reverse
= false);
574 // node monitoring calls
575 virtual void StartWatching();
576 virtual void StopWatching();
578 status_t
WatchNewNode(const node_ref
* item
);
579 // the above would ideally be the only call of these three and
580 // it would be a virtual, overriding the specific watch mask in
581 // query pose view, etc. however we need to call WatchNewNode
582 // from inside AddPosesTask while the window is unlocked - we
583 // have to use the static and a cached messenger and masks.
584 static status_t
WatchNewNode(const node_ref
*, uint32
, BMessenger
);
585 virtual uint32
WatchNewNodeMask();
586 // override to change different watch modes for query pose
589 // drag&drop handling
590 static bool EachItemInDraggedSelection(const BMessage
* message
,
591 bool (*)(BPose
*, BPoseView
*, void*), BPoseView
* poseView
,
593 // iterates through each pose in current selectiond in the source
594 // window of the current drag message; locks the window
596 BRect
GetDragRect(int32 clickedPoseIndex
);
597 BBitmap
* MakeDragBitmap(BRect dragRect
, BPoint clickedPoint
,
598 int32 clickedPoseIndex
, BPoint
&offset
);
599 static bool FindDragNDropAction(const BMessage
* dragMessage
,
600 bool&canCopy
, bool&canMove
, bool&canLink
, bool&canErase
);
602 static bool CanTrashForeignDrag(const Model
*);
603 static bool CanCopyOrMoveForeignDrag(const Model
*, const BMessage
*);
604 static bool DragSelectionContains(const BPose
* target
,
605 const BMessage
* dragMessage
);
606 static status_t
CreateClippingFile(BPoseView
* poseView
, BFile
&result
,
607 char* resultingName
, BDirectory
* directory
, BMessage
* message
,
608 const char* fallbackName
, bool setLocation
= false,
609 BPoint dropPoint
= BPoint(0, 0));
611 // opening files, lanunching
612 void OpenSelectionCommon(BPose
*, int32
*, bool);
613 // used by OpenSelection and OpenSelectionUsing
614 static void LaunchAppWithSelection(Model
*, const BMessage
*,
615 bool checkTypes
= true);
617 // node monitoring calls
618 virtual bool EntryMoved(const BMessage
*);
619 virtual bool AttributeChanged(const BMessage
*);
620 virtual bool NoticeMetaMimeChanged(const BMessage
*);
621 virtual void MetaMimeChanged(const char*, const char*);
624 bool WasDoubleClick(const BPose
*, BPoint point
, int32 buttons
);
625 bool WasClickInPath(const BPose
*, int32 index
,
626 BPoint mouseLocation
) const;
629 void SelectPosesListMode(BRect
, BList
**);
630 void SelectPosesIconMode(BRect
, BList
**);
631 void AddRemoveSelectionRange(BPoint where
, bool extendSelection
,
634 void _BeginSelectionRect(const BPoint
& point
, bool extendSelection
);
635 void _UpdateSelectionRect(const BPoint
& point
);
636 void _EndSelectionRect();
639 void SynchronousUpdate(BRect
, bool clip
= false);
642 void HandleAutoScroll();
643 bool CheckAutoScroll(BPoint mouseLoc
, bool shouldScroll
);
645 // view extent handling
647 void AddToExtent(const BRect
&);
649 void RemoveFromExtent(const BRect
&);
651 virtual void EditQueries();
653 void HandleAttrMenuItemSelected(BMessage
*);
654 void TryUpdatingBrokenLinks();
655 // ran a little after a volume gets mounted
657 void MapToNewIconMode(BPose
*, BPoint oldGrid
, BPoint oldOffset
);
659 void PinPointToValidRange(BPoint
&);
660 // used to ensure pose locations make sense after getting them
661 // in pose info from attributes, etc.
663 void FinishPendingScroll(float&listViewScrollBy
, BRect bounds
);
664 // utility call for CreatePoses
666 // background AddPoses task calls
667 static status_t
AddPosesTask(void*);
668 virtual void AddPosesCompleted();
669 bool IsValidAddPosesThread(thread_id
) const;
671 // typeahead filtering
672 void EnsurePoseUnselected(BPose
* pose
);
673 void RemoveFilteredPose(BPose
* pose
, int32 index
);
674 void FilterChanged();
675 void UpdateAfterFilterChange();
676 bool FilterPose(BPose
* pose
);
677 void StartFiltering();
678 void StopFiltering();
680 PoseList
* CurrentPoseList() const;
683 BList
* GetDropPointList(BPoint dropPoint
, BPoint startPoint
,
684 const PoseList
*, bool sourceInListMode
, bool dropOnGrid
) const;
685 void SendSelectionAsRefs(uint32 what
, bool onlyQueries
= false);
686 void MoveListToTrash(BObjectList
<entry_ref
>*, bool selectNext
,
687 bool deleteDirectly
);
688 void Delete(BObjectList
<entry_ref
>*, bool selectNext
, bool askUser
);
689 void Delete(const entry_ref
&ref
, bool selectNext
, bool askUser
);
690 void RestoreItemsFromTrash(BObjectList
<entry_ref
>*, bool selectNext
);
692 void WatchParentOf(const entry_ref
*);
693 void StopWatchingParentsOf(const entry_ref
*);
695 void ExcludeTrashFromSelection();
698 void DrawOpenAnimation(BRect
);
700 void MoveSelectionOrEntryToTrash(const entry_ref
* ref
, bool selectNext
);
703 TScrollBar
* fHScrollBar
;
704 BScrollBar
* fVScrollBar
;
708 // the following should probably be just member lists, not pointers
710 PoseList
* fFilteredPoseList
;
711 PoseList
* fVSPoseList
;
712 PoseList
* fSelectionList
;
713 NodeSet fInsertedNodes
;
714 BObjectList
<BString
> fMimeTypesInSelectionCache
;
715 // used for mime string based icon highliting during a drag
716 BObjectList
<Model
>* fZombieList
;
717 PendingNodeMonitorCache pendingNodeMonitorCache
;
718 BObjectList
<BColumn
>* fColumnList
;
719 BObjectList
<BString
>* fMimeTypeList
;
720 BObjectList
<Model
>* fBrokenLinks
;
721 bool fMimeTypeListIsDirty
;
722 BViewState
* fViewState
;
723 bool fStateNeedsSaving
;
724 BCountView
* fCountView
;
725 float fListElemHeight
;
726 float fIconPoseHeight
;
728 BPose
* fAlreadySelectedDropTarget
;
729 BLooper
* fSelectionHandler
;
730 BPoint fLastClickPoint
;
731 int32 fLastClickButtons
;
732 const BPose
* fLastClickedPose
;
735 BTitleView
* fTitleView
;
736 BRefFilter
* fRefFilter
;
739 BPoint fHintLocation
;
740 float fAutoScrollInc
;
741 int32 fAutoScrollState
;
742 std::set
<thread_id
> fAddPosesThreads
;
743 bool fWidgetTextOutline
;
744 const BPose
* fSelectionPivotPose
;
745 const BPose
* fRealPivotPose
;
746 BMessageRunner
* fKeyRunner
;
747 bool fTrackRightMouseUp
;
749 struct SelectionRectInfo
{
764 SelectionRectInfo fSelectionRectInfo
;
766 bool fSelectionVisible
: 1;
767 bool fMultipleSelection
: 1;
768 bool fDragEnabled
: 1;
769 bool fDropEnabled
: 1;
770 bool fSelectionRectEnabled
: 1;
771 bool fAlwaysAutoPlace
: 1;
772 bool fAllowPoseEditing
: 1;
773 bool fSelectionChangedHook
: 1;
775 bool fSavePoseLocations
: 1;
776 bool fShowHideSelection
: 1;
777 bool fOkToMapIcons
: 1;
778 bool fEnsurePosesVisible
: 1;
779 bool fShouldAutoScroll
: 1;
780 bool fIsDesktopWindow
: 1;
781 bool fIsWatchingDateFormatChange
: 1;
782 bool fHasPosesInClipboard
: 1;
783 bool fCursorCheck
: 1;
786 BObjectList
<BString
> fFilterStrings
;
787 int32 fLastFilterStringCount
;
788 int32 fLastFilterStringLength
;
792 static float sFontHeight
;
793 static font_height sFontInfo
;
794 static BFont sCurrentFont
;
795 static BString sMatchString
;
796 // used for typeahead - should be replaced by a typeahead state
798 bigtime_t fLastKeyTime
;
799 bigtime_t fLastDeskbarFrameCheckTime
;
802 static OffscreenBitmap
* sOffscreen
;
804 BTextWidget
* fTextWidgetToCheck
;
806 typedef BView _inherited
;
810 class TScrollBar
: public BScrollBar
{
812 TScrollBar(const char*, BView
*, float, float);
813 void SetTitleView(BView
*);
815 // BScrollBar overrides
816 virtual void ValueChanged(float);
821 typedef BScrollBar _inherited
;
825 class TPoseViewFilter
: public BMessageFilter
{
827 TPoseViewFilter(BPoseView
* pose
);
830 filter_result
Filter(BMessage
*, BHandler
**);
833 filter_result
ObjectDropFilter(BMessage
*, BHandler
**);
835 BPoseView
* fPoseView
;
840 ClearViewOriginOne(const char* name
, uint32 type
, off_t size
, void* data
,
847 inline BContainerWindow
*
848 BPoseView::ContainerWindow() const
850 return dynamic_cast<BContainerWindow
*>(Window());
855 BPoseView::TargetModel() const
862 BPoseView::ListElemHeight() const
864 return fListElemHeight
;
869 BPoseView::SetListElemHeight()
872 if (IconSize() > B_MINI_ICON
)
873 extra
= kLargeIconSeparator
;
875 fListElemHeight
= std::max((float)IconSize() + extra
,
876 ceilf(sFontHeight
) < 20 ? 20 : ceilf(sFontHeight
* 1.1f
));
881 BPoseView::IconPoseHeight() const
883 return fIconPoseHeight
;
888 BPoseView::IconSizeInt() const
890 return fViewState
->IconSize();
895 BPoseView::IconSize() const
897 return (icon_size
)fViewState
->IconSize();
902 BPoseView::SelectionList() const
904 return fSelectionList
;
908 inline BObjectList
<BString
>*
909 BPoseView::MimeTypesInSelection()
911 return &fMimeTypesInSelectionCache
;
916 BPoseView::HScrollBar() const
923 BPoseView::VScrollBar() const
930 BPoseView::CountView() const
937 BPoseView::TitleView() const
944 BPoseView::StateNeedsSaving()
946 return fStateNeedsSaving
|| fViewState
->StateNeedsSaving();
951 BPoseView::ViewMode() const
953 return fViewState
->ViewMode();
958 BPoseView::FontInfo() const
965 BPoseView::FontHeight() const
972 BPoseView::ActivePose() const
979 BPoseView::DisableSaveLocation()
981 fSavePoseLocations
= false;
986 BPoseView::IsFilePanel() const
993 BPoseView::IsDesktopWindow() const
995 return fIsDesktopWindow
;
1000 BPoseView::IsDesktopView() const
1007 BPoseView::PrimarySort() const
1009 return fViewState
->PrimarySort();
1014 BPoseView::PrimarySortType() const
1016 return fViewState
->PrimarySortType();
1021 BPoseView::SecondarySort() const
1023 return fViewState
->SecondarySort();
1028 BPoseView::SecondarySortType() const
1030 return fViewState
->SecondarySortType();
1035 BPoseView::ReverseSort() const
1037 return fViewState
->ReverseSort();
1042 BPoseView::SetShowHideSelection(bool on
)
1044 fShowHideSelection
= on
;
1049 BPoseView::SetIconMapping(bool on
)
1056 BPoseView::AddToExtent(const BRect
&rect
)
1058 fExtent
= fExtent
| rect
;
1063 BPoseView::ClearExtent()
1065 fExtent
.Set(INT32_MAX
, INT32_MAX
, INT32_MIN
, INT32_MIN
);
1070 BPoseView::CountColumns() const
1072 return fColumnList
->CountItems();
1077 BPoseView::StartOffset() const
1079 return kListOffset
+ IconSizeInt() + kMiniIconSeparator
+ 1;
1084 BPoseView::IndexOfColumn(const BColumn
* column
) const
1086 return fColumnList
->IndexOf(const_cast<BColumn
*>(column
));
1091 BPoseView::IndexOfPose(const BPose
* pose
) const
1093 return CurrentPoseList()->IndexOf(pose
);
1098 BPoseView::PoseAtIndex(int32 index
) const
1100 return CurrentPoseList()->ItemAt(index
);
1105 BPoseView::ColumnAt(int32 index
) const
1107 return fColumnList
->ItemAt(index
);
1112 BPoseView::FirstColumn() const
1114 return fColumnList
->FirstItem();
1119 BPoseView::LastColumn() const
1121 return fColumnList
->LastItem();
1126 BPoseView::CountItems() const
1128 return CurrentPoseList()->CountItems();
1133 BPoseView::SetMultipleSelection(bool state
)
1135 fMultipleSelection
= state
;
1140 BPoseView::SetSelectionChangedHook(bool state
)
1142 fSelectionChangedHook
= state
;
1147 BPoseView::SetAutoScroll(bool state
)
1149 fShouldAutoScroll
= state
;
1154 BPoseView::SetPoseEditing(bool state
)
1156 fAllowPoseEditing
= state
;
1161 BPoseView::SetDragEnabled(bool state
)
1163 fDragEnabled
= state
;
1168 BPoseView::SetDropEnabled(bool state
)
1170 fDropEnabled
= state
;
1175 BPoseView::SetSelectionRectEnabled(bool state
)
1177 fSelectionRectEnabled
= state
;
1182 BPoseView::SetAlwaysAutoPlace(bool state
)
1184 fAlwaysAutoPlace
= state
;
1189 BPoseView::SetEnsurePosesVisible(bool state
)
1191 fEnsurePosesVisible
= state
;
1196 BPoseView::SetSelectionHandler(BLooper
* looper
)
1198 fSelectionHandler
= looper
;
1203 TScrollBar::SetTitleView(BView
* view
)
1210 BPoseView::SetRefFilter(BRefFilter
* filter
)
1212 fRefFilter
= filter
;
1219 BPoseView::RefFilter() const
1226 BPoseView::FindPose(const Model
* model
, int32
* index
) const
1228 return CurrentPoseList()->FindPose(model
, index
);
1233 BPoseView::FindPose(const node_ref
* node
, int32
* index
) const
1235 return CurrentPoseList()->FindPose(node
, index
);
1240 BPoseView::FindPose(const entry_ref
* entry
, int32
* index
) const
1242 return CurrentPoseList()->FindPose(entry
, index
);
1247 BPoseView::HasPosesInClipboard()
1249 return fHasPosesInClipboard
;
1254 BPoseView::SetHasPosesInClipboard(bool hasPoses
)
1256 fHasPosesInClipboard
= hasPoses
;
1261 BPoseView::CurrentPoseList() const
1263 return fFiltering
? fFilteredPoseList
: fPoseList
;
1267 template<class Param1
>
1269 EachTextWidget(BPose
* pose
, BPoseView
* poseView
,
1270 void (*func
)(BTextWidget
*, BPose
*, BPoseView
*, BColumn
*, Param1
), Param1 p1
)
1272 for (int32 index
= 0; ;index
++) {
1273 BColumn
* column
= poseView
->ColumnAt(index
);
1277 BTextWidget
* widget
= pose
->WidgetFor(column
->AttrHash());
1279 (func
)(widget
, pose
, poseView
, column
, p1
);
1284 template<class Param1
, class Param2
>
1286 EachTextWidget(BPose
* pose
, BPoseView
* poseView
,
1287 void (*func
)(BTextWidget
*, BPose
*, BPoseView
*, BColumn
*,
1288 Param1
, Param2
), Param1 p1
, Param2 p2
)
1290 for (int32 index
= 0; ;index
++) {
1291 BColumn
* column
= poseView
->ColumnAt(index
);
1295 BTextWidget
* widget
= pose
->WidgetFor(column
->AttrHash());
1297 (func
)(widget
, pose
, poseView
, column
, p1
, p2
);
1302 template<class Result
, class Param1
, class Param2
>
1304 WhileEachTextWidget(BPose
* pose
, BPoseView
* poseView
,
1305 Result (*func
)(BTextWidget
*, BPose
*, BPoseView
*, BColumn
*,
1306 Param1
, Param2
), Param1 p1
, Param2 p2
)
1308 for (int32 index
= 0; ;index
++) {
1309 BColumn
* column
= poseView
->ColumnAt(index
);
1313 BTextWidget
* widget
= pose
->WidgetFor(column
->AttrHash());
1314 if (widget
!= NULL
) {
1315 Result result
= (func
)(widget
, pose
, poseView
, column
, p1
, p2
);
1325 } // namespace BPrivate
1327 using namespace BPrivate
;
1330 #endif // _POSE_VIEW_H