quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*> CheckView::MakeField(uint16 width, string name, uint16* xpos, uint16* ypos) { BStringView* sv = new BStringView(BRect((*xpos), (*ypos), (*xpos) + width, (*ypos) + 10), (name + "Text").c_str(), name.c_str()); BFont font; sv->GetFont(&font); font.SetSize(10); sv->SetFont(&font); AddChild(sv); BTextControl* tc = new BTextControl(BRect((*xpos) - 5, (*ypos) + 10, (*xpos) + width, (*ypos) + 10), (name + "Field").c_str(), "", "", 0); (*xpos) += width; tc->SetDivider(0); AddChild(tc); BPopUpMenu* pu = new BPopUpMenu("", true, false); BMenuField* mf = new BMenuField(BRect((*xpos) + 2, (*ypos) + 9, (*xpos) + 2, (*ypos) + 9), (name + "Menu").c_str(), "", pu); mf->SetDivider(0); AddChild(mf); (*xpos) += 30; return quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*>(tc, pu, mf, sv); }
ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BStringView *titleView = new BStringView("title", B_TRANSLATE("Rich Text Format (RTF) translator")); titleView->SetFont(be_bold_font); char version[256]; snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( RTF_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView( "Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc."); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .AddGlue(); }
InfoView::InfoView() : BGroupView(B_TRANSLATE("Information"), B_HORIZONTAL) { BStringView* rendererView = new BStringView(NULL, (const char*)glGetString(GL_RENDERER)); rendererView->SetExplicitAlignment(kLabelAlignment); rendererView->SetFont(be_bold_font); BStringView* vendorNameView = new BStringView(NULL, (const char*)glGetString(GL_VENDOR)); vendorNameView->SetExplicitAlignment(kLabelAlignment); BStringView* glVersionView = new BStringView(NULL, (const char*)glGetString(GL_VERSION)); glVersionView->SetExplicitAlignment(kLabelAlignment); BString apiString("GLU "); apiString << (const char*)gluGetString(GLU_VERSION); apiString << ", GLUT "; apiString << (int32)GLUT_API_VERSION; BStringView* apiVersionView = new BStringView(NULL, apiString.String()); apiVersionView->SetExplicitAlignment(kLabelAlignment); BLayoutBuilder::Group<>(this) .AddGroup(B_VERTICAL, 0) .Add(rendererView) .Add(vendorNameView) .Add(glVersionView) .Add(apiVersionView) .End(); }
ServiceView::ServiceView(const char* name, const char* executable, const char* title, const char* description, BNetworkSettings& settings) : BView("service", 0), fName(name), fExecutable(executable), fSettings(settings) { BStringView* titleView = new BStringView("service", title); titleView->SetFont(be_bold_font); titleView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BTextView* descriptionView = new BTextView("description"); descriptionView->SetText(description); descriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); descriptionView->MakeEditable(false); fEnableButton = new BButton("toggler", B_TRANSLATE("Enable"), new BMessage(kMsgToggleService)); BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(titleView) .Add(descriptionView) .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fEnableButton); SetExplicitMinSize(BSize(200, B_SIZE_UNSET)); _UpdateEnableButton(); fWasEnabled = IsEnabled(); }
WonderBrushView::WonderBrushView(const BRect &frame, const char *name, uint32 resize, uint32 flags, TranslatorSettings *settings) : BView(frame, name, resize, flags), fSettings(settings) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("WonderBrush image translator")); titleView->SetFont(be_bold_font); char version[100]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(WBI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(WBI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( WBI_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView("copyright", kWBICopyright); BStringView *copyright2View = new BStringView("copyright2", B_TRANSLATE("written by:")); BStringView *copyright3View = new BStringView("copyright3", kAuthor); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .AddGlue() .Add(copyright2View) .Add(copyright3View); }
void Shelf::StartConfig(BView *view) { PRINT(("%p:%s()\n", this, __FUNCTION__)); fInConfig = true; BStringView* titleString = new BStringView("Title", B_TRANSLATE("Shelf")); titleString->SetFont(be_bold_font); BStringView* copyrightString = new BStringView("Copyright", B_TRANSLATE("© 2012 François Revol.")); BTextView* helpText = new BTextView("Help Text"); helpText->MakeEditable(false); helpText->SetViewColor(view->ViewColor()); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); helpText->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); BString help; help << B_TRANSLATE("Drop replicants on the full-screen window " "behind the preferences panel."); //help << "\n\n"; //help << B_TRANSLATE("You can also drop colors."); helpText->SetText(help.String()); BLayoutBuilder::Group<>(view, B_VERTICAL, B_USE_HALF_ITEM_SPACING) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleString) .Add(copyrightString) .AddStrut(roundf(be_control_look->DefaultItemSpacing() / 2)) .Add(helpText) .AddGlue() .End(); BScreen screen; fConfigWindow = new BWindow(screen.Frame(), "Shelf Config", B_UNTYPED_WINDOW, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FRONT | B_AVOID_FOCUS); BView *shelfView = new BView(fConfigWindow->Bounds(), "ShelfView", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS); shelfView->SetViewColor(216, 216, 216, 0); fConfigWindow->AddChild(shelfView); fShelfData.Seek(SEEK_SET, 0LL); fShelf = new BShelf(&fShelfData, shelfView); fShelf->SetDisplaysZombies(true); fShelfData.Seek(SEEK_SET, 0LL); // start the Looper fConfigWindow->Show(); fConfigWindow->Lock(); fConfigWindow->SendBehind(view->Window()); fConfigWindow->Unlock(); //"\nDrop replicants on me!" }
void Clock::StartConfig(BView *view) { tview = new BStringView(BRect(10, 10, 200, 35), B_EMPTY_STRING, "Simple Clock"); tview->SetFont(be_bold_font); tview->SetFontSize(15); view->AddChild(tview); view->AddChild(new BStringView(BRect(10, 40, 200, 65), B_EMPTY_STRING, " Ver 0.1, ©3dEyes**")); }
BView* AboutView::_CreateLabel(const char* name, const char* label) { BStringView* labelView = new BStringView(name, label); labelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); labelView->SetFont(be_bold_font); return labelView; }
AskName::AskName(): BWindow(BRect(100, 100, 500, 200), "Enter your name", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE), Text(NULL), text(NULL) { BView *back; BButton * Accept; BTextView *TV; BStringView *str; const char *names[] = { "BeOS forever!", "BShisen Rules!", "Thanks Sheppy", "Say NO to drugs!", "Say NO to piracy!", "Say YES to BeOS!", "Just say \"BShisen\"", "Say YES to BShisen!", }; back = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW); back->SetViewColor(216, 216, 216); AddChild(back); str = new BStringView(BRect(10, 10, 390, 25), "", "Congratulations! Enter your name for posterity."); str->SetFont(be_bold_font); back->AddChild(str); Accept = new BButton( BRect(10, 60+5, 90, 75+5), "Accept", "Accept", new BMessage(ACCEPT_BUTTON)); Accept->MakeDefault(true); back->AddChild(Accept); Text = new BTextControl(BRect(10, 35, 390, 50), "", "Your Name", "", NULL); Text->SetDivider(Text->StringWidth("Your Name ")); TV = Text->TextView(); TV->SetMaxBytes(31); Text->SetText(REGISTERED ? names[rand() % 8] : "I Want To Register!"); back->AddChild(Text); Text->MakeFocus(true); }
SetKeyWindow::SetKeyWindow(BPoint p, int32 i, BView *v) : BWindow(BRect(p.x,p.y,p.x,p.y),Language.get("SET_KEY_WINDOW"), B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) , index(i), parent(v) { BRect r(0,0,300,150); ResizeTo(r.Width(), r.Height()); MoveBy(-r.Width()/2, -r.Height()/2); BView *view = new BView(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); r.InsetBy(8,8); r.bottom = r.top+19; BStringView *st; r.right = r.left + be_bold_font->StringWidth(Language.get("KEY_SETTINGS_FOR")); view->AddChild(st = new BStringView(r, NULL, Language.get("KEY_SETTINGS_FOR") )); st->SetFont(be_bold_font); r.left = r.right+8; r.right = Bounds().right-8; view->AddChild(new BStringView(r, NULL, Language.get(KeyBind.GetID(index)) )); // request the installed message key = KeyBind.GetKey( KeyBind.GetID(index) ); key2 = KeyBind.GetKeyAlt( KeyBind.GetID(index) ); mod = KeyBind.GetMod( KeyBind.GetID(index) ); mod2 = KeyBind.GetModAlt( KeyBind.GetID(index) ); message = KeyBind.GetMessage( KeyBind.GetID(index) ); menu = KeyBind.IsMenuItem( KeyBind.GetID(index) ); r.OffsetBy(0,30); r.left = 8; float x = 8 + MAX( be_plain_font->StringWidth(Language.get("PRIMARY")), be_plain_font->StringWidth(Language.get("ALTERNATE"))); r.right = Bounds().right -96; view->AddChild(control1 = new KeyControl(r, Language.get("PRIMARY"), key, mod, menu)); control1->SetDivider(x); view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, Language.get("CLEAR"), new BMessage(CLEAR1)) ); r.OffsetBy(0,30); view->AddChild(control2 = new KeyControl(r, Language.get("ALTERNATE"), key2, mod2, false)); control2->SetDivider(x); view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, Language.get("CLEAR"), new BMessage(CLEAR2)) ); r = Bounds(); r.InsetBy(8,8); r.top = r.bottom - 23; r.left = r.right - 80; view->AddChild(new BButton(r, NULL, Language.get("APPLY"), new BMessage(SET)) ); r.OffsetBy(-(r.Width()+8), 0); view->AddChild(new BButton(r, NULL, Language.get("CANCEL"), new BMessage(B_QUIT_REQUESTED)) ); AddChild(view); Run(); Show(); }
AlertView::AlertView(BRect frame, const char *name) : BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED), // we will wait 12 seconds until we send a message fSeconds(12) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fBitmap = InitIcon(); BRect rect(60, 8, 400, 36); BStringView *stringView = new BStringView(rect, NULL, "Do you wish to keep these settings?"); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); AddChild(stringView); rect = stringView->Frame(); rect.OffsetBy(0, rect.Height()); fCountdownView = new BStringView(rect, "countdown", NULL); UpdateCountdownView(); fCountdownView->ResizeToPreferred(); AddChild(fCountdownView); BButton* keepButton = new BButton(rect, "keep", "Keep", new BMessage(BUTTON_KEEP_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); keepButton->ResizeToPreferred(); AddChild(keepButton); BButton* button = new BButton(rect, "undo", "Undo", new BMessage(BUTTON_UNDO_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); AddChild(button); // we're resizing ourselves to the right size // (but we're not implementing GetPreferredSize(), bad style!) float width = stringView->Frame().right; if (fCountdownView->Frame().right > width) width = fCountdownView->Frame().right; if (width < Bounds().Width()) width = Bounds().Width(); float height = fCountdownView->Frame().bottom + 24 + button->Bounds().Height(); ResizeTo(width, height); keepButton->MoveTo(Bounds().Width() - 8 - keepButton->Bounds().Width(), Bounds().Height() - 8 - keepButton->Bounds().Height()); button->MoveTo(keepButton->Frame().left - button->Bounds().Width() - 8, keepButton->Frame().top); keepButton->MakeDefault(true); }
ConfigView::ConfigView(TranslatorSettings *settings) : BGroupView("ICNSTranslator Settings", B_VERTICAL, 0) { fSettings = settings; BStringView *titleView = new BStringView("title", B_TRANSLATE("Apple icon translator")); titleView->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(ICNS_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(ICNS_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(ICNS_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView("copyright", B_UTF8_COPYRIGHT "2005-2006 Haiku Inc."); BStringView *copyright2View = new BStringView("my_copyright", B_UTF8_COPYRIGHT "2012 Gerasim Troeglazov <*****@*****.**>."); BStringView *infoView = new BStringView("support_sizes", B_TRANSLATE("Valid sizes: 16, 32, 48, 128, 256, 512, 1024")); BStringView *info2View = new BStringView("support_colors", B_TRANSLATE("Valid colors: RGB32, RGBA32")); BStringView *copyright3View = new BStringView("copyright3", "libicns v0.8.1\n"); BStringView *copyright4View = new BStringView("copyright4", "2001-2012 Mathew Eis <*****@*****.**>"); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .Add(copyright2View) .AddGlue() .Add(infoView) .Add(info2View) .AddGlue() .Add(copyright3View) .Add(copyright4View); SetExplicitPreferredSize(GroupLayout()->MinSize()); }
// This is used to provide a consistent look for the settings view for screen // savers without any configuration. void BuildScreenSaverDefaultSettingsView(BView* view, const char* moduleName, const char* info) { BRect rect(15, 15, 20, 20); BStringView* stringView = new BStringView(rect, "module", moduleName); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); view->AddChild(stringView); rect.OffsetBy(0, stringView->Bounds().Height() + 4); stringView = new BStringView(rect, "info", info); stringView->ResizeToPreferred(); view->AddChild(stringView); }
BView * LibraryWindow::AddHeader(BPoint location, const char *label) { Lock(); BRect r(location.x,location.y,location.x + 1, location.y + 1); BStringView *header = new BStringView(r,"header",label); fCheckList->AddChild(header); header->SetFont(be_bold_font); header->SetHighColor(0,0,255); header->ResizeToPreferred(); Unlock(); return header; }
void UninstallView::_InitView() { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fAppList = new BListView("pkg_list", B_SINGLE_SELECTION_LIST); fAppList->SetSelectionMessage(new BMessage(P_MSG_SELECT)); BScrollView* scrollView = new BScrollView("list_scroll", fAppList, 0, false, true, B_NO_BORDER); BStringView* descriptionLabel = new BStringView("desc_label", B_TRANSLATE("Package description")); descriptionLabel->SetFont(be_bold_font); fDescription = new BTextView("description", B_WILL_DRAW); fDescription->MakeSelectable(false); fDescription->MakeEditable(false); fDescription->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fDescription->SetText(fNoPackageSelectedString); fButton = new BButton("removal", B_TRANSLATE("Remove"), new BMessage(P_MSG_REMOVE)); fButton->SetEnabled(false); const float spacing = be_control_look->DefaultItemSpacing(); BGroupLayoutBuilder builder(GroupLayout()); builder.Add(scrollView) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(BGroupLayoutBuilder(B_VERTICAL) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(descriptionLabel) .AddGlue() ) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(fDescription) ) .SetInsets(spacing, spacing, spacing, spacing) ) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(BGroupLayoutBuilder(B_HORIZONTAL) .AddGlue() .Add(fButton) .SetInsets(spacing, spacing, spacing, spacing) ) ; }
ConfigView::ConfigView(uint32 flags) : BView("EXRTranslator Settings", flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BStringView *fTitle = new BStringView("title", B_TRANSLATE("EXR image translator")); fTitle->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(EXR_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(EXR_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(EXR_TRANSLATOR_VERSION)), __DATE__); BStringView *fVersion = new BStringView("version", version); BStringView *fCopyright = new BStringView("copyright", B_UTF8_COPYRIGHT "2008 Haiku Inc."); BStringView *fCopyright2 = new BStringView("copyright2", B_TRANSLATE("Based on OpenEXR (http://www.openexr.com)")); BStringView *fCopyright3 = new BStringView("copyright3", B_UTF8_COPYRIGHT "2006, Industrial Light & Magic,"); BStringView *fCopyright4 = new BStringView("copyright4", B_TRANSLATE("a division of Lucasfilm Entertainment Company Ltd")); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL, 7) .SetInsets(5) .Add(fTitle) .Add(fVersion) .AddGlue() .Add(fCopyright) .Add(fCopyright2) .AddGlue() .Add(fCopyright3) .Add(fCopyright4) .AddGlue(); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize(font.Size() * 400 / 12, font.Size() * 200 / 12)); }
// Provides a consistent look for the settings view for screen savers // that don't provide any configuration settings. void BuildDefaultSettingsView(BView* view, const char* moduleName, const char* info) { view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView* nameStringView = new BStringView("module", moduleName); nameStringView->SetFont(be_bold_font); BStringView* infoStringView = new BStringView("info", info); BLayoutBuilder::Group<>(view, B_VERTICAL, B_USE_SMALL_SPACING) .Add(nameStringView) .Add(infoStringView) .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING) .End(); }
ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); font_height fontHeight; be_bold_font->GetHeight(&fontHeight); float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; BRect rect(10, 10, 200, 10 + height); BStringView *stringView = new BStringView(rect, "title", B_TRANSLATE("Rich Text Format (RTF) files")); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); AddChild(stringView); float maxWidth = stringView->Bounds().Width(); rect.OffsetBy(0, height + 10); char version[256]; snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( RTF_TRANSLATOR_VERSION)), __DATE__); stringView = new BStringView(rect, "version", version); stringView->ResizeToPreferred(); AddChild(stringView); if (stringView->Bounds().Width() > maxWidth) maxWidth = stringView->Bounds().Width(); GetFontHeight(&fontHeight); height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; rect.OffsetBy(0, height + 5); stringView = new BStringView(rect, "Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc."); stringView->ResizeToPreferred(); AddChild(stringView); if (maxWidth + 20 > Bounds().Width()) ResizeTo(maxWidth + 20, Bounds().Height()); }
bool ResultWindow::AddLocationChanges(const char* location, const PackageList& packagesToInstall, const PackageSet& packagesAlreadyAdded, const PackageList& packagesToUninstall, const PackageSet& packagesAlreadyRemoved) { BGroupView* locationGroup = new BGroupView(B_VERTICAL); ObjectDeleter<BGroupView> locationGroupDeleter(locationGroup); locationGroup->GroupLayout()->SetInsets(B_USE_SMALL_INSETS); rgb_color background = ui_color(B_LIST_BACKGROUND_COLOR); if ((fContainerView->CountChildren() & 1) != 0) background = tint_color(background, 1.04); locationGroup->SetViewColor(background); BStringView* locationView = new BStringView(NULL, BString().SetToFormat("in %s:", location)); locationGroup->AddChild(locationView); locationView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BFont locationFont; locationView->GetFont(&locationFont); locationFont.SetFace(B_BOLD_FACE); locationView->SetFont(&locationFont); BGroupLayout* packagesGroup = new BGroupLayout(B_VERTICAL); locationGroup->GroupLayout()->AddItem(packagesGroup); packagesGroup->SetInsets(20, 0, 0, 0); bool packagesAdded = _AddPackages(packagesGroup, packagesToInstall, packagesAlreadyAdded, true); packagesAdded |= _AddPackages(packagesGroup, packagesToUninstall, packagesAlreadyRemoved, false); if (!packagesAdded) return false; fContainerView->AddChild(locationGroup); locationGroupDeleter.Detach(); return true; }
ConfigView::ConfigView(uint32 flags) : BView(kShortName2, flags) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *fTitle = new BStringView("title", B_TRANSLATE("RAW image translator")); fTitle->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(RAW_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(RAW_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(RAW_TRANSLATOR_VERSION)), __DATE__); BStringView *fVersion = new BStringView("version", version); BStringView *fCopyright = new BStringView("copyright", B_UTF8_COPYRIGHT "2007-2009 Haiku Inc."); BStringView *fCopyright2 = new BStringView("copyright2", B_TRANSLATE("Based on Dave Coffin's dcraw 8.63")); BStringView *fCopyright3 = new BStringView("copyright3", B_UTF8_COPYRIGHT "1997-2007 Dave Coffin"); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(fTitle) .Add(fVersion) .Add(fCopyright) .AddGlue() .Add(fCopyright2) .Add(fCopyright3); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 233)/12, (font.Size() * 200)/12)); }
void BBox::SetLabel(const char *label) { if (!(label == NULL || *label == 0)) { BStringView *strView = cast_as(fLabelView, BStringView); if (strView != NULL) { strView->SetText(label); strView->ResizeToPreferred(); ReAdjustLabel(); return; } if ((strView = new BStringView(BRect(0, 0, 1, 1), NULL, label, B_FOLLOW_NONE)) == NULL) return; strView->SetFont(be_bold_font); strView->ResizeToPreferred(); if (SetLabel(strView) != B_OK) delete strView; } else if (fLabelView != NULL) { BView *view = fLabelView; fLabelView = NULL; view->RemoveSelf(); delete view; } }
SGIView::SGIView(const char* name, uint32 flags, TranslatorSettings* settings) : BView(name, flags, new BGroupLayout(B_VERTICAL)), fSettings(settings) { BPopUpMenu* menu = new BPopUpMenu("pick compression"); uint32 currentCompression = fSettings->SetGetInt32(SGI_SETTING_COMPRESSION); // create the menu items with the various compression methods add_menu_item(menu, SGI_COMP_NONE, B_TRANSLATE("None"), currentCompression); //menu->AddSeparatorItem(); add_menu_item(menu, SGI_COMP_RLE, B_TRANSLATE("RLE"), currentCompression); // DON'T turn this on, it's so slow that I didn't wait long enough // the one time I tested this. So I don't know if the code even works. // Supposedly, this would look for an already written scanline, and // modify the scanline tables so that the current row is not written // at all... //add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression); fCompressionMF = new BMenuField("compression", B_TRANSLATE("Use compression:"), menu); BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL); BStringView* titleView = new BStringView("title", B_TRANSLATE("SGI image translator")); titleView->SetFont(be_bold_font); titleView->SetExplicitAlignment(labelAlignment); char detail[100]; sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( SGI_TRANSLATOR_VERSION)), __DATE__); BStringView* detailView = new BStringView("details", detail); detailView->SetExplicitAlignment(labelAlignment); BTextView* infoView = new BTextView("info"); infoView->SetText(BString(B_TRANSLATE("written by:\n")) .Append(author) .Append(B_TRANSLATE("\n\nbased on GIMP SGI plugin v1.5:\n")) .Append(kSGICopyright).String()); infoView->SetExplicitAlignment(labelAlignment); infoView->SetWordWrap(false); infoView->MakeEditable(false); infoView->MakeResizable(true); infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); float padding = 5.0f; BLayoutBuilder::Group<>(this, B_VERTICAL, padding) .SetInsets(padding) .Add(titleView) .Add(detailView) .AddGroup(B_HORIZONTAL) .Add(fCompressionMF) .AddGlue() .End() .Add(infoView) .AddGlue(); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 390) / 12, (font.Size() * 180) / 12)); // TODO: remove this workaround for ticket #4217 infoView->SetExplicitPreferredSize( BSize(infoView->LineWidth(4), infoView->TextHeight(0, 80))); infoView->SetExplicitMaxSize(infoView->ExplicitPreferredSize()); infoView->SetExplicitMinSize(infoView->ExplicitPreferredSize()); }
SettingsWindow::SettingsWindow(BRect frame) : BWindow(frame, B_TRANSLATE("MediaPlayer settings"), B_FLOATING_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS) { const float kSpacing = be_control_look->DefaultItemSpacing(); BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, kSpacing / 2); settingsBox->SetLayout(settingsLayout); BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 2); buttonBox->SetLayout(buttonLayout); BStringView* playModeLabel = new BStringView("stringViewPlayMode", B_TRANSLATE("Play mode")); BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions", B_TRANSLATE("View options")); BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg", B_TRANSLATE("Volume of background clips")); BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER); playModeLabel->SetExplicitAlignment(alignment); playModeLabel->SetFont(be_bold_font); viewOptionsLabel->SetExplicitAlignment(alignment); viewOptionsLabel->SetFont(be_bold_font); bgMoviesModeLabel->SetExplicitAlignment(alignment); bgMoviesModeLabel->SetFont(be_bold_font); fAutostartCB = new BCheckBox("chkboxAutostart", B_TRANSLATE("Automatically start playing"), new BMessage(M_SETTINGS_CHANGED)); fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies", B_TRANSLATE("Close window after playing video"), new BMessage(M_SETTINGS_CHANGED)); fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds", B_TRANSLATE("Close window after playing audio"), new BMessage(M_SETTINGS_CHANGED)); fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie", B_TRANSLATE("Loop video"), new BMessage(M_SETTINGS_CHANGED)); fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds", B_TRANSLATE("Loop audio"), new BMessage(M_SETTINGS_CHANGED)); fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays", B_TRANSLATE("Use hardware video overlays if available"), new BMessage(M_SETTINGS_CHANGED)); fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear", B_TRANSLATE("Scale movies smoothly (non-overlay mode)"), new BMessage(M_SETTINGS_CHANGED)); fScaleFullscreenControlsCB = new BCheckBox("chkBoxScaleControls", B_TRANSLATE("Scale controls in full screen mode"), new BMessage(M_SETTINGS_CHANGED)); fSubtitleSizeOP = new BOptionPopUp("subtitleSize", B_TRANSLATE("Subtitle size:"), new BMessage(M_SETTINGS_CHANGED)); fSubtitleSizeOP->AddOption( B_TRANSLATE("Small"), mpSettings::SUBTITLE_SIZE_SMALL); fSubtitleSizeOP->AddOption( B_TRANSLATE("Medium"), mpSettings::SUBTITLE_SIZE_MEDIUM); fSubtitleSizeOP->AddOption( B_TRANSLATE("Large"), mpSettings::SUBTITLE_SIZE_LARGE); fSubtitlePlacementOP = new BOptionPopUp("subtitlePlacement", B_TRANSLATE("Subtitle placement:"), new BMessage(M_SETTINGS_CHANGED)); fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of video"), mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO); fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of screen"), mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_SCREEN); fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", B_TRANSLATE("Full volume"), new BMessage(M_SETTINGS_CHANGED)); fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume", B_TRANSLATE("Low volume"), new BMessage(M_SETTINGS_CHANGED)); fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", B_TRANSLATE("Muted"), new BMessage(M_SETTINGS_CHANGED)); fRevertB = new BButton("revert", B_TRANSLATE("Revert"), new BMessage(M_SETTINGS_REVERT)); BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), new BMessage(M_SETTINGS_CANCEL)); BButton* okButton = new BButton("ok", B_TRANSLATE("OK"), new BMessage(M_SETTINGS_SAVE)); okButton->MakeDefault(true); // Build the layout BGroupLayout* volumeGroup; BGroupLayout* startGroup; BGroupLayout* playGroup; BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .AddGroup(settingsLayout) .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING) .Add(playModeLabel) .AddGroup(B_HORIZONTAL, 0) .GetLayout(&playGroup) .AddStrut(10) .AddGroup(B_VERTICAL, 0) .GetLayout(&startGroup) .Add(fAutostartCB) .AddGrid(kSpacing, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 0) .Add(fCloseWindowMoviesCB, 1, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 1) .Add(fCloseWindowSoundsCB, 1, 1) .End() .Add(fLoopMoviesCB) .Add(fLoopSoundsCB) .End() .End() .AddStrut(kSpacing) .Add(viewOptionsLabel) .AddGroup(B_HORIZONTAL, 0) .AddStrut(10) .AddGroup(B_VERTICAL, 0) .Add(fUseOverlaysCB) .Add(fScaleBilinearCB) .Add(fScaleFullscreenControlsCB) .Add(fSubtitleSizeOP) .Add(fSubtitlePlacementOP) .End() .End() .AddStrut(kSpacing) .Add(bgMoviesModeLabel) .AddGroup(B_HORIZONTAL, 0) .AddStrut(10) .AddGroup(B_VERTICAL, 0) .GetLayout(&volumeGroup) .Add(fFullVolumeBGMoviesRB) .Add(fHalfVolumeBGMoviesRB) .Add(fMutedVolumeBGMoviesRB) .End() .End() .AddStrut(kSpacing) .End() .AddGroup(buttonLayout) .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING) .Add(fRevertB) .AddGlue() .Add(cancelButton) .Add(okButton); startGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); playGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); volumeGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); }
ConfigView::ConfigView(TranslatorSettings *settings) : BGroupView(B_TRANSLATE("PSDTranslator Settings"), B_VERTICAL, 0) { fSettings = settings; BPopUpMenu* compressionPopupMenu = new BPopUpMenu("popup_compression"); uint32 currentCompression = fSettings->SetGetInt32(PSD_SETTING_COMPRESSION); _AddItemToMenu(compressionPopupMenu, B_TRANSLATE("Uncompressed"), MSG_COMPRESSION_CHANGED, PSD_COMPRESSED_RAW, currentCompression); _AddItemToMenu(compressionPopupMenu, B_TRANSLATE("RLE"), MSG_COMPRESSION_CHANGED, PSD_COMPRESSED_RLE, currentCompression); fCompressionField = new BMenuField("compression", B_TRANSLATE("Compression: "), compressionPopupMenu); fCompressionField->SetAlignment(B_ALIGN_RIGHT); BPopUpMenu* versionPopupMenu = new BPopUpMenu("popup_version"); uint32 currentVersion = fSettings->SetGetInt32(PSD_SETTING_VERSION); _AddItemToMenu(versionPopupMenu, B_TRANSLATE("Photoshop Document (PSD file)"), MSG_VERSION_CHANGED, PSD_FILE, currentVersion); _AddItemToMenu(versionPopupMenu, B_TRANSLATE("Photoshop Big Document (PSB file)"), MSG_VERSION_CHANGED, PSB_FILE, currentVersion); fVersionField = new BMenuField("version", B_TRANSLATE("Format: "), versionPopupMenu); fVersionField->SetAlignment(B_ALIGN_RIGHT); BStringView *titleView = new BStringView("title", B_TRANSLATE("Photoshop image translator")); titleView->SetFont(be_bold_font); char version[256]; sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(PSD_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(PSD_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(PSD_TRANSLATOR_VERSION)), __DATE__); BStringView *versionView = new BStringView("version", version); BStringView *copyrightView = new BStringView("copyright", B_UTF8_COPYRIGHT "2005-2013 Haiku Inc."); BStringView *copyright2View = new BStringView("my_copyright", B_UTF8_COPYRIGHT "2012-2013 Gerasim Troeglazov <*****@*****.**>"); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(versionView) .Add(copyrightView) .AddGlue() .AddGrid(10.0f, 5.0f) .Add(fVersionField->CreateLabelLayoutItem(), 0, 0) .Add(fVersionField->CreateMenuBarLayoutItem(), 1, 0) .Add(fCompressionField->CreateLabelLayoutItem(), 0, 1) .Add(fCompressionField->CreateMenuBarLayoutItem(), 1, 1) .End() .AddGlue() .Add(copyright2View); SetExplicitPreferredSize(GroupLayout()->MinSize()); }
SetKeyWindow::SetKeyWindow(BPoint p, int32 i, BView *v) : BWindow(BRect(p.x,p.y,p.x,p.y), B_TRANSLATE("Change Key Binding"), B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE), index(i), parent(v) { BRect r(0,0,300,150); ResizeTo(r.Width(), r.Height()); MoveBy(-r.Width()/2, -r.Height()/2); BView *view = new BView(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); r.InsetBy(8,8); r.bottom = r.top+19; BStringView *st; r.right = r.left + be_bold_font->StringWidth(B_TRANSLATE("Enter new bindings for:")); view->AddChild(st = new BStringView(r, NULL, B_TRANSLATE("Enter new bindings for:"))); st->SetFont(be_bold_font); r.left = r.right+8; r.right = Bounds().right-8; uint32 code = gKeyBind->GetCode(index); view->AddChild(new BStringView(r, NULL, B_TRANSLATE(gKeyBind->GetLabel(code)))); // request the installed message key = gKeyBind->GetKey(code); key2 = gKeyBind->GetKeyAlt(code); mod = gKeyBind->GetMod(code); mod2 = gKeyBind->GetModAlt(code); message = code; menu = gKeyBind->IsMenuItem(code); r.OffsetBy(0,30); r.left = 8; float x = 8 + MAX( be_plain_font->StringWidth(B_TRANSLATE("Primary")), be_plain_font->StringWidth(B_TRANSLATE("Alternate"))); r.right = Bounds().right -96; view->AddChild(control1 = new KeyControl(r, B_TRANSLATE("Primary"), key, mod, menu)); control1->SetDivider(x); view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, B_TRANSLATE("CLEAR"), new BMessage(CLEAR1)) ); r.OffsetBy(0,30); view->AddChild(control2 = new KeyControl(r, B_TRANSLATE("Alternate"), key2, mod2, false)); control2->SetDivider(x); view->AddChild(new BButton(BRect(r.right+8, r.top, Bounds().right-8, r.bottom), NULL, B_TRANSLATE("CLEAR"), new BMessage(CLEAR2)) ); r = Bounds(); r.InsetBy(8,8); r.top = r.bottom - 23; r.left = r.right - 80; view->AddChild(new BButton(r, NULL, B_TRANSLATE("Apply"), new BMessage(SET)) ); r.OffsetBy(-(r.Width()+8), 0); view->AddChild(new BButton(r, NULL, B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)) ); AddChild(view); Run(); Show(); }
ConfigView::ConfigView(TranslatorSettings* settings) : BGroupView(B_TRANSLATE("WebPTranslator Settings"), B_VERTICAL), fSettings(settings) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView* title = new BStringView("title", B_TRANSLATE("WebP image translator")); title->SetFont(be_bold_font); char versionString[256]; sprintf(versionString, "v%d.%d.%d, %s", static_cast<int>(B_TRANSLATION_MAJOR_VERSION(WEBP_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(WEBP_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( WEBP_TRANSLATOR_VERSION)), __DATE__); BStringView* version = new BStringView("version", versionString); BString copyrightsText; BStringView *copyrightView = new BStringView("Copyright", B_TRANSLATE(B_UTF8_COPYRIGHT "2010-2011 Haiku Inc.")); BStringView *copyright2View = new BStringView("Copyright2", B_TRANSLATE("Based on libwebp v0.1,")); BStringView *copyright3View = new BStringView("Copyright3", B_TRANSLATE(B_UTF8_COPYRIGHT "2010-2011 Google Inc.")); // output parameters fPresetsMenu = new BPopUpMenu(B_TRANSLATE("Preset")); const struct preset_name* preset = kPresetNames; while (preset->name != NULL) { BMessage* msg = new BMessage(kMsgPreset); msg->AddInt32("value", preset->id); BMenuItem* item = new BMenuItem(preset->name, msg); if (fSettings->SetGetInt32(WEBP_SETTING_PRESET) == preset->id) item->SetMarked(true); fPresetsMenu->AddItem(item); preset++; } BMenuField* presetsField = new BMenuField(B_TRANSLATE("Output preset:"), fPresetsMenu); fQualitySlider = new BSlider("quality", B_TRANSLATE("Output quality:"), new BMessage(kMsgQuality), 0, 100, B_HORIZONTAL, B_BLOCK_THUMB); fQualitySlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fQualitySlider->SetHashMarkCount(10); fQualitySlider->SetLimitLabels(B_TRANSLATE("Low"), B_TRANSLATE("High")); fQualitySlider->SetValue(fSettings->SetGetInt32(WEBP_SETTING_QUALITY)); fMethodSlider = new BSlider("method", B_TRANSLATE("Compression method:"), new BMessage(kMsgMethod), 0, 6, B_HORIZONTAL, B_BLOCK_THUMB); fMethodSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fMethodSlider->SetHashMarkCount(7); fMethodSlider->SetLimitLabels(B_TRANSLATE("Fast"), B_TRANSLATE("Slower but better")); fMethodSlider->SetValue(fSettings->SetGetInt32(WEBP_SETTING_METHOD)); fPreprocessingCheckBox = new BCheckBox("preprocessing", B_TRANSLATE("Preprocessing filter"), new BMessage(kMsgPreprocessing)); if (fSettings->SetGetBool(WEBP_SETTING_PREPROCESSING)) fPreprocessingCheckBox->SetValue(B_CONTROL_ON); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(title) .Add(version) .Add(copyrightView) .AddGlue() .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(presetsField->CreateLabelLayoutItem(), 0, 0) .AddGroup(B_HORIZONTAL, 0.0f, 1, 0) .Add(presetsField->CreateMenuBarLayoutItem(), 0.0f) .AddGlue() .End() .End() .Add(fQualitySlider) .Add(fMethodSlider) .Add(fPreprocessingCheckBox) .AddGlue() .Add(copyright2View) .Add(copyright3View); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 250) / 12, (font.Size() * 350) / 12)); }
ModifierKeysWindow::ModifierKeysWindow() : BWindow(BRect(0, 0, 360, 220), B_TRANSLATE("Modifier keys"), B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { get_key_map(&fCurrentMap, &fCurrentBuffer); get_key_map(&fSavedMap, &fSavedBuffer); BStringView* keyRole = new BStringView("key role", B_TRANSLATE_COMMENT("Role", "As in the role of a modifier key")); keyRole->SetAlignment(B_ALIGN_RIGHT); keyRole->SetFont(be_bold_font); BStringView* keyLabel = new BStringView("key label", B_TRANSLATE_COMMENT("Key", "As in a computer keyboard key")); keyLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); keyLabel->SetFont(be_bold_font); BMenuField* shiftMenuField = _CreateShiftMenuField(); shiftMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* controlMenuField = _CreateControlMenuField(); controlMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* optionMenuField = _CreateOptionMenuField(); optionMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* commandMenuField = _CreateCommandMenuField(); commandMenuField->SetAlignment(B_ALIGN_RIGHT); fShiftConflictView = new ConflictView("shift warning view"); fShiftConflictView->SetExplicitMaxSize(BSize(15, 15)); fControlConflictView = new ConflictView("control warning view"); fControlConflictView->SetExplicitMaxSize(BSize(15, 15)); fOptionConflictView = new ConflictView("option warning view"); fOptionConflictView->SetExplicitMaxSize(BSize(15, 15)); fCommandConflictView = new ConflictView("command warning view"); fCommandConflictView->SetExplicitMaxSize(BSize(15, 15)); fCancelButton = new BButton("cancelButton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"), new BMessage(kMsgRevertModifiers)); fRevertButton->SetEnabled(false); fOkButton = new BButton("okButton", B_TRANSLATE("Set modifier keys"), new BMessage(kMsgApplyModifiers)); fOkButton->MakeDefault(true); // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); float forcedMinWidth = be_plain_font->StringWidth("XXX") * 4; keyRole->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* shiftLabel = shiftMenuField->CreateLabelLayoutItem(); shiftLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* controlLabel = controlMenuField->CreateLabelLayoutItem(); controlLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* optionLabel = optionMenuField->CreateLabelLayoutItem(); optionLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* commandLabel = commandMenuField->CreateLabelLayoutItem(); commandLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); AddChild(BLayoutBuilder::Group<>(B_VERTICAL, B_USE_SMALL_SPACING) .AddGroup(B_HORIZONTAL) .Add(keyRole) .Add(keyLabel) .End() .AddGroup(B_HORIZONTAL) .Add(shiftLabel) .Add(shiftMenuField->CreateMenuBarLayoutItem()) .Add(fShiftConflictView) .End() .AddGroup(B_HORIZONTAL) .Add(controlLabel) .Add(controlMenuField->CreateMenuBarLayoutItem()) .Add(fControlConflictView) .End() .AddGroup(B_HORIZONTAL) .Add(optionLabel) .Add(optionMenuField->CreateMenuBarLayoutItem()) .Add(fOptionConflictView) .End() .AddGroup(B_HORIZONTAL) .Add(commandLabel) .Add(commandMenuField->CreateMenuBarLayoutItem()) .Add(fCommandConflictView) .End() .AddGlue() .AddGroup(B_HORIZONTAL) .Add(fCancelButton) .AddGlue() .Add(fRevertButton) .Add(fOkButton) .End() .SetInsets(B_USE_DEFAULT_SPACING) ); _MarkMenuItems(); _ValidateDuplicateKeys(); PostMessage(kMsgHideShowIcons); }
SettingsWindow::SettingsWindow(BRect frame) : BWindow(frame, "MediaPlayer settings", B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE #ifdef __ANTARES__ | B_AUTO_UPDATE_SIZE_LIMITS) #else ) #endif { #ifdef __ANTARES__ BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, 5); settingsBox->SetLayout(settingsLayout); BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, 5); buttonBox->SetLayout(buttonLayout); BStringView* playModeLabel = new BStringView("stringViewPlayMode", "Play mode"); BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions", "View options"); BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg", "Play background clips at"); BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER); playModeLabel->SetExplicitAlignment(alignment); playModeLabel->SetFont(be_bold_font); viewOptionsLabel->SetExplicitAlignment(alignment); viewOptionsLabel->SetFont(be_bold_font); bgMoviesModeLabel->SetExplicitAlignment(alignment); bgMoviesModeLabel->SetFont(be_bold_font); fAutostartCB = new BCheckBox("chkboxAutostart", "Automatically start playing", new BMessage(M_AUTOSTART)); fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies", "Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE)); fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds", "Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS)); fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie", "Loop movies by default", new BMessage(M_LOOP_MOVIE)); fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds", "Loop sounds by default", new BMessage(M_LOOP_SOUND)); fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays", "Use hardware video overlays if available", new BMessage(M_USE_OVERLAYS)); fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear", "Scale movies smoothly (non-overlay mode)", new BMessage(M_SCALE_BILINEAR)); fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", "Full volume", new BMessage(M_START_FULL_VOLUME)); fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume", "Low volume", new BMessage(M_START_HALF_VOLUME)); fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", "Muted", new BMessage(M_START_MUTE_VOLUME)); fRevertB = new BButton("revert", "Revert", new BMessage(M_SETTINGS_REVERT)); BButton* cancelButton = new BButton("cancel", "Cancel", new BMessage(M_SETTINGS_CANCEL)); BButton* okButton = new BButton("ok", "OK", new BMessage(M_SETTINGS_SAVE)); okButton->MakeDefault(true); // Build the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(BGroupLayoutBuilder(settingsLayout) .Add(playModeLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fAutostartCB) .Add(BGridLayoutBuilder(5, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 0) .Add(fCloseWindowMoviesCB, 1, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1) .Add(fCloseWindowSoundsCB, 1, 1) ) .Add(fLoopMoviesCB) .Add(fLoopSoundsCB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(viewOptionsLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fUseOverlaysCB) .Add(fScaleBilinearCB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(bgMoviesModeLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fFullVolumeBGMoviesRB) .Add(fHalfVolumeBGMoviesRB) .Add(fMutedVolumeBGMoviesRB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .SetInsets(5, 5, 15, 5) ) .Add(BGroupLayoutBuilder(buttonLayout) .Add(fRevertB) .AddGlue() .Add(cancelButton) .Add(okButton) .SetInsets(5, 5, 5, 5) ) ); #else frame = Bounds(); BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW); view->SetViewColor(216, 216, 216); BRect btnRect(80.00, frame.bottom - (SPACE + BUTTONHEIGHT), 145.00, frame.bottom-SPACE); fRevertB = new BButton(btnRect, "revert", "Revert", new BMessage(M_SETTINGS_REVERT)); view->AddChild(fRevertB); btnRect.OffsetBy(btnRect.Width() + SPACE, 0); BButton* btn = new BButton(btnRect, "btnCancel", "Cancel", new BMessage(M_SETTINGS_CANCEL)); view->AddChild(btn); btnRect.OffsetBy(btnRect.Width() + SPACE, 0); btn = new BButton(btnRect, "btnOK", "OK", new BMessage(M_SETTINGS_SAVE)); view->AddChild(btn); BRect rectBox(frame.left + SPACE, frame.top + SPACE, frame.right - SPACE, btnRect.top- SPACE); BBox* bbox = new BBox(rectBox, "box1", B_FOLLOW_ALL_SIDES,B_WILL_DRAW | B_NAVIGABLE, B_FANCY_BORDER); bbox->SetLabel("MediaPlayer Settings"); BFont font; font_height fh1; font.GetHeight(&fh1); BString str("Play Mode:"); BRect rect(rectBox.left, rectBox.top + SPACE, rectBox.right - (12*2), rectBox.top + fh1.leading + fh1.ascent + 10); bbox->AddChild(new BStringView(rect, "stringViewPlayMode", str.String())); rect.OffsetBy(0, rect.Height()); bbox->AddChild(fAutostartCB = new BCheckBox(rect, "chkboxAutostart", "Automatically start playing", new BMessage(M_AUTOSTART))); rect.OffsetBy(SPACE, rect.Height() + SPACEING); bbox->AddChild(fCloseWindowMoviesCB = new BCheckBox(rect, "chkBoxCloseWindowMovies", "Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fCloseWindowSoundsCB = new BCheckBox(rect, "chkBoxCloseWindowSounds", "Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS))); rect.OffsetBy(-SPACE, rect.Height() + SPACEING); bbox->AddChild(fLoopMoviesCB = new BCheckBox(rect, "chkBoxLoopMovie", "Loop movies by default", new BMessage(M_LOOP_MOVIE))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fLoopSoundsCB = new BCheckBox(rect, "chkBoxLoopSounds", "Loop sounds by default", new BMessage(M_LOOP_SOUND))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fUseOverlaysCB = new BCheckBox(rect, "chkBoxUseOverlays", "Use hardware video overlays if available", new BMessage(M_USE_OVERLAYS))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fScaleBilinearCB = new BCheckBox(rect, "chkBoxScaleBilinear", "Scale movies smoothly (non-overlay mode)", new BMessage(M_SCALE_BILINEAR))); rect.OffsetBy(0, rect.Height() + SPACE + SPACEING); bbox->AddChild(new BStringView(rect, "stringViewPlayBackg", "Play backgrounds clips at:")); rect.OffsetBy(SPACE, rect.Height() + SPACEING); fFullVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Full Volume", new BMessage(M_START_FULL_VOLUME)); bbox->AddChild(fFullVolumeBGMoviesRB); rect.OffsetBy(0, rect.Height() + SPACEING); fHalfVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnhalfvolume", "Low Volume", new BMessage(M_START_HALF_VOLUME)); bbox->AddChild(fHalfVolumeBGMoviesRB); rect.OffsetBy(0, rect.Height() + SPACEING); fMutedVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Muted", new BMessage(M_START_MUTE_VOLUME)); bbox->AddChild(fMutedVolumeBGMoviesRB); view->AddChild(bbox); AddChild(view); #endif // disable currently unsupported features fLoopMoviesCB->SetEnabled(false); fLoopSoundsCB->SetEnabled(false); }
void TextDocumentTest::ReadyToRun() { Init(); BRect frame(50.0, 50.0, 749.0, 549.0); BWindow* window = new BWindow(frame, "Text document test", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS); TextDocumentView* documentView = new TextDocumentView("text document view"); BScrollView* scrollView = new BScrollView("text scroll view", documentView, false, true, B_NO_BORDER); BuildFontMenu(); BToolBar* toolBar= new BToolBar(); toolBar->AddAction(MENU_FILE_NEW,this,LoadIcon("document_new")); toolBar->AddAction(MENU_FILE_OPEN,this,LoadIcon("document_open")); toolBar->AddAction(MENU_FILE_SAVE,this,LoadIcon("document_save")); toolBar->AddSeparator(); toolBar->AddView(new BButton("StyleList")); toolBar->AddView(fFontMenuField); toolBar->AddView(new BButton("Size")); toolBar->AddSeparator(); toolBar->AddAction(FONTBOLD_MSG,this,LoadIcon("text_bold"),"Bold",NULL,false); toolBar->AddAction(FONTITALIC_MSG,this,LoadIcon("text_italic"),"Bold",NULL,true);; toolBar->AddAction(FONTUNDERLINE_MSG,this,LoadIcon("text_underline"),"Bold",NULL,true);; toolBar->AddSeparator(); /*toolBar->AddView(new BButton("Left")); toolBar->AddView(new BButton("Center")); toolBar->AddView(new BButton("Right")); toolBar->AddView(new BButton("Block")); toolBar->AddSeparator(); toolBar->AddView(new BButton("Inset Right")); toolBar->AddView(new BButton("Inset Left")); toolBar->AddSeparator(); toolBar->AddView(new BButton("Bullet List")); toolBar->AddSeparator();*/ toolBar->AddGlue(); BToolBar* statusBar= new BToolBar(); BFont* tmpFont = new BFont(); BStringView* stringView = new BStringView("firstStatus","Here will be the Status View"); stringView->GetFont(tmpFont); tmpFont->SetSize(tmpFont->Size()-2); stringView->SetFont(tmpFont); statusBar->AddView(stringView); statusBar->AddSeparator(); BLayoutBuilder::Group<>(window, B_VERTICAL,0) .Add(toolBar) .Add(scrollView) .SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)) .Add(statusBar) ; CharacterStyle regularStyle; float fontSize = regularStyle.Font().Size(); ParagraphStyle paragraphStyle; paragraphStyle.SetJustify(true); paragraphStyle.SetSpacingTop(ceilf(fontSize * 0.6f)); paragraphStyle.SetLineSpacing(ceilf(fontSize * 0.2f)); CharacterStyle boldStyle(regularStyle); boldStyle.SetBold(true); CharacterStyle italicStyle(regularStyle); italicStyle.SetItalic(true); CharacterStyle italicAndBoldStyle(boldStyle); italicAndBoldStyle.SetItalic(true); CharacterStyle bigStyle(regularStyle); bigStyle.SetFontSize(24); bigStyle.SetBold(true); bigStyle.SetForegroundColor(255, 50, 50); TextDocumentRef document(new TextDocument(), true); Paragraph paragraph(paragraphStyle); paragraph.Append(TextSpan("This is a", regularStyle)); paragraph.Append(TextSpan(" test ", bigStyle)); paragraph.Append(TextSpan("to see if ", regularStyle)); paragraph.Append(TextSpan("different", boldStyle)); paragraph.Append(TextSpan(" character styles already work.", regularStyle)); document->Append(paragraph); paragraphStyle.SetSpacingTop(8.0f); paragraphStyle.SetAlignment(ALIGN_CENTER); paragraphStyle.SetJustify(false); paragraph = Paragraph(paragraphStyle); paragraph.Append(TextSpan("Different alignment styles ", regularStyle)); paragraph.Append(TextSpan("are", boldStyle)); paragraph.Append(TextSpan(" supported as of now!", regularStyle)); document->Append(paragraph); paragraphStyle.SetAlignment(ALIGN_RIGHT); paragraphStyle.SetJustify(true); paragraph = Paragraph(paragraphStyle); paragraph.Append(TextSpan("I am on the ", regularStyle)); paragraph.Append(TextSpan("Right", boldStyle)); paragraph.Append(TextSpan("Side", italicStyle)); document->Append(paragraph); // Test a bullet list paragraphStyle.SetSpacingTop(8.0f); paragraphStyle.SetAlignment(ALIGN_LEFT); paragraphStyle.SetJustify(true); paragraphStyle.SetBullet(Bullet("->", 12.0f)); paragraphStyle.SetLineInset(10.0f); paragraph = Paragraph(paragraphStyle); paragraph.Append(TextSpan("Even bullet lists are supported.", regularStyle)); document->Append(paragraph); paragraph = Paragraph(paragraphStyle); paragraph.Append(TextSpan("The wrapping in ", regularStyle)); paragraph.Append(TextSpan("this", italicStyle)); paragraph.Append(TextSpan(" bullet item should look visually " "pleasing. And ", regularStyle)); paragraph.Append(TextSpan("why", italicAndBoldStyle)); paragraph.Append(TextSpan(" should it not?", regularStyle)); document->Append(paragraph); /* MarkupParser parser(regularStyle, paragraphStyle); TextDocumentRef document = parser.CreateDocumentFromMarkup( "== Text document test ==\n" "This is a test to see if '''different''' " "character styles already work.\n" "Different alignment styles '''are''' supported as of now!\n" " * Even bullet lists are supported.\n" " * The wrapping in ''this'' bullet item should look visually " "pleasing. And ''why'' should it not?\n" );*/ documentView->SetTextDocument(document); documentView->SetTextEditor(TextEditorRef(new TextEditor(), true)); documentView->MakeFocus(); window->Show(); FontPanel *fPanel = new FontPanel(); fPanel->Show(); }
void SetFont(const BFont* font, uint32 properties = B_FONT_ALL) { BView::SetFont(font); mTotalCount_ ->SetFont(font); mMarkedCount_->SetFont(font); }