void TTeamMenuItem::DrawContent() { BMenu* menu = Menu(); if (fIcon != NULL) { if (fIcon->ColorSpace() == B_RGBA32) { menu->SetDrawingMode(B_OP_ALPHA); menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); } else menu->SetDrawingMode(B_OP_OVER); BRect frame(Frame()); BRect iconBounds(fIcon->Bounds()); BRect dstRect(iconBounds); float extra = fVertical ? 0.0f : -1.0f; BPoint contLoc = ContentLocation(); BPoint drawLoc = contLoc + BPoint(kHPad, kVPad); if (!fDrawLabel || (fVertical && iconBounds.Width() > 32)) { float offsetx = contLoc.x + ((frame.Width() - iconBounds.Width()) / 2) + extra; float offsety = contLoc.y + 3.0f + extra; dstRect.OffsetTo(BPoint(offsetx, offsety)); menu->DrawBitmapAsync(fIcon, dstRect); drawLoc.x = ((frame.Width() - LabelWidth()) / 2); drawLoc.y = frame.top + iconBounds.Height() + 4.0f; } else { float offsetx = contLoc.x + kHPad; float offsety = contLoc.y + ((frame.Height() - iconBounds.Height()) / 2) + extra; dstRect.OffsetTo(BPoint(offsetx, offsety)); menu->DrawBitmapAsync(fIcon, dstRect); float labelHeight = fLabelAscent + fLabelDescent; drawLoc.x += iconBounds.Width() + kLabelOffset; drawLoc.y = frame.top + ((frame.Height() - labelHeight) / 2) + extra; } menu->MovePenTo(drawLoc); } // set the pen to black so that either method will draw in the same color // low color is set in inherited::DrawContent, override makes sure its // what we want if (fDrawLabel) { menu->SetDrawingMode(B_OP_OVER); menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); // override the drawing of the content when the item is disabled // the wrong lowcolor is used when the item is disabled since the // text color does not change DrawContentLabel(); } // Draw the expandable icon. TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView(); if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando && barView->ExpandoState()) { BRect frame(Frame()); BRect rect(0, 0, kSwitchWidth, 10); rect.OffsetTo(BPoint(frame.right - rect.Width(), ContentLocation().y + ((frame.Height() - rect.Height()) / 2))); if (be_control_look != NULL) { uint32 arrowDirection = fExpanded ? BControlLook::B_UP_ARROW : BControlLook::B_DOWN_ARROW; be_control_look->DrawArrowShape(menu, rect, rect, menu->LowColor(), arrowDirection, 0, B_DARKEN_3_TINT); } else { rgb_color outlineColor = {80, 80, 80, 255}; rgb_color middleColor = {200, 200, 200, 255}; menu->SetDrawingMode(B_OP_OVER); if (!fExpanded) { menu->BeginLineArray(6); menu->AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); menu->AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 7, rect.top + 5), outlineColor); menu->AddLine(BPoint(rect.left + 7, rect.top + 5), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); menu->AddLine(BPoint(rect.left + 4, rect.top + 3), BPoint(rect.left + 4, rect.bottom - 3), middleColor); menu->AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 5, rect.bottom - 4), middleColor); menu->AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 6, rect.top + 5), middleColor); menu->EndLineArray(); } else { // expanded state menu->BeginLineArray(6); menu->AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.right - 3, rect.top + 3), outlineColor); menu->AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.left + 5, rect.top + 7), outlineColor); menu->AddLine(BPoint(rect.left + 5, rect.top + 7), BPoint(rect.right - 3, rect.top + 3), outlineColor); menu->AddLine(BPoint(rect.left + 3, rect.top + 4), BPoint(rect.right - 5, rect.top + 4), middleColor); menu->AddLine(BPoint(rect.left + 4, rect.top + 5), BPoint(rect.right - 6, rect.top + 5), middleColor); menu->AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 5, rect.top + 6), middleColor); menu->EndLineArray(); } } } }
void TBarMenuTitle::DrawContent() { BMenu* menu = Menu(); BRect frame(Frame()); if (be_control_look != NULL) { menu->SetDrawingMode(B_OP_ALPHA); if (fIcon != NULL) { BRect dstRect(fIcon->Bounds()); dstRect.OffsetTo(frame.LeftTop()); dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2) - 1.0f), rintf(((frame.Height() - dstRect.Height()) / 2) - 0.0f)); menu->DrawBitmapAsync(fIcon, dstRect); } return; } rgb_color menuColor = menu->ViewColor(); rgb_color dark = tint_color(menuColor, B_DARKEN_1_TINT); rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); rgb_color black = {0, 0, 0, 255}; bool inExpandoMode = dynamic_cast<TExpandoMenuBar*>(menu) != NULL; BRect bounds(menu->Window()->Bounds()); if (bounds.right < frame.right) frame.right = bounds.right; menu->SetDrawingMode(B_OP_COPY); if (!IsSelected() && !menu->IsRedrawAfterSticky()) { menu->BeginLineArray(8); menu->AddLine(frame.RightTop(), frame.LeftTop(), light); menu->AddLine(frame.LeftBottom(), frame.RightBottom(), dark); menu->AddLine(frame.LeftTop(), frame.LeftBottom()+BPoint(0, inExpandoMode ? 0 : -1), light); menu->AddLine(frame.RightBottom(), frame.RightTop(), dark); if (inExpandoMode) { frame.top += 1; menu->AddLine(frame.LeftTop(), frame.RightTop() + BPoint(-1, 0), light); } menu->EndLineArray(); frame.InsetBy(1, 1); menu->SetHighColor(menuColor); menu->FillRect(frame); menu->SetHighColor(black); frame.InsetBy(-1, -1); if (inExpandoMode) frame.top -= 1; } ASSERT(IsEnabled()); if (IsSelected() && !menu->IsRedrawAfterSticky()) { menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT)); menu->FillRect(frame); if (menu->IndexOf(this) > 0) { menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT)); menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); } menu->SetHighColor(black); } menu->SetDrawingMode(B_OP_ALPHA); if (fIcon != NULL) { BRect dstRect(fIcon->Bounds()); dstRect.OffsetTo(frame.LeftTop()); dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2) - 1.0f), rintf(((frame.Height() - dstRect.Height()) / 2) - 0.0f)); menu->DrawBitmapAsync(fIcon, dstRect); } }