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
41 #include <Application.h>
47 #include "BarMenuBar.h"
49 #include "DeskbarUtils.h"
50 #include "StatusView.h"
51 #include "TeamMenuItem.h"
54 // #pragma mark - TTeamMenuItem
57 TTeamMenu::TTeamMenu()
61 SetItemMargins(0.0f
, 0.0f
, 0.0f
, 0.0f
);
62 SetFont(be_plain_font
);
67 TTeamMenu::CompareByName(const void* first
, const void* second
)
70 BLocale::Default()->GetCollator(&collator
);
72 return collator
.Compare(
73 (*(static_cast<BarTeamInfo
* const*>(first
)))->name
,
74 (*(static_cast<BarTeamInfo
* const*>(second
)))->name
);
79 TTeamMenu::AttachedToWindow()
81 RemoveItems(0, CountItems(), true);
84 BMessenger
self(this);
86 TBarApp::Subscribe(self
, &teamList
);
88 TBarView
* barview
= (dynamic_cast<TBarApp
*>(be_app
))->BarView();
89 bool dragging
= barview
&& barview
->Dragging();
90 int32 iconSize
= static_cast<TBarApp
*>(be_app
)->IconSize();
91 desk_settings
* settings
= ((TBarApp
*)be_app
)->Settings();
93 float width
= gMinimumWindowWidth
- iconSize
- 4;
95 if (settings
->sortRunningApps
)
96 teamList
.SortItems(TTeamMenu::CompareByName
);
98 int32 count
= teamList
.CountItems();
99 for (int32 i
= 0; i
< count
; i
++) {
101 BarTeamInfo
* barInfo
= (BarTeamInfo
*)teamList
.ItemAt(i
);
102 TTeamMenuItem
* item
= new TTeamMenuItem(barInfo
->teams
,
103 barInfo
->icon
, barInfo
->name
, barInfo
->sig
, width
, -1);
105 if (settings
->trackerAlwaysFirst
106 && strcasecmp(barInfo
->sig
, kTrackerSignature
) == 0) {
111 if (dragging
&& item
!= NULL
) {
112 bool canhandle
= (dynamic_cast<TBarApp
*>(be_app
))->BarView()->
113 AppCanHandleTypes(item
->Signature());
114 if (item
->IsEnabled() != canhandle
)
115 item
->SetEnabled(canhandle
);
117 BMenu
* menu
= item
->Submenu();
119 menu
->SetTrackingHook(barview
->MenuTrackingHook
,
120 barview
->GetTrackingHookData());
125 if (CountItems() == 0) {
126 BMenuItem
* item
= new BMenuItem("no application running", NULL
);
127 item
->SetEnabled(false);
131 if (dragging
&& barview
->LockLooper()) {
132 SetTrackingHook(barview
->MenuTrackingHook
,
133 barview
->GetTrackingHookData());
134 barview
->DragStart();
135 barview
->UnlockLooper();
138 BMenu::AttachedToWindow();
143 TTeamMenu::DetachedFromWindow()
145 TBarView
* barView
= (dynamic_cast<TBarApp
*>(be_app
))->BarView();
146 if (barView
!= NULL
) {
147 BLooper
* looper
= barView
->Looper();
148 if (looper
!= NULL
&& looper
->Lock()) {
154 BMenu::DetachedFromWindow();
156 BMessenger
self(this);
157 TBarApp::Unsubscribe(self
);