コード例 #1
0
void BitmapMenuItem::Draw(void)
{
	BMenu* menu = Menu();
	if (menu) {
		BRect itemFrame = Frame();
		BRect bitmapFrame = itemFrame;
		bitmapFrame.InsetBy(2, 2); // account for 2-pixel margin
		
		menu->SetDrawingMode(B_OP_COPY);
		menu->SetHighColor(BKG_GREY);
		menu->FillRect(itemFrame);
		menu->DrawBitmap(&m_bitmap, bitmapFrame);
		
		if (IsSelected()) {
			// a nonstandard but simple way to draw highlights
			menu->SetDrawingMode(B_OP_INVERT);
			menu->SetHighColor(0,0,0);
			menu->FillRect(itemFrame);
		}
	}
}
コード例 #2
0
ファイル: MemoryBarMenuItem.cpp プロジェクト: DonCN/haiku
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);
}