Exemplo n.º 1
0
void
BIconItem::DrawItem(BView* owner, BRect frame, bool complete)
{
	float iconSize = fFrame.Width();
	DrawItemWithTextOffset(owner, frame, complete, iconSize + 4);

	BRect iconFrame(frame.left + kLeftInset, frame.top,
		frame.left + kLeftInset + iconSize - 1, frame.top + iconSize - 1);
	owner->SetDrawingMode(B_OP_OVER);
	owner->DrawPicture(&fPicture, iconFrame.LeftTop());
	owner->SetDrawingMode(B_OP_COPY);
}
Exemplo n.º 2
0
void
TeamListItem::DrawItem(BView* owner, BRect frame, bool complete)
{
	rgb_color kHighlight = { 140, 140, 140, 0 };
	rgb_color kBlack = { 0, 0, 0, 0 };
	rgb_color kBlue = { 0, 0, 255, 0 };
	rgb_color kRed = { 255, 0, 0, 0 };

	BRect r(frame);

	if (IsSelected() || complete) {
		rgb_color color;
		if (IsSelected())
			color = kHighlight;
		else
			color = owner->ViewColor();

		owner->SetHighColor(color);
		owner->SetLowColor(color);
		owner->FillRect(r);
		owner->SetHighColor(kBlack);
	} else {
		owner->SetLowColor(owner->ViewColor());
	}

	frame.left += 4;
	BRect iconFrame(frame);
	iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15,
		iconFrame.top + 16);
	owner->SetDrawingMode(B_OP_ALPHA);
	owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	owner->DrawBitmap(&fMiniIcon, iconFrame);
	owner->SetDrawingMode(B_OP_COPY);

	frame.left += 16;
	if (fRefusingToQuit)
		owner->SetHighColor(kRed);
	else
		owner->SetHighColor(IsSystemServer() ? kBlue : kBlack);

	BFont font = be_plain_font;
	font_height	finfo;
	font.GetHeight(&finfo);
	owner->SetFont(&font);
	owner->MovePenTo(frame.left + 8, frame.top + ((frame.Height()
			- (finfo.ascent + finfo.descent + finfo.leading)) / 2)
		+ finfo.ascent);

	if (gLocalizedNamePreferred)
		owner->DrawString(fLocalizedName.String());
	else
		owner->DrawString(fPath.Leaf());
}
Exemplo n.º 3
0
void
IconsSaver::Draw(BView *view, int32 frame)
{
	static int32 previousFrame = 0;

	// Update drawing
	if (fBackBitmap->Lock()) {
		for (uint8 i = 0 ; i < MAX_ICONS ; i++) {
			fIcons[i].ClearOn(fBackView);
		}

		int32 delta = frame - previousFrame;

		for (uint8 i = 0 ; i < MAX_ICONS ; i++) {
			fIcons[i].DrawOn(fBackView, delta);
		}
		fBackView->Sync();
		fBackBitmap->Unlock();
	}

	// Sync the view with the back buffer
	view->DrawBitmap(fBackBitmap);
	previousFrame = frame;

	if (fVectorIconsCount <= 0)
		return;

	// Restart one icon
	for (uint8 i = 0 ; i < MAX_ICONS ; i++) {
		if (!fIcons[i].IsRunning()) {
			uint16 size = RAND_BETWEEN(fMinSize, fMaxSize);
			uint16 maxX = view->Frame().IntegerWidth() - size;
			uint16 maxY = view->Frame().IntegerHeight() - size;

			BRect iconFrame(0, 0, size, size);
			iconFrame.OffsetTo(RAND_BETWEEN(0, maxX), RAND_BETWEEN(0, maxY));

			// Check that the icon doesn't overlap with others
			for (uint8 j = 0 ; j < MAX_ICONS ; j++) {
				if (fIcons[j].IsRunning() &&
					iconFrame.Intersects(fIcons[j].GetFrame()))
					return;
			}

			int32 index = RAND_BETWEEN(0, fVectorIconsCount - 1);

			fIcons[i].Run((VectorIcon*)fVectorIcons.ItemAt(index), iconFrame);

			return;
		}
	}
}
	void Render(BView* onto, BRect frame, bool complete = false)
	{
		const rgb_color lowColor = onto->LowColor();
		const rgb_color highColor = onto->HighColor();
		const rgb_color kBlack = {0, 0, 0, 255};
	
		if (fSelected || complete) {
			if (fSelected)
				onto->SetLowColor(tint_color(lowColor, B_DARKEN_2_TINT));
			onto->FillRect(frame, B_SOLID_LOW);
		}

		frame.left += 4;
		frame.top += kITEM_MARGIN;
		BRect iconFrame(MediaIcons::IconRectAt(frame.LeftTop() + BPoint(1, 0)));
	
		onto->SetDrawingMode(B_OP_OVER);
		if (fPrimaryIcon && !fDoubleInsets) {
			onto->DrawBitmap(fPrimaryIcon, iconFrame);
			frame.left = iconFrame.right + 1;
		} else if (fSecondaryIcon) {
			onto->DrawBitmap(fSecondaryIcon, iconFrame);
		}
		iconFrame = MediaIcons::IconRectAt(iconFrame.RightTop() + BPoint(1, 0));

		if (fDoubleInsets && fPrimaryIcon) {
			onto->DrawBitmap(fPrimaryIcon, iconFrame);
			frame.left = iconFrame.right + 1;
		}

		onto->SetDrawingMode(B_OP_COPY);
		onto->SetHighColor(kBlack);
		
		BFont font = be_plain_font;
		font_height	fontInfo;
		font.GetHeight(&fontInfo);
		float lineHeight = fontInfo.ascent + fontInfo.descent
			+ fontInfo.leading;
		onto->SetFont(&font);
		onto->MovePenTo(frame.left + 8, frame.top
			+ ((frame.Height() - (lineHeight)) / 2)
			+ (fontInfo.ascent + fontInfo.descent) - 1);
		onto->DrawString(fTitle);

		onto->SetHighColor(highColor);
		onto->SetLowColor(lowColor);
	}
