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
30 trademarks of Be Incorporated in the United States and other countries. Other
31 brand product names are registered trademarks or trademarks of their respective
39 #include <AppFileInfo.h>
42 #include <Directory.h>
43 #include <LocaleRoster.h>
51 #include "BarMenuBar.h"
52 #include "BarWindow.h"
53 #include "DeskbarMenu.h"
54 #include "DeskbarUtils.h"
55 #include "ExpandoMenuBar.h"
57 #include "InlineScrollView.h"
58 #include "ResourceSet.h"
59 #include "StatusView.h"
60 #include "TeamMenuItem.h"
63 const int32 kDefaultRecentDocCount
= 10;
64 const int32 kDefaultRecentFolderCount
= 10;
65 const int32 kDefaultRecentAppCount
= 10;
67 const int32 kMenuTrackMargin
= 20;
69 const uint32 kUpdateOrientation
= 'UpOr';
70 const float kSepItemWidth
= 5.0f
;
73 class BarViewMessageFilter
: public BMessageFilter
76 BarViewMessageFilter(TBarView
* barView
);
77 virtual ~BarViewMessageFilter();
79 virtual filter_result
Filter(BMessage
* message
, BHandler
** target
);
86 BarViewMessageFilter::BarViewMessageFilter(TBarView
* barView
)
88 BMessageFilter(B_ANY_DELIVERY
, B_ANY_SOURCE
),
94 BarViewMessageFilter::~BarViewMessageFilter()
100 BarViewMessageFilter::Filter(BMessage
* message
, BHandler
** target
)
102 if (message
->what
== B_MOUSE_DOWN
|| message
->what
== B_MOUSE_MOVED
) {
103 BPoint where
= message
->FindPoint("be:view_where");
104 uint32 transit
= message
->FindInt32("be:transit");
105 BMessage
* dragMessage
= NULL
;
106 if (message
->HasMessage("be:drag_message")) {
107 dragMessage
= new BMessage();
108 message
->FindMessage("be:drag_message", dragMessage
);
111 switch (message
->what
) {
113 fBarView
->MouseDown(where
);
117 fBarView
->MouseMoved(where
, transit
, dragMessage
);
124 return B_DISPATCH_MESSAGE
;
128 // #pragma mark - TBarView
131 TBarView::TBarView(BRect frame
, bool vertical
, bool left
, bool top
,
134 BView(frame
, "BarView", B_FOLLOW_ALL_SIDES
, B_WILL_DRAW
),
135 fBarApp(static_cast<TBarApp
*>(be_app
)),
136 fInlineScrollView(NULL
),
138 fExpandoMenuBar(NULL
),
146 fCachedTypesList(NULL
),
147 fMaxRecentDocs(kDefaultRecentDocCount
),
148 fMaxRecentApps(kDefaultRecentAppCount
),
152 // determine the initial Be menu size
153 BRect
menuFrame(frame
);
155 menuFrame
.bottom
= menuFrame
.top
+ kMenuBarHeight
;
157 menuFrame
.bottom
= menuFrame
.top
+ fBarApp
->IconSize() + 4;
159 // create and add the Be menu
160 fBarMenuBar
= new TBarMenuBar(menuFrame
, "BarMenuBar", this);
161 AddChild(fBarMenuBar
);
163 // create and add the status tray
164 fReplicantTray
= new TReplicantTray(this, fVertical
);
165 fDragRegion
= new TDragRegion(this, fReplicantTray
);
166 fDragRegion
->AddChild(fReplicantTray
);
167 if (fTrayLocation
!= 0)
168 AddChild(fDragRegion
);
170 // create and add the application menubar
171 fExpandoMenuBar
= new TExpandoMenuBar(this, fVertical
);
172 fInlineScrollView
= new TInlineScrollView(fExpandoMenuBar
,
173 fVertical
? B_VERTICAL
: B_HORIZONTAL
);
174 AddChild(fInlineScrollView
);
176 // If mini mode, hide the application menubar
177 if (state
== kMiniState
)
178 fInlineScrollView
->Hide();
182 TBarView::~TBarView()
185 delete fCachedTypesList
;
191 TBarView::AttachedToWindow()
193 BView::AttachedToWindow();
195 SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR
));
196 SetFont(be_plain_font
);
198 fMouseFilter
= new BarViewMessageFilter(this);
199 Window()->AddCommonFilter(fMouseFilter
);
201 fTrackingHookData
.fTrackingHook
= MenuTrackingHook
;
202 fTrackingHookData
.fTarget
= BMessenger(this);
203 fTrackingHookData
.fDragMessage
= new BMessage(B_REFS_RECEIVED
);
208 TBarView::DetachedFromWindow()
210 Window()->RemoveCommonFilter(fMouseFilter
);
213 delete fTrackingHookData
.fDragMessage
;
214 fTrackingHookData
.fDragMessage
= NULL
;
219 TBarView::Draw(BRect
)
221 BRect
bounds(Bounds());
223 rgb_color hilite
= tint_color(ViewColor(), B_DARKEN_1_TINT
);
225 SetHighColor(hilite
);
227 StrokeLine(bounds
.LeftBottom(), bounds
.RightBottom());
228 else if (AcrossBottom())
229 StrokeLine(bounds
.LeftTop(), bounds
.RightTop());
231 if (fVertical
&& fState
== kExpandoState
) {
232 SetHighColor(hilite
);
233 BRect
frame(fExpandoMenuBar
->Frame());
234 StrokeLine(BPoint(frame
.left
, frame
.top
- 1),
235 BPoint(frame
.right
, frame
.top
-1));
241 TBarView::MessageReceived(BMessage
* message
)
243 switch (message
->what
) {
244 case B_LOCALE_CHANGED
:
249 case kGetClockSettings
:
250 fReplicantTray
->MessageReceived(message
);
253 case B_REFS_RECEIVED
:
254 // received when an item is selected during DnD
255 // message is targeted here from Be menu
256 HandleDeskbarMenu(message
);
259 case B_ARCHIVED_OBJECT
:
261 // this message has been retargeted to here
262 // instead of directly to the replicant tray
263 // so that I can follow the common pathway
264 // for adding icons to the tray
266 if (AddItem(message
, B_DESKBAR_TRAY
, &id
) == B_OK
)
267 Looper()->DetachCurrentMessage();
271 case kUpdateOrientation
:
273 _ChangeState(message
);
278 BView::MessageReceived(message
);
284 TBarView::MouseMoved(BPoint where
, uint32 transit
, const BMessage
* dragMessage
)
286 if (fDragRegion
->IsDragging()) {
287 fDragRegion
->MouseMoved(where
, transit
, dragMessage
);
291 if (transit
== B_ENTERED_VIEW
&& EventMask() == 0)
292 SetEventMask(B_POINTER_EVENTS
, B_NO_POINTER_HISTORY
);
294 desk_settings
* settings
= fBarApp
->Settings();
295 bool alwaysOnTop
= settings
->alwaysOnTop
;
296 bool autoRaise
= settings
->autoRaise
;
297 bool autoHide
= settings
->autoHide
;
299 if (!autoRaise
&& !autoHide
) {
300 if (transit
== B_EXITED_VIEW
|| transit
== B_OUTSIDE_VIEW
)
305 bool isTopMost
= Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL
;
308 where
= ConvertToScreen(where
);
309 BRect screenFrame
= (BScreen(Window())).Frame();
310 if ((where
.x
== screenFrame
.left
|| where
.x
== screenFrame
.right
311 || where
.y
== screenFrame
.top
|| where
.y
== screenFrame
.bottom
)
312 && Window()->Frame().Contains(where
)) {
313 // cursor is on a screen edge within the window frame
315 if (!alwaysOnTop
&& autoRaise
&& !isTopMost
)
318 if (autoHide
&& IsHidden())
322 TBarWindow
* window
= (TBarWindow
*)Window();
323 if (window
->IsShowingMenu())
326 // cursor is not on screen edge
327 BRect preventHideArea
= Window()->Frame().InsetByCopy(
328 -kMaxPreventHidingDist
, -kMaxPreventHidingDist
);
330 if (preventHideArea
.Contains(where
))
333 // cursor to bar distance above threshold
334 if (!alwaysOnTop
&& autoRaise
&& isTopMost
) {
339 if (autoHide
&& !IsHidden())
346 TBarView::MouseDown(BPoint where
)
348 where
= ConvertToScreen(where
);
350 if (Window()->Frame().Contains(where
)) {
351 Window()->Activate();
353 if ((modifiers() & (B_CONTROL_KEY
| B_COMMAND_KEY
| B_OPTION_KEY
354 | B_SHIFT_KEY
)) == (B_CONTROL_KEY
| B_COMMAND_KEY
)) {
355 // The window key was pressed - enter dragging code
356 fDragRegion
->MouseDown(fDragRegion
->DragRegion().LeftTop());
360 // hide deskbar if required
361 desk_settings
* settings
= fBarApp
->Settings();
362 bool alwaysOnTop
= settings
->alwaysOnTop
;
363 bool autoRaise
= settings
->autoRaise
;
364 bool autoHide
= settings
->autoHide
;
365 bool isTopMost
= Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL
;
367 if (!alwaysOnTop
&& autoRaise
&& isTopMost
)
370 if (autoHide
&& !IsHidden())
377 TBarView::PlaceDeskbarMenu()
380 height
= fVertical
? kMenuBarHeight
: fBarApp
->IconSize() + 4;
382 BPoint
loc(B_ORIGIN
);
383 float width
= gMinimumWindowWidth
;
385 if (fState
== kFullState
) {
386 fBarMenuBar
->RemoveTeamMenu();
387 fBarMenuBar
->RemoveSeperatorItem();
388 loc
= Bounds().LeftTop();
389 } else if (fState
== kExpandoState
) {
390 fBarMenuBar
->RemoveTeamMenu();
392 // shows apps below tray
393 fBarMenuBar
->RemoveSeperatorItem();
396 // shows apps to the right of bemenu
397 fBarMenuBar
->AddSeparatorItem();
398 width
= floorf(width
) / 2 + kSepItemWidth
;
400 loc
= Bounds().LeftTop();
402 // mini mode, DeskbarMenu next to team menu
403 fBarMenuBar
->RemoveSeperatorItem();
404 fBarMenuBar
->AddTeamMenu();
407 fBarMenuBar
->SmartResize(width
, height
);
408 fBarMenuBar
->MoveTo(loc
);
413 TBarView::PlaceTray(bool vertSwap
, bool leftSwap
)
416 if (fState
== kFullState
) {
417 fDragRegion
->ResizeTo(fBarMenuBar
->Frame().Width(), kMenuBarHeight
);
418 statusLoc
.y
= fBarMenuBar
->Frame().bottom
+ 1;
420 fDragRegion
->MoveTo(statusLoc
);
422 if (!fReplicantTray
->IsHidden())
423 fReplicantTray
->Hide();
428 if (fReplicantTray
->IsHidden())
429 fReplicantTray
->Show();
431 if (fTrayLocation
!= 0) {
432 fReplicantTray
->SetMultiRow(fVertical
);
433 fReplicantTray
->RealignReplicants();
434 fDragRegion
->ResizeToPreferred();
437 statusLoc
.y
= fBarMenuBar
->Frame().bottom
+ 1;
439 if (fLeft
&& fVertical
)
440 fReplicantTray
->MoveTo(5, 2);
442 fReplicantTray
->MoveTo(2, 2);
444 BRect screenFrame
= (BScreen(Window())).Frame();
445 statusLoc
.x
= screenFrame
.right
- fDragRegion
->Bounds().Width();
449 fDragRegion
->MoveTo(statusLoc
);
455 TBarView::PlaceApplicationBar()
457 BRect screenFrame
= (BScreen(Window())).Frame();
458 if (fState
== kMiniState
) {
459 if (!fInlineScrollView
->IsHidden())
460 fInlineScrollView
->Hide();
461 SizeWindow(screenFrame
);
462 PositionWindow(screenFrame
);
463 Window()->UpdateIfNeeded();
468 if (fInlineScrollView
->IsHidden())
469 fInlineScrollView
->Show();
471 BRect
expandoFrame(0, 0, 0, 0);
474 expandoFrame
.top
= fTrayLocation
!= 0 ? fDragRegion
->Frame().bottom
+ 1
475 : fBarMenuBar
->Frame().bottom
+ 1;
476 expandoFrame
.left
= fDragRegion
->Frame().left
;
477 expandoFrame
.right
= expandoFrame
.left
+ gMinimumWindowWidth
;
478 expandoFrame
.bottom
= fState
== kFullState
? screenFrame
.bottom
479 : expandoFrame
.top
+ 1;
482 expandoFrame
.top
= 0;
483 expandoFrame
.bottom
= fBarApp
->IconSize() + 4;
485 if (fBarMenuBar
!= NULL
)
486 expandoFrame
.left
= fBarMenuBar
->Frame().Width() + 1;
488 if (fTrayLocation
!= 0 && fDragRegion
!= NULL
) {
489 expandoFrame
.right
= screenFrame
.Width()
490 - fDragRegion
->Frame().Width() - 1;
492 expandoFrame
.right
= screenFrame
.Width();
495 fInlineScrollView
->DetachScrollers();
496 fInlineScrollView
->MoveTo(expandoFrame
.LeftTop());
497 fInlineScrollView
->ResizeTo(expandoFrame
.Width(), fVertical
498 ? screenFrame
.bottom
- expandoFrame
.top
499 : expandoFrame
.Height());
500 fExpandoMenuBar
->MoveTo(0, 0);
501 fExpandoMenuBar
->ResizeTo(expandoFrame
.Width(), expandoFrame
.Height());
504 // Set the max item width based on icon size
505 fExpandoMenuBar
->SetMaxItemWidth();
508 if (fState
== kExpandoState
)
509 fExpandoMenuBar
->BuildItems();
511 SizeWindow(screenFrame
);
512 PositionWindow(screenFrame
);
513 fExpandoMenuBar
->DoLayout();
514 // force menu to resize
516 Window()->UpdateIfNeeded();
522 TBarView::GetPreferredWindowSize(BRect screenFrame
, float* width
, float* height
)
524 float windowHeight
= 0;
525 float windowWidth
= gMinimumWindowWidth
;
526 bool setToHiddenSize
= fBarApp
->Settings()->autoHide
&& IsHidden()
527 && !fDragRegion
->IsDragging();
529 if (setToHiddenSize
) {
530 windowHeight
= kHiddenDimension
;
532 if (fState
== kExpandoState
&& !fVertical
) {
533 // top or bottom, full
534 fExpandoMenuBar
->CheckItemSizes(0);
535 windowWidth
= screenFrame
.Width();
537 windowWidth
= kHiddenDimension
;
539 if (fState
== kFullState
) {
540 windowHeight
= screenFrame
.bottom
;
541 windowWidth
= fBarMenuBar
->Frame().Width();
542 } else if (fState
== kExpandoState
) {
545 if (fTrayLocation
!= 0)
546 windowHeight
= fDragRegion
->Frame().bottom
+ 1;
548 windowHeight
= fBarMenuBar
->Frame().bottom
+ 1;
550 windowHeight
+= fExpandoMenuBar
->Bounds().Height();
552 // top or bottom, full
553 fExpandoMenuBar
->CheckItemSizes(0);
554 windowHeight
= fBarApp
->IconSize() + 4;
555 windowWidth
= screenFrame
.Width();
559 if (fTrayLocation
!= 0)
560 windowHeight
= fDragRegion
->Frame().bottom
;
562 windowHeight
= fBarMenuBar
->Frame().bottom
;
566 *width
= windowWidth
;
567 *height
= windowHeight
;
572 TBarView::SizeWindow(BRect screenFrame
)
576 GetPreferredWindowSize(screenFrame
, &windowWidth
, &windowHeight
);
577 Window()->ResizeTo(windowWidth
, windowHeight
);
582 TBarView::PositionWindow(BRect screenFrame
)
586 GetPreferredWindowSize(screenFrame
, &windowWidth
, &windowHeight
);
588 BPoint
moveLoc(0, 0);
590 if (!fLeft
&& fVertical
) {
591 if (fState
== kFullState
)
592 moveLoc
.x
= screenFrame
.right
- fBarMenuBar
->Frame().Width();
594 moveLoc
.x
= screenFrame
.right
- windowWidth
;
597 // bottom, full or corners
599 moveLoc
.y
= screenFrame
.bottom
- windowHeight
;
601 Window()->MoveTo(moveLoc
);
606 TBarView::CheckForScrolling()
608 if (fInlineScrollView
!= NULL
&& fExpandoMenuBar
!= NULL
) {
609 if (fExpandoMenuBar
->CheckForSizeOverrun())
610 fInlineScrollView
->AttachScrollers();
612 fInlineScrollView
->DetachScrollers();
618 TBarView::SaveSettings()
620 desk_settings
* settings
= fBarApp
->Settings();
622 settings
->vertical
= fVertical
;
623 settings
->left
= fLeft
;
624 settings
->top
= fTop
;
625 settings
->state
= fState
;
628 fReplicantTray
->SaveTimeSettings();
633 TBarView::UpdatePlacement()
635 ChangeState(fState
, fVertical
, fLeft
, fTop
);
640 TBarView::ChangeState(int32 state
, bool vertical
, bool left
, bool top
,
643 BMessage
message(kUpdateOrientation
);
644 message
.AddInt32("state", state
);
645 message
.AddBool("vertical", vertical
);
646 message
.AddBool("left", left
);
647 message
.AddBool("top", top
);
650 BMessenger(this).SendMessage(&message
);
652 _ChangeState(&message
);
657 TBarView::_ChangeState(BMessage
* message
)
659 int32 state
= message
->FindInt32("state");
660 bool vertical
= message
->FindBool("vertical");
661 bool left
= message
->FindBool("left");
662 bool top
= message
->FindBool("top");
664 bool vertSwap
= (fVertical
!= vertical
);
665 bool leftSwap
= (fLeft
!= left
);
666 bool stateChanged
= (fState
!= state
);
669 fVertical
= vertical
;
673 if (stateChanged
|| vertSwap
) {
674 be_app
->PostMessage(kStateChanged
);
675 // Send a message to the preferences window to let it know to
676 // enable or disable preference items.
678 if (vertSwap
&& fExpandoMenuBar
!= NULL
) {
680 fInlineScrollView
->SetOrientation(B_VERTICAL
);
681 fExpandoMenuBar
->SetMenuLayout(B_ITEMS_IN_COLUMN
);
682 fExpandoMenuBar
->StartMonitoringWindows();
684 fInlineScrollView
->SetOrientation(B_HORIZONTAL
);
685 fExpandoMenuBar
->SetMenuLayout(B_ITEMS_IN_ROW
);
686 fExpandoMenuBar
->StopMonitoringWindows();
692 PlaceTray(vertSwap
, leftSwap
);
693 PlaceApplicationBar();
698 TBarView::RaiseDeskbar(bool raise
)
701 Window()->SetFeel(B_FLOATING_ALL_WINDOW_FEEL
);
703 Window()->SetFeel(B_NORMAL_WINDOW_FEEL
);
708 TBarView::HideDeskbar(bool hide
)
710 BRect screenFrame
= (BScreen(Window())).Frame();
714 PositionWindow(screenFrame
);
715 SizeWindow(screenFrame
);
718 SizeWindow(screenFrame
);
719 PositionWindow(screenFrame
);
724 // #pragma mark - Drag and Drop
728 TBarView::CacheDragData(const BMessage
* incoming
)
733 if (Dragging() && SpringLoadedFolderCompareMessages(incoming
, fDragMessage
))
736 // disposes then fills cached drag message and
738 SpringLoadedFolderCacheDragData(incoming
, &fDragMessage
, &fCachedTypesList
);
743 init_tracking_hook(BMenuItem
* item
,
744 bool (*hookFunction
)(BMenu
*, void*), void* state
)
749 BMenu
* windowMenu
= item
->Submenu();
751 // have a menu, set the tracking hook
752 windowMenu
->SetTrackingHook(hookFunction
, state
);
758 TBarView::DragStart()
765 GetMouse(&loc
, &buttons
);
767 if (fExpandoMenuBar
!= NULL
&& fExpandoMenuBar
->Frame().Contains(loc
)) {
768 ConvertToScreen(&loc
);
769 BPoint expandoLocation
= fExpandoMenuBar
->ConvertFromScreen(loc
);
770 TTeamMenuItem
* item
= fExpandoMenuBar
->TeamItemAtPoint(expandoLocation
);
773 init_tracking_hook(fLastDragItem
, NULL
, NULL
);
776 if (item
== fLastDragItem
)
779 fLastDragItem
= item
;
788 TBarView::MenuTrackingHook(BMenu
* menu
, void* castToThis
)
790 // return true if the menu should go away
791 TrackingHookData
* data
= static_cast<TrackingHookData
*>(castToThis
);
795 TBarView
* barview
= dynamic_cast<TBarView
*>(data
->fTarget
.Target(NULL
));
796 if (!barview
|| !menu
->LockLooper())
801 menu
->GetMouse(&location
, &buttons
);
804 BRect
frame(menu
->Bounds());
805 frame
.InsetBy(-kMenuTrackMargin
, -kMenuTrackMargin
);
807 if (frame
.Contains(location
)) {
808 // if current loc is still in the menu
812 // see if the mouse is in the team/deskbar menu item
813 menu
->ConvertToScreen(&location
);
814 if (barview
->LockLooper()) {
815 TExpandoMenuBar
* expando
= barview
->ExpandoMenuBar();
817 = (dynamic_cast<TBarWindow
*>(barview
->Window()))->DeskbarMenu();
819 if (bemenu
&& bemenu
->LockLooper()) {
820 bemenu
->ConvertFromScreen(&location
);
821 if (bemenu
->Frame().Contains(location
))
824 bemenu
->UnlockLooper();
827 if (endMenu
&& expando
) {
828 expando
->ConvertFromScreen(&location
);
829 BMenuItem
* item
= expando
->TeamItemAtPoint(location
);
833 barview
->UnlockLooper();
837 menu
->UnlockLooper();
842 // used by WindowMenu and TeamMenu to
843 // set the tracking hook for dragging
845 TBarView::GetTrackingHookData()
847 // all tracking hook data is
848 // preset in AttachedToWindow
849 // data should never change
850 return &fTrackingHookData
;
855 TBarView::DragStop(bool full
)
860 if (fExpandoMenuBar
!= NULL
) {
861 if (fLastDragItem
!= NULL
) {
862 init_tracking_hook(fLastDragItem
, NULL
, NULL
);
863 fLastDragItem
= NULL
;
871 delete fCachedTypesList
;
872 fCachedTypesList
= NULL
;
878 TBarView::AppCanHandleTypes(const char* signature
)
880 // used for filtering apps/teams in the ExpandoMenuBar and TeamMenu
882 if (modifiers() & B_CONTROL_KEY
) {
883 // control key forces acceptance, just like drag&drop on icons
887 if (!signature
|| strlen(signature
) == 0
888 || !fCachedTypesList
|| fCachedTypesList
->CountItems() == 0)
891 if (strcasecmp(signature
, kTrackerSignature
) == 0) {
892 // tracker should support all types
893 // and should pass them on to the appropriate application
898 BMimeType
appmime(signature
);
899 if (appmime
.GetAppHint(&hintref
) != B_OK
)
902 // an app was found, now see if it supports any of
903 // the refs in the message
904 BFile
file(&hintref
, O_RDONLY
);
905 BAppFileInfo
fileinfo(&file
);
907 // scan the cached mimetype list and see if this app
908 // supports anything in the list
909 // only one item needs to match in the list of refs
911 int32 count
= fCachedTypesList
->CountItems();
912 for (int32 i
= 0 ; i
< count
; i
++) {
913 if (fileinfo
.IsSupportedType(fCachedTypesList
->ItemAt(i
)->String()))
922 TBarView::SetDragOverride(bool on
)
929 TBarView::DragOverride()
931 return fRefsRcvdOnly
;
936 TBarView::SendDragMessage(const char* signature
, entry_ref
* ref
)
938 status_t err
= B_ERROR
;
939 if (fDragMessage
!= NULL
) {
941 // current message sent to apps is only B_REFS_RECEIVED
942 fDragMessage
->what
= B_REFS_RECEIVED
;
946 if (signature
!= NULL
&& *signature
!= '\0'
947 && roster
.IsRunning(signature
)) {
948 BMessenger
messenger(signature
);
949 // drag message is still owned by DB, copy is sent
950 // can toss it after send
951 err
= messenger
.SendMessage(fDragMessage
);
952 } else if (ref
!= NULL
) {
953 FSLaunchItem((const entry_ref
*)ref
, (const BMessage
*)fDragMessage
,
955 } else if (signature
!= NULL
&& *signature
!= '\0')
956 roster
.Launch(signature
, fDragMessage
);
964 TBarView::InvokeItem(const char* signature
)
966 // sent from TeamMenuItem
967 if (Dragging() && AppCanHandleTypes(signature
)) {
968 SendDragMessage(signature
);
969 // invoking okay to toss memory
979 TBarView::HandleDeskbarMenu(BMessage
* messagewithdestination
)
985 if (fVertical
&& fState
!= kExpandoState
) {
986 // if drop is in the team menu, bail
987 if (fBarMenuBar
->CountItems() >= 2) {
990 GetMouse(&location
, &buttons
);
991 if (fBarMenuBar
->ItemAt(1)->Frame().Contains(location
))
996 if (messagewithdestination
) {
998 if (messagewithdestination
->FindRef("refs", &ref
) == B_OK
) {
999 BEntry
entry(&ref
, true);
1000 if (entry
.IsDirectory()) {
1001 // if the ref received (should only be 1) is a directory
1002 // then add the drag refs to the directory
1003 AddRefsToDeskbarMenu(DragMessage(), &ref
);
1005 SendDragMessage(NULL
, &ref
);
1008 // adds drag refs to top level in deskbar menu
1009 AddRefsToDeskbarMenu(DragMessage(), NULL
);
1012 // clean up drag message and types list
1017 // #pragma mark - Add-ons
1020 // shelf is ignored for now,
1021 // it exists in anticipation of having other 'shelves' for
1025 TBarView::ItemInfo(int32 id
, const char** name
, DeskbarShelf
* shelf
)
1027 *shelf
= B_DESKBAR_TRAY
;
1028 return fReplicantTray
->ItemInfo(id
, name
);
1033 TBarView::ItemInfo(const char* name
, int32
* id
, DeskbarShelf
* shelf
)
1035 *shelf
= B_DESKBAR_TRAY
;
1036 return fReplicantTray
->ItemInfo(name
, id
);
1041 TBarView::ItemExists(int32 id
, DeskbarShelf
)
1043 return fReplicantTray
->IconExists(id
);
1048 TBarView::ItemExists(const char* name
, DeskbarShelf
)
1050 return fReplicantTray
->IconExists(name
);
1055 TBarView::CountItems(DeskbarShelf
)
1057 return fReplicantTray
->IconCount();
1062 TBarView::AddItem(BMessage
* item
, DeskbarShelf
, int32
* id
)
1064 return fReplicantTray
->AddIcon(item
, id
);
1069 TBarView::AddItem(BEntry
* entry
, DeskbarShelf
, int32
* id
)
1071 return fReplicantTray
->LoadAddOn(entry
, id
);
1076 TBarView::RemoveItem(int32 id
)
1078 fReplicantTray
->RemoveIcon(id
);
1083 TBarView::RemoveItem(const char* name
, DeskbarShelf
)
1085 fReplicantTray
->RemoveIcon(name
);
1090 TBarView::OffsetIconFrame(BRect rect
) const
1092 BRect
frame(Frame());
1094 frame
.left
+= fDragRegion
->Frame().left
+ fReplicantTray
->Frame().left
1096 frame
.top
+= fDragRegion
->Frame().top
+ fReplicantTray
->Frame().top
1099 frame
.right
= frame
.left
+ rect
.Width();
1100 frame
.bottom
= frame
.top
+ rect
.Height();
1107 TBarView::IconFrame(int32 id
) const
1109 return OffsetIconFrame(fReplicantTray
->IconFrame(id
));
1114 TBarView::IconFrame(const char* name
) const
1116 return OffsetIconFrame(fReplicantTray
->IconFrame(name
));