本文整理汇总了C++中BButton::SetFont方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::SetFont方法的具体用法?C++ BButton::SetFont怎么用?C++ BButton::SetFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BButton
的用法示例。
在下文中一共展示了BButton::SetFont方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BView
TView::TView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
: BView(frame, name, resizingMode, flags)
{
BFont font;
BButton *btn = new BButton(BRect(10, 10, 150, 50), NULL, "Hello World", new BMessage(BTN_HELLO_WORLD_EN_MSG));
btn->ForceFontAliasing(true);
if (font.SetFamilyAndStyle("SimSun", "Regular") == B_OK) btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
btn->SetFontSize(20);
AddChild(btn);
btn = new BButton(BRect(10, 100, 50, 120), NULL, "Ciao Mondo", new BMessage(BTN_HELLO_WORLD_IT_MSG));
btn->ForceFontAliasing(true);
if (font.SetFamilyAndStyle("SimHei", "Regular") == B_OK) {
btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
btn->SetFontSize(24);
}
AddChild(btn);
btn->ResizeToPreferred();
btn = new BButton(BRect(10, 150, 40, 180), NULL, "Disabled", new BMessage(BTN_NOT_ENABLED_MSG));
btn->SetEnabled(false);
AddChild(btn);
btn->ResizeToPreferred();
}
示例2: 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;
}