141281cf3SAxel Dörfler /* 241281cf3SAxel Dörfler Open Tracker License 341281cf3SAxel Dörfler 441281cf3SAxel Dörfler Terms and Conditions 541281cf3SAxel Dörfler 641281cf3SAxel Dörfler Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 741281cf3SAxel Dörfler 841281cf3SAxel Dörfler Permission is hereby granted, free of charge, to any person obtaining a copy of 941281cf3SAxel Dörfler this software and associated documentation files (the "Software"), to deal in 1041281cf3SAxel Dörfler the Software without restriction, including without limitation the rights to 1141281cf3SAxel Dörfler use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 1241281cf3SAxel Dörfler of the Software, and to permit persons to whom the Software is furnished to do 1341281cf3SAxel Dörfler so, subject to the following conditions: 1441281cf3SAxel Dörfler 1541281cf3SAxel Dörfler The above copyright notice and this permission notice applies to all licensees 1641281cf3SAxel Dörfler and shall be included in all copies or substantial portions of the Software. 1741281cf3SAxel Dörfler 1841281cf3SAxel Dörfler THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1941281cf3SAxel Dörfler IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 2041281cf3SAxel Dörfler FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2141281cf3SAxel Dörfler BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2241281cf3SAxel Dörfler AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 2341281cf3SAxel Dörfler WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2441281cf3SAxel Dörfler 2541281cf3SAxel Dörfler Except as contained in this notice, the name of Be Incorporated shall not be 2641281cf3SAxel Dörfler used in advertising or otherwise to promote the sale, use or other dealings in 2741281cf3SAxel Dörfler this Software without prior written authorization from Be Incorporated. 2841281cf3SAxel Dörfler 291687edd0SFredrik Holmqvist Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered 301687edd0SFredrik Holmqvist trademarks of Be Incorporated in the United States and other countries. Other 311687edd0SFredrik Holmqvist brand product names are registered trademarks or trademarks of their respective 321687edd0SFredrik Holmqvist holders. 3341281cf3SAxel Dörfler All rights reserved. 3441281cf3SAxel Dörfler */ 3541281cf3SAxel Dörfler 36136d40a8SStefano Ceccherini 37cb6afcb1SStephan Aßmus #include "TeamMenuItem.h" 38cb6afcb1SStephan Aßmus 3941281cf3SAxel Dörfler #include <string.h> 4041281cf3SAxel Dörfler #include <stdio.h> 41136d40a8SStefano Ceccherini #include <stdlib.h> 42136d40a8SStefano Ceccherini 4341281cf3SAxel Dörfler #include <Bitmap.h> 44cb6afcb1SStephan Aßmus #include <ControlLook.h> 451cd61330SJohn Scipione #include <Debug.h> 4641281cf3SAxel Dörfler #include <Font.h> 4741281cf3SAxel Dörfler #include <Region.h> 4841281cf3SAxel Dörfler #include <Roster.h> 4941281cf3SAxel Dörfler #include <Resources.h> 5041281cf3SAxel Dörfler 5141281cf3SAxel Dörfler #include "BarApp.h" 5241281cf3SAxel Dörfler #include "BarMenuBar.h" 534ae3e542SJohn Scipione #include "BarView.h" 5441281cf3SAxel Dörfler #include "ExpandoMenuBar.h" 5541281cf3SAxel Dörfler #include "ResourceSet.h" 5641281cf3SAxel Dörfler #include "ShowHideMenuItem.h" 5741281cf3SAxel Dörfler #include "TeamMenu.h" 5841281cf3SAxel Dörfler #include "WindowMenu.h" 5941281cf3SAxel Dörfler #include "WindowMenuItem.h" 6041281cf3SAxel Dörfler 6141281cf3SAxel Dörfler 6241281cf3SAxel Dörfler const float kHPad = 8.0f; 635e625eadSJohn Scipione const float kVPad = 2.0f; 6441281cf3SAxel Dörfler const float kLabelOffset = 8.0f; 65a7c02e02SJohn Scipione const float kSwitchWidth = 12.0f; 6641281cf3SAxel Dörfler 6741281cf3SAxel Dörfler 68072c2dcdSJohn Scipione // #pragma mark - TTeamMenuItem 69072c2dcdSJohn Scipione 70072c2dcdSJohn Scipione 71c9363f78SJohn Scipione TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, 72c9363f78SJohn Scipione char* signature, float width, float height) 7301f35d10SJohn Scipione : 74c9363f78SJohn Scipione TTruncatableMenuItem(new TWindowMenu(team, signature)) 7541281cf3SAxel Dörfler { 76e9982f68SJohn Scipione _Init(team, icon, name, signature, width, height); 7741281cf3SAxel Dörfler } 7841281cf3SAxel Dörfler 7941281cf3SAxel Dörfler 8018bcf77aSJohn Scipione TTeamMenuItem::TTeamMenuItem(float width, float height) 8101f35d10SJohn Scipione : 82c9363f78SJohn Scipione TTruncatableMenuItem("", NULL) 8341281cf3SAxel Dörfler { 84e9982f68SJohn Scipione _Init(NULL, NULL, strdup(""), strdup(""), width, height); 8541281cf3SAxel Dörfler } 8641281cf3SAxel Dörfler 8741281cf3SAxel Dörfler 8841281cf3SAxel Dörfler TTeamMenuItem::~TTeamMenuItem() 8941281cf3SAxel Dörfler { 9041281cf3SAxel Dörfler delete fTeam; 9141281cf3SAxel Dörfler delete fIcon; 92c9363f78SJohn Scipione free(fSignature); 935e625eadSJohn Scipione } 945e625eadSJohn Scipione 955e625eadSJohn Scipione 9641281cf3SAxel Dörfler status_t 9741281cf3SAxel Dörfler TTeamMenuItem::Invoke(BMessage* message) 9841281cf3SAxel Dörfler { 991dccb7aaSJohn Scipione if (fBarView->InvokeItem(Signature())) { 10041281cf3SAxel Dörfler // handles drop on application 10141281cf3SAxel Dörfler return B_OK; 1021dccb7aaSJohn Scipione } 10341281cf3SAxel Dörfler 10441281cf3SAxel Dörfler // if the app could not handle the drag message 10541281cf3SAxel Dörfler // and we were dragging, then kill the drag 10641281cf3SAxel Dörfler // should never get here, disabled item will not invoke 1071dccb7aaSJohn Scipione if (fBarView != NULL && fBarView->Dragging()) 1081dccb7aaSJohn Scipione fBarView->DragStop(); 10941281cf3SAxel Dörfler 11041281cf3SAxel Dörfler // bring to front or minimize shortcuts 11141281cf3SAxel Dörfler uint32 mods = modifiers(); 1121687edd0SFredrik Holmqvist if (mods & B_CONTROL_KEY) { 11341281cf3SAxel Dörfler TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY) 11441281cf3SAxel Dörfler ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams()); 1151687edd0SFredrik Holmqvist } 11641281cf3SAxel Dörfler 11741281cf3SAxel Dörfler return BMenuItem::Invoke(message); 11841281cf3SAxel Dörfler } 11941281cf3SAxel Dörfler 12041281cf3SAxel Dörfler 12141281cf3SAxel Dörfler void 122249a4a18SStephan Aßmus TTeamMenuItem::SetOverrideSelected(bool selected) 123249a4a18SStephan Aßmus { 124249a4a18SStephan Aßmus fOverriddenSelected = selected; 125249a4a18SStephan Aßmus Highlight(selected); 126249a4a18SStephan Aßmus } 127249a4a18SStephan Aßmus 128249a4a18SStephan Aßmus 1291dccb7aaSJohn Scipione void 130c9d2a320SJohn Scipione TTeamMenuItem::SetIcon(BBitmap* icon) { 131c9d2a320SJohn Scipione delete fIcon; 132c9d2a320SJohn Scipione fIcon = icon; 1332ce9bab8SJohn Scipione } 1342ce9bab8SJohn Scipione 1352ce9bab8SJohn Scipione 13641281cf3SAxel Dörfler void 13741281cf3SAxel Dörfler TTeamMenuItem::GetContentSize(float* width, float* height) 13841281cf3SAxel Dörfler { 13941281cf3SAxel Dörfler BRect iconBounds; 14041281cf3SAxel Dörfler 14101f35d10SJohn Scipione if (fIcon != NULL) 14241281cf3SAxel Dörfler iconBounds = fIcon->Bounds(); 14341281cf3SAxel Dörfler else 1442ce9bab8SJohn Scipione iconBounds = BRect(0, 0, kMinimumIconSize - 1, kMinimumIconSize - 1); 14541281cf3SAxel Dörfler 14641281cf3SAxel Dörfler BMenuItem::GetContentSize(width, height); 14741281cf3SAxel Dörfler 14841281cf3SAxel Dörfler if (fOverrideWidth != -1.0f) 14941281cf3SAxel Dörfler *width = fOverrideWidth; 1502ce9bab8SJohn Scipione else { 1512ce9bab8SJohn Scipione *width = kHPad + iconBounds.Width() + kHPad; 15218bcf77aSJohn Scipione if (iconBounds.Width() <= 32 15318bcf77aSJohn Scipione && !static_cast<TBarApp*>(be_app)->Settings()->hideLabels) { 1542ce9bab8SJohn Scipione *width += LabelWidth() + kHPad; 1552ce9bab8SJohn Scipione } 15618bcf77aSJohn Scipione } 15741281cf3SAxel Dörfler 15841281cf3SAxel Dörfler if (fOverrideHeight != -1.0f) 15941281cf3SAxel Dörfler *height = fOverrideHeight; 16041281cf3SAxel Dörfler else { 16118bcf77aSJohn Scipione if (fBarView->Vertical()) { 1625e625eadSJohn Scipione *height = iconBounds.Height() + kVPad * 2; 16318bcf77aSJohn Scipione if (!static_cast<TBarApp*>(be_app)->Settings()->hideLabels 16418bcf77aSJohn Scipione && iconBounds.Width() > 32) { 1652ce9bab8SJohn Scipione *height += fLabelAscent + fLabelDescent; 16618bcf77aSJohn Scipione } 1672ce9bab8SJohn Scipione } else { 1685e625eadSJohn Scipione *height = iconBounds.Height() + kVPad * 2; 1692ce9bab8SJohn Scipione } 17041281cf3SAxel Dörfler } 17141281cf3SAxel Dörfler *height += 2; 17241281cf3SAxel Dörfler } 17341281cf3SAxel Dörfler 17441281cf3SAxel Dörfler 17541281cf3SAxel Dörfler void 17641281cf3SAxel Dörfler TTeamMenuItem::Draw() 17741281cf3SAxel Dörfler { 1786b65d934SJohn Scipione BRect frame = Frame(); 17941281cf3SAxel Dörfler BMenu* menu = Menu(); 180fe624b39SJohn Scipione 18141281cf3SAxel Dörfler menu->PushState(); 1825b0fd10dSJohn Scipione 183cb6afcb1SStephan Aßmus rgb_color menuColor = menu->LowColor(); 1841dccb7aaSJohn Scipione bool canHandle = !fBarView->Dragging() 1851dccb7aaSJohn Scipione || fBarView->AppCanHandleTypes(Signature()); 186cb6afcb1SStephan Aßmus uint32 flags = 0; 187cb6afcb1SStephan Aßmus if (_IsSelected() && canHandle) 188cb6afcb1SStephan Aßmus flags |= BControlLook::B_ACTIVATED; 189cb6afcb1SStephan Aßmus 190cb6afcb1SStephan Aßmus uint32 borders = BControlLook::B_TOP_BORDER; 19118bcf77aSJohn Scipione if (fBarView->Vertical()) { 192cb6afcb1SStephan Aßmus menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT)); 193cb6afcb1SStephan Aßmus borders |= BControlLook::B_LEFT_BORDER 194cb6afcb1SStephan Aßmus | BControlLook::B_RIGHT_BORDER; 195cb6afcb1SStephan Aßmus menu->StrokeLine(frame.LeftBottom(), frame.RightBottom()); 196cb6afcb1SStephan Aßmus frame.bottom--; 197cb6afcb1SStephan Aßmus 198cb6afcb1SStephan Aßmus be_control_look->DrawMenuBarBackground(menu, frame, frame, 199cb6afcb1SStephan Aßmus menuColor, flags, borders); 200cb6afcb1SStephan Aßmus } else { 201cb6afcb1SStephan Aßmus if (flags & BControlLook::B_ACTIVATED) 202cb6afcb1SStephan Aßmus menu->SetHighColor(tint_color(menuColor, B_DARKEN_3_TINT)); 203cb6afcb1SStephan Aßmus else 204cb6afcb1SStephan Aßmus menu->SetHighColor(tint_color(menuColor, 1.22)); 205cb6afcb1SStephan Aßmus borders |= BControlLook::B_BOTTOM_BORDER; 206cb6afcb1SStephan Aßmus menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); 207cb6afcb1SStephan Aßmus frame.left++; 208cb6afcb1SStephan Aßmus 209cb6afcb1SStephan Aßmus be_control_look->DrawButtonBackground(menu, frame, frame, 210cb6afcb1SStephan Aßmus menuColor, flags, borders); 211cb6afcb1SStephan Aßmus } 212cb6afcb1SStephan Aßmus 213cb6afcb1SStephan Aßmus menu->MovePenTo(ContentLocation()); 214cb6afcb1SStephan Aßmus DrawContent(); 215fe624b39SJohn Scipione 216cb6afcb1SStephan Aßmus menu->PopState(); 21741281cf3SAxel Dörfler } 21841281cf3SAxel Dörfler 21941281cf3SAxel Dörfler 22041281cf3SAxel Dörfler void 22141281cf3SAxel Dörfler TTeamMenuItem::DrawContent() 22241281cf3SAxel Dörfler { 22341281cf3SAxel Dörfler BMenu* menu = Menu(); 2242ce9bab8SJohn Scipione if (fIcon != NULL) { 22559deaf10SStephan Aßmus if (fIcon->ColorSpace() == B_RGBA32) { 22659deaf10SStephan Aßmus menu->SetDrawingMode(B_OP_ALPHA); 22759deaf10SStephan Aßmus menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); 2281687edd0SFredrik Holmqvist } else 22941281cf3SAxel Dörfler menu->SetDrawingMode(B_OP_OVER); 23041281cf3SAxel Dörfler 2316b65d934SJohn Scipione BRect frame = Frame(); 2326b65d934SJohn Scipione BRect iconBounds = fIcon->Bounds(); 2336b65d934SJohn Scipione BRect updateRect = iconBounds; 23418bcf77aSJohn Scipione float extra = fBarView->Vertical() ? 0.0f : -1.0f; 235c9363f78SJohn Scipione BPoint contentLocation = ContentLocation(); 236c9363f78SJohn Scipione BPoint drawLocation = contentLocation + BPoint(kHPad, kVPad); 2371687edd0SFredrik Holmqvist 23818bcf77aSJohn Scipione if (static_cast<TBarApp*>(be_app)->Settings()->hideLabels 23918bcf77aSJohn Scipione || (fBarView->Vertical() && iconBounds.Width() > 32)) { 240c9363f78SJohn Scipione float offsetx = contentLocation.x 2412ce9bab8SJohn Scipione + ((frame.Width() - iconBounds.Width()) / 2) + extra; 242c9363f78SJohn Scipione float offsety = contentLocation.y + 3.0f + extra; 2432ce9bab8SJohn Scipione 2446b65d934SJohn Scipione updateRect.OffsetTo(BPoint(offsetx, offsety)); 2456b65d934SJohn Scipione menu->DrawBitmapAsync(fIcon, updateRect); 2462ce9bab8SJohn Scipione 247c9363f78SJohn Scipione drawLocation.x = ((frame.Width() - LabelWidth()) / 2); 248c9363f78SJohn Scipione drawLocation.y = frame.top + iconBounds.Height() + kVPad * 2; 2492ce9bab8SJohn Scipione } else { 250c9363f78SJohn Scipione float offsetx = contentLocation.x + kHPad; 251c9363f78SJohn Scipione float offsety = contentLocation.y + 2522ce9bab8SJohn Scipione ((frame.Height() - iconBounds.Height()) / 2) + extra; 2532ce9bab8SJohn Scipione 2546b65d934SJohn Scipione updateRect.OffsetTo(BPoint(offsetx, offsety)); 2556b65d934SJohn Scipione menu->DrawBitmapAsync(fIcon, updateRect); 25641281cf3SAxel Dörfler 25741281cf3SAxel Dörfler float labelHeight = fLabelAscent + fLabelDescent; 258c9363f78SJohn Scipione drawLocation.x += iconBounds.Width() + kLabelOffset; 259c9363f78SJohn Scipione drawLocation.y = frame.top + ((frame.Height() - labelHeight) / 2) 26018bcf77aSJohn Scipione + extra; 2612ce9bab8SJohn Scipione } 2622ce9bab8SJohn Scipione 263c9363f78SJohn Scipione menu->MovePenTo(drawLocation); 26441281cf3SAxel Dörfler } 26541281cf3SAxel Dörfler 266cb6afcb1SStephan Aßmus menu->SetDrawingMode(B_OP_OVER); 267e19488b2SRyan Leavengood menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); 26841281cf3SAxel Dörfler 26941281cf3SAxel Dörfler // override the drawing of the content when the item is disabled 27041281cf3SAxel Dörfler // the wrong lowcolor is used when the item is disabled since the 27141281cf3SAxel Dörfler // text color does not change 27241281cf3SAxel Dörfler menu->MovePenBy(0, fLabelAscent); 27341281cf3SAxel Dörfler 2741dccb7aaSJohn Scipione bool canHandle = !fBarView->Dragging() 2751dccb7aaSJohn Scipione || fBarView->AppCanHandleTypes(Signature()); 276249a4a18SStephan Aßmus if (_IsSelected() && IsEnabled() && canHandle) 277ab4e79c3SRyan Leavengood menu->SetLowColor(tint_color(menu->LowColor(), 27841281cf3SAxel Dörfler B_HIGHLIGHT_BACKGROUND_TINT)); 27941281cf3SAxel Dörfler else 280ab4e79c3SRyan Leavengood menu->SetLowColor(menu->LowColor()); 28141281cf3SAxel Dörfler 282859c3781SJohn Scipione if (IsSelected()) 283859c3781SJohn Scipione menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR)); 284859c3781SJohn Scipione else 285859c3781SJohn Scipione menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); 286859c3781SJohn Scipione 287c9363f78SJohn Scipione if (!static_cast<TBarApp*>(be_app)->Settings()->hideLabels) { 288c9363f78SJohn Scipione float labelWidth = menu->StringWidth(Label()); 289c9363f78SJohn Scipione BPoint penLocation = menu->PenLocation(); 290c9363f78SJohn Scipione float offset = penLocation.x - Frame().left; 291c9363f78SJohn Scipione menu->DrawString(Label(labelWidth + offset)); 292c9363f78SJohn Scipione } 29341281cf3SAxel Dörfler 2945e625eadSJohn Scipione if (fBarView->Vertical() 2955e625eadSJohn Scipione && static_cast<TBarApp*>(be_app)->Settings()->superExpando 2965e625eadSJohn Scipione && fBarView->ExpandoState()) { 2975e625eadSJohn Scipione DrawExpanderArrow(); 2985e625eadSJohn Scipione } 2995e625eadSJohn Scipione } 3005e625eadSJohn Scipione 30141281cf3SAxel Dörfler 3025b0fd10dSJohn Scipione void 3031dccb7aaSJohn Scipione TTeamMenuItem::DrawExpanderArrow() 3045b0fd10dSJohn Scipione { 3055b0fd10dSJohn Scipione BMenu* menu = Menu(); 3066b65d934SJohn Scipione BRect frame = Frame(); 307c9363f78SJohn Scipione BRect rect(0.0f, 0.0f, kSwitchWidth, kHPad + 2.0f); 3082b8d4131SJohn Scipione 3095b0fd10dSJohn Scipione rect.OffsetTo(BPoint(frame.right - rect.Width(), 3105b0fd10dSJohn Scipione ContentLocation().y + ((frame.Height() - rect.Height()) / 2))); 3115b0fd10dSJohn Scipione be_control_look->DrawArrowShape(menu, rect, rect, menu->LowColor(), 3121dccb7aaSJohn Scipione fArrowDirection, 0, B_DARKEN_3_TINT); 31341281cf3SAxel Dörfler } 31441281cf3SAxel Dörfler 31541281cf3SAxel Dörfler 31641281cf3SAxel Dörfler void 31741281cf3SAxel Dörfler TTeamMenuItem::ToggleExpandState(bool resizeWindow) 31841281cf3SAxel Dörfler { 31941281cf3SAxel Dörfler fExpanded = !fExpanded; 3201dccb7aaSJohn Scipione fArrowDirection = fExpanded ? BControlLook::B_DOWN_ARROW 3211dccb7aaSJohn Scipione : BControlLook::B_RIGHT_ARROW; 32241281cf3SAxel Dörfler 32341281cf3SAxel Dörfler if (fExpanded) { 32441281cf3SAxel Dörfler // Populate Menu() with the stuff from SubMenu(). 32541281cf3SAxel Dörfler TWindowMenu* sub = (static_cast<TWindowMenu*>(Submenu())); 3265b0fd10dSJohn Scipione if (sub != NULL) { 32741281cf3SAxel Dörfler // force the menu to update it's contents. 328bdfed6c0SAxel Dörfler bool locked = sub->LockLooper(); 329bdfed6c0SAxel Dörfler // if locking the looper failed, the menu is just not visible 330bdfed6c0SAxel Dörfler sub->AttachedToWindow(); 331bdfed6c0SAxel Dörfler if (locked) 332bdfed6c0SAxel Dörfler sub->UnlockLooper(); 333bdfed6c0SAxel Dörfler 33441281cf3SAxel Dörfler if (sub->CountItems() > 1) { 33541281cf3SAxel Dörfler TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu()); 33641281cf3SAxel Dörfler int myindex = parent->IndexOf(this) + 1; 33741281cf3SAxel Dörfler 33841281cf3SAxel Dörfler TWindowMenuItem* windowItem = NULL; 339deaae5fcSJohn Scipione int32 childIndex = 0; 340deaae5fcSJohn Scipione int32 totalChildren = sub->CountItems() - 4; 34171bd3ba5SJonas Sundström // hide, show, close, separator. 34241281cf3SAxel Dörfler for (; childIndex < totalChildren; childIndex++) { 34371bd3ba5SJonas Sundström windowItem = static_cast<TWindowMenuItem*> 34471bd3ba5SJonas Sundström (sub->RemoveItem((int32)0)); 34541281cf3SAxel Dörfler parent->AddItem(windowItem, myindex + childIndex); 3465e625eadSJohn Scipione windowItem->SetExpanded(true); 34741281cf3SAxel Dörfler } 34841281cf3SAxel Dörfler sub->SetExpanded(true, myindex + childIndex); 34941281cf3SAxel Dörfler 35041281cf3SAxel Dörfler if (resizeWindow) 351afa1c291SJohn Scipione parent->SizeWindow(-1); 352c0107fb2SJonas Sundström } 35341281cf3SAxel Dörfler } 35441281cf3SAxel Dörfler } else { 35541281cf3SAxel Dörfler // Remove the goodies from the Menu() that should be in the SubMenu(); 35641281cf3SAxel Dörfler TWindowMenu* sub = static_cast<TWindowMenu*>(Submenu()); 3575b0fd10dSJohn Scipione if (sub != NULL) { 35841281cf3SAxel Dörfler TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu()); 35941281cf3SAxel Dörfler 36041281cf3SAxel Dörfler TWindowMenuItem* windowItem = NULL; 361deaae5fcSJohn Scipione int32 childIndex = parent->IndexOf(this) + 1; 362deaae5fcSJohn Scipione while (parent->SubmenuAt(childIndex) == NULL 363deaae5fcSJohn Scipione && childIndex < parent->CountItems()) { 364deaae5fcSJohn Scipione windowItem 365deaae5fcSJohn Scipione = static_cast<TWindowMenuItem*>(parent->RemoveItem(childIndex)); 36641281cf3SAxel Dörfler sub->AddItem(windowItem, 0); 3675e625eadSJohn Scipione windowItem->SetExpanded(false); 36841281cf3SAxel Dörfler } 36941281cf3SAxel Dörfler sub->SetExpanded(false, 0); 37041281cf3SAxel Dörfler 37141281cf3SAxel Dörfler if (resizeWindow) 37249ff476dSJohn Scipione parent->SizeWindow(1); 373c0107fb2SJonas Sundström } 37441281cf3SAxel Dörfler } 37541281cf3SAxel Dörfler } 37641281cf3SAxel Dörfler 37741281cf3SAxel Dörfler 37841281cf3SAxel Dörfler TWindowMenuItem* 37941281cf3SAxel Dörfler TTeamMenuItem::ExpandedWindowItem(int32 id) 38041281cf3SAxel Dörfler { 3811687edd0SFredrik Holmqvist if (!fExpanded) { 3821687edd0SFredrik Holmqvist // Paranoia 38341281cf3SAxel Dörfler return NULL; 3841687edd0SFredrik Holmqvist } 38541281cf3SAxel Dörfler 38641281cf3SAxel Dörfler TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu()); 38741281cf3SAxel Dörfler int childIndex = parent->IndexOf(this) + 1; 38841281cf3SAxel Dörfler 38971bd3ba5SJonas Sundström while (!parent->SubmenuAt(childIndex) 39071bd3ba5SJonas Sundström && childIndex < parent->CountItems()) { 39171bd3ba5SJonas Sundström TWindowMenuItem* item 39271bd3ba5SJonas Sundström = static_cast<TWindowMenuItem*>(parent->ItemAt(childIndex)); 39341281cf3SAxel Dörfler if (item->ID() == id) 39441281cf3SAxel Dörfler return item; 39541281cf3SAxel Dörfler 39641281cf3SAxel Dörfler childIndex++; 39741281cf3SAxel Dörfler } 39841281cf3SAxel Dörfler return NULL; 39941281cf3SAxel Dörfler } 40041281cf3SAxel Dörfler 40141281cf3SAxel Dörfler 40241281cf3SAxel Dörfler BRect 40341281cf3SAxel Dörfler TTeamMenuItem::ExpanderBounds() const 40441281cf3SAxel Dörfler { 40541281cf3SAxel Dörfler BRect bounds(Frame()); 40641281cf3SAxel Dörfler bounds.left = bounds.right - kSwitchWidth; 40741281cf3SAxel Dörfler return bounds; 40841281cf3SAxel Dörfler } 40941281cf3SAxel Dörfler 410249a4a18SStephan Aßmus 4115b0fd10dSJohn Scipione // #pragma mark - Private methods 4125b0fd10dSJohn Scipione 4135b0fd10dSJohn Scipione 4145b0fd10dSJohn Scipione void 415e9982f68SJohn Scipione TTeamMenuItem::_Init(BList* team, BBitmap* icon, char* name, char* signature, 41618bcf77aSJohn Scipione float width, float height) 4175b0fd10dSJohn Scipione { 4185b0fd10dSJohn Scipione fTeam = team; 4195b0fd10dSJohn Scipione fIcon = icon; 420c9363f78SJohn Scipione fSignature = signature; 421*c38afcd6SJohn Scipione 422*c38afcd6SJohn Scipione if (name == NULL) { 4235b0fd10dSJohn Scipione char temp[32]; 4245b0fd10dSJohn Scipione snprintf(temp, sizeof(temp), "team %ld", (addr_t)team->ItemAt(0)); 425*c38afcd6SJohn Scipione name = strdup(temp); 4265b0fd10dSJohn Scipione } 427c9363f78SJohn Scipione 428*c38afcd6SJohn Scipione SetLabel(name); 429c9363f78SJohn Scipione 4301dccb7aaSJohn Scipione fOverrideWidth = width; 4311dccb7aaSJohn Scipione fOverrideHeight = height; 4325b0fd10dSJohn Scipione 4331dccb7aaSJohn Scipione fBarView = static_cast<TBarApp*>(be_app)->BarView(); 4345b0fd10dSJohn Scipione 435*c38afcd6SJohn Scipione BFont font(be_plain_font); 436*c38afcd6SJohn Scipione fLabelWidth = ceilf(font.StringWidth(name)); 437*c38afcd6SJohn Scipione font_height fontHeight; 438*c38afcd6SJohn Scipione font.GetHeight(&fontHeight); 439*c38afcd6SJohn Scipione fLabelAscent = ceilf(fontHeight.ascent); 440*c38afcd6SJohn Scipione fLabelDescent = ceilf(fontHeight.descent + fontHeight.leading); 441*c38afcd6SJohn Scipione 4425b0fd10dSJohn Scipione fOverriddenSelected = false; 4435b0fd10dSJohn Scipione 4445b0fd10dSJohn Scipione fExpanded = false; 4451dccb7aaSJohn Scipione fArrowDirection = BControlLook::B_RIGHT_ARROW; 4465b0fd10dSJohn Scipione } 4475b0fd10dSJohn Scipione 4485b0fd10dSJohn Scipione 449249a4a18SStephan Aßmus bool 450249a4a18SStephan Aßmus TTeamMenuItem::_IsSelected() const 451249a4a18SStephan Aßmus { 452249a4a18SStephan Aßmus return IsSelected() || fOverriddenSelected; 453249a4a18SStephan Aßmus } 454