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(); }
BButton* ScreenWindow::_CreateColumnRowButton(bool columns, bool plus) { BMessage* message = new BMessage(kMsgWorkspaceLayoutChanged); message->AddInt32("delta_x", columns ? (plus ? 1 : -1) : 0); message->AddInt32("delta_y", !columns ? (plus ? 1 : -1) : 0); BButton* button = new BButton(plus ? "+" : "-", message); button->SetFontSize(be_plain_font->Size() * 0.9); BSize size = button->MinSize(); size.width = button->StringWidth("+") + 16; button->SetExplicitMinSize(size); button->SetExplicitMaxSize(size); fWorkspacesButtons[(columns ? 0 : 2) + (plus ? 1 : 0)] = button; return button; }