Example #1
0
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();
}
Example #2
0
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();
}
Example #3
0
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));
}
Example #4
0
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();
			}
		}
	}
}
Example #5
0
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();
}
Example #6
0
	virtual	void DrawContent()
	{
		BRect		b = Frame();
		BMenu		*parent = Menu();
		BPoint		loc = parent->PenLocation();

		enum {
			W_CHAR = 0,
			A_CHAR = 1,
			OPEN_CHAR = 2,
			CLOSE_CHAR = 3,
			SPACE_CHAR = 4,
			NUM_CHARS = 5
		};
		float escapements[NUM_CHARS];
		BFont font;
		parent->GetFont(&font);
		font.GetEscapements("WA() ", NUM_CHARS, escapements);
		for (int32 i=0; i<NUM_CHARS; i++) {
			escapements[i] *= font.Size();
		}

		const float blockWidth = escapements[W_CHAR]+escapements[A_CHAR];

		const rgb_color old_col = parent->HighColor();
		font_height fh;

		const bool showInitial = !CompareColors(fInitialColor, fColor);

		b.InsetBy(1, 1);
		b.bottom -= 1;
		b.left = loc.x;

		if (showInitial) {
			parent->GetFontHeight(&fh);
			parent->DrawString("(", BPoint(b.left, loc.y+fh.ascent));
		}
		b.left += escapements[OPEN_CHAR];
		b.InsetBy(2, 2);
		b.right = b.left + escapements[W_CHAR];
		if (showInitial) {
			parent->SetHighColor(fInitialColor);
			parent->FillRect(b);
		}
		b.InsetBy(-1, -1);
		if (showInitial) {
			parent->SetHighColor(old_col);
			parent->StrokeRect(b);
		}
		b.InsetBy(-1, -1);
		if (showInitial) {
			parent->DrawString(")", BPoint(b.right+1, loc.y+fh.ascent));
		}
		b.right += escapements[CLOSE_CHAR] + 1;

		b.left = b.right + escapements[SPACE_CHAR];
		b.right = b.left + blockWidth;

		parent->SetHighColor(fColor);
		parent->FillRect(b);
		parent->SetHighColor(old_col);
		b.InsetBy(-1, -1);
		parent->StrokeRect(b);

		parent->MovePenTo(b.right + escapements[SPACE_CHAR]*2 + 2, loc.y);

		BMenuItem::DrawContent();
	}