void DataTranslationsWindow::_ShowInfoView() { if (fConfigView) { fRightBox->RemoveChild(fConfigView); delete fConfigView; fConfigView = NULL; } BTextView* view = new BTextView("info text"); view->MakeEditable(false); view->MakeSelectable(false); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetText(B_TRANSLATE( "Use this control panel to set default values for translators, " "to be used when no other settings are specified by an application.")); BGroupView* group = new BGroupView(B_VERTICAL); group->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); group->AddChild(view); float spacing = be_control_look->DefaultItemSpacing(); group->GroupLayout()->SetInsets(spacing, spacing, spacing, spacing); fRightBox->AddChild(group); fConfigView = group; }
void DataTranslationsWindow::_ShowInfoView() { if (fConfigView != NULL) { fRightBox->RemoveChild(fConfigView); delete fConfigView; fConfigView = NULL; fInfoText = NULL; if (fRelease != NULL) { fRelease->Release(); fRelease = NULL; } } fInfoText = new BTextView("info text"); fInfoText->MakeEditable(false); fInfoText->MakeSelectable(false); fInfoText->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fInfoText->SetText(B_TRANSLATE( "Use this control panel to set default values for translators, " "to be used when no other settings are specified by an application.")); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); fInfoText->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); BGroupView* group = new BGroupView(B_VERTICAL); group->AddChild(fInfoText); float spacing = be_control_look->DefaultItemSpacing(); group->GroupLayout()->SetInsets(spacing, spacing, spacing, spacing); fRightBox->AddChild(group); fConfigView = group; }
Window::Window() : BWindow(BRect(100, 100, 520, 430), "ToolTip-Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) { BView* simple = new BStringView("1", "Simple Tool Tip"); simple->SetToolTip("This is a really\nsimple tool tip!"); BView* custom = new BStringView("2", "Custom Tool Tip"); custom->SetToolTip(new CustomToolTip("Custom tool tip!")); BView* changing = new BStringView("3", "Changing Tool Tip"); changing->SetToolTip(new ChangingToolTip()); BView* mouse = new BStringView("4", "Mouse Tool Tip (sticky)"); mouse->SetToolTip(new MouseToolTip()); BView* immediate = new ImmediateView("5", "Immediate Tool Tip (sticky)"); BView* pulseString = new PulseStringView("pulseString", "Periodically changing tool tip text"); BView* pulseToolTip = new PulseToolTipView("pulseToolTip", "Periodically changing tool tip"); BGroupView* nested = new BGroupView(); nested->SetViewColor(50, 50, 90); nested->GroupLayout()->SetInsets(30); nested->SetToolTip("The outer view has a tool tip,\n" "the inner one doesn't."); nested->AddChild(new BGroupView("inner")); BLayoutBuilder::Group<>(this, B_HORIZONTAL) .SetInsets(B_USE_DEFAULT_SPACING) .AddGroup(B_VERTICAL) .Add(simple) .Add(custom) .Add(changing) .Add(mouse) .Add(immediate) .End() .AddGroup(B_VERTICAL) .Add(pulseString) .Add(pulseToolTip) .Add(nested); SetPulseRate(1000000LL); }
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; }
void MainWindow::_CreateGUI() { SetLayout(new BGroupLayout(B_HORIZONTAL)); BGridLayout* layout = new BGridLayout(); layout->SetSpacing(0, 0); BView* rootView = new BView("root view", 0, layout); AddChild(rootView); rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BGroupView* leftTopView = new BGroupView(B_VERTICAL, 0); layout->AddView(leftTopView, 0, 0); // views along the left side leftTopView->AddChild(_CreateMenuBar()); float splitWidth = 13 * be_plain_font->Size(); BSize minSize = leftTopView->MinSize(); splitWidth = std::max(splitWidth, minSize.width); leftTopView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET)); leftTopView->SetExplicitMinSize(BSize(splitWidth, B_SIZE_UNSET)); BGroupView* iconPreviews = new BGroupView(B_HORIZONTAL); iconPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); iconPreviews->GroupLayout()->SetSpacing(5); // icon previews fIconPreview16Folder = new IconView(BRect(0, 0, 15, 15), "icon preview 16 folder"); fIconPreview16Menu = new IconView(BRect(0, 0, 15, 15), "icon preview 16 menu"); fIconPreview16Menu->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR)); fIconPreview32Folder = new IconView(BRect(0, 0, 31, 31), "icon preview 32 folder"); fIconPreview32Desktop = new IconView(BRect(0, 0, 31, 31), "icon preview 32 desktop"); fIconPreview32Desktop->SetLowColor(ui_color(B_DESKTOP_COLOR)); fIconPreview64 = new IconView(BRect(0, 0, 63, 63), "icon preview 64"); fIconPreview64->SetLowColor(ui_color(B_DESKTOP_COLOR)); BGroupView* smallPreviews = new BGroupView(B_VERTICAL); smallPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); smallPreviews->GroupLayout()->SetSpacing(5); smallPreviews->AddChild(fIconPreview16Folder); smallPreviews->AddChild(fIconPreview16Menu); BGroupView* mediumPreviews = new BGroupView(B_VERTICAL); mediumPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); mediumPreviews->GroupLayout()->SetSpacing(5); mediumPreviews->AddChild(fIconPreview32Folder); mediumPreviews->AddChild(fIconPreview32Desktop); // iconPreviews->AddChild(fIconPreview48); iconPreviews->AddChild(smallPreviews); iconPreviews->AddChild(mediumPreviews); iconPreviews->AddChild(fIconPreview64); iconPreviews->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED)); leftTopView->AddChild(iconPreviews); BGroupView* leftSideView = new BGroupView(B_VERTICAL, 0); layout->AddView(leftSideView, 0, 1); leftSideView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET)); // path menu and list view BMenuBar* menuBar = new BMenuBar("path menu bar"); menuBar->AddItem(fPathMenu); leftSideView->AddChild(menuBar); fPathListView = new PathListView(BRect(0, 0, splitWidth, 100), "path list view", new BMessage(MSG_PATH_SELECTED), this); BView* scrollView = new BScrollView("path list scroll view", fPathListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER); leftSideView->AddChild(scrollView); // shape list view menuBar = new BMenuBar("shape menu bar"); menuBar->AddItem(fShapeMenu); leftSideView->AddChild(menuBar); fShapeListView = new ShapeListView(BRect(0, 0, splitWidth, 100), "shape list view", new BMessage(MSG_SHAPE_SELECTED), this); scrollView = new BScrollView("shape list scroll view", fShapeListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER); leftSideView->AddChild(scrollView); // transformer list view menuBar = new BMenuBar("transformer menu bar"); menuBar->AddItem(fTransformerMenu); leftSideView->AddChild(menuBar); fTransformerListView = new TransformerListView(BRect(0, 0, splitWidth, 100), "transformer list view"); scrollView = new BScrollView("transformer list scroll view", fTransformerListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER); leftSideView->AddChild(scrollView); // property list view menuBar = new BMenuBar("property menu bar"); menuBar->AddItem(fPropertyMenu); leftSideView->AddChild(menuBar); fPropertyListView = new IconObjectListView(); // scroll view around property list view ScrollView* propScrollView = new ScrollView(fPropertyListView, SCROLL_VERTICAL, BRect(0, 0, splitWidth, 100), "property scroll view", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER, BORDER_RIGHT); leftSideView->AddChild(propScrollView); BGroupLayout* topSide = new BGroupLayout(B_HORIZONTAL); topSide->SetSpacing(0); BView* topSideView = new BView("top side view", 0, topSide); layout->AddView(topSideView, 1, 0); // canvas view BRect canvasBounds = BRect(0, 0, 200, 200); fCanvasView = new CanvasView(canvasBounds); // scroll view around canvas view canvasBounds.bottom += B_H_SCROLL_BAR_HEIGHT; canvasBounds.right += B_V_SCROLL_BAR_WIDTH; ScrollView* canvasScrollView = new ScrollView(fCanvasView, SCROLL_VERTICAL | SCROLL_HORIZONTAL | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS, canvasBounds, "canvas scroll view", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER); layout->AddView(canvasScrollView, 1, 1); // views along the top BGroupLayout* styleGroup = new BGroupLayout(B_VERTICAL, 0); BView* styleGroupView = new BView("style group", 0, styleGroup); topSide->AddView(styleGroupView); // style list view menuBar = new BMenuBar("style menu bar"); menuBar->AddItem(fStyleMenu); styleGroup->AddView(menuBar); fStyleListView = new StyleListView(BRect(0, 0, splitWidth, 100), "style list view", new BMessage(MSG_STYLE_SELECTED), this); scrollView = new BScrollView("style list scroll view", fStyleListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER); scrollView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNLIMITED)); styleGroup->AddView(scrollView); // style view fStyleView = new StyleView(BRect(0, 0, 200, 100)); topSide->AddView(fStyleView); // swatch group BGroupLayout* swatchGroup = new BGroupLayout(B_VERTICAL); swatchGroup->SetSpacing(0); BView* swatchGroupView = new BView("swatch group", 0, swatchGroup); topSide->AddView(swatchGroupView); menuBar = new BMenuBar("swatches menu bar"); menuBar->AddItem(fSwatchMenu); swatchGroup->AddView(menuBar); fSwatchGroup = new SwatchGroup(BRect(0, 0, 100, 100)); swatchGroup->AddView(fSwatchGroup); swatchGroupView->SetExplicitMaxSize(swatchGroupView->MinSize()); // make sure the top side has fixed height topSideView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, swatchGroupView->MinSize().height)); }
TeamMonitorWindow::TeamMonitorWindow() : BWindow(BRect(0, 0, 350, 400), B_TRANSLATE("Team monitor"), B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL, B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), fQuitting(false), fUpdateRunner(NULL) { BGroupLayout* layout = new BGroupLayout(B_VERTICAL); float inset = 10; layout->SetInsets(inset, inset, inset, inset); layout->SetSpacing(inset); SetLayout(layout); layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fListView = new BListView("teams"); fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM)); BScrollView* scrollView = new BScrollView("scroll_teams", fListView, 0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER); layout->AddView(scrollView); BGroupView* groupView = new BGroupView(B_HORIZONTAL); layout->AddView(groupView); fKillButton = new BButton("kill", B_TRANSLATE("Kill application"), new BMessage(TM_KILL_APPLICATION)); groupView->AddChild(fKillButton); fKillButton->SetEnabled(false); fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"), new BMessage(TM_QUIT_APPLICATION)); groupView->AddChild(fQuitButton); fQuitButton->SetEnabled(false); groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fDescriptionView = new TeamDescriptionView; layout->AddView(fDescriptionView); groupView = new BGroupView(B_HORIZONTAL); layout->AddView(groupView); BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"), new BMessage(TM_FORCE_REBOOT)); groupView->GroupLayout()->AddView(forceReboot); BSpaceLayoutItem* glue = BSpaceLayoutItem::CreateGlue(); glue->SetExplicitMinSize(BSize(inset, -1)); groupView->GroupLayout()->AddItem(glue); fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"), new BMessage(TM_RESTART_DESKTOP)); SetDefaultButton(fRestartButton); groupView->GroupLayout()->AddView(fRestartButton); glue = BSpaceLayoutItem::CreateGlue(); glue->SetExplicitMinSize(BSize(inset, -1)); groupView->GroupLayout()->AddItem(glue); fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), new BMessage(TM_CANCEL)); SetDefaultButton(fCancelButton); groupView->GroupLayout()->AddView(fCancelButton); BSize preferredSize = layout->View()->PreferredSize(); if (preferredSize.width > Bounds().Width()) ResizeTo(preferredSize.width, Bounds().Height()); if (preferredSize.height > Bounds().Height()) ResizeTo(Bounds().Width(), preferredSize.height); BRect screenFrame = BScreen(this).Frame(); BPoint point; point.x = (screenFrame.Width() - Bounds().Width()) / 2; point.y = (screenFrame.Height() - Bounds().Height()) / 2; if (screenFrame.Contains(point)) MoveTo(point); SetSizeLimits(Bounds().Width(), Bounds().Width() * 2, Bounds().Height(), screenFrame.Height()); fRestartButton->Hide(); AddShortcut('T', B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kMsgLaunchTerminal)); AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); gLocalizedNamePreferred = BLocaleRoster::Default()->IsFilesystemTranslationPreferred(); gTeamMonitorWindow = this; if (be_app->Lock()) { be_app->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_LOCALE_CHANGED, FilterLocaleChanged)); be_app->Unlock(); } }
void HWindow::InitGUI() { fEventList = new HEventList(); fEventList->SetType(BMediaFiles::B_SOUNDS); fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST); BGroupView* view = new BGroupView(); BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP | B_PULSE_NEEDED); BMenu* menu = new BMenu("file"); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"), new BMessage(M_NONE_MESSAGE))); menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS), new BMessage(M_OTHER_MESSAGE))); BString label(B_TRANSLATE("Sound file:")); BMenuField* menuField = new BMenuField("filemenu", label, menu); menuField->SetDivider(menuField->StringWidth(label) + 10); BButton* stopbutton = new BButton("stop", B_TRANSLATE("Stop"), new BMessage(M_STOP_MESSAGE)); stopbutton->SetEnabled(false); BButton* playbutton = new BButton("play", B_TRANSLATE("Play"), new BMessage(M_PLAY_MESSAGE)); playbutton->SetEnabled(false); const float kInset = be_control_look->DefaultItemSpacing(); view->SetLayout(new BGroupLayout(B_HORIZONTAL)); view->AddChild(BGroupLayoutBuilder(B_VERTICAL, kInset) .AddGroup(B_HORIZONTAL) .Add(menuField) .AddGlue() .End() .AddGroup(B_HORIZONTAL, kInset) .AddGlue() .Add(playbutton) .Add(stopbutton) .End() .SetInsets(kInset, kInset, kInset, kInset) ); box->AddChild(view); SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL) .AddGroup(B_VERTICAL, kInset) .Add(fEventList) .Add(box) .End() .SetInsets(kInset, kInset, kInset, kInset) ); // setup file menu SetupMenuField(); BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>")); if (noneItem != NULL) noneItem->SetMarked(true); }
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry) : BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position), B_TRANSLATE("Application type"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS), fChangedProperties(0) { float padding = be_control_look->DefaultItemSpacing(); BAlignment labelAlignment = be_control_look->DefaultLabelAlignment(); BMenuBar* menuBar = new BMenuBar((char*)NULL); menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP)); BMenu* menu = new BMenu(B_TRANSLATE("File")); fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"), new BMessage(kMsgSave), 'S'); fSaveMenuItem->SetEnabled(false); menu->AddItem(fSaveMenuItem); BMenuItem* item; menu->AddItem(item = new BMenuItem( B_TRANSLATE("Save into resource file" B_UTF8_ELLIPSIS), NULL)); item->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY)); menuBar->AddItem(menu); // Signature fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL, new BMessage(kMsgSignatureChanged)); fSignatureControl->SetModificationMessage( new BMessage(kMsgSignatureChanged)); // filter out invalid characters that can't be part of a MIME type name BTextView* textView = fSignatureControl->TextView(); textView->SetMaxBytes(B_MIME_TYPE_LENGTH); const char* disallowedCharacters = "<>@,;:\"()[]?= "; for (int32 i = 0; disallowedCharacters[i]; i++) { textView->DisallowChar(disallowedCharacters[i]); } // "Application Flags" group BBox* flagsBox = new BBox("flagsBox"); fFlagsCheckBox = new BCheckBox("flags", B_TRANSLATE("Application flags"), new BMessage(kMsgToggleAppFlags)); fFlagsCheckBox->SetValue(B_CONTROL_ON); fSingleLaunchButton = new BRadioButton("single", B_TRANSLATE("Single launch"), new BMessage(kMsgAppFlagsChanged)); fMultipleLaunchButton = new BRadioButton("multiple", B_TRANSLATE("Multiple launch"), new BMessage(kMsgAppFlagsChanged)); fExclusiveLaunchButton = new BRadioButton("exclusive", B_TRANSLATE("Exclusive launch"), new BMessage(kMsgAppFlagsChanged)); fArgsOnlyCheckBox = new BCheckBox("args only", B_TRANSLATE("Args only"), new BMessage(kMsgAppFlagsChanged)); fBackgroundAppCheckBox = new BCheckBox("background", B_TRANSLATE("Background app"), new BMessage(kMsgAppFlagsChanged)); BLayoutBuilder::Grid<>(flagsBox, 0, 0) .SetInsets(padding, padding * 2, padding, padding) .Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0) .Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1) .Add(fExclusiveLaunchButton, 0, 2); flagsBox->SetLabel(fFlagsCheckBox); // "Icon" group BBox* iconBox = new BBox("IconBox"); iconBox->SetLabel(B_TRANSLATE("Icon")); fIconView = new IconView("icon"); fIconView->SetModificationMessage(new BMessage(kMsgIconChanged)); BLayoutBuilder::Group<>(iconBox, B_HORIZONTAL) .SetInsets(padding, padding * 2, padding, padding) .Add(fIconView); // "Supported Types" group BBox* typeBox = new BBox("typesBox"); typeBox->SetLabel(B_TRANSLATE("Supported types")); fTypeListView = new SupportedTypeListView("Suppported Types", B_SINGLE_SELECTION_LIST); fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected)); BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fAddTypeButton = new BButton("add type", B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType)); fRemoveTypeButton = new BButton("remove type", B_TRANSLATE("Remove"), new BMessage(kMsgRemoveType)); fTypeIconView = new IconView("type icon"); BGroupView* iconHolder = new BGroupView(B_HORIZONTAL); iconHolder->AddChild(fTypeIconView); fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged)); BLayoutBuilder::Grid<>(typeBox, padding, padding) .SetInsets(padding, padding * 2, padding, padding) .Add(scrollView, 0, 0, 1, 4) .Add(fAddTypeButton, 1, 0, 1, 2) .Add(fRemoveTypeButton, 1, 2, 1, 2) .Add(iconHolder, 2, 1, 1, 2) .SetColumnWeight(0, 3) .SetColumnWeight(1, 2) .SetColumnWeight(2, 1); iconHolder->SetExplicitAlignment( BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); // "Version Info" group BBox* versionBox = new BBox("versionBox"); versionBox->SetLabel(B_TRANSLATE("Version info")); fMajorVersionControl = new BTextControl(B_TRANSLATE("Version:"), NULL, NULL); _MakeNumberTextControl(fMajorVersionControl); fMiddleVersionControl = new BTextControl(".", NULL, NULL); _MakeNumberTextControl(fMiddleVersionControl); fMinorVersionControl = new BTextControl(".", NULL, NULL); _MakeNumberTextControl(fMinorVersionControl); fVarietyMenu = new BPopUpMenu("variety", true, true); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Development"), NULL)); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Alpha"), NULL)); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Beta"), NULL)); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Gamma"), NULL)); item = new BMenuItem(B_TRANSLATE("Golden master"), NULL); fVarietyMenu->AddItem(item); item->SetMarked(true); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Final"), NULL)); BMenuField* varietyField = new BMenuField("", fVarietyMenu); fInternalVersionControl = new BTextControl("/", NULL, NULL); fShortDescriptionControl = new BTextControl(B_TRANSLATE("Short description:"), NULL, NULL); // TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says? version_info versionInfo; fShortDescriptionControl->TextView()->SetMaxBytes( sizeof(versionInfo.short_info)); BStringView* longLabel = new BStringView(NULL, B_TRANSLATE("Long description:")); longLabel->SetExplicitAlignment(labelAlignment); fLongDescriptionView = new TabFilteringTextView("long desc"); fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info)); scrollView = new BScrollView("desc scrollview", fLongDescriptionView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); // TODO: remove workaround (bug #5678) BSize minScrollSize = scrollView->ScrollBar(B_VERTICAL)->MinSize(); minScrollSize.width += fLongDescriptionView->MinSize().width; scrollView->SetExplicitMinSize(minScrollSize); // Manually set a minimum size for the version text controls // TODO: the same does not work when applied to the layout items float width = be_plain_font->StringWidth("99") + 16; fMajorVersionControl->TextView()->SetExplicitMinSize( BSize(width, fMajorVersionControl->MinSize().height)); fMiddleVersionControl->TextView()->SetExplicitMinSize( BSize(width, fMiddleVersionControl->MinSize().height)); fMinorVersionControl->TextView()->SetExplicitMinSize( BSize(width, fMinorVersionControl->MinSize().height)); fInternalVersionControl->TextView()->SetExplicitMinSize( BSize(width, fInternalVersionControl->MinSize().height)); BLayoutBuilder::Grid<>(versionBox, padding / 2, padding / 2) .SetInsets(padding, padding * 2, padding, padding) .Add(fMajorVersionControl->CreateLabelLayoutItem(), 0, 0) .Add(fMajorVersionControl->CreateTextViewLayoutItem(), 1, 0) .Add(fMiddleVersionControl, 2, 0, 2) .Add(fMinorVersionControl, 4, 0, 2) .Add(varietyField, 6, 0, 3) .Add(fInternalVersionControl, 9, 0, 2) .Add(fShortDescriptionControl->CreateLabelLayoutItem(), 0, 1) .Add(fShortDescriptionControl->CreateTextViewLayoutItem(), 1, 1, 10) .Add(longLabel, 0, 2) .Add(scrollView, 1, 2, 10, 3) .SetRowWeight(3, 3); // put it all together BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(0, 0, 0, 0) .Add(menuBar) .AddGroup(B_VERTICAL, padding) .SetInsets(padding, padding, padding, padding) .Add(fSignatureControl) .AddGroup(B_HORIZONTAL, padding) .Add(flagsBox, 3) .Add(iconBox, 1) .End() .Add(typeBox) .Add(versionBox); SetKeyMenuBar(menuBar); fSignatureControl->MakeFocus(true); BMimeType::StartWatching(this); _SetTo(entry); }
void TouchpadPrefView::SetupView() { SetLayout(new BGroupLayout(B_VERTICAL)); BBox* scrollBox = new BBox("Touchpad"); scrollBox->SetLabel(B_TRANSLATE("Scrolling")); fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120)); fTouchpadView->SetExplicitMaxSize(BSize(130, 120)); // Create the "Mouse Speed" slider... fScrollAccelSlider = new BSlider("scroll_accel", B_TRANSLATE("Scroll acceleration"), new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollAccelSlider->SetHashMarkCount(7); fScrollAccelSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); fScrollStepXSlider = new BSlider("scroll_stepX", B_TRANSLATE("Horizontal scroll speed"), new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollStepXSlider->SetHashMarkCount(7); fScrollStepXSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); fScrollStepYSlider = new BSlider("scroll_stepY", B_TRANSLATE("Vertical scroll speed"), new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollStepYSlider->SetHashMarkCount(7); fScrollStepYSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); fTwoFingerBox = new BCheckBox(B_TRANSLATE("Two finger scrolling"), new BMessage(SCROLL_CONTROL_CHANGED)); fTwoFingerHorizontalBox = new BCheckBox( B_TRANSLATE("Horizontal scrolling"), new BMessage(SCROLL_CONTROL_CHANGED)); BGroupView* scrollPrefLeftLayout = new BGroupView(B_VERTICAL); BLayoutBuilder::Group<>(scrollPrefLeftLayout) .Add(fTouchpadView) .Add(fTwoFingerBox) .AddGroup(B_HORIZONTAL) .AddStrut(20) .Add(fTwoFingerHorizontalBox); BGroupView* scrollPrefRightLayout = new BGroupView(B_VERTICAL); scrollPrefRightLayout->AddChild(fScrollAccelSlider); scrollPrefRightLayout->AddChild(fScrollStepXSlider); scrollPrefRightLayout->AddChild(fScrollStepYSlider); BGroupLayout* scrollPrefLayout = new BGroupLayout(B_HORIZONTAL); scrollPrefLayout->SetSpacing(10); scrollPrefLayout->SetInsets(10, scrollBox->TopBorderOffset() * 2 + 10, 10, 10); scrollBox->SetLayout(scrollPrefLayout); scrollPrefLayout->AddView(scrollPrefLeftLayout); scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(15)); scrollPrefLayout->AddView(scrollPrefRightLayout); BBox* tapBox = new BBox("tapbox"); tapBox->SetLabel(B_TRANSLATE("Tap gesture")); BGroupLayout* tapPrefLayout = new BGroupLayout(B_HORIZONTAL); tapPrefLayout->SetInsets(10, tapBox->TopBorderOffset() * 2 + 10, 10, 10); tapBox->SetLayout(tapPrefLayout); fTapSlider = new BSlider("tap_sens", B_TRANSLATE("Tap click sensitivity"), new BMessage(TAP_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); fTapSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fTapSlider->SetHashMarkCount(7); fTapSlider->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("High")); tapPrefLayout->AddView(fTapSlider); BGroupView* buttonView = new BGroupView(B_HORIZONTAL); fDefaultButton = new BButton(B_TRANSLATE("Defaults"), new BMessage(DEFAULT_SETTINGS)); buttonView->AddChild(fDefaultButton); buttonView->GetLayout()->AddItem( BSpaceLayoutItem::CreateHorizontalStrut(7)); fRevertButton = new BButton(B_TRANSLATE("Revert"), new BMessage(REVERT_SETTINGS)); fRevertButton->SetEnabled(false); buttonView->AddChild(fRevertButton); buttonView->GetLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); BGroupLayout* layout = new BGroupLayout(B_VERTICAL); layout->SetInsets(10, 10, 10, 10); layout->SetSpacing(10); BView* rootView = new BView("root view", 0, layout); AddChild(rootView); rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); layout->AddView(scrollBox); layout->AddView(tapBox); layout->AddView(buttonView); }
void BJobSetupPanel::_SetupInterface() { BGroupView* groupView = new BGroupView(B_VERTICAL, 10.0); // printers fPrinterPopUp = new BPopUpMenu(""); fPrinterPopUp->SetRadioMode(true); fPrinterMenuField = new BMenuField("", fPrinterPopUp); fPrinterMenuField->Menu()->SetLabelFromMarked(true); BPrinter printer; while (fPrinterRoster->GetNextPrinter(&printer) == B_OK) { BMenuItem* item = new BMenuItem(printer.Name().String(), NULL); fPrinterPopUp->AddItem(item); if (printer == *fPrinter) item->SetMarked(true); } if (fPrinterRoster->CountPrinters() > 0) fPrinterPopUp->AddItem(new BSeparatorItem); BMenuItem* pdf = new BMenuItem("Save as PDF file" , NULL); fPrinterPopUp->AddItem(pdf); if (fPrinterPopUp->FindMarked() == NULL) pdf->SetMarked(true); fProperties = new BButton("Properties" B_UTF8_ELLIPSIS , new BMessage('prop')); fPrinterInfo = new BStringView("label", ""); fPrinterInfo->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BBox* divider = new BBox(B_FANCY_BORDER, NULL); divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); fPrintToFile = new BCheckBox("Print to file"); BView* view = BGroupLayoutBuilder(B_VERTICAL, 5.0) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10.0) .Add(fPrinterMenuField->CreateMenuBarLayoutItem()) .Add(fProperties)) .Add(BGroupLayoutBuilder(B_HORIZONTAL,5.0) .Add(new BStringView("label", "Printer info:")) .Add(fPrinterInfo)) .Add(divider) .Add(fPrintToFile) .SetInsets(10.0, 5.0, 10.0, 5.0); BBox *box = new BBox(B_FANCY_BORDER, view); box->SetLabel(BGroupLayoutBuilder() .Add(new BStringView("", "Printer")) .SetInsets(2.0, 0.0, 2.0, 0.0)); groupView->AddChild(box); // page range fPrintAll = new BRadioButton("Print all", new BMessage('prrg')); fPrintAll->SetValue(B_CONTROL_ON); fPagesFrom = new BRadioButton("Pages from:", new BMessage('prrg')); fFirstPage = new BTextControl("", "", NULL); _DisallowChar(fFirstPage->TextView()); fLastPage = new BTextControl("to:", "", NULL); _DisallowChar(fLastPage->TextView()); fSelection = new BRadioButton("Print selection", new BMessage('prrg')); fFirstPage->CreateLabelLayoutItem(); view = BGroupLayoutBuilder(B_VERTICAL, 5.0) .Add(fPrintAll) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 5.0) .Add(fPagesFrom) .Add(fFirstPage->CreateTextViewLayoutItem()) .Add(fLastPage->CreateLabelLayoutItem()) .Add(fLastPage->CreateTextViewLayoutItem())) .Add(fSelection) .SetInsets(10.0, 5.0, 10.0, 5.0); box = new BBox(B_FANCY_BORDER, view); box->SetLabel(BGroupLayoutBuilder() .Add(new BStringView("", "Page range")) .SetInsets(2.0, 0.0, 2.0, 0.0)); // copies fNumberOfCopies = new BTextControl("Number of copies:", "1", NULL); _DisallowChar(fNumberOfCopies->TextView()); fCollate = new BCheckBox("Collate"); fReverse = new BCheckBox("Reverse"); BView* view2 = BGroupLayoutBuilder(B_VERTICAL, 5.0) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 5.0) .Add(fNumberOfCopies->CreateLabelLayoutItem()) .Add(fNumberOfCopies->CreateTextViewLayoutItem())) .Add(fCollate) .Add(fReverse) .SetInsets(10.0, 5.0, 10.0, 5.0); BBox* box2 = new BBox(B_FANCY_BORDER, view2); box2->SetLabel(BGroupLayoutBuilder() .Add(new BStringView("", "Copies")) .SetInsets(2.0, 0.0, 2.0, 0.0)); groupView->AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10.0) .Add(box) .Add(box2)); // other fColor = new BCheckBox("Print in color"); fDuplex = new BCheckBox("Double side printing"); view = BGroupLayoutBuilder(B_VERTICAL, 5.0) .Add(fColor) .Add(fDuplex) .SetInsets(10.0, 5.0, 10.0, 5.0); box = new BBox(B_FANCY_BORDER, view); box->SetLabel(BGroupLayoutBuilder() .Add(new BStringView("", "Other")) .SetInsets(2.0, 0.0, 2.0, 0.0)); groupView->AddChild(box); AddPanel(groupView); SetOptionFlags(fJobPanelFlags); }
void TouchpadPrefView::SetupView() { SetLayout(new BGroupLayout(B_VERTICAL)); BBox* scrollBox = new BBox("Touchpad"); scrollBox->SetLabel(B_TRANSLATE("Scrolling")); fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120)); fTouchpadView->SetExplicitMaxSize(BSize(130, 120)); // Create the "Mouse Speed" slider... fScrollAccelSlider = new BSlider("scroll_accel", B_TRANSLATE("Acceleration"), new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollAccelSlider->SetHashMarkCount(7); fScrollAccelSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); fScrollAccelSlider->SetExplicitMinSize(BSize(150, B_SIZE_UNSET)); fScrollStepXSlider = new BSlider("scroll_stepX", B_TRANSLATE("Horizontal"), new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollStepXSlider->SetHashMarkCount(7); fScrollStepXSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); fScrollStepYSlider = new BSlider("scroll_stepY", B_TRANSLATE("Vertical"), new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollStepYSlider->SetHashMarkCount(7); fScrollStepYSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); fTwoFingerBox = new BCheckBox(B_TRANSLATE("Two finger scrolling"), new BMessage(SCROLL_CONTROL_CHANGED)); fTwoFingerHorizontalBox = new BCheckBox( B_TRANSLATE("Horizontal scrolling"), new BMessage(SCROLL_CONTROL_CHANGED)); float spacing = be_control_look->DefaultItemSpacing(); BView* scrollPrefLeftLayout = BLayoutBuilder::Group<>(B_VERTICAL, 0) .Add(fTouchpadView) .AddStrut(spacing) .Add(fTwoFingerBox) .AddGroup(B_HORIZONTAL, 0) .AddStrut(spacing * 2) .Add(fTwoFingerHorizontalBox) .End() .AddGlue() .View(); BGroupView* scrollPrefRightLayout = new BGroupView(B_VERTICAL); scrollPrefRightLayout->AddChild(fScrollAccelSlider); scrollPrefRightLayout->AddChild(fScrollStepXSlider); scrollPrefRightLayout->AddChild(fScrollStepYSlider); BGroupLayout* scrollPrefLayout = new BGroupLayout(B_HORIZONTAL); scrollPrefLayout->SetSpacing(spacing); scrollPrefLayout->SetInsets(spacing, scrollBox->TopBorderOffset() * 2 + spacing, spacing, spacing); scrollBox->SetLayout(scrollPrefLayout); scrollPrefLayout->AddView(scrollPrefLeftLayout); scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(spacing * 1.5)); scrollPrefLayout->AddView(scrollPrefRightLayout); BBox* tapBox = new BBox("tapbox"); tapBox->SetLabel(B_TRANSLATE("Tapping")); BGroupLayout* tapPrefLayout = new BGroupLayout(B_HORIZONTAL); tapPrefLayout->SetInsets(spacing, tapBox->TopBorderOffset() * 2 + spacing, spacing, spacing); tapBox->SetLayout(tapPrefLayout); fTapSlider = new BSlider("tap_sens", B_TRANSLATE("Sensitivity"), new BMessage(TAP_CONTROL_CHANGED), 0, spacing * 2, B_HORIZONTAL); fTapSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fTapSlider->SetHashMarkCount(7); fTapSlider->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("High")); tapPrefLayout->AddView(fTapSlider); fDefaultButton = new BButton(B_TRANSLATE("Defaults"), new BMessage(DEFAULT_SETTINGS)); fRevertButton = new BButton(B_TRANSLATE("Revert"), new BMessage(REVERT_SETTINGS)); fRevertButton->SetEnabled(false); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_WINDOW_SPACING) .Add(scrollBox) .Add(tapBox) .AddGroup(B_HORIZONTAL) .Add(fDefaultButton) .Add(fRevertButton) .AddGlue() .End() .End(); }