bool ResultWindow::_AddPackages(BGroupLayout* packagesGroup, const PackageList& packages, const PackageSet& ignorePackages, bool install) { bool packagesAdded = false; for (int32 i = 0; BSolverPackage* package = packages.ItemAt(i); i++) { if (ignorePackages.find(package) != ignorePackages.end()) continue; BString text; if (install) { text.SetToFormat("install package %s from repository %s\n", package->Info().FileName().String(), package->Repository()->Name().String()); } else { text.SetToFormat("uninstall package %s\n", package->VersionedName().String()); } BStringView* packageView = new BStringView(NULL, text); packagesGroup->AddView(packageView); packageView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); packagesAdded = true; } return packagesAdded; }
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(); }
void MidiPlayerWindow::CreateViews() { // Set up needed views scopeView = new ScopeView; showScope = new BCheckBox("showScope", B_TRANSLATE("Scope"), new BMessage(MSG_SHOW_SCOPE)); showScope->SetValue(B_CONTROL_ON); CreateInputMenu(); CreateReverbMenu(); volumeSlider = new BSlider("volumeSlider", NULL, NULL, 0, 100, B_HORIZONTAL); rgb_color col = { 152, 152, 255 }; volumeSlider->UseFillColor(true, &col); volumeSlider->SetModificationMessage(new BMessage(MSG_VOLUME)); playButton = new BButton("playButton", B_TRANSLATE("Play"), new BMessage(MSG_PLAY_STOP)); playButton->SetEnabled(false); BBox* divider = new BBox(B_EMPTY_STRING, B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER); divider->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, 1)); BStringView* volumeLabel = new BStringView(NULL, B_TRANSLATE("Volume:")); volumeLabel->SetAlignment(B_ALIGN_LEFT); volumeLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); // Build the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) .Add(scopeView) .Add(BGridLayoutBuilder(10, 10) .Add(BSpaceLayoutItem::CreateGlue(), 0, 0) .Add(showScope, 1, 0) .Add(reverbMenu->CreateLabelLayoutItem(), 0, 1) .Add(reverbMenu->CreateMenuBarLayoutItem(), 1, 1) .Add(inputMenu->CreateLabelLayoutItem(), 0, 2) .Add(inputMenu->CreateMenuBarLayoutItem(), 1, 2) .Add(volumeLabel, 0, 3) .Add(volumeSlider, 1, 3) ) .AddGlue() .Add(divider) .AddGlue() .Add(playButton) .AddGlue() .SetInsets(5, 5, 5, 5) ); }
BStringView* InfoWin::_CreateInfo(const char* name) { BStringView* view = new BStringView(name, ""); view->SetExplicitMinSize(BSize(200, B_SIZE_UNSET)); view->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); view->SetTruncation(B_TRUNCATE_SMART); return view; }
TestWindow::TestWindow() : BWindow(BRect(50.0, 50.0, 450.0, 250.0), "ClipToPicture Test", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) { fClippingTestView = new TestView(); fValidateTestView = new TestView(); BGroupView* group = new BGroupView(B_HORIZONTAL); BLayoutBuilder::Group<>(group, B_HORIZONTAL, 0.0f) .Add(fClippingTestView) .Add(fValidateTestView) ; BScrollView* scrollView = new BScrollView("scroll", group, 0, true, true); BStringView* leftLabel = new BStringView("left label", "ClipToPicture:"); leftLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BStringView* rightLabel = new BStringView("right label", "Validation:"); rightLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fTestSelectionField = new BMenuField("test selection", "Select test:", new BPopUpMenu("select")); BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) .AddGroup(B_HORIZONTAL) .Add(fTestSelectionField) .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING) .End() .AddGroup(B_HORIZONTAL) .Add(leftLabel) .Add(rightLabel) .SetInsets(B_USE_DEFAULT_SPACING) .End() .Add(scrollView) ; }
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; }
ResultWindow::ResultWindow() : BWindow(BRect(0, 0, 400, 300), "Package changes", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), fDoneSemaphore(-1), fClientWaiting(false), fAccepted(false), fContainerView(NULL), fCancelButton(NULL), fApplyButton(NULL) { fDoneSemaphore = create_sem(0, "package changes"); if (fDoneSemaphore < 0) throw std::bad_alloc(); BStringView* topTextView = NULL; BViewPort* viewPort = NULL; BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(B_USE_SMALL_INSETS) .Add(topTextView = new BStringView(NULL, "The following additional package changes have to be made:")) .Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true)) .AddGroup(B_HORIZONTAL) .Add(fCancelButton = new BButton("Cancel", new BMessage(B_CANCEL))) .AddGlue() .Add(fApplyButton = new BButton("Apply changes", new BMessage(kApplyMessage))) .End(); topTextView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); viewPort->SetChildView(fContainerView = new BGroupView(B_VERTICAL, 0)); // set small scroll step (large step will be set by the view port) font_height fontHeight; topTextView->GetFontHeight(&fontHeight); float smallStep = ceilf(fontHeight.ascent + fontHeight.descent); viewPort->ScrollBar(B_VERTICAL)->SetSteps(smallStep, smallStep); }
void MediaWindow::_MakeEmptyParamView() { fParamWeb = NULL; BStringView* stringView = new BStringView("noControls", B_TRANSLATE("This hardware has no controls.")); BSize unlimited(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED); stringView->SetExplicitMaxSize(unlimited); BAlignment centered(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER); stringView->SetExplicitAlignment(centered); stringView->SetAlignment(B_ALIGN_CENTER); fContentLayout->AddView(stringView); fContentLayout->SetVisibleItem(fContentLayout->CountItems() - 1); rgb_color panel = stringView->LowColor(); stringView->SetHighColor(tint_color(panel, B_DISABLED_LABEL_TINT)); }
ScreenshotWindow::ScreenshotWindow(const Utility& utility, bool silent, bool clipboard) : BWindow(BRect(0, 0, 200.0, 100.0), B_TRANSLATE_SYSTEM_NAME("Screenshot"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AVOID_FRONT | B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), fUtility(utility), fDelayControl(NULL), fScreenshot(NULL), fOutputPathPanel(NULL), fLastSelectedPath(NULL), fSettingsWindow(NULL), fDelay(0), fIncludeBorder(false), fIncludeCursor(false), fGrabActiveWindow(false), fOutputFilename(NULL), fExtension(""), fImageFileType(B_PNG_FORMAT) { // _ReadSettings() needs a valid fOutputPathMenu fOutputPathMenu = new BMenu(B_TRANSLATE("Please select")); _ReadSettings(); // _NewScreenshot() needs a valid fNameControl BString name(B_TRANSLATE_NOCOLLECT(fUtility.sDefaultFileNameBase)); name << 1; name = _FindValidFileName(name.String()); fNameControl = new BTextControl("", B_TRANSLATE("Name:"), name, NULL); // Check if fUtility contains valid data if (fUtility.wholeScreen == NULL) { _NewScreenshot(silent, clipboard, true); return; } fScreenshot = fUtility.MakeScreenshot(fIncludeCursor, fGrabActiveWindow, fIncludeBorder); fActiveWindow = new BCheckBox(B_TRANSLATE("Capture active window"), new BMessage(kActiveWindow)); if (fGrabActiveWindow) fActiveWindow->SetValue(B_CONTROL_ON); fWindowBorder = new BCheckBox(B_TRANSLATE("Include window border"), new BMessage(kIncludeBorder)); if (fIncludeBorder) fWindowBorder->SetValue(B_CONTROL_ON); if (!fGrabActiveWindow) fWindowBorder->SetEnabled(false); fShowCursor = new BCheckBox(B_TRANSLATE("Include mouse pointer"), new BMessage(kIncludeCursor)); if (fIncludeCursor) fShowCursor->SetValue(B_CONTROL_ON); BString delay; delay << fDelay / 1000000; fDelayControl = new BTextControl("", B_TRANSLATE("Delay:"), delay.String(), NULL); _DisallowChar(fDelayControl->TextView()); fDelayControl->TextView()->SetAlignment(B_ALIGN_RIGHT); BStringView* seconds = new BStringView("", B_TRANSLATE("seconds")); seconds->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BMenuField* menuLocation = new BMenuField(B_TRANSLATE("Save in:"), fOutputPathMenu); menuLocation->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTranslatorMenu = new BMenu(B_TRANSLATE("Please select")); _SetupTranslatorMenu(); BMenuField* menuFormat = new BMenuField(B_TRANSLATE("Save as:"), fTranslatorMenu); menuFormat->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BButton* showSettings = new BButton("", B_TRANSLATE("Settings" B_UTF8_ELLIPSIS), new BMessage(kSettings)); showSettings->SetExplicitAlignment( BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM)); BBox* divider = new BBox(B_FANCY_BORDER, NULL); divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); BButton* saveScreenshot = new BButton("", B_TRANSLATE("Save"), new BMessage(kSaveScreenshot)); const float kSpacing = be_control_look->DefaultItemSpacing(); const float kLabelSpacing = be_control_look->DefaultLabelSpacing(); fPreview = new BView("preview", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); BBox* previewBox = new BBox(B_FANCY_BORDER, fPreview); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .AddGroup(B_HORIZONTAL) .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING) .Add(previewBox) .AddGroup(B_VERTICAL, 0) .Add(fActiveWindow) .Add(fWindowBorder) .Add(fShowCursor) .AddStrut(kSpacing) .AddGrid(0.0, kSpacing / 2) .Add(fDelayControl->CreateLabelLayoutItem(), 0, 0) .Add(fDelayControl->CreateTextViewLayoutItem(), 1, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(kLabelSpacing), 2, 0) .Add(seconds, 3, 0) .Add(fNameControl->CreateLabelLayoutItem(), 0, 1) .Add(fNameControl->CreateTextViewLayoutItem(), 1, 1, 3, 1) .Add(menuLocation->CreateLabelLayoutItem(), 0, 2) .Add(menuLocation->CreateMenuBarLayoutItem(), 1, 2, 3, 1) .Add(menuFormat->CreateLabelLayoutItem(), 0, 3) .Add(menuFormat->CreateMenuBarLayoutItem(), 1, 3, 3, 1) .End() .AddStrut(kSpacing / 2) .Add(showSettings) .AddGlue() .End() .End() .Add(new BSeparatorView(B_HORIZONTAL)) .AddGroup(B_HORIZONTAL) .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING) .Add(new BButton("", B_TRANSLATE("Copy to clipboard"), new BMessage(B_COPY))) .Add(new BButton("", B_TRANSLATE("New screenshot"), new BMessage(kNewScreenshot))) .AddGlue() .Add(saveScreenshot); saveScreenshot->MakeDefault(true); _UpdatePreviewPanel(); _UpdateFilenameSelection(); CenterOnScreen(); Show(); }
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); }