void IconMenuItem::DrawContent() { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; if (fHeightDelta > 0) drawPoint.y += ceil(fHeightDelta / 2); Menu()->MovePenTo(drawPoint); _inherited::DrawContent(); Menu()->PushState(); BPoint where(ContentLocation()); float deltaHeight = fHeightDelta < 0 ? -fHeightDelta : 0; where.y += ceil(deltaHeight / 2); if (fDeviceIcon) { if (IsEnabled()) Menu()->SetDrawingMode(B_OP_ALPHA); else { Menu()->SetDrawingMode(B_OP_ALPHA); Menu()->SetHighColor(0, 0, 0, 64); Menu()->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); } Menu()->DrawBitmapAsync(fDeviceIcon, where); } Menu()->PopState(); }
//: BeOS hook function. void CColorSelectMenuItem::DrawContent() { BPoint pos = ContentLocation(); Menu()->MovePenTo(pos.x+boxSize+10.0, pos.y); BMenuItem::DrawContent(); rgb_color oldColor = Menu()->HighColor(); if(IsEnabled()) Menu()->SetHighColor(CColor::Black); else Menu()->SetHighColor(CColor::BeDarkShadow); Menu()->StrokeRect(BRect(pos.x+2, pos.y+2, pos.x+boxSize+2, pos.y+boxSize+2)); if(IsEnabled()) Menu()->SetHighColor(color); else Menu()->SetHighColor(CColor::BeInactiveGray); Menu()->FillRect(BRect(pos.x+3, pos.y+3, pos.x+boxSize+1, pos.y+boxSize+1)); Menu()->SetHighColor(oldColor); }
void ModelMenuItem::DrawIcon() { Menu()->PushState(); BPoint where(ContentLocation()); // center icon with text. float deltaHeight = fHeightDelta < 0 ? -fHeightDelta : 0; where.y += ceil(deltaHeight / 2); if (fExtraPad) where.x += 6; Menu()->SetDrawingMode(B_OP_OVER); Menu()->SetLowColor(B_TRANSPARENT_32_BIT); // draw small icon, synchronously if (IsEnabled()) { IconCache::sIconCache->Draw(fModel.ResolveIfLink(), Menu(), where, kNormalIcon, B_MINI_ICON); } else { // dimmed, for now use a special blitter; icon cache should // know how to blit one eventually IconCache::sIconCache->SyncDraw(fModel.ResolveIfLink(), Menu(), where, kNormalIcon, B_MINI_ICON, DimmedIconBlitter); } Menu()->PopState(); }
void TBarMenuTitle::Draw() { BMenu* menu = Menu(); if (menu == NULL) return; BRect frame(Frame()); rgb_color base = menu->LowColor(); menu->PushState(); BRect windowBounds = menu->Window()->Bounds(); if (frame.right > windowBounds.right) frame.right = windowBounds.right; // fill in background if (IsSelected()) { be_control_look->DrawMenuItemBackground(menu, frame, frame, base, BControlLook::B_ACTIVATED); } else be_control_look->DrawButtonBackground(menu, frame, frame, base); menu->MovePenTo(ContentLocation()); DrawContent(); menu->PopState(); }
void KernelMemoryBarMenuItem::DrawContent() { DrawBar(true); Menu()->MovePenTo(ContentLocation()); BMenuItem::DrawContent(); }
/*! * \brief Performs actual drawing of the item. */ void CategoryMenuItem::DrawContent( void ) { float height; this->GetContentSize( NULL, &height ); if ( this->icon != NULL ) { // Drawing icon BPoint drawPoint( ContentLocation() ); Menu()->SetDrawingMode( B_OP_OVER ); Menu()->SetLowColor( B_TRANSPARENT_32_BIT ); // If the item is enabled, draw its icon semi-transparent if ( this->IsEnabled() == false ) { Menu()->SetDrawingMode( B_OP_BLEND ); Menu()->DrawBitmap( this->icon, drawPoint ); Menu()->SetDrawingMode( B_OP_OVER ); } else // else, use original color { Menu()->DrawBitmap( this->icon, drawPoint ); } // Move the pen to starting position of the label drawPoint.x += 2 * SPACING + ceilf( height - 2 ); Menu()->MovePenTo( drawPoint ); } // Draw the label using BMenuItem's function BMenuItem::DrawContent(); } // <-- end of function "CategoryMenuItem::DrawContent"
void ColorMenuItem::Draw /*Content*/() { float w, h; BPoint p; BMenu *m = Menu(); if (m == NULL) return; p = ContentLocation(); GetContentSize(&w, &h); rgb_color c = color; if (!IsEnabled()) { c.green = c.blue = c.red = (uint8) (0.4 * c.red + 0.2 * c.blue + 0.4 * c.green); } m->SetHighColor(c); m->FillRect(BRect(p.x+2, p.y+2, p.x+w-2, p.y+h-2)); if (IsMarked()) { rgb_color blue={0, 0, 255, 255}; m->SetHighColor(blue); m->StrokeRect(BRect(p.x, p.y, p.x+w, p.y+h)); } if (IsSelected()) { rgb_color red={0, 0, 255, 255}; m->SetHighColor(red); m->StrokeRect(BRect(p.x, p.y, p.x+w, p.y+h)); } }
void _AmIconMenuItem::DrawContent() { BPoint drawPoint( ContentLocation() ); drawPoint.x += 20; Menu()->MovePenTo( drawPoint ); inherited::DrawContent(); BPoint where( ContentLocation() ); where.y = Frame().top; if( mIcon ) { if( IsEnabled() ) Menu()->SetDrawingMode( B_OP_OVER ); else Menu()->SetDrawingMode( B_OP_BLEND ); Menu()->DrawBitmapAsync( mIcon, where ); } }
void TWindowMenuItem::DrawContent() { BMenu* menu = Menu(); BPoint contentLocation = ContentLocation() + BPoint(kHPad, 0); if (fID >= 0) { menu->SetDrawingMode(B_OP_OVER); float width = fBitmap->Bounds().Width(); if (width > 16) contentLocation.x -= 8; float height; GetContentSize(NULL, &height); contentLocation.y += (height - fBitmap->Bounds().Height()) / 2; menu->MovePenTo(contentLocation); menu->DrawBitmapAsync(fBitmap); if (width > 16) contentLocation.x += 8; contentLocation.x += kIconRect.Width() + kLabelOffset; } contentLocation.y = ContentLocation().y + kVPad + fLabelAscent; menu->SetDrawingMode(B_OP_COPY); menu->MovePenTo(contentLocation); if (IsSelected()) menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR)); else menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); float labelWidth = menu->StringWidth(Label()); BPoint penLocation = menu->PenLocation(); float offset = penLocation.x - Frame().left; menu->DrawString(Label(labelWidth + offset)); }
void BitmapMenuItem::DrawContent(void) { if (!Label() && !fBitmap) return; float width, height; GetContentSize(&width, &height); BRect drawrect(Frame()); drawrect.bottom--; drawrect.top++; drawrect.left = ContentLocation().x; if (fBitmap) { // Scale the fBitmap down to completely fit within the field's height if (fBitmap->Bounds().Height() > drawrect.Height()) { drawrect.right = drawrect.left + (fBitmap->Bounds().Width() * (Frame().Height() / fBitmap->Bounds().Height())); } else { drawrect.right = drawrect.left + fBitmap->Bounds().Width(); } } else { drawrect.right = drawrect.left - 5; } BPoint stringpoint(ContentLocation()); stringpoint.x = drawrect.right + 10; Menu()->MovePenTo(stringpoint); BMenuItem::DrawContent(); if (fBitmap) { Menu()->PushState(); Menu()->SetDrawingMode(B_OP_ALPHA); Menu()->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); Menu()->DrawBitmap(fBitmap, fBitmap->Bounds(), drawrect, B_FILTER_BITMAP_BILINEAR); Menu()->PopState(); } }
void LgiMenuItem::DrawContent() { BMenuItem::DrawContent(); if (i) { GScreenDC DC(Menu()); BPoint p = ContentLocation(); DC.SetOrigin(-p.x, -p.y); i->_Paint(&DC, 0); DC.SetOrigin(0, 0); } }
void ModelMenuItem::DrawContent() { if (fDrawText) { BPoint drawPoint(ContentLocation()); drawPoint.x += 20 + (fExtraPad ? 6 : 0); if (fHeightDelta > 0) drawPoint.y += ceil(fHeightDelta / 2); Menu()->MovePenTo(drawPoint); _inherited::DrawContent(); } DrawIcon(); }
BRect CTool::Frame() const { D_ACCESS(("CTool::Frame()\n")); BRect rect; float width, height; GetContentSize(&width, &height); rect.OffsetTo(ContentLocation()); rect.right = rect.left + width; rect.bottom = rect.top + height; return rect; }
void MemoryBarMenuItem::DrawContent() { DrawIcon(); if (fWriteMemory < 0) BarUpdate(); else DrawBar(true); BPoint loc = ContentLocation(); loc.x += 20; Menu()->MovePenTo(loc); BMenuItem::DrawContent(); }
void TWindowMenuItem::SetLabel(const char* string) { fFullTitle = string; BString truncatedTitle = fFullTitle; if (fExpanded && Menu()) { BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad); contLoc.x += kIconRect.Width() + kLabelOffset; be_plain_font->TruncateString(&truncatedTitle, B_TRUNCATE_MIDDLE, Frame().Width() - contLoc.x - 3.0f); } if (strcmp(Label(), truncatedTitle.String()) != 0) BMenuItem::SetLabel(truncatedTitle.String()); }
void TWindowMenuItem::DrawContent() { BMenu* menu = Menu(); menu->PushState(); BRect frame(Frame()); BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad); //if (fExpanded) // contLoc.x += kHPad; if (fID >= 0) { menu->SetDrawingMode(B_OP_OVER); float width = fBitmap->Bounds().Width(); if (width > 16) contLoc.x -= 8; menu->MovePenTo(contLoc); menu->DrawBitmapAsync(fBitmap); if (width > 16) contLoc.x += 8; contLoc.x += kIconRect.Width() + kLabelOffset; } menu->SetDrawingMode(B_OP_COPY); contLoc.y = frame.top + ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f; menu->MovePenTo(contLoc); if (IsSelected()) menu->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR)); else menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); BMenuItem::DrawContent(); menu->PopState(); }
void HTGTweetMenuItem::DrawContent() { if(linkIcon != NULL) { BRect rect( BPoint(ContentLocation().x-11.5, ContentLocation().y-1.5), BPoint(ContentLocation().x-11.5+B_MINI_ICON-1, ContentLocation().y-1.5+B_MINI_ICON-1) ); Menu()->SetDrawingMode(B_OP_ALPHA); Menu()->DrawBitmap(linkIcon, rect); Menu()->SetDrawingMode(B_OP_OVER); } Menu()->DrawString(Label(), BPoint(ContentLocation().x+6, ContentLocation().y+10.5)); }
void MemoryBarMenuItem::DrawIcon() { // TODO: exact code duplication with TeamBarMenuItem::DrawIcon() if (!fIcon) return; BPoint loc = ContentLocation(); BRect frame = Frame(); loc.y = frame.top + (frame.bottom - frame.top - 15) / 2; BMenu* menu = Menu(); if (fIcon->ColorSpace() == B_RGBA32) { menu->SetDrawingMode(B_OP_ALPHA); menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); } else menu->SetDrawingMode(B_OP_OVER); menu->DrawBitmap(fIcon, loc); menu->SetDrawingMode(B_OP_COPY); }
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 TTeamMenuItem::Draw() { BRect frame(Frame()); BMenu* menu = Menu(); menu->PushState(); rgb_color menuColor = menu->LowColor(); TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView(); bool canHandle = !barView->Dragging() || barView->AppCanHandleTypes(Signature()); if (be_control_look != NULL) { uint32 flags = 0; if (_IsSelected() && canHandle) flags |= BControlLook::B_ACTIVATED; uint32 borders = BControlLook::B_TOP_BORDER; if (fVertical) { menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT)); borders |= BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER; menu->StrokeLine(frame.LeftBottom(), frame.RightBottom()); frame.bottom--; be_control_look->DrawMenuBarBackground(menu, frame, frame, menuColor, flags, borders); } else { if (flags & BControlLook::B_ACTIVATED) menu->SetHighColor(tint_color(menuColor, B_DARKEN_3_TINT)); else menu->SetHighColor(tint_color(menuColor, 1.22)); borders |= BControlLook::B_BOTTOM_BORDER; menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); frame.left++; be_control_look->DrawButtonBackground(menu, frame, frame, menuColor, flags, borders); } menu->MovePenTo(ContentLocation()); DrawContent(); menu->PopState(); return; } // if not selected or being tracked on, fill with gray if ((!_IsSelected() && !menu->IsRedrawAfterSticky()) || !canHandle || !IsEnabled()) { frame.InsetBy(1, 1); menu->SetHighColor(menuColor); menu->FillRect(frame); } // draw the gray, unselected item, border if (!_IsSelected() || !IsEnabled()) { rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT); rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); frame = Frame(); menu->SetHighColor(shadow); if (fVertical) menu->StrokeLine(frame.LeftBottom(), frame.RightBottom()); else menu->StrokeLine(frame.LeftBottom() + BPoint(1, 0), frame.RightBottom()); menu->StrokeLine(frame.RightBottom(), frame.RightTop()); menu->SetHighColor(light); menu->StrokeLine(frame.RightTop() + BPoint(-1, 0), frame.LeftTop()); if (fVertical) menu->StrokeLine(frame.LeftTop(), frame.LeftBottom() + BPoint(0, -1)); else menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); } // if selected or being tracked on, fill with the hilite gray color if (IsEnabled() && _IsSelected() && !menu->IsRedrawAfterSticky() && canHandle) { // fill menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT)); menu->FillRect(frame); // these continue the dark grey border on the left or top edge menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT)); if (fVertical) { // dark line at top menu->StrokeLine(frame.LeftTop(), frame.RightTop()); } else { // dark line on the left menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); } } else menu->SetLowColor(menuColor); menu->MovePenTo(ContentLocation()); DrawContent(); menu->PopState(); }
void BSCMenuItem::DrawContent() { Menu()->SetFontSize(10); switch (fAction) { case BSC_START: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BRect imageRect; imageRect.SetLeftTop(ContentLocation()); imageRect.top += 2; imageRect.right = imageRect.left + 10; imageRect.bottom = Frame().bottom - 2; Menu()->SetHighColor(248, 0, 0); Menu()->FillEllipse(imageRect); break; } case BSC_STOP: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BRect imageRect; imageRect.SetLeftTop(ContentLocation()); imageRect.top += 2; imageRect.right = imageRect.left + 10; imageRect.bottom = Frame().bottom - 2; Menu()->SetHighColor(248, 0, 0); Menu()->FillRect(imageRect); break; } case BSC_PAUSE: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BRect imageRect; imageRect.SetLeftTop(ContentLocation()); imageRect.top += 2; imageRect.right = imageRect.left + 4; imageRect.bottom = Frame().bottom - 2; Menu()->SetHighColor(0, 250, 0); Menu()->FillRect(imageRect); imageRect.OffsetBy(6, 0); Menu()->FillRect(imageRect); break; } case BSC_RESUME: { BPoint drawPoint(ContentLocation()); drawPoint.x += 20; drawPoint.y += 2; Menu()->MovePenTo(drawPoint); BMenuItem::DrawContent(); BPoint ptOne = ContentLocation(); BPoint ptTwo = ptOne; ptTwo.y = Frame().bottom - 2; BPoint ptThree = ptOne; ptThree.x += 10; ptThree.y += (ptTwo.y - ptOne.y) / 2; Menu()->SetHighColor(0, 250, 0); Menu()->FillTriangle(ptOne, ptTwo, ptThree); break; } default: BMenuItem::DrawContent(); break; } }