CookieWindow::CookieWindow(BRect frame, BNetworkCookieJar& jar) : BWindow(frame, B_TRANSLATE("Cookie manager"), B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL, B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE), fCookieJar(jar) { BGroupLayout* root = new BGroupLayout(B_HORIZONTAL, 0.0); SetLayout(root); fDomains = new BOutlineListView("domain list"); root->AddView(new BScrollView("scroll", fDomains, 0, false, true), 1); fHeaderView = new BStringView("label", B_TRANSLATE("The cookie jar is empty!")); fCookies = new BColumnListView("cookie list", B_WILL_DRAW, B_FANCY_BORDER, false); int em = fCookies->StringWidth("M"); int flagsLength = fCookies->StringWidth("Mhttps hostOnly" B_UTF8_ELLIPSIS); fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Name"), 20 * em, 10 * em, 50 * em, 0), 0); fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Path"), 10 * em, 10 * em, 50 * em, 0), 1); fCookies->AddColumn(new CookieDateColumn(B_TRANSLATE("Expiration"), fCookies->StringWidth("88/88/8888 88:88:88 AM")), 2); fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Value"), 20 * em, 10 * em, 50 * em, 0), 3); fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Flags"), flagsLength, flagsLength, flagsLength, 0), 4); root->AddItem(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(5, 5, 5, 5) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(fHeaderView) .AddGlue() .End() .Add(fCookies) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .SetInsets(5, 5, 5, 5) #if 0 .Add(new BButton("import", B_TRANSLATE("Import" B_UTF8_ELLIPSIS), NULL)) .Add(new BButton("export", B_TRANSLATE("Export" B_UTF8_ELLIPSIS), NULL)) #endif .AddGlue() .Add(new BButton("delete", B_TRANSLATE("Delete"), new BMessage(COOKIE_DELETE))), 3); fDomains->SetSelectionMessage(new BMessage(DOMAIN_SELECTED)); }
void GroupListView::SetModel(GroupListModel* model) { // TODO: remove all previous // TODO: add change mechanism // TODO: use a "virtual" BGroupLayout (ie. one that create its layout items // on the fly). fModel = model; std::map<addr_t, BGroupLayout*> groupMap; int32 groupCount = model->CountGroups(); for (int groupIndex = 0; groupIndex < groupCount; groupIndex++) { BGroupLayout* groupItem = new BGroupLayout(B_VERTICAL, 0); groupItem->SetVisible(false); AddChild(groupItem); void* group = model->GroupAt(groupIndex); groupMap[(addr_t)group] = groupItem; groupItem->AddItem(new RendererLayoutItem(this, groupIndex, group, fGroupRenderer)); } int32 itemCount = model->CountItems(); for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) { void* group = model->GroupForItemAt(itemIndex); if (group == NULL) continue; BGroupLayout* groupItem = groupMap[(addr_t)group]; if (groupItem == NULL) continue; groupItem->SetVisible(true); RendererLayoutItem* rendererItem = new RendererLayoutItem(this, itemIndex, model->ItemAt(itemIndex), fItemRenderer); groupItem->AddItem(rendererItem); } }
ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface) : BWindow(BRect(100, 150, 500, 500), "Extended battery info", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT | B_ASYNCHRONOUS_CONTROLS), fDriverInterface(interface), fSelectedView(NULL) { fDriverInterface->AcquireReference(); BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(view); BGroupLayout* mainLayout = new BGroupLayout(B_VERTICAL); mainLayout->SetSpacing(10); mainLayout->SetInsets(10, 10, 10, 10); view->SetLayout(mainLayout); BRect rect = Bounds(); rect.InsetBy(5, 5); BBox *infoBox = new BBox(rect, "Power status box"); infoBox->SetLabel("Battery info"); BGroupLayout* infoLayout = new BGroupLayout(B_HORIZONTAL); infoLayout->SetInsets(10, infoBox->TopBorderOffset() * 2 + 10, 10, 10); infoLayout->SetSpacing(10); infoBox->SetLayout(infoLayout); mainLayout->AddView(infoBox); BGroupView* batteryView = new BGroupView(B_VERTICAL); batteryView->GroupLayout()->SetSpacing(10); infoLayout->AddView(batteryView); // create before the battery views fBatteryInfoView = new BatteryInfoView(); BGroupLayout* batteryLayout = batteryView->GroupLayout(); BRect batteryRect(0, 0, 50, 30); for (int i = 0; i < interface->GetBatteryCount(); i++) { ExtPowerStatusView* view = new ExtPowerStatusView(interface, batteryRect, B_FOLLOW_NONE, i, this); view->SetExplicitMaxSize(BSize(70, 80)); view->SetExplicitMinSize(BSize(70, 80)); batteryLayout->AddView(view); fBatteryViewList.AddItem(view); fDriverInterface->StartWatching(view); if (!view->IsCritical()) fSelectedView = view; } batteryLayout->AddItem(BSpaceLayoutItem::CreateGlue()); infoLayout->AddView(fBatteryInfoView); if (!fSelectedView && fBatteryViewList.CountItems() > 0) fSelectedView = fBatteryViewList.ItemAt(0); fSelectedView->Select(); BSize size = mainLayout->PreferredSize(); ResizeTo(size.width, size.height); }
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 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(); }