PoorManAdvancedView::PoorManAdvancedView(const char* name) : BView(name, B_WILL_DRAW, NULL) { PoorManWindow* win; win = ((PoorManApplication*)be_app)->GetPoorManWindow(); BBox* connectionOptions = new BBox(B_TRANSLATE("Connections")); connectionOptions->SetLabel(STR_BBX_CONNECTION); fMaxConnections = new StatusSlider("Max Slider", STR_SLD_LABEL, STR_SLD_STATUS_LABEL, new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200); // labels below the slider 1 and 200 fMaxConnections->SetLimitLabels("1", "200"); SetMaxSimutaneousConnections(win->MaxConnections()); BGroupLayout* connectionOptionsLayout = new BGroupLayout(B_VERTICAL, 0); connectionOptions->SetLayout(connectionOptionsLayout); BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGroup(connectionOptionsLayout) .SetInsets(B_USE_ITEM_INSETS) .AddStrut(B_USE_ITEM_SPACING) .Add(fMaxConnections) .End() .AddGlue() .SetInsets(B_USE_ITEM_INSETS); }
SettingsView::SettingsView(Core* core) : BView("SettingsView", B_WILL_DRAW, 0), fCore(core) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // Engines entry BBox* audioBox = new BBox("audiobox"); audioBox->SetLabel("Engines"); BGroupLayout* audioLayout = new BGroupLayout(B_VERTICAL); audioLayout->SetInsets(10, audioBox->TopBorderOffset() * 2 + 10, 10, 10); audioBox->SetLayout(audioLayout); fEngines[0] = new BRadioButton("sine", "Sine", _ButtonMsg(CRONO_SINE_ENGINE)); audioLayout->AddView(fEngines[0]); fEngines[1] = new BRadioButton("triangle", "Triangle", _ButtonMsg(CRONO_TRIANGLE_ENGINE)); audioLayout->AddView(fEngines[1]); fEngines[2] = new BRadioButton("sawtooth", "Sawtooth", _ButtonMsg(CRONO_SAWTOOTH_ENGINE)); audioLayout->AddView(fEngines[2]); fEngines[3] = new BRadioButton("file", "File Engine", _ButtonMsg(CRONO_FILE_ENGINE)); audioLayout->AddView(fEngines[3]); fSoundEntry = new BTextControl("Soundfile", "Soundfile", gCronoSettings.SoundFileLocation, new BMessage(MSG_SET), B_WILL_DRAW); fSoundEntry->SetDivider(70); fSoundEntry->SetAlignment(B_ALIGN_CENTER, B_ALIGN_CENTER); audioLayout->AddView(fSoundEntry); fSoundEntry->SetEnabled(false); fDefaultsButton = new BButton("Defaults", new BMessage(MSG_DEFAULTS)); BLayoutBuilder::Group<>(this, B_VERTICAL, 5) .AddGroup(B_VERTICAL) .Add(audioBox, 0) .End() .AddGroup(B_HORIZONTAL) .Add(fDefaultsButton, 0) .End(); _SetEngine(fCore->Engine()); }
VolumeWindow::VolumeWindow(BRect frame, bool dontBeep, int32 volumeWhich) : BWindow(frame, "VolumeWindow", B_BORDERED_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK | B_AUTO_UPDATE_SIZE_LIMITS, 0), fUpdatedCount(0) { SetLayout(new BGroupLayout(B_HORIZONTAL)); BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL); layout->SetInsets(5, 5, 5, 5); BBox* box = new BBox("sliderbox"); box->SetLayout(layout); box->SetBorder(B_PLAIN_BORDER); AddChild(box); BSlider* slider = new VolumeControl(volumeWhich, !dontBeep, new BMessage(kMsgVolumeChanged)); slider->SetModificationMessage(new BMessage(kMsgVolumeUpdate)); box->AddChild(slider); slider->SetTarget(this); ResizeTo(300, 50); // Make sure it's not outside the screen. const int32 kMargin = 3; BRect windowRect = Frame(); BRect screenFrame(BScreen(B_MAIN_SCREEN_ID).Frame()); if (screenFrame.right < windowRect.right + kMargin) MoveBy(- kMargin - windowRect.right + screenFrame.right, 0); if (screenFrame.bottom < windowRect.bottom + kMargin) MoveBy(0, - kMargin - windowRect.bottom + screenFrame.bottom); if (screenFrame.left > windowRect.left - kMargin) MoveBy(kMargin + screenFrame.left - windowRect.left, 0); if (screenFrame.top > windowRect.top - kMargin) MoveBy(0, kMargin + screenFrame.top - windowRect.top); }
void add_status_bars(BGridLayout* layout, int32& row) { BBox* box = new BBox(B_FANCY_BORDER, NULL); box->SetLabel("Info"); BGroupLayout* boxLayout = new BGroupLayout(B_VERTICAL, kInset); boxLayout->SetInsets(kInset, kInset + box->TopBorderOffset(), kInset, kInset); box->SetLayout(boxLayout); BStatusBar* statusBar = new BStatusBar("status bar", "Status", "Completed"); statusBar->SetMaxValue(100); statusBar->SetTo(0); statusBar->SetBarHeight(12); boxLayout->AddView(statusBar); statusBar = new BStatusBar("status bar", "Progress", "Completed"); statusBar->SetMaxValue(100); statusBar->SetTo(40); statusBar->SetBarHeight(12); boxLayout->AddView(statusBar); statusBar = new BStatusBar("status bar", "Lifespan of capitalism", "Completed"); statusBar->SetMaxValue(100); statusBar->SetTo(100); statusBar->SetBarHeight(12); boxLayout->AddView(statusBar); layout->AddView(box, 0, row, 4); row++; }
CronoView::CronoView() : BView("CronoView", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), fAccentsList(false) { fReplicated = false; // Core fCore = new Core(); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); rgb_color barColor = { 0, 200, 0 }; rgb_color fillColor = { 240, 240, 240 }; _BuildMenu(); // Volume slider BBox* volBox = new BBox("volbox"); volBox->SetLabel("Volume"); BGroupLayout* volLayout = new BGroupLayout(B_VERTICAL); volLayout->SetInsets(10, volBox->TopBorderOffset() * 2 + 10, 10, 10); volBox->SetLayout(volLayout); fVolumeSlider = new VolumeSlider("", 0, 1000, DEFAULT_VOLUME, new BMessage(MSG_VOLUME)); fVolumeSlider->SetLimitLabels("Min", "Max"); fVolumeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fVolumeSlider->SetHashMarkCount(20); fVolumeSlider->SetValue((int32)fCore->Volume()*10); fVolumeSlider->UseFillColor(true, &fillColor); fVolumeSlider->SetPosition(gCronoSettings.CronoVolume); fVolumeSlider->SetLabel(BString() << gCronoSettings.CronoVolume); volLayout->AddView(fVolumeSlider); // Speed Slider & TextControl BBox* speedBox = new BBox("speedbox"); speedBox->SetLabel("BPM"); BGroupLayout* speedLayout = new BGroupLayout(B_HORIZONTAL); speedLayout->SetInsets(10, speedBox->TopBorderOffset() * 2 + 10, 10, 10); speedBox->SetLayout(speedLayout); fSpeedSlider = new VolumeSlider("", MIN_SPEED, MAX_SPEED, DEFAULT_SPEED, new BMessage(MSG_SPEED_SLIDER)); fSpeedSlider->SetLimitLabels(BString() << MIN_SPEED, BString() << MAX_SPEED); fSpeedSlider->SetKeyIncrementValue(5); fSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fSpeedSlider->SetHashMarkCount(15); fSpeedSlider->SetValue(fCore->Speed()); fSpeedSlider->UseFillColor(true, &fillColor); _UpdateTempoName(gCronoSettings.Speed); fSpeedEntry = new BTextControl("", "", BString() << gCronoSettings.Speed, new BMessage(MSG_SPEED_ENTRY), B_WILL_DRAW); fSpeedEntry->SetDivider(70); fSpeedEntry->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_RIGHT); fSpeedEntry->SetExplicitSize(BSize(35, 20)); speedLayout->AddView(fSpeedSlider); speedLayout->AddView(fSpeedEntry); // Meter buttons BBox* tempoBox = new BBox("tempoBox"); tempoBox->SetLabel("Tempo"); for(int i = 0; i < 5; i++) fTempoRadios[i] = new BRadioButton("", "", new BMessage(MSG_METER_RADIO)); fTempoRadios[0]->SetLabel("1/4"); fTempoRadios[1]->SetLabel("2/4"); fTempoRadios[2]->SetLabel("3/4"); fTempoRadios[3]->SetLabel("4/4"); fTempoRadios[4]->SetLabel("Other"); fTempoRadios[fCore->Meter()]->SetValue(1); fTempoEntry = new BTextControl("", "", "4", new BMessage(MSG_METER_ENTRY), B_WILL_DRAW); fTempoEntry->SetDivider(70); if (fTempoRadios[4]->Value() == 1) fTempoEntry->SetEnabled(true); else fTempoEntry->SetEnabled(false); fAccentsView = new BGroupView(B_HORIZONTAL, 0); BLayoutBuilder::Group<>(tempoBox, B_VERTICAL, 0) .SetInsets(10, tempoBox->TopBorderOffset() * 2 + 10, 10, 10) .AddGroup(B_HORIZONTAL, 0) .Add(fTempoRadios[0]) .Add(fTempoRadios[1]) .Add(fTempoRadios[2]) .Add(fTempoRadios[3]) .Add(fTempoRadios[4]) .Add(fTempoEntry) .AddGlue() .End() .Add(fAccentsView) .AddGlue() .End(); if (gCronoSettings.AccentTable == true) _ShowTable(true); fStartButton = new BButton("Start", new BMessage(MSG_START)); fStartButton->MakeDefault(true); fStopButton = new BButton("Stop", new BMessage(MSG_STOP)); #ifdef CRONO_REPLICANT_ACTIVE // Dragger BRect frame(Bounds()); frame.left = frame.right - 7; frame.top = frame.bottom - 7; BDragger *dragger = new BDragger(frame, this, B_FOLLOW_RIGHT | B_FOLLOW_TOP); #endif // Create view BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(fMenuBar) .Add(volBox) .Add(speedBox) .Add(tempoBox) .AddGroup(B_HORIZONTAL) .Add(fStartButton) .Add(fStopButton) .End() #ifdef CRONO_REPLICANT_ACTIVE .Add(dragger) #endif .End(); }
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)); }
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); }
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); }
ScreenWindow::ScreenWindow(ScreenSettings* settings) : BWindow(settings->WindowFrame(), B_TRANSLATE_SYSTEM_NAME("Screen"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), fIsVesa(false), fBootWorkspaceApplied(false), fOtherRefresh(NULL), fScreenMode(this), fUndoScreenMode(this), fModified(false) { BScreen screen(this); accelerant_device_info info; if (screen.GetDeviceInfo(&info) == B_OK && !strcasecmp(info.chipset, "VESA")) fIsVesa = true; _UpdateOriginal(); _BuildSupportedColorSpaces(); fActive = fSelected = fOriginal; fSettings = settings; // we need the "Current Workspace" first to get its height BPopUpMenu *popUpMenu = new BPopUpMenu(B_TRANSLATE("Current workspace"), true, true); fAllWorkspacesItem = new BMenuItem(B_TRANSLATE("All workspaces"), new BMessage(WORKSPACE_CHECK_MSG)); popUpMenu->AddItem(fAllWorkspacesItem); BMenuItem *item = new BMenuItem(B_TRANSLATE("Current workspace"), new BMessage(WORKSPACE_CHECK_MSG)); popUpMenu->AddItem(item); fAllWorkspacesItem->SetMarked(true); BMenuField* workspaceMenuField = new BMenuField("WorkspaceMenu", NULL, popUpMenu); workspaceMenuField->ResizeToPreferred(); // box on the left with workspace count and monitor view BBox* screenBox = new BBox("screen box"); BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 5.0); layout->SetInsets(10, 10, 10, 10); screenBox->SetLayout(layout); fMonitorInfo = new BStringView("monitor info", ""); screenBox->AddChild(fMonitorInfo); fMonitorView = new MonitorView(BRect(0.0, 0.0, 80.0, 80.0), "monitor", screen.Frame().IntegerWidth() + 1, screen.Frame().IntegerHeight() + 1); screenBox->AddChild(fMonitorView); fColumnsControl = new BTextControl(B_TRANSLATE("Columns:"), "0", new BMessage(kMsgWorkspaceColumnsChanged)); fRowsControl = new BTextControl(B_TRANSLATE("Rows:"), "0", new BMessage(kMsgWorkspaceRowsChanged)); screenBox->AddChild(BLayoutBuilder::Grid<>(5.0, 5.0) .Add(new BStringView("", B_TRANSLATE("Workspaces")), 0, 0, 3) .AddTextControl(fColumnsControl, 0, 1, B_ALIGN_RIGHT) .AddGroup(B_HORIZONTAL, 0, 2, 1) .Add(_CreateColumnRowButton(true, false)) .Add(_CreateColumnRowButton(true, true)) .End() .AddTextControl(fRowsControl, 0, 2, B_ALIGN_RIGHT) .AddGroup(B_HORIZONTAL, 0, 2, 2) .Add(_CreateColumnRowButton(false, false)) .Add(_CreateColumnRowButton(false, true)) .End() .View()); fBackgroundsButton = new BButton("BackgroundsButton", B_TRANSLATE("Set background" B_UTF8_ELLIPSIS), new BMessage(BUTTON_LAUNCH_BACKGROUNDS_MSG)); fBackgroundsButton->SetFontSize(be_plain_font->Size() * 0.9); screenBox->AddChild(fBackgroundsButton); // box on the right with screen resolution, etc. BBox* controlsBox = new BBox("controls box"); controlsBox->SetLabel(workspaceMenuField); BGroupView* outerControlsView = new BGroupView(B_VERTICAL, 10.0); outerControlsView->GroupLayout()->SetInsets(10, 10, 10, 10); controlsBox->AddChild(outerControlsView); fResolutionMenu = new BPopUpMenu("resolution", true, true); uint16 maxWidth = 0; uint16 maxHeight = 0; uint16 previousWidth = 0; uint16 previousHeight = 0; for (int32 i = 0; i < fScreenMode.CountModes(); i++) { screen_mode mode = fScreenMode.ModeAt(i); if (mode.width == previousWidth && mode.height == previousHeight) continue; previousWidth = mode.width; previousHeight = mode.height; if (maxWidth < mode.width) maxWidth = mode.width; if (maxHeight < mode.height) maxHeight = mode.height; BMessage* message = new BMessage(POP_RESOLUTION_MSG); message->AddInt32("width", mode.width); message->AddInt32("height", mode.height); BString name; name << mode.width << " x " << mode.height; fResolutionMenu->AddItem(new BMenuItem(name.String(), message)); } fMonitorView->SetMaxResolution(maxWidth, maxHeight); fResolutionField = new BMenuField("ResolutionMenu", B_TRANSLATE("Resolution:"), fResolutionMenu); fColorsMenu = new BPopUpMenu("colors", true, false); for (int32 i = 0; i < kColorSpaceCount; i++) { if ((fSupportedColorSpaces & (1 << i)) == 0) continue; BMessage* message = new BMessage(POP_COLORS_MSG); message->AddInt32("bits_per_pixel", kColorSpaces[i].bits_per_pixel); message->AddInt32("space", kColorSpaces[i].space); BMenuItem* item = new BMenuItem(kColorSpaces[i].label, message); if (kColorSpaces[i].space == screen.ColorSpace()) fUserSelectedColorSpace = item; fColorsMenu->AddItem(item); } fColorsField = new BMenuField("ColorsMenu", B_TRANSLATE("Colors:"), fColorsMenu); fRefreshMenu = new BPopUpMenu("refresh rate", true, true); float min, max; if (fScreenMode.GetRefreshLimits(fActive, min, max) != B_OK) { // if we couldn't obtain the refresh limits, reset to the default // range. Constraints from detected monitors will fine-tune this // later. min = kRefreshRates[0]; max = kRefreshRates[kRefreshRateCount - 1]; } if (min == max) { // This is a special case for drivers that only support a single // frequency, like the VESA driver BString name; refresh_rate_to_string(min, name); BMessage *message = new BMessage(POP_REFRESH_MSG); message->AddFloat("refresh", min); BMenuItem *item = new BMenuItem(name.String(), message); fRefreshMenu->AddItem(item); item->SetEnabled(false); } else { monitor_info info; if (fScreenMode.GetMonitorInfo(info) == B_OK) { min = max_c(info.min_vertical_frequency, min); max = min_c(info.max_vertical_frequency, max); } for (int32 i = 0; i < kRefreshRateCount; ++i) { if (kRefreshRates[i] < min || kRefreshRates[i] > max) continue; BString name; name << kRefreshRates[i] << " " << B_TRANSLATE("Hz"); BMessage *message = new BMessage(POP_REFRESH_MSG); message->AddFloat("refresh", kRefreshRates[i]); fRefreshMenu->AddItem(new BMenuItem(name.String(), message)); } fOtherRefresh = new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS), new BMessage(POP_OTHER_REFRESH_MSG)); fRefreshMenu->AddItem(fOtherRefresh); } fRefreshField = new BMenuField("RefreshMenu", B_TRANSLATE("Refresh rate:"), fRefreshMenu); if (_IsVesa()) fRefreshField->Hide(); // enlarged area for multi-monitor settings { bool dummy; uint32 dummy32; bool multiMonSupport; bool useLaptopPanelSupport; bool tvStandardSupport; multiMonSupport = TestMultiMonSupport(&screen) == B_OK; useLaptopPanelSupport = GetUseLaptopPanel(&screen, &dummy) == B_OK; tvStandardSupport = GetTVStandard(&screen, &dummy32) == B_OK; // even if there is no support, we still create all controls // to make sure we don't access NULL pointers later on fCombineMenu = new BPopUpMenu("CombineDisplays", true, true); for (int32 i = 0; i < kCombineModeCount; i++) { BMessage *message = new BMessage(POP_COMBINE_DISPLAYS_MSG); message->AddInt32("mode", kCombineModes[i].mode); fCombineMenu->AddItem(new BMenuItem(kCombineModes[i].name, message)); } fCombineField = new BMenuField("CombineMenu", B_TRANSLATE("Combine displays:"), fCombineMenu); if (!multiMonSupport) fCombineField->Hide(); fSwapDisplaysMenu = new BPopUpMenu("SwapDisplays", true, true); // !order is important - we rely that boolean value == idx BMessage *message = new BMessage(POP_SWAP_DISPLAYS_MSG); message->AddBool("swap", false); fSwapDisplaysMenu->AddItem(new BMenuItem(B_TRANSLATE("no"), message)); message = new BMessage(POP_SWAP_DISPLAYS_MSG); message->AddBool("swap", true); fSwapDisplaysMenu->AddItem(new BMenuItem(B_TRANSLATE("yes"), message)); fSwapDisplaysField = new BMenuField("SwapMenu", B_TRANSLATE("Swap displays:"), fSwapDisplaysMenu); if (!multiMonSupport) fSwapDisplaysField->Hide(); fUseLaptopPanelMenu = new BPopUpMenu("UseLaptopPanel", true, true); // !order is important - we rely that boolean value == idx message = new BMessage(POP_USE_LAPTOP_PANEL_MSG); message->AddBool("use", false); fUseLaptopPanelMenu->AddItem(new BMenuItem(B_TRANSLATE("if needed"), message)); message = new BMessage(POP_USE_LAPTOP_PANEL_MSG); message->AddBool("use", true); fUseLaptopPanelMenu->AddItem(new BMenuItem(B_TRANSLATE("always"), message)); fUseLaptopPanelField = new BMenuField("UseLaptopPanel", B_TRANSLATE("Use laptop panel:"), fUseLaptopPanelMenu); if (!useLaptopPanelSupport) fUseLaptopPanelField->Hide(); fTVStandardMenu = new BPopUpMenu("TVStandard", true, true); // arbitrary limit uint32 i; for (i = 0; i < 100; ++i) { uint32 mode; if (GetNthSupportedTVStandard(&screen, i, &mode) != B_OK) break; BString name = tv_standard_to_string(mode); message = new BMessage(POP_TV_STANDARD_MSG); message->AddInt32("tv_standard", mode); fTVStandardMenu->AddItem(new BMenuItem(name.String(), message)); } fTVStandardField = new BMenuField("tv standard", B_TRANSLATE("Video format:"), fTVStandardMenu); fTVStandardField->SetAlignment(B_ALIGN_RIGHT); if (!tvStandardSupport || i == 0) fTVStandardField->Hide(); } BLayoutBuilder::Group<>(outerControlsView) .AddGrid(5.0, 5.0) .AddMenuField(fResolutionField, 0, 0, B_ALIGN_RIGHT) .AddMenuField(fColorsField, 0, 1, B_ALIGN_RIGHT) .AddMenuField(fRefreshField, 0, 2, B_ALIGN_RIGHT) .AddMenuField(fCombineField, 0, 3, B_ALIGN_RIGHT) .AddMenuField(fSwapDisplaysField, 0, 4, B_ALIGN_RIGHT) .AddMenuField(fUseLaptopPanelField, 0, 5, B_ALIGN_RIGHT) .AddMenuField(fTVStandardField, 0, 6, B_ALIGN_RIGHT) .End(); // TODO: we don't support getting the screen's preferred settings /* fDefaultsButton = new BButton(buttonRect, "DefaultsButton", "Defaults", new BMessage(BUTTON_DEFAULTS_MSG));*/ fApplyButton = new BButton("ApplyButton", B_TRANSLATE("Apply"), new BMessage(BUTTON_APPLY_MSG)); fApplyButton->SetEnabled(false); BLayoutBuilder::Group<>(outerControlsView) .AddGlue() .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fApplyButton); fRevertButton = new BButton("RevertButton", B_TRANSLATE("Revert"), new BMessage(BUTTON_REVERT_MSG)); fRevertButton->SetEnabled(false); BLayoutBuilder::Group<>(this, B_VERTICAL, 10.0) .SetInsets(10, 10, 10, 10) .AddGroup(B_HORIZONTAL, 10.0) .AddGroup(B_VERTICAL) .AddStrut(floor(controlsBox->TopBorderOffset() / 16) - 1) .Add(screenBox) .End() .Add(controlsBox) .End() .AddGroup(B_HORIZONTAL, 10.0) .Add(fRevertButton) .AddGlue(); _UpdateControls(); _UpdateMonitor(); }
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); }
AutomountSettingsPanel::AutomountSettingsPanel(BMessage* settings, const BMessenger& target) : BBox("", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_NO_BORDER), fTarget(target) { const float spacing = be_control_look->DefaultItemSpacing(); // "Automatic Disk Mounting" group BBox* autoMountBox = new BBox("autoMountBox", B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED | B_NAVIGABLE_JUMP); autoMountBox->SetLabel(B_TRANSLATE("Automatic disk mounting")); BGroupLayout* autoMountLayout = new BGroupLayout(B_VERTICAL, 0); autoMountBox->SetLayout(autoMountLayout); autoMountLayout->SetInsets(spacing, autoMountBox->InnerFrame().top + spacing / 2, spacing, spacing); fScanningDisabledCheck = new BRadioButton("scanningOff", B_TRANSLATE("Don't automount"), new BMessage(kAutomountSettingsChanged)); fAutoMountAllBFSCheck = new BRadioButton("autoBFS", B_TRANSLATE("All BeOS disks"), new BMessage(kAutomountSettingsChanged)); fAutoMountAllCheck = new BRadioButton("autoAll", B_TRANSLATE("All disks"), new BMessage(kAutomountSettingsChanged)); // "Disk Mounting During Boot" group BBox* bootMountBox = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED | B_NAVIGABLE_JUMP); bootMountBox->SetLabel(B_TRANSLATE("Disk mounting during boot")); BGroupLayout* bootMountLayout = new BGroupLayout(B_VERTICAL, 0); bootMountBox->SetLayout(bootMountLayout); bootMountLayout->SetInsets(spacing, bootMountBox->InnerFrame().top + spacing / 2, spacing, spacing); fInitialDontMountCheck = new BRadioButton("initialNone", B_TRANSLATE("Only the boot disk"), new BMessage(kBootMountSettingsChanged)); fInitialMountRestoreCheck = new BRadioButton("initialRestore", B_TRANSLATE("Previously mounted disks"), new BMessage(kBootMountSettingsChanged)); fInitialMountAllBFSCheck = new BRadioButton("initialBFS", B_TRANSLATE("All BeOS disks"), new BMessage(kBootMountSettingsChanged)); fInitialMountAllCheck = new BRadioButton("initialAll", B_TRANSLATE("All disks"), new BMessage(kBootMountSettingsChanged)); fEjectWhenUnmountingCheckBox = new BCheckBox("ejectWhenUnmounting", B_TRANSLATE("Eject when unmounting"), new BMessage(kEjectWhenUnmountingChanged)); // Buttons fDone = new BButton(B_TRANSLATE("Done"), new BMessage(B_QUIT_REQUESTED)); fMountAllNow = new BButton("mountAll", B_TRANSLATE("Mount all disks now"), new BMessage(kMountAllNow)); fDone->MakeDefault(true); // Layout the controls BGroupView* contentView = new BGroupView(B_VERTICAL, 0); AddChild(contentView); BLayoutBuilder::Group<>(contentView) .AddGroup(B_VERTICAL, spacing) .SetInsets(spacing, spacing, spacing, spacing) .AddGroup(autoMountLayout) .Add(fScanningDisabledCheck) .Add(fAutoMountAllBFSCheck) .Add(fAutoMountAllCheck) .End() .AddGroup(bootMountLayout) .Add(fInitialDontMountCheck) .Add(fInitialMountRestoreCheck) .Add(fInitialMountAllBFSCheck) .Add(fInitialMountAllCheck) .End() .AddGroup(B_HORIZONTAL) .AddStrut(spacing - 1) .Add(fEjectWhenUnmountingCheckBox) .End() .End() .Add(new BSeparatorView(B_HORIZONTAL/*, B_FANCY_BORDER*/)) .AddGroup(B_HORIZONTAL, spacing) .SetInsets(0, spacing, spacing, spacing) .AddGlue() .Add(fMountAllNow) .Add(fDone); // Apply the settings bool result; if (settings->FindBool("autoMountAll", &result) == B_OK && result) fAutoMountAllCheck->SetValue(B_CONTROL_ON); else if (settings->FindBool("autoMountAllBFS", &result) == B_OK && result) fAutoMountAllBFSCheck->SetValue(B_CONTROL_ON); else fScanningDisabledCheck->SetValue(B_CONTROL_ON); if (settings->FindBool("suspended", &result) == B_OK && result) fScanningDisabledCheck->SetValue(B_CONTROL_ON); if (settings->FindBool("initialMountAll", &result) == B_OK && result) fInitialMountAllCheck->SetValue(B_CONTROL_ON); else if (settings->FindBool("initialMountRestore", &result) == B_OK && result) { fInitialMountRestoreCheck->SetValue(B_CONTROL_ON); } else if (settings->FindBool("initialMountAllBFS", &result) == B_OK && result) { fInitialMountAllBFSCheck->SetValue(B_CONTROL_ON); } else fInitialDontMountCheck->SetValue(B_CONTROL_ON); if (settings->FindBool("ejectWhenUnmounting", &result) == B_OK && result) fEjectWhenUnmountingCheckBox->SetValue(B_CONTROL_ON); }
/*! \function CalendarModulePreferences::CreateWeekendSelectionBox * \brief Create box for selection of the weekend days * \note Additionally, select the color for weekends and weekdays * \param[in] frame Enclosing rectangle. * \param[in] label Reference to label of the enclosing BBox. * \param[in] calModule The calendar module for which the preferences are set. */ void CalendarModulePreferences::CreateWeekendSelectionBox( BRect frame, BString &label, CalendarModule* calModule ) { /*! \par Notes on implementation: * It's not all that straightforward - to create this selection box. * The problem is that number of days in week is dependent on the * Calendar Module, therefore the frame rectangle must be divided * properly. We should take into account the possibility that there's * not enough place for all days in the submitted frame. * * \par * The solution will be as follows: * Let number of days in week be N. I create two columns and * several rows (the number depends on N). Days in week will be * proceeded in the order <em>as Calendar Module supplies them</em>. * The days occupy both columns, and are located in rows * [0, (ceiling of (N/2)) ). Days returned from CalendarModule are * placed as follows: days from 0 to (ceiling of (N/2)-1) in the left * column, days from (ceiling of (N/2)-1) to (N-1) in right column. * * \par * Two controls for setting the colors of weekdays and weekends * are located at the bottom row of the grid; weekdays on right, * weekends on left. * * \par * There will be an empty cell in the right column, if number * of days in week is odd. */ BMessage* toSend = NULL; BCheckBox* dayCheckBox = NULL; BString tempString; /* indexX is 0 for left column or 1 for right column. * indexY is 0 for topmost row, 1 for second from top row, etc. * Max value for indexY = (ceiling of (N/2)). */ int indexX, indexY; // Prepare the item to be returned BBox* enclosingBox = new BBox( frame, "Weekend selector" ); if ( !enclosingBox ) { /* Panic! */ exit(1); } // Prepare the layout to be used BGridLayout* layout = new BGridLayout(); if ( !layout) { /* Panic! */ exit(1); } enclosingBox->SetLayout( layout ); // Get the data on days of week unsigned int daysInWeek = (unsigned int)( calModule->GetDaysInWeek() ); map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames(); indexX = indexY = 0; for (unsigned char day = 0; day < daysInWeek; ++day ) { /* Creating the message to be sent */ toSend = new BMessage( kCalendarModuleWeekendDaySelected ); if ( !toSend ) { /* Panic! */ exit(1); } toSend->AddInt32( "Weekday no", day ); /* Obtain the name of the day. I use the long name. */ tempString = (DoubleNames)weekdayNames[ day ].longName; /* Creating the checkbox */ dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1), "Weekday", tempString.String(), toSend ); if (!dayCheckBox) { // Panic! exit(1); } dayCheckBox->ResizeToPreferred(); /* Adding the item to the BBox */ layout->AddView( dayCheckBox, indexX, indexY ); /* Advancing to the next cell in grid */ // If arrived to the last item in the first column, advancing to second if ( day == ( int )( ( daysInWeek + 1 ) / 2 ) ) { indexX = 1; indexY = 0; } else // Staying in the same column, but advancing down { ++indexY; } } // <-- end of "for (all days in week)" BListView* weekdayColorSelector = NULL; }
/*! \brief Add the interface for configuring colors. * \param[in] frame The frame of the view. * \param[in] id The ID of the interface to configure the colors for. */ BBox* CalendarModulePreferencesView::BuildColorSelectors( BRect frame, const BString& id ) { BBox* toReturn = NULL; BLayoutItem* layoutItem = NULL; BString sb; BRect tempRect = frame; // tempRect.InsetBySelf( 10, 10 ); BMessage* toSend = NULL; // Access the preferences CalendarModulePreferences* prefs = pref_GetPreferencesForCalendarModule( id ); if ( !prefs ) { return NULL; } // Prepare the overall BBox toReturn = new BBox( frame, "Color selector" ); if ( ! toReturn ) return NULL; toReturn->SetLabel( "Set up colors" ); // Set up the layout for this BBox BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL ); if ( !groupLayout ) { delete toReturn; return NULL; } groupLayout->SetInsets( 10, 15, 10, 5 ); groupLayout->SetSpacing( 2 ); toReturn->SetLayout( groupLayout ); // Label over the CategoryListView for the viewer BStringView* viewerString = new BStringView( BRect( 0, 0, 1, 1 ), "Colors Changer Explanation", "Double-click the color to edit it." ); if ( !viewerString ) { delete toReturn; return NULL; } viewerString->ResizeToPreferred(); layoutItem = groupLayout->AddView( 0, viewerString, 0 ); layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) ); toSend = new BMessage( kCategoryInvoked ); if ( !toSend ) { /* Panic! */ exit( 1 ); } toSend->AddString( "Calendar module", id ); CategoryListView* menuColors = new CategoryListView( BRect( 0, 0, tempRect.Width() + B_V_SCROLL_BAR_WIDTH, tempRect.Height() + B_H_SCROLL_BAR_HEIGHT ), "Colors list view" ); if ( !menuColors ) { // menuString->RemoveSelf(); delete menuString; // viewerString->RemoveSelf(); delete viewerString; delete toReturn; return NULL; } menuColors->SetInvocationMessage( toSend ); // Fill the CategoryListView for the menu colors sb.SetTo( "Color for displaying weekdays in the controls" ); CategoryListItem* toAdd = new CategoryListItem( prefs->GetWeekdaysColor( false ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying weekends in the controls" ); toAdd = new CategoryListItem( prefs->GetWeekendsColor( false ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying weekdays in Viewer" ); toAdd = new CategoryListItem( prefs->GetWeekdaysColor( true ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying weekends in Viewer" ); toAdd = new CategoryListItem( prefs->GetWeekendsColor( true ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying service items in the controls" ); toAdd = new CategoryListItem( prefs->GetServiceItemsColor( false ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying service items in the Viewer" ); toAdd = new CategoryListItem( prefs->GetServiceItemsColor( true ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } menuColors->ResizeToPreferred(); // BSize setSize( menuColors->Bounds().Width(), menuColors->Bounds().Height() ); BSize setSize( frame.Width(), menuColors->Bounds().Height()+5 ); layoutItem = groupLayout->AddView( 1, menuColors, 0 ); layoutItem->SetExplicitMaxSize( setSize ); layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) ); groupLayout->InvalidateLayout(); return toReturn; } // <-- end of function CalendarModulePreferecesView::BuildColorSelectors
/*! * \brief Create box for selection of the weekend days * \note Additionally, select the color for weekends and weekdays * \param[in] frame Enclosing rectangle. * \param[in] id Reference to name of the selected Calendar module. * \returns Pointer to all-set-up BBox. Or NULL in case of error. */ BBox* CalendarModulePreferencesView::CreateWeekendSelectionBox( BRect frame, const BString &id ) { /*! \par Notes on implementation: * It's not all that straightforward - to create this selection box. * The problem is that number of days in week is dependent on the * Calendar Module, therefore the frame rectangle must be divided * properly. We should take into account the possibility that there's * not enough place for all days in the submitted frame. * * \par * The solution will be as follows: * Let number of days in week be N. I create two columns and * several rows (the number depends on N). Days in week will be * proceeded in the order <em>as Calendar Module supplies them</em>. * The days occupy both columns, and are located in rows * [0, (ceiling of (N/2)) ). Days returned from CalendarModule are * placed as follows: days from 0 to (ceiling of (N/2)-1) in the left * column, days from (ceiling of (N/2)-1) to (N-1) in right column. * * \par * There will be an empty cell in the right column, if number * of days in week is odd, (which is usually the case). */ frame.InsetBySelf( 5, 0 ); BMessage* toSend = NULL; BCheckBox* dayCheckBox = NULL; BString tempString; BLayoutItem* layoutItem = NULL; CalendarModulePreferences* prefs = NULL; CalendarModule* calModule = NULL; int height = 0; //!< this is used to resize the BBox to proper size calModule = utl_FindCalendarModule( id ); if ( calModule == NULL ) { /* Error */ utl_Deb = new DebuggerPrintout( "Did not succeed to find the calendar module." ); return NULL; } // Get the data on days of week uint32 daysInWeek = ( uint32 )( calModule->GetDaysInWeek() ); map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames(); /* Obtain the current Calendar Module preferences */ prefs = pref_GetPreferencesForCalendarModule( id ); if ( !prefs ) { utl_Deb = new DebuggerPrintout( "Did not succeed to find the preferences for the calendar module." ); return NULL; } // At this point, "pref" points to current preferences of this calendar module. BList* weekends = prefs->GetWeekends(); // Get info on currently selected weekends // Prepare the item to be returned BBox* enclosingBox = new BBox( frame, "Weekend selector" ); if ( !enclosingBox ) { /* Panic! */ exit(1); } enclosingBox->SetLabel( "Select the non-working days (weekends)" ); // Prepare the layout to be used BGridLayout* layout = new BGridLayout(); if ( !layout) { /* Panic! */ exit(1); } enclosingBox->SetLayout( layout ); layout->SetInsets( 10, 15, 10, 5 ); layout->SetVerticalSpacing( 1 ); /* indexX is 0 for left column or 1 for right column. * indexY is 0 for topmost row, 1 for second from top row, etc. * Max value for indexY = (ceiling of (N/2)). */ int indexX = 0, indexY = 0; for (uint32 day = prefs->GetFirstDayOfWeek(), i = 0; i < ( uint32 )daysInWeek; ++i ) { /* Creating the message to be sent */ toSend = new BMessage( kCalendarModuleWeekendDaySelected ); if ( !toSend ) { /* Panic! */ exit(1); } toSend->AddInt32( "Weekday const", day ); toSend->AddString( "Calendar module", id ); /* Set the name of the checkbox. * This is used to identify if the checkbox was checked or unchecked. */ tempString.SetTo( "Weekday" ); tempString << day; /* Creating the checkbox */ dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1), tempString.String(), weekdayNames[ day ].longName.String(), toSend ); if (!dayCheckBox) { // Panic! exit(1); } dayCheckBox->ResizeToPreferred(); // Check if the checkbox should be checked if ( weekends->HasItem( ( void* )day ) ) { dayCheckBox->SetValue( 1 ); } else { dayCheckBox->SetValue( 0 ); } /* Adding the item to the BBox */ layoutItem = layout->AddView( dayCheckBox, indexX, indexY ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) ); // layoutItem->SetExplicitMaxSize( BSize( (int )dayCheckBox->Bounds().Width(), (int )dayCheckBox->Bounds().Height() ) ); layout->SetMaxRowHeight( indexY, (int )dayCheckBox->Bounds().Height() + 10 ); layout->SetRowWeight( indexY, 0 ); } /* Advancing to the next cell in grid */ // If arrived to the last item in the first column, advancing to second // The +1 is needed because i starts from 0, but days are starting from 1 if ( ( i + 1 ) == ( unsigned int )( ( daysInWeek + 1 ) / 2 ) ) { indexX = 1; indexY = 0; } else // Staying in the same column, but advancing down { ++indexY; } /* Advancing to the next day */ ( day == daysInWeek ) ? day = kSunday : ++day; } // <-- end of "for (all days in week)" // Resizing the BBox to the correct size. // Note: dayCheckBox is surely not NULL; if it were, we would exit earlier. height =(int )( ( dayCheckBox->Bounds().Height() + 5 ) * ( int )( ( daysInWeek + 1 ) / 2 ) - 5 ); // Formula: ( ^height of one checkbox^ + ^separator^ ) * ( ^number of days in column^ ) - ^one unneeded extra separator^ enclosingBox->ResizeTo( enclosingBox->Bounds().Width() - 10, ( int )height ); // layout->SetExplicitMaxSize( BSize( enclosingBox->Bounds().Width() - 5, ( int )height + 25 ) ); return enclosingBox; }
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(); }