Example #1
0
void
TSeparatorItem::Draw()
{
	BMenu* menu = Menu();
	if (menu == NULL)
		return;

	BRect frame(Frame());
	frame.right = frame.left + kSepItemWidth;
	rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);

	menu->PushState();

	menu->SetHighColor(tint_color(base, 1.22));
	frame.top--;
		// need to expand the frame for some reason

	// stroke a darker line on the left edge
	menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
	frame.left++;

	// fill in background
	be_control_look->DrawButtonBackground(menu, frame, frame, base);

	menu->PopState();
}
Example #2
0
void
BSeparatorItem::Draw()
{
	BMenu *menu = Menu();
	if (menu == NULL)
		return;

	BRect bounds = Frame();
	rgb_color oldColor = menu->HighColor();
	rgb_color lowColor = menu->LowColor();

	const float startTop = bounds.top + (floor(bounds.Height())) / 2;
	menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
	menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop),
		BPoint(bounds.right - 1.0f, startTop));
	menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
	menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
		BPoint(bounds.right - 1.0f, startTop + 1.0f));

	menu->SetHighColor(oldColor);
}
Example #3
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 #4
0
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);
	}
}