diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp
index 881dfef..a3f3619 100644
a
|
b
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
26 | 26 | used in advertising or otherwise to promote the sale, use or other dealings in |
27 | 27 | this Software without prior written authorization from Be Incorporated. |
28 | 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. |
| 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 |
| 32 | holders. |
32 | 33 | All rights reserved. |
33 | 34 | */ |
34 | 35 | |
… |
… |
TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig,
|
71 | 72 | } |
72 | 73 | |
73 | 74 | |
74 | | TTeamMenuItem::TTeamMenuItem(float width,float height,bool vertical) |
| 75 | TTeamMenuItem::TTeamMenuItem(float width, float height, bool vertical) |
75 | 76 | : BMenuItem("", NULL) |
76 | 77 | { |
77 | | InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, vertical); |
| 78 | InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, |
| 79 | vertical); |
78 | 80 | } |
79 | 81 | |
80 | 82 | |
… |
… |
TTeamMenuItem::Invoke(BMessage* message)
|
136 | 138 | barview->DragStop(); |
137 | 139 | |
138 | 140 | // bring to front or minimize shortcuts |
139 | | uint32 mods = modifiers(); |
140 | | if (mods & B_CONTROL_KEY) |
| 141 | uint32 mods = modifiers(); |
| 142 | if (mods & B_CONTROL_KEY) { |
141 | 143 | TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY) |
142 | 144 | ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams()); |
| 145 | } |
143 | 146 | |
144 | 147 | return BMenuItem::Invoke(message); |
145 | 148 | } |
… |
… |
TTeamMenuItem::GetContentSize(float* width, float* height)
|
213 | 216 | *width = kHPad + iconBounds.Width() + kLabelOffset + fLabelWidth + kHPad |
214 | 217 | + 20; |
215 | 218 | |
216 | | if (fOverrideHeight != -1.0f) |
| 219 | if (fOverrideHeight != -1.0f) |
217 | 220 | *height = fOverrideHeight; |
218 | 221 | else { |
219 | 222 | *height = iconBounds.Height(); |
… |
… |
TTeamMenuItem::Draw()
|
233 | 236 | BMenu* menu = Menu(); |
234 | 237 | menu->PushState(); |
235 | 238 | rgb_color menuColor = menu->LowColor(); |
236 | | |
237 | 239 | TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView(); |
| 240 | |
238 | 241 | bool canHandle = !barview->Dragging() |
239 | 242 | || barview->AppCanHandleTypes(Signature()); |
240 | 243 | |
… |
… |
TTeamMenuItem::Draw()
|
314 | 317 | |
315 | 318 | // these continue the dark grey border on the left or top edge |
316 | 319 | menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT)); |
317 | | if (fVertical) |
| 320 | if (fVertical) { |
318 | 321 | // dark line at top |
319 | 322 | menu->StrokeLine(frame.LeftTop(), frame.RightTop()); |
320 | | else |
| 323 | } else { |
321 | 324 | // dark line on the left |
322 | 325 | menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); |
323 | | } else |
| 326 | } |
| 327 | } else |
324 | 328 | menu->SetLowColor(menuColor); |
325 | 329 | |
326 | 330 | menu->MovePenTo(ContentLocation()); |
… |
… |
TTeamMenuItem::DrawContent()
|
337 | 341 | if (fIcon->ColorSpace() == B_RGBA32) { |
338 | 342 | menu->SetDrawingMode(B_OP_ALPHA); |
339 | 343 | menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); |
340 | | } else { |
| 344 | } else |
341 | 345 | menu->SetDrawingMode(B_OP_OVER); |
342 | | } |
343 | | BRect frame(Frame()); |
344 | 346 | |
| 347 | BRect frame(Frame()); |
345 | 348 | BRect iconBounds(fIcon->Bounds()); |
346 | 349 | BRect dstRect(iconBounds); |
347 | 350 | float extra = fVertical ? 0.0f : 1.0f; |
348 | 351 | BPoint contLoc = ContentLocation(); |
| 352 | |
349 | 353 | dstRect.OffsetTo(BPoint(contLoc.x + kHPad, contLoc.y + |
350 | 354 | ((frame.Height() - iconBounds.Height()) / 2) + extra)); |
351 | 355 | menu->DrawBitmapAsync(fIcon, dstRect); |
… |
… |
TTeamMenuItem::DrawContent()
|
357 | 361 | menu->MovePenTo(drawLoc); |
358 | 362 | } |
359 | 363 | |
360 | | // set the pen to black so that either method will draw in the same color |
361 | | // low color is set in inherited::DrawContent, override makes sure its |
362 | | // what we want |
| 364 | // set the pen to black so that either method will draw in the same color |
| 365 | // low color is set in inherited::DrawContent, override makes sure its |
| 366 | // what we want |
363 | 367 | if (fDrawLabel) { |
364 | 368 | menu->SetDrawingMode(B_OP_OVER); |
365 | 369 | menu->SetHighColor(0, 0, 0); |
366 | 370 | |
367 | | // override the drawing of the content when the item is disabled |
368 | | // the wrong lowcolor is used when the item is disabled since the |
369 | | // text color does not change |
370 | | DrawContentLabel(); |
| 371 | // override the drawing of the content when the item is disabled |
| 372 | // the wrong lowcolor is used when the item is disabled since the |
| 373 | // text color does not change |
| 374 | DrawContentLabel(); |
371 | 375 | } |
372 | 376 | |
373 | 377 | // Draw the expandable icon. |
… |
… |
TTeamMenuItem::DrawContent()
|
387 | 391 | } else { |
388 | 392 | rgb_color outlineColor = {80, 80, 80, 255}; |
389 | 393 | rgb_color middleColor = {200, 200, 200, 255}; |
390 | | |
| 394 | |
391 | 395 | menu->SetDrawingMode(B_OP_OVER); |
392 | | |
| 396 | |
393 | 397 | if (!fExpanded) { |
394 | 398 | menu->BeginLineArray(6); |
395 | | |
396 | | menu->AddLine(BPoint(rect.left + 3, rect.top + 1), |
| 399 | |
| 400 | menu->AddLine(BPoint(rect.left + 3, rect.top + 1), |
397 | 401 | BPoint(rect.left + 3, rect.bottom - 1), outlineColor); |
398 | | menu->AddLine(BPoint(rect.left + 3, rect.top + 1), |
| 402 | menu->AddLine(BPoint(rect.left + 3, rect.top + 1), |
399 | 403 | BPoint(rect.left + 7, rect.top + 5), outlineColor); |
400 | | menu->AddLine(BPoint(rect.left + 7, rect.top + 5), |
| 404 | menu->AddLine(BPoint(rect.left + 7, rect.top + 5), |
401 | 405 | BPoint(rect.left + 3, rect.bottom - 1), outlineColor); |
402 | | |
403 | | menu->AddLine(BPoint(rect.left + 4, rect.top + 3), |
| 406 | |
| 407 | menu->AddLine(BPoint(rect.left + 4, rect.top + 3), |
404 | 408 | BPoint(rect.left + 4, rect.bottom - 3), middleColor); |
405 | | menu->AddLine(BPoint(rect.left + 5, rect.top + 4), |
| 409 | menu->AddLine(BPoint(rect.left + 5, rect.top + 4), |
406 | 410 | BPoint(rect.left + 5, rect.bottom - 4), middleColor); |
407 | | menu->AddLine(BPoint(rect.left + 5, rect.top + 5), |
| 411 | menu->AddLine(BPoint(rect.left + 5, rect.top + 5), |
408 | 412 | BPoint(rect.left + 6, rect.top + 5), middleColor); |
409 | 413 | menu->EndLineArray(); |
410 | 414 | } else { |
411 | 415 | // expanded state |
412 | | |
| 416 | |
413 | 417 | menu->BeginLineArray(6); |
414 | | menu->AddLine(BPoint(rect.left + 1, rect.top + 3), |
| 418 | menu->AddLine(BPoint(rect.left + 1, rect.top + 3), |
415 | 419 | BPoint(rect.right - 3, rect.top + 3), outlineColor); |
416 | | menu->AddLine(BPoint(rect.left + 1, rect.top + 3), |
| 420 | menu->AddLine(BPoint(rect.left + 1, rect.top + 3), |
417 | 421 | BPoint(rect.left + 5, rect.top + 7), outlineColor); |
418 | | menu->AddLine(BPoint(rect.left + 5, rect.top + 7), |
| 422 | menu->AddLine(BPoint(rect.left + 5, rect.top + 7), |
419 | 423 | BPoint(rect.right - 3, rect.top + 3), outlineColor); |
420 | | |
421 | | menu->AddLine(BPoint(rect.left + 3, rect.top + 4), |
| 424 | |
| 425 | menu->AddLine(BPoint(rect.left + 3, rect.top + 4), |
422 | 426 | BPoint(rect.right - 5, rect.top + 4), middleColor); |
423 | | menu->AddLine(BPoint(rect.left + 4, rect.top + 5), |
| 427 | menu->AddLine(BPoint(rect.left + 4, rect.top + 5), |
424 | 428 | BPoint(rect.right - 6, rect.top + 5), middleColor); |
425 | | menu->AddLine(BPoint(rect.left + 5, rect.top + 5), |
| 429 | menu->AddLine(BPoint(rect.left + 5, rect.top + 5), |
426 | 430 | BPoint(rect.left + 5, rect.top + 6), middleColor); |
427 | 431 | menu->EndLineArray(); |
428 | 432 | } |
… |
… |
TTeamMenuItem::DrawContentLabel()
|
437 | 441 | BMenu* menu = Menu(); |
438 | 442 | menu->MovePenBy(0, fLabelAscent); |
439 | 443 | |
440 | | float cachedWidth = menu->StringWidth(Label()); |
| 444 | float cachedWidth = menu->StringWidth(Label()); |
441 | 445 | if (Submenu() && fVertical) |
442 | 446 | cachedWidth += 18; |
443 | 447 | |
444 | 448 | const char* label = Label(); |
445 | 449 | char* truncLabel = NULL; |
446 | 450 | float max = 0; |
| 451 | |
447 | 452 | if (static_cast<TBarApp*>(be_app)->Settings()->superExpando && fVertical) |
448 | 453 | max = menu->MaxContentWidth() - kSwitchWidth; |
449 | 454 | else |
450 | 455 | max = menu->MaxContentWidth(); |
451 | 456 | |
452 | 457 | if (max > 0) { |
453 | | BPoint penloc = menu->PenLocation(); |
| 458 | BPoint penloc = menu->PenLocation(); |
454 | 459 | BRect frame = Frame(); |
455 | 460 | float offset = penloc.x - frame.left; |
456 | | if (cachedWidth + offset > max) { |
| 461 | if (cachedWidth + offset > max) { |
457 | 462 | truncLabel = (char*)malloc(strlen(label) + 4); |
458 | 463 | if (!truncLabel) |
459 | 464 | return; |
… |
… |
void
|
491 | 496 | TTeamMenuItem::ToggleExpandState(bool resizeWindow) |
492 | 497 | { |
493 | 498 | fExpanded = !fExpanded; |
494 | | |
| 499 | |
495 | 500 | if (fExpanded) { |
496 | 501 | // Populate Menu() with the stuff from SubMenu(). |
497 | 502 | TWindowMenu* sub = (static_cast<TWindowMenu*>(Submenu())); |
… |
… |
TTeamMenuItem::ToggleExpandState(bool resizeWindow)
|
503 | 508 | if (locked) |
504 | 509 | sub->UnlockLooper(); |
505 | 510 | |
506 | | if (sub->CountItems() > 1){ |
| 511 | if (sub->CountItems() > 1) { |
507 | 512 | TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu()); |
508 | 513 | int myindex = parent->IndexOf(this) + 1; |
509 | 514 | |
… |
… |
TTeamMenuItem::ToggleExpandState(bool resizeWindow)
|
551 | 556 | TWindowMenuItem* |
552 | 557 | TTeamMenuItem::ExpandedWindowItem(int32 id) |
553 | 558 | { |
554 | | if (!fExpanded) // Paranoia |
| 559 | if (!fExpanded) { |
| 560 | // Paranoia |
555 | 561 | return NULL; |
| 562 | } |
556 | 563 | |
557 | 564 | TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu()); |
558 | 565 | int childIndex = parent->IndexOf(this) + 1; |