KeyRequestView() : BView("KeyRequestView", B_WILL_DRAW), fPassword(NULL) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BGroupLayout* rootLayout = new(std::nothrow) BGroupLayout(B_VERTICAL); if (rootLayout == NULL) return; SetLayout(rootLayout); BGridView* controls = new(std::nothrow) BGridView(); if (controls == NULL) return; BGridLayout* layout = controls->GridLayout(); float inset = ceilf(be_plain_font->Size() * 0.7); rootLayout->SetInsets(inset, inset, inset, inset); rootLayout->SetSpacing(inset); layout->SetSpacing(inset, inset); BStringView* label = new(std::nothrow) BStringView("keyringLabel", B_TRANSLATE("Keyring:")); if (label == NULL) return; int32 row = 0; layout->AddView(label, 0, row); fKeyringName = new(std::nothrow) BStringView("keyringName", ""); if (fKeyringName == NULL) return; layout->AddView(fKeyringName, 1, row++); fPassword = new(std::nothrow) BTextControl(B_TRANSLATE("Password:"******"", NULL); if (fPassword == NULL) return; BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem(); layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth( "0123456789012345678901234567890123456789") + inset, B_SIZE_UNSET)); layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row); layout->AddItem(layoutItem, 1, row++); BGroupView* buttons = new(std::nothrow) BGroupView(B_HORIZONTAL); if (buttons == NULL) return; fCancelButton = new(std::nothrow) BButton(B_TRANSLATE("Cancel"), new BMessage(kMessageCancel)); buttons->GroupLayout()->AddView(fCancelButton); buttons->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fUnlockButton = new(std::nothrow) BButton(B_TRANSLATE("Unlock"), new BMessage(kMessageUnlock)); buttons->GroupLayout()->AddView(fUnlockButton); BTextView* message = new(std::nothrow) BTextView("message"); message->SetText(B_TRANSLATE("An application wants to access the " "keyring below, but it is locked with a passphrase. Please enter " "the passphrase to unlock the keyring.\n" "If you unlock the keyring, it stays unlocked until the system is " "shut down or the keyring is manually locked again.\n" "If you cancel this dialog the keyring will remain locked.")); message->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); message->MakeEditable(false); message->MakeSelectable(false); message->SetWordWrap(true); rootLayout->AddView(message); rootLayout->AddView(controls); rootLayout->AddView(buttons); }
void PackageView::_InitView() { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); float fontHeight = be_plain_font->Size(); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); BTextView* packageDescriptionView = new DescriptionTextView( "package description", fontHeight * 13); packageDescriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); packageDescriptionView->SetText(fInfo.GetDescription()); packageDescriptionView->MakeEditable(false); packageDescriptionView->MakeSelectable(false); packageDescriptionView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); BScrollView* descriptionScrollView = new BScrollView( "package description scroll view", packageDescriptionView, 0, false, true, B_NO_BORDER); // Install type menu field fInstallTypes = new BPopUpMenu(B_TRANSLATE("none")); BMenuField* installType = new BMenuField("install_type", B_TRANSLATE("Installation type:"), fInstallTypes); // Install type description text view fInstallTypeDescriptionView = new DescriptionTextView( "install type description", fontHeight * 4); fInstallTypeDescriptionView->MakeEditable(false); fInstallTypeDescriptionView->MakeSelectable(false); fInstallTypeDescriptionView->SetInsets(8, 0, 0, 0); // Left inset needs to match BMenuField text offset fInstallTypeDescriptionView->SetText( B_TRANSLATE("No installation type selected")); fInstallTypeDescriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BFont font(be_plain_font); font.SetSize(ceilf(font.Size() * 0.85)); fInstallTypeDescriptionView->SetFontAndColor(&font, B_FONT_ALL, &textColor); BScrollView* installTypeScrollView = new BScrollView( "install type description scroll view", fInstallTypeDescriptionView, 0, false, true, B_NO_BORDER); // Destination menu field fDestination = new BPopUpMenu(B_TRANSLATE("none")); fDestField = new BMenuField("install_to", B_TRANSLATE("Install to:"), fDestination); fBeginButton = new BButton("begin_button", B_TRANSLATE("Begin"), new BMessage(P_MSG_INSTALL)); BLayoutItem* typeLabelItem = installType->CreateLabelLayoutItem(); BLayoutItem* typeMenuItem = installType->CreateMenuBarLayoutItem(); BLayoutItem* destFieldLabelItem = fDestField->CreateLabelLayoutItem(); BLayoutItem* destFieldMenuItem = fDestField->CreateMenuBarLayoutItem(); float forcedMinWidth = be_plain_font->StringWidth("XXX") * 5; destFieldMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); typeMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BAlignment labelAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET); typeLabelItem->SetExplicitAlignment(labelAlignment); destFieldLabelItem->SetExplicitAlignment(labelAlignment); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(descriptionScrollView) .AddGrid(B_USE_SMALL_SPACING, B_USE_DEFAULT_SPACING) .Add(typeLabelItem, 0, 0) .Add(typeMenuItem, 1, 0) .Add(installTypeScrollView, 1, 1) .Add(destFieldLabelItem, 0, 2) .Add(destFieldMenuItem, 1, 2) .End() .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fBeginButton) .End() .SetInsets(B_USE_DEFAULT_SPACING) ; fBeginButton->MakeDefault(true); }
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("\nbased on GIMP SGI plugin v1.5:\n")) .Append(kSGICopyright).String()); infoView->SetExplicitAlignment(labelAlignment); infoView->SetWordWrap(false); infoView->MakeEditable(false); infoView->MakeResizable(true); infoView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) .Add(titleView) .Add(detailView) .AddGlue() .AddGroup(B_HORIZONTAL) .Add(fCompressionMF) .AddGlue() .End() .AddGlue() .Add(infoView); 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(3), infoView->TextHeight(0, 80))); infoView->SetExplicitMaxSize(infoView->ExplicitPreferredSize()); infoView->SetExplicitMinSize(infoView->ExplicitPreferredSize()); }