void
LanguageListItemWithFlag::DrawItem(BView* owner, BRect frame, bool complete)
{
	if (fIcon == NULL || !fIcon->IsValid()) {
		DrawItemWithTextOffset(owner, frame, complete, 0);
		return;
	}

	float iconSize = fIcon->Bounds().Width();
	DrawItemWithTextOffset(owner, frame, complete, iconSize + 4);

	BRect iconFrame(frame.left + kLeftInset, frame.top,
		frame.left + kLeftInset + iconSize - 1, frame.top + iconSize - 1);
	owner->SetDrawingMode(B_OP_OVER);
	owner->DrawBitmap(fIcon, iconFrame);
	owner->SetDrawingMode(B_OP_COPY);
}
Exemplo n.º 6
0
void
TimeZoneListItem::DrawItem(BView* owner, BRect frame, bool complete)
{
	if (fIcon != NULL && fIcon->IsValid()) {
		float iconSize = fIcon->Bounds().Width();
		_DrawItemWithTextOffset(owner, frame, complete,
			iconSize + be_control_look->DefaultLabelSpacing());

		BRect iconFrame(frame.left + be_control_look->DefaultLabelSpacing(),
			frame.top,
			frame.left + iconSize - 1 + be_control_look->DefaultLabelSpacing(),
			frame.top + iconSize - 1);
		owner->SetDrawingMode(B_OP_OVER);
		owner->DrawBitmap(fIcon, iconFrame);
		owner->SetDrawingMode(B_OP_COPY);
	} else
		_DrawItemWithTextOffset(owner, frame, complete, 0);
}
void
TimeZoneListItem::DrawItem(BView* owner, BRect frame, bool complete)
{
	rgb_color kHighlight = {140, 140, 140, 0};
	rgb_color kBlack = {0, 0, 0, 0};

	if (IsSelected() || complete) {
		rgb_color color;
		if (IsSelected())
			color = kHighlight;
		else
			color = owner->ViewColor();
		owner->SetHighColor(color);
		owner->SetLowColor(color);
		owner->FillRect(frame);
		owner->SetHighColor(kBlack);
	} else
		owner->SetLowColor(owner->ViewColor());

	// Draw the text
	BString text = Text();

	BFont font = be_plain_font;
	font_height	finfo;
	font.GetHeight(&finfo);
	owner->SetFont(&font);
	// TODO: the position is unnecessarily complicated, and not correct either
	owner->MovePenTo(frame.left + 8, frame.top
		+ (frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2
		+ (finfo.ascent + finfo.descent) - 1);
	owner->DrawString(text.String());

	// Draw the icon
	frame.left = frame.right - 16;
	BRect iconFrame(frame);
	iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15,
		iconFrame.top + 16);

	if (fIcon != NULL && fIcon->IsValid()) {
		owner->SetDrawingMode(B_OP_OVER);
		owner->DrawBitmap(fIcon, iconFrame);
		owner->SetDrawingMode(B_OP_COPY);
	}
}