当前位置: 首页>>代码示例>>C++>>正文


C++ BMenu::GetFont方法代码示例

本文整理汇总了C++中BMenu::GetFont方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenu::GetFont方法的具体用法?C++ BMenu::GetFont怎么用?C++ BMenu::GetFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BMenu的用法示例。


在下文中一共展示了BMenu::GetFont方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BWindow

Tearoff::Tearoff(BRect frame, const char *name, MainWindow *parent, MenuName menu_name, int idx)
	: BWindow(frame, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0)
{
	int y = 0;
	BFont font;
	BMenu *menu;
	
	this->parent = parent;
	menu = parent->GetMenu(menu_name);
	menu->GetFont(&font);
	for(int i = 1; i < menu->CountItems(); i++) {
		BMenuItem *item = menu->ItemAt(i);
		if(item->Message()) {
			BButton *b = new BButton(BRect(0, y, frame.IntegerWidth(), y + TEAROFF_BUTTON_HEIGHT), "", item->Label(), new BMessage(item->Message()->what), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); 
			font.SetSize(TEAROFF_FONT_SIZE);
			b->SetFont(&font);
			AddChild(b);
			y = y + TEAROFF_BUTTON_HEIGHT;
		}
	}
	this->ResizeTo(frame.IntegerWidth(), y);
	this->SetTitle(menu->Name());
	this->index = idx;
	delete menu;
}
开发者ID:brennanos,项目名称:XFile-Haiku,代码行数:25,代码来源:Tearoff.cpp

示例2: Menu

void
BMenuItem::_DrawShortcutSymbol()
{
	BMenu *menu = Menu();
	BFont font;
	menu->GetFont(&font);
	BPoint where = ContentLocation();
	where.x = fBounds.right - font.Size();

	if (fSubmenu)
		where.x -= fBounds.Height() - 3;

	const float ascent = MenuPrivate(fSuper).Ascent();
	if (fShortcutChar < B_SPACE && kUTF8ControlMap[(int)fShortcutChar])
		_DrawControlChar(fShortcutChar, where + BPoint(0, ascent));
	else
		fSuper->DrawChar(fShortcutChar, where + BPoint(0, ascent));

	where.y += (fBounds.Height() - 11) / 2 - 1;
	where.x -= 4;

	if (fModifiers & B_COMMAND_KEY) {
		const BBitmap *command = MenuPrivate::MenuItemCommand();
		const BRect &rect = command->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(command, where);
	}

	if (fModifiers & B_CONTROL_KEY) {
		const BBitmap *control = MenuPrivate::MenuItemControl();
		const BRect &rect = control->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(control, where);
	}

	if (fModifiers & B_OPTION_KEY) {
		const BBitmap *option = MenuPrivate::MenuItemOption();
		const BRect &rect = option->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(option, where);
	}

	if (fModifiers & B_SHIFT_KEY) {
		const BBitmap *shift = MenuPrivate::MenuItemShift();
		const BRect &rect = shift->Bounds();
		where.x -= rect.Width() + 1;
		fSuper->DrawBitmap(shift, where);
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:49,代码来源:MenuItem.cpp

示例3: DrawContent

	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();
	}
开发者ID:jessicah,项目名称:Vision,代码行数:68,代码来源:ColorSelector.cpp


注:本文中的BMenu::GetFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。