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; }
ScreenshotWindow::ScreenshotWindow(BWindow* parent, BRect frame) : BWindow(frame, B_TRANSLATE("Screenshot"), B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fDownloadPending(false), fWorkerThread(-1) { AddToSubset(parent); fScreenshotView = new BitmapView("screenshot view"); fScreenshotView->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); BGroupView* groupView = new BGroupView(B_VERTICAL); groupView->SetViewColor(0, 0, 0); fScreenshotView->SetLowColor(0, 0, 0); // Build layout BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGroup(groupView) .Add(fScreenshotView) .SetInsets(B_USE_WINDOW_INSETS) .End() ; CenterOnScreen(); }
ScreenshotWindow::ScreenshotWindow(BWindow* parent, BRect frame) : BWindow(frame, B_TRANSLATE("Screenshot"), B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fBarberPoleShown(false), fDownloadPending(false), fWorkerThread(-1) { AddToSubset(parent); atomic_set(&fCurrentScreenshotIndex, 0); fBarberPole = new BarberPole("barber pole"); fBarberPole->SetExplicitMaxSize(BSize(100, B_SIZE_UNLIMITED)); fBarberPole->Hide(); fIndexView = new BStringView("screenshot index", NULL); fToolBar = new BToolBar(); fToolBar->AddAction(MSG_PREVIOUS_SCREENSHOT, this, sNextButtonIcon->Bitmap(SharedBitmap::SIZE_22), NULL, NULL); fToolBar->AddAction(MSG_NEXT_SCREENSHOT, this, sPreviousButtonIcon->Bitmap(SharedBitmap::SIZE_22), NULL, NULL); fToolBar->AddView(fIndexView); fToolBar->AddGlue(); fToolBar->AddView(fBarberPole); fScreenshotView = new BitmapView("screenshot view"); fScreenshotView->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); fScreenshotView->SetScaleBitmap(false); BGroupView* groupView = new BGroupView(B_VERTICAL); groupView->SetViewColor(kBackgroundColor); // Build layout BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(0, 3, 0, 0) .Add(fToolBar) .AddStrut(3) .AddGroup(groupView) .Add(fScreenshotView) .SetInsets(B_USE_WINDOW_INSETS) .End() ; fScreenshotView->SetLowColor(kBackgroundColor); // Set after attaching all views to prevent it from being overriden // again by BitmapView::AllAttached() CenterOnScreen(); }
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); }
// AddGroup BGroupLayoutBuilder& BGroupLayoutBuilder::AddGroup(enum orientation orientation, float spacing, float weight) { if (BGroupLayout* layout = TopLayout()) { BGroupView* group = new(nothrow) BGroupView(orientation, spacing); if (group) { if (layout->AddView(group, weight)) _PushLayout(group->GroupLayout()); else delete group; } } return *this; }
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; }
NetworkView::NetworkView() : BView("NetworkView", 0, NULL) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // build the GUI BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); SetLayout(rootLayout); //BGridView* controlsGroup = new BGridView(); //BGridLayout* layout = controlsGroup->GridLayout(); // insets /* float inset = ceilf(be_plain_font->Size() * 0.7); rootLayout->SetInsets(inset, inset, inset, inset); rootLayout->SetSpacing(inset); layout->SetSpacing(inset, inset); */ // available network lists // button group BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL); fRefreshButton = new BButton(B_TRANSLATE("Refresh"), new BMessage(kMsgRefresh)); fRefreshButton->SetEnabled(false); buttonGroup->GroupLayout()->AddView(fRefreshButton); buttonGroup->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fNewNetworkButton = new BButton(B_TRANSLATE("New Network"), new BMessage(kMsgNewNetwork)); fNewNetworkButton->SetEnabled(false); buttonGroup->GroupLayout()->AddView(fNewNetworkButton); //rootLayout->AddView(controlsGroup); rootLayout->AddView(buttonGroup); }
BrowserWindow::BrowserWindow() : BWindow(BRect(100, 100, 400, 400), "Tranquility", B_DOCUMENT_WINDOW, 0) { fToolbar = new BrowserToolbar(); fProxyView = new ProxyView(Bounds(), "Proxy"); BGroupView *view = new BGroupView(B_VERTICAL, 10); view->SetViewColor(255, 255, 255); // Set the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(view) .Add(fToolbar) .Add(fProxyView) ); ResizeTo(500, 500); AddShortcut('N', B_COMMAND_KEY, new BMessage(kMsgNewTab), this); AddShortcut('W', B_COMMAND_KEY, new BMessage(kMsgCloseTab), this); }
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(); }
TransportControlGroup::TransportControlGroup(BRect frame, bool usePlaybackFrame, bool useSkipButtons, bool usePeakView, bool useWindButtons, bool useSeekSlider) : BGroupView(B_VERTICAL, 0), fSeekSlider(NULL), fPeakView(NULL), fPlaybackFrame(NULL), fVolumeSlider(NULL), fSkipBack(NULL), fSkipForward(NULL), fRewind(NULL), fForward(NULL), fPlayPause(NULL), fStop(NULL), fMute(NULL), fSeekLayout(NULL), fControlLayout(NULL), fSymbolScale(0.0f) { // Seek slider if (useSeekSlider) { BGroupView* seekGroup = new BGroupView(B_HORIZONTAL, 0); fSeekLayout = seekGroup->GroupLayout(); GroupLayout()->AddView(seekGroup); fSeekSlider = new SeekSlider("seek slider", new BMessage(MSG_SEEK), 0, 10000); fSeekLayout->AddView(fSeekSlider); } // Buttons uint32 topBottomBorder = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER; if (useSkipButtons) { // Skip Back fSkipBack = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_SKIP_BACKWARDS), BControlLook::B_LEFT_BORDER | topBottomBorder); // Skip Foward fSkipForward = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_SKIP_FORWARD), BControlLook::B_RIGHT_BORDER | topBottomBorder); } if (useWindButtons) { // Rewind fRewind = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_REWIND), useSkipButtons ? topBottomBorder : BControlLook::B_LEFT_BORDER | topBottomBorder); // Forward fForward = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_FORWARD), useSkipButtons ? topBottomBorder : BControlLook::B_RIGHT_BORDER | topBottomBorder); } // Play Pause fPlayPause = new PlayPauseButton(B_EMPTY_STRING, NULL, NULL, new BMessage(MSG_PLAY), useWindButtons || useSkipButtons ? topBottomBorder : topBottomBorder | BControlLook::B_LEFT_BORDER); // Stop fStop = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_STOP), useWindButtons || useSkipButtons ? topBottomBorder : topBottomBorder | BControlLook::B_RIGHT_BORDER); // Mute fMute = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_SET_MUTE), 0); // Volume Slider fVolumeSlider = new VolumeSlider("volume slider", 0, VIRTUAL_MAX_VOLUME, SNAP_VOLUME, new BMessage(MSG_SET_VOLUME)); fVolumeSlider->SetValue(100); // Peak view if (usePeakView) fPeakView = new PeakView("peak view", false, false); // Playback Frame if (usePlaybackFrame) fPlaybackFrame = new PlaybackFrameView(); // Layout the controls BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL, 0); BGroupLayout* buttonLayout = buttonGroup->GroupLayout(); if (fSkipBack != NULL) buttonLayout->AddView(fSkipBack); if (fRewind != NULL) buttonLayout->AddView(fRewind); buttonLayout->AddView(fPlayPause); buttonLayout->AddView(fStop); if (fForward != NULL) buttonLayout->AddView(fForward); if (fSkipForward != NULL) buttonLayout->AddView(fSkipForward); BGroupView* controlGroup = new BGroupView(B_HORIZONTAL, 0); GroupLayout()->AddView(controlGroup); fControlLayout = controlGroup->GroupLayout(); fControlLayout->AddView(buttonGroup, 0.6f); fControlLayout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(5)); fControlLayout->AddView(fMute); fControlLayout->AddView(fVolumeSlider); if (fPeakView != NULL) fControlLayout->AddView(fPeakView, 0.6f); if (fPlaybackFrame != NULL) { fControlLayout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(5)); fControlLayout->AddView(fPlaybackFrame, 0.0f); } BSize size = fControlLayout->MinSize(); size.width *= 3; size.height = B_SIZE_UNSET; fControlLayout->SetExplicitMaxSize(size); fControlLayout->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP)); SetSymbolScale(1.0f); }
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(); } }
int main(int argc, char** argv) { BApplication app("application/x-vnd.haiku-look"); BWindow* window = new Window(BRect(50, 50, 100, 100), "Look at these pretty controls!", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE); window->SetLayout(new BGroupLayout(B_HORIZONTAL)); // create some controls // BListView BListView* listView = new BListView(); for (int32 i = 0; i < 20; i++) { BString itemLabel("List item "); itemLabel << i + 1; listView->AddItem(new BStringItem(itemLabel.String())); } BScrollView* scrollView = new BScrollView("scroller", listView, 0, true, true); scrollView->SetExplicitMinSize(BSize(300, 140)); // BColumnListView BColumnListView* columnListView = new BColumnListView("clv", 0, B_FANCY_BORDER); // B_PLAIN_BORDER); // B_NO_BORDER); columnListView->AddColumn(new BTitledColumn("Short", 150, 50, 500, B_ALIGN_LEFT), 0); columnListView->AddColumn(new BTitledColumn("Medium Length", 100, 50, 500, B_ALIGN_CENTER), 1); columnListView->AddColumn(new BTitledColumn("Some Long Column Name", 130, 50, 500, B_ALIGN_RIGHT), 2); // for (int32 i = 0; i < 20; i++) { // BString itemLabel("List Item "); // itemLabel << i + 1; // columnListView->AddItem(new BStringItem(itemLabel.String())); // } BGridView* controls = new BGridView(kInset, kInset); BGridLayout* layout = controls->GridLayout(); controls->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); int32 row = 0; add_controls<BButton>(layout, row); add_controls<BCheckBox>(layout, row); add_controls<BRadioButton>(layout, row); add_menu_fields(layout, row); add_text_controls(layout, row); add_sliders(layout, row); add_status_bars(layout, row); BColorControl* colorControl = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0f, "color control"); layout->AddView(colorControl, 0, row, 4); BTabView* tabView = new BTabView("tab view", B_WIDTH_FROM_WIDEST); BGroupView* content = new BGroupView(B_VERTICAL, kInset); BLayoutBuilder::Group<>(content) .Add(scrollView) .Add(columnListView) .Add(controls) .SetInsets(kInset, kInset, kInset, kInset); content->SetName("Tab 1"); tabView->AddTab(content); BView* tab2 = new BView("Tab 2", 0); tab2->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); tabView->AddTab(tab2); tabView->AddTab(new BView("Tab 3", 0)); BMenuBar* menuBar = new BMenuBar("menu bar"); BMenu* menu = new BMenu("File"); menu->AddItem(new BMenuItem("Test Open BFilePanel", new BMessage(MSG_TEST_OPEN_FILE_PANEL))); menu->AddItem(new BMenuItem("Test Save BFilePanel", new BMessage(MSG_TEST_SAVE_FILE_PANEL))); menu->AddItem(new BMenuItem("Click me!", NULL)); menu->AddItem(new BMenuItem("Another option", NULL)); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); menuBar->AddItem(menu); menu = new BMenu("Edit"); menu->SetEnabled(false); menu->AddItem(new BMenuItem("Cut", NULL)); menu->AddItem(new BMenuItem("Copy", NULL)); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Past", NULL)); menuBar->AddItem(menu); menu = new BMenu("One Item"); menu->AddItem(new BMenuItem("Only", NULL)); menuBar->AddItem(menu); menu = new BMenu("Sub Menu"); BMenu* subMenu = new BMenu("Click me"); subMenu->AddItem(new BMenuItem("Either", NULL)); subMenu->AddItem(new BMenuItem("Or", NULL)); subMenu->SetRadioMode(true); menu->AddItem(subMenu); menuBar->AddItem(menu); BButton* okButton = new BButton("OK", new BMessage(B_QUIT_REQUESTED)); BLayoutBuilder::Group<>(window, B_VERTICAL, 0) .Add(menuBar) .AddGroup(B_VERTICAL, kInset) .SetInsets(kInset, kInset, kInset, kInset) .Add(tabView) .AddGroup(B_HORIZONTAL, kInset) .Add(new BButton("Revert", new BMessage(MSG_TOGGLE_LOOK))) .AddGlue() .Add(new BButton("Cancel", NULL)) .Add(okButton); window->SetDefaultButton(okButton); window->Show(); app.Run(); return 0; }
/** * _ConstructGUI() * * Creates the GUI for the View. MUST be called AFTER the View is attached to * the Window, or will crash and/or create strange behaviour * * @param none * @return void */ void MarginView::_ConstructGUI() { fPage = new PageView(); fPage->SetViewColor(ViewColor()); fPageSize = new BStringView("pageSize", "?x?"); BString str; // Create text fields // top str << fMargins.top/fUnitValue; fTop = new BTextControl("top", "Top:", str.String(), NULL); fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED)); fTop->SetTarget(this); _AllowOnlyNumbers(fTop, kNumCount); //left str = ""; str << fMargins.left/fUnitValue; fLeft = new BTextControl("left", "Left:", str.String(), NULL); fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED)); fLeft->SetTarget(this); _AllowOnlyNumbers(fLeft, kNumCount); //bottom str = ""; str << fMargins.bottom/fUnitValue; fBottom = new BTextControl("bottom", "Bottom:", str.String(), NULL); fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED)); fBottom->SetTarget(this); _AllowOnlyNumbers(fBottom, kNumCount); //right str = ""; str << fMargins.right/fUnitValue; fRight = new BTextControl("right", "Right:", str.String(), NULL); fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED)); fRight->SetTarget(this); _AllowOnlyNumbers(fRight, kNumCount); // Create Units popup BPopUpMenu *menu = new BPopUpMenu("units"); BMenuField *units = new BMenuField("units", "Units:", menu); BMenuItem *item; // Construct menu items for (int32 i = 0; kUnitNames[i] != NULL; i++) { BMessage *msg = new BMessage(MARGIN_UNIT_CHANGED); msg->AddInt32("marginUnit", kUnitMsg[i]); menu->AddItem(item = new BMenuItem(kUnitNames[i], msg)); item->SetTarget(this); if (fMarginUnit == kUnitMsg[i]) item->SetMarked(true); } BGridView* settings = new BGridView(); BGridLayout* settingsLayout = settings->GridLayout(); settingsLayout->AddItem(fTop->CreateLabelLayoutItem(), 0, 0); settingsLayout->AddItem(fTop->CreateTextViewLayoutItem(), 1, 0); settingsLayout->AddItem(fLeft->CreateLabelLayoutItem(), 0, 1); settingsLayout->AddItem(fLeft->CreateTextViewLayoutItem(), 1, 1); settingsLayout->AddItem(fBottom->CreateLabelLayoutItem(), 0, 2); settingsLayout->AddItem(fBottom->CreateTextViewLayoutItem(), 1, 2); settingsLayout->AddItem(fRight->CreateLabelLayoutItem(), 0, 3); settingsLayout->AddItem(fRight->CreateTextViewLayoutItem(), 1, 3); settingsLayout->AddItem(units->CreateLabelLayoutItem(), 0, 4); settingsLayout->AddItem(units->CreateMenuBarLayoutItem(), 1, 4); settingsLayout->SetSpacing(0, 0); BGroupView* groupView = new BGroupView(B_HORIZONTAL, 10); BGroupLayout* groupLayout = groupView->GroupLayout(); groupLayout->AddView(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fPage) .Add(fPageSize) .SetInsets(0, 0, 0, 0) .TopView() ); groupLayout->AddView(settings); groupLayout->SetInsets(5, 5, 5, 5); AddChild(groupView); UpdateView(MARGIN_CHANGED); }
void JobSetupView::AttachedToWindow() { // quality BBox* qualityBox = new BBox("quality"); qualityBox->SetLabel("Quality"); // color fColorType = new BPopUpMenu("color"); fColorType->SetRadioMode(true); FillCapabilityMenu(fColorType, kMsgQuality, PrinterCap::kColor, fJobData->GetColor()); BMenuField* colorMenuField = new BMenuField("color", "Color:", fColorType); fColorType->SetTargetForItems(this); if (IsHalftoneConfigurationNeeded()) CreateHalftoneConfigurationUI(); // page range BBox* pageRangeBox = new BBox("pageRange"); pageRangeBox->SetLabel("Page Range"); fAll = new BRadioButton("all", "Print all Pages", new BMessage(kMsgRangeAll)); BRadioButton *range = new BRadioButton("selection", "Print selected Pages:", new BMessage(kMsgRangeSelection)); fFromPage = new BTextControl("from", "From:", "", NULL); fFromPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); AllowOnlyDigits(fFromPage->TextView(), 6); fToPage = new BTextControl("to", "To:", "", NULL); fToPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); AllowOnlyDigits(fToPage->TextView(), 6); int first_page = fJobData->GetFirstPage(); int last_page = fJobData->GetLastPage(); if (first_page <= 1 && last_page <= 0) { fAll->SetValue(B_CONTROL_ON); } else { range->SetValue(B_CONTROL_ON); if (first_page < 1) first_page = 1; if (first_page > last_page) last_page = -1; BString oss1; oss1 << first_page; fFromPage->SetText(oss1.String()); BString oss2; oss2 << last_page; fToPage->SetText(oss2.String()); } fAll->SetTarget(this); range->SetTarget(this); // paper source fPaperFeed = new BPopUpMenu(""); fPaperFeed->SetRadioMode(true); FillCapabilityMenu(fPaperFeed, kMsgNone, PrinterCap::kPaperSource, fJobData->GetPaperSource()); BMenuField* paperSourceMenufield = new BMenuField("paperSource", "Paper Source:", fPaperFeed); // Pages per sheet fNup = new BPopUpMenu(""); fNup->SetRadioMode(true); FillCapabilityMenu(fNup, kMsgNone, gNups, sizeof(gNups) / sizeof(gNups[0]), (int)fJobData->GetNup()); BMenuField* pagesPerSheet = new BMenuField("pagesPerSheet", "Pages Per Sheet:", fNup); // duplex if (fPrinterCap->Supports(PrinterCap::kPrintStyle)) { fDuplex = new BCheckBox("duplex", "Duplex", new BMessage(kMsgDuplexChanged)); if (fJobData->GetPrintStyle() != JobData::kSimplex) { fDuplex->SetValue(B_CONTROL_ON); } fDuplex->SetTarget(this); } else { fDuplex = NULL; } // copies fCopies = new BTextControl("copies", "Number of Copies:", "", NULL); AllowOnlyDigits(fCopies->TextView(), 3); BString copies; copies << fJobData->GetCopies(); fCopies->SetText(copies.String()); // collate fCollate = new BCheckBox("collate", "Collate", new BMessage(kMsgCollateChanged)); if (fJobData->GetCollate()) { fCollate->SetValue(B_CONTROL_ON); } fCollate->SetTarget(this); // reverse fReverse = new BCheckBox("reverse", "Reverse Order", new BMessage(kMsgReverseChanged)); if (fJobData->GetReverse()) { fReverse->SetValue(B_CONTROL_ON); } fReverse->SetTarget(this); // pages view // TODO make layout API compatible fPages = new PagesView(BRect(0, 0, 150, 40), "pages", B_FOLLOW_ALL, B_WILL_DRAW); fPages->SetCollate(fJobData->GetCollate()); fPages->SetReverse(fJobData->GetReverse()); fPages->SetExplicitMinSize(BSize(150, 40)); fPages->SetExplicitMaxSize(BSize(150, 40)); // page selection BBox* pageSelectionBox = new BBox("pageSelection"); pageSelectionBox->SetLabel("Page Selection"); fAllPages = CreatePageSelectionItem("allPages", "All Pages", JobData::kAllPages); fOddNumberedPages = CreatePageSelectionItem("oddPages", "Odd-Numbered Pages", JobData::kOddNumberedPages); fEvenNumberedPages = CreatePageSelectionItem("evenPages", "Even-Numbered Pages", JobData::kEvenNumberedPages); fPreview = new BCheckBox("preview", "Show preview before printing", NULL); if (fJobData->GetShowPreview()) fPreview->SetValue(B_CONTROL_ON); // separator line BBox *separator = new BBox("separator"); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); // buttons BButton* cancel = new BButton("cancel", "Cancel", new BMessage(kMsgCancel)); BButton* ok = new BButton("ok", "OK", new BMessage(kMsgOK)); ok->MakeDefault(true); if (IsHalftoneConfigurationNeeded()) { BGroupView* halftoneGroup = new BGroupView(B_VERTICAL, 0); BGroupLayout* halftoneLayout = halftoneGroup->GroupLayout(); halftoneLayout->AddView(fHalftone); fHalftoneBox->AddChild(halftoneGroup); } BGridView* qualityGrid = new BGridView(); BGridLayout* qualityGridLayout = qualityGrid->GridLayout(); qualityGridLayout->AddItem(colorMenuField->CreateLabelLayoutItem(), 0, 0); qualityGridLayout->AddItem(colorMenuField->CreateMenuBarLayoutItem(), 1, 0); if (IsHalftoneConfigurationNeeded()) { qualityGridLayout->AddItem(fDitherMenuField->CreateLabelLayoutItem(), 0, 1); qualityGridLayout->AddItem(fDitherMenuField->CreateMenuBarLayoutItem(), 1, 1); qualityGridLayout->AddView(fGamma, 0, 2, 2); qualityGridLayout->AddView(fInkDensity, 0, 3, 2); qualityGridLayout->AddView(fHalftoneBox, 0, 4, 2); } else { AddDriverSpecificSettings(qualityGridLayout, 1); } qualityGridLayout->SetSpacing(0, 0); qualityGridLayout->SetInsets(5, 5, 5, 5); qualityBox->AddChild(qualityGrid); // TODO put qualityGrid in a scroll view // the layout of the box surrounding the scroll view using the following // code is not correct; the box still has the size of the qualityGird; // and the scroll view is vertically centered inside the box! //BScrollView* qualityScroller = new BScrollView("qualityScroller", // qualityGrid, 0, false, true); //qualityScroller->SetExplicitMaxSize(BSize(500, 500)); //qualityBox->AddChild(qualityScroller); BGridView* pageRangeGrid = new BGridView(); BGridLayout* pageRangeLayout = pageRangeGrid->GridLayout(); pageRangeLayout->AddItem(fFromPage->CreateLabelLayoutItem(), 0, 0); pageRangeLayout->AddItem(fFromPage->CreateTextViewLayoutItem(), 1, 0); pageRangeLayout->AddItem(fToPage->CreateLabelLayoutItem(), 0, 1); pageRangeLayout->AddItem(fToPage->CreateTextViewLayoutItem(), 1, 1); pageRangeLayout->SetInsets(0, 0, 0, 0); pageRangeLayout->SetSpacing(0, 0); BGroupView* pageRangeGroup = new BGroupView(B_VERTICAL, 0); BGroupLayout* pageRangeGroupLayout = pageRangeGroup->GroupLayout(); pageRangeGroupLayout->AddView(fAll); pageRangeGroupLayout->AddView(range); pageRangeGroupLayout->AddView(pageRangeGrid); pageRangeGroupLayout->SetInsets(5, 5, 5, 5); pageRangeBox->AddChild(pageRangeGroup); BGridView* settings = new BGridView(); BGridLayout* settingsLayout = settings->GridLayout(); settingsLayout->AddItem(paperSourceMenufield->CreateLabelLayoutItem(), 0, 0); settingsLayout->AddItem(paperSourceMenufield->CreateMenuBarLayoutItem(), 1, 0); settingsLayout->AddItem(pagesPerSheet->CreateLabelLayoutItem(), 0, 1); settingsLayout->AddItem(pagesPerSheet->CreateMenuBarLayoutItem(), 1, 1); int row = 2; if (fDuplex != NULL) { settingsLayout->AddView(fDuplex, 0, row, 2); row ++; } settingsLayout->AddItem(fCopies->CreateLabelLayoutItem(), 0, row); settingsLayout->AddItem(fCopies->CreateTextViewLayoutItem(), 1, row); settingsLayout->SetSpacing(0, 0); BGroupView* pageSelectionGroup = new BGroupView(B_VERTICAL, 0); BGroupLayout* groupLayout = pageSelectionGroup->GroupLayout(); groupLayout->AddView(fAllPages); groupLayout->AddView(fOddNumberedPages); groupLayout->AddView(fEvenNumberedPages); groupLayout->SetInsets(5, 5, 5, 5); pageSelectionBox->AddChild(pageSelectionGroup); SetLayout(new BGroupLayout(B_VERTICAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) .AddGroup(B_HORIZONTAL, 10, 1.0f) .AddGroup(B_VERTICAL, 10, 1.0f) .Add(qualityBox) .Add(pageRangeBox) .AddGlue() .End() .AddGroup(B_VERTICAL, 0, 1.0f) .Add(settings) .AddStrut(5) .Add(fCollate) .Add(fReverse) .Add(fPages) .AddStrut(5) .Add(pageSelectionBox) .AddGlue() .End() .End() .Add(fPreview) .AddGlue() .Add(separator) .AddGroup(B_HORIZONTAL, 10, 1.0f) .AddGlue() .Add(cancel) .Add(ok) .End() .SetInsets(0, 0, 0, 0) ); UpdateHalftonePreview(); UpdateButtonEnabledState(); }
BSCWindow::BSCWindow() : BDirectWindow(kWindowRect, "BeScreenCapture", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS|B_AUTO_UPDATE_SIZE_LIMITS), fController(dynamic_cast<Controller*>(gControllerLooper)), fCapturing(false) { OutputView *outputView = new OutputView(fController); AdvancedOptionsView *advancedView = new AdvancedOptionsView(fController); fStartStopButton = new BButton("Start", "Start Recording", new BMessage(kMsgGUIStartCapture)); fStartStopButton->SetTarget(fController); fStartStopButton->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE)); fCardLayout = new BCardLayout(); BView* cardsView = new BView("status", 0, fCardLayout); cardsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fCardLayout->AddView(fCamStatus = new CamStatusView("CamStatusView")); fCamStatus->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); BView* statusView = BLayoutBuilder::Group<>() .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(fStringView = new BStringView("stringview", kEncodingString)) .Add(fStatusBar = new BStatusBar("", "")) .End() .View(); statusView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); fStatusBar->SetExplicitMinSize(BSize(100, 20)); fCardLayout->AddView(statusView); BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGroup(B_VERTICAL, 1) .SetInsets(B_USE_DEFAULT_SPACING, 1, B_USE_DEFAULT_SPACING, 1) .Add(fTabView = new BTabView("Tab View", B_WIDTH_FROM_LABEL)) .AddGroup(B_HORIZONTAL) .Add(cardsView) .Add(fStartStopButton) .End() .End(); fCardLayout->SetVisibleItem((int32)0); BGroupView* outputGroup = new BGroupView(B_HORIZONTAL); outputGroup->SetName("Output"); outputGroup->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); fTabView->AddTab(outputGroup); BLayoutBuilder::Group<>(outputGroup) .Add(outputView); BGroupView* advancedGroup = new BGroupView(B_HORIZONTAL); advancedGroup->SetName("Advanced Options"); advancedGroup->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); fTabView->AddTab(advancedGroup); BLayoutBuilder::Group<>(advancedGroup) .Add(advancedView); if (fController->LockLooper()) { // controller should watch for these messages //StartWatching(fController, kMsgGUIStartCapture); //StartWatching(fController, kMsgGUIStopCapture); StartWatching(fController, kSelectionWindowClosed); advancedView->StartWatching(fController, kClipSizeChanged); //StartWatching(fCamStatus, kMsgControllerCaptureResumed); // watch Controller for these fController->StartWatching(this, B_UPDATE_STATUS_BAR); fController->StartWatching(this, B_RESET_STATUS_BAR); fController->StartWatching(this, kMsgControllerEncodeStarted); fController->StartWatching(this, kMsgControllerEncodeProgress); fController->StartWatching(this, kMsgControllerEncodeFinished); fController->StartWatching(this, kMsgControllerTargetFrameChanged); fController->StartWatching(this, kMsgControllerCaptureStarted); fController->StartWatching(this, kMsgControllerCaptureStopped); fController->StartWatching(fCamStatus, kMsgControllerCaptureStarted); fController->StartWatching(fCamStatus, kMsgControllerCaptureStopped); fController->StartWatching(fCamStatus, kMsgControllerCapturePaused); fController->StartWatching(fCamStatus, kMsgControllerCaptureResumed); fController->StartWatching(outputView, kMsgControllerTargetFrameChanged); fController->StartWatching(outputView, kMsgControllerCodecListUpdated); fController->UnlockLooper(); } StartWatching(outputView, kSelectionWindowClosed); StartWatching(outputView, kClipSizeChanged); CenterOnScreen(); }
KeyRequestView() : BView("KeyRequestView", B_WILL_DRAW), fPassword(NULL) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BGroupLayout* rootLayout = new(std::nothrow) BGroupLayout(B_VERTICAL); if (rootLayout == NULL) return; SetLayout(rootLayout); BGridView* controls = new(std::nothrow) BGridView(); if (controls == NULL) return; BGridLayout* layout = controls->GridLayout(); float inset = ceilf(be_plain_font->Size() * 0.7); rootLayout->SetInsets(inset, inset, inset, inset); rootLayout->SetSpacing(inset); layout->SetSpacing(inset, inset); BStringView* label = new(std::nothrow) BStringView("keyringLabel", B_TRANSLATE("Keyring:")); if (label == NULL) return; int32 row = 0; layout->AddView(label, 0, row); fKeyringName = new(std::nothrow) BStringView("keyringName", ""); if (fKeyringName == NULL) return; layout->AddView(fKeyringName, 1, row++); fPassword = new(std::nothrow) BTextControl(B_TRANSLATE("Password:"******"", NULL); if (fPassword == NULL) return; BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem(); layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth( "0123456789012345678901234567890123456789") + inset, B_SIZE_UNSET)); layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row); layout->AddItem(layoutItem, 1, row++); BGroupView* buttons = new(std::nothrow) BGroupView(B_HORIZONTAL); if (buttons == NULL) return; fCancelButton = new(std::nothrow) BButton(B_TRANSLATE("Cancel"), new BMessage(kMessageCancel)); buttons->GroupLayout()->AddView(fCancelButton); buttons->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fUnlockButton = new(std::nothrow) BButton(B_TRANSLATE("Unlock"), new BMessage(kMessageUnlock)); buttons->GroupLayout()->AddView(fUnlockButton); BTextView* message = new(std::nothrow) BTextView("message"); message->SetText(B_TRANSLATE("An application wants to access the " "keyring below, but it is locked with a passphrase. Please enter " "the passphrase to unlock the keyring.\n" "If you unlock the keyring, it stays unlocked until the system is " "shut down or the keyring is manually locked again.\n" "If you cancel this dialog the keyring will remain locked.")); message->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); message->MakeEditable(false); message->MakeSelectable(false); message->SetWordWrap(true); rootLayout->AddView(message); rootLayout->AddView(controls); rootLayout->AddView(buttons); }
void TeamWindow::_Init() { BScrollView* sourceScrollView; const float splitSpacing = 3.0f; BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) .Add(fMenuBar = new BMenuBar("Menu")) .AddSplit(B_VERTICAL, splitSpacing) .GetSplitView(&fFunctionSplitView) .SetInsets(B_USE_SMALL_INSETS) .Add(fTabView = new BTabView("tab view"), 0.4f) .AddSplit(B_HORIZONTAL, splitSpacing) .GetSplitView(&fSourceSplitView) .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(fRunButton = new BButton("Run")) .Add(fStepOverButton = new BButton("Step over")) .Add(fStepIntoButton = new BButton("Step into")) .Add(fStepOutButton = new BButton("Step out")) .AddGlue() .End() .Add(fSourcePathView = new BStringView( "source path", "Source path unavailable."), 4.0f) .Add(sourceScrollView = new BScrollView("source scroll", NULL, 0, true, true), splitSpacing) .End() .Add(fLocalsTabView = new BTabView("locals view")) .End() .AddSplit(B_VERTICAL, splitSpacing) .GetSplitView(&fConsoleSplitView) .SetInsets(0.0) .Add(fConsoleOutputView = ConsoleOutputView::Create()) .End() .End(); // add source view sourceScrollView->SetTarget(fSourceView = SourceView::Create(fTeam, this)); // add threads tab BSplitView* threadGroup = new BSplitView(B_HORIZONTAL, splitSpacing); threadGroup->SetName("Threads"); fTabView->AddTab(threadGroup); BLayoutBuilder::Split<>(threadGroup) .GetSplitView(&fThreadSplitView) .Add(fThreadListView = ThreadListView::Create(fTeam, this)) .Add(fStackTraceView = StackTraceView::Create(this)); // add images tab BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL, splitSpacing); imagesGroup->SetName("Images"); fTabView->AddTab(imagesGroup); BLayoutBuilder::Split<>(imagesGroup) .GetSplitView(&fImageSplitView) .Add(fImageListView = ImageListView::Create(fTeam, this)) .Add(fImageFunctionsView = ImageFunctionsView::Create(this)); // add breakpoints tab BGroupView* breakpointsGroup = new BGroupView(B_HORIZONTAL, B_USE_SMALL_SPACING); breakpointsGroup->SetName("Breakpoints"); fTabView->AddTab(breakpointsGroup); BLayoutBuilder::Group<>(breakpointsGroup) // .SetInsets(0.0f) .Add(fBreakpointsView = BreakpointsView::Create(fTeam, this)); // add local variables tab BView* tab = fVariablesView = VariablesView::Create(this); fLocalsTabView->AddTab(tab); // add registers tab tab = fRegistersView = RegistersView::Create(fTeam->GetArchitecture()); fLocalsTabView->AddTab(tab); fRunButton->SetMessage(new BMessage(MSG_THREAD_RUN)); fStepOverButton->SetMessage(new BMessage(MSG_THREAD_STEP_OVER)); fStepIntoButton->SetMessage(new BMessage(MSG_THREAD_STEP_INTO)); fStepOutButton->SetMessage(new BMessage(MSG_THREAD_STEP_OUT)); fRunButton->SetTarget(this); fStepOverButton->SetTarget(this); fStepIntoButton->SetTarget(this); fStepOutButton->SetTarget(this); fSourcePathView->SetExplicitMinSize(BSize(100.0, B_SIZE_UNSET)); fSourcePathView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BMessageFilter* filter = new(std::nothrow) PathViewMessageFilter( BMessenger(this)); if (filter != NULL) fSourcePathView->AddFilter(filter); // add menus and menu items BMenu* menu = new BMenu("Team"); fMenuBar->AddItem(menu); BMenuItem* item = new BMenuItem("Restart", new BMessage( MSG_TEAM_RESTART_REQUESTED), 'R', B_SHIFT_KEY); menu->AddItem(item); item->SetTarget(this); item = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W'); menu->AddItem(item); item->SetTarget(this); menu = new BMenu("Edit"); fMenuBar->AddItem(menu); item = new BMenuItem("Copy", new BMessage(B_COPY), 'C'); menu->AddItem(item); item->SetTarget(this); item = new BMenuItem("Select all", new BMessage(B_SELECT_ALL), 'A'); menu->AddItem(item); item->SetTarget(this); menu = new BMenu("Tools"); fMenuBar->AddItem(menu); item = new BMenuItem("Save debug report", new BMessage(MSG_CHOOSE_DEBUG_REPORT_LOCATION)); menu->AddItem(item); item->SetTarget(this); item = new BMenuItem("Inspect memory", new BMessage(MSG_SHOW_INSPECTOR_WINDOW), 'I'); menu->AddItem(item); item->SetTarget(this); AutoLocker< ::Team> locker(fTeam); _UpdateRunButtons(); }
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); }
BSCWindow::BSCWindow() : BDirectWindow(kWindowRect, "BeScreenCapture", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS|B_AUTO_UPDATE_SIZE_LIMITS), fController(dynamic_cast<Controller*>(gControllerLooper)), fCapturing(false) { OutputView *outputView = new OutputView(fController); PostProcessingView *ppView = new PostProcessingView("Post Processing"); AdvancedOptionsView *advancedView = new AdvancedOptionsView(fController); fStartStopButton = new BButton("Start", "Start Recording", new BMessage(kMsgGUIToggleCapture)); const char *kString = "Encoding movie..."; BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .Add(fTabView = new BTabView("Tab View", B_WIDTH_FROM_LABEL)) .AddGroup(B_HORIZONTAL) .Add(fCamStatus = new CamStatusView("CamStatusView")) .Add(fStringView = new BStringView("stringview", kString)) .Add(fStatusBar = new BStatusBar("", "")) .AddGlue(1) .Add(fStartStopButton) .End() .End(); BGroupView* outputGroup = new BGroupView(B_HORIZONTAL); outputGroup->SetName("Output"); outputGroup->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); fTabView->AddTab(outputGroup); BLayoutBuilder::Group<>(outputGroup) .Add(outputView); BGroupView* postGroup = new BGroupView(B_HORIZONTAL); postGroup->SetName("Post Processing"); postGroup->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); fTabView->AddTab(postGroup); BLayoutBuilder::Group<>(postGroup) .Add(ppView); BGroupView* advancedGroup = new BGroupView(B_HORIZONTAL); advancedGroup->SetName("Advanced Options"); advancedGroup->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); fTabView->AddTab(advancedGroup); BLayoutBuilder::Group<>(advancedGroup) .Add(advancedView); fStatusBar->Hide(); fStringView->Hide(); if (fController->LockLooper()) { // controller should watch for capture messages StartWatching(fController, kMsgGUIToggleCapture); StartWatching(fCamStatus, kAreaSelected); //StartWatching(fCamStatus, kMsgControllerCaptureResumed); // watch Controller for these fController->StartWatching(this, B_UPDATE_STATUS_BAR); fController->StartWatching(this, B_RESET_STATUS_BAR); fController->StartWatching(this, kMsgControllerEncodeStarted); fController->StartWatching(this, kMsgControllerEncodeProgress); fController->StartWatching(this, kMsgControllerEncodeFinished); fController->UnlockLooper(); } StartWatching(fCamStatus, kMsgGUIToggleCapture); CenterOnScreen(); }
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); }
EthernetSettingsView::EthernetSettingsView() : BView("EthernetSettingsView", 0, NULL), fCurrentSettings(NULL) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fSocket = socket(AF_INET, SOCK_DGRAM, 0); _GatherInterfaces(); // build the GUI BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); SetLayout(rootLayout); BGridView* controlsGroup = new BGridView(); BGridLayout* layout = controlsGroup->GridLayout(); // insets float inset = ceilf(be_plain_font->Size() * 0.7); rootLayout->SetInsets(inset, inset, inset, inset); rootLayout->SetSpacing(inset); layout->SetSpacing(inset, inset); BPopUpMenu* deviceMenu = new BPopUpMenu(B_TRANSLATE("<no adapter>")); for (int32 i = 0; i < fInterfaces.CountItems(); i++) { BString& name = *fInterfaces.ItemAt(i); BString label = name; BMessage* info = new BMessage(kMsgInfo); info->AddString("interface", name.String()); BMenuItem* item = new BMenuItem(label.String(), info); deviceMenu->AddItem(item); } BPopUpMenu* modeMenu = new BPopUpMenu("modes"); modeMenu->AddItem(new BMenuItem(B_TRANSLATE("Static"), new BMessage(kMsgStaticMode))); modeMenu->AddItem(new BMenuItem(B_TRANSLATE("DHCP"), new BMessage(kMsgDHCPMode))); modeMenu->AddSeparatorItem(); modeMenu->AddItem(new BMenuItem(B_TRANSLATE("Disabled"), new BMessage(kMsgDisabledMode))); BPopUpMenu* networkMenu = new BPopUpMenu("networks"); fDeviceMenuField = new BMenuField(B_TRANSLATE("Adapter:"), deviceMenu); layout->AddItem(fDeviceMenuField->CreateLabelLayoutItem(), 0, 0); layout->AddItem(fDeviceMenuField->CreateMenuBarLayoutItem(), 1, 0); fNetworkMenuField = new BMenuField(B_TRANSLATE("Network:"), networkMenu); layout->AddItem(fNetworkMenuField->CreateLabelLayoutItem(), 0, 1); layout->AddItem(fNetworkMenuField->CreateMenuBarLayoutItem(), 1, 1); fTypeMenuField = new BMenuField(B_TRANSLATE("Mode:"), modeMenu); layout->AddItem(fTypeMenuField->CreateLabelLayoutItem(), 0, 2); layout->AddItem(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 2); fIPTextControl = new BTextControl(B_TRANSLATE("IP address:"), "", NULL); SetupTextControl(fIPTextControl); BLayoutItem* layoutItem = fIPTextControl->CreateTextViewLayoutItem(); layoutItem->SetExplicitMinSize(BSize( fIPTextControl->StringWidth("XXX.XXX.XXX.XXX") + inset, B_SIZE_UNSET)); layout->AddItem(fIPTextControl->CreateLabelLayoutItem(), 0, 3); layout->AddItem(layoutItem, 1, 3); fNetMaskTextControl = new BTextControl(B_TRANSLATE("Netmask:"), "", NULL); SetupTextControl(fNetMaskTextControl); layout->AddItem(fNetMaskTextControl->CreateLabelLayoutItem(), 0, 4); layout->AddItem(fNetMaskTextControl->CreateTextViewLayoutItem(), 1, 4); fGatewayTextControl = new BTextControl(B_TRANSLATE("Gateway:"), "", NULL); SetupTextControl(fGatewayTextControl); layout->AddItem(fGatewayTextControl->CreateLabelLayoutItem(), 0, 5); layout->AddItem(fGatewayTextControl->CreateTextViewLayoutItem(), 1, 5); // TODO: Replace the DNS text controls by a BListView with add/remove // functionality and so on... fPrimaryDNSTextControl = new BTextControl(B_TRANSLATE("DNS #1:"), "", NULL); SetupTextControl(fPrimaryDNSTextControl); layout->AddItem(fPrimaryDNSTextControl->CreateLabelLayoutItem(), 0, 6); layout->AddItem(fPrimaryDNSTextControl->CreateTextViewLayoutItem(), 1, 6); fSecondaryDNSTextControl = new BTextControl(B_TRANSLATE("DNS #2:"), "", NULL); SetupTextControl(fSecondaryDNSTextControl); layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 7); layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 1, 7); fDomainTextControl = new BTextControl(B_TRANSLATE("Domain:"), "", NULL); SetupTextControl(fDomainTextControl); layout->AddItem(fDomainTextControl->CreateLabelLayoutItem(), 0, 8); layout->AddItem(fDomainTextControl->CreateTextViewLayoutItem(), 1, 8); fErrorMessage = new BStringView("error", ""); fErrorMessage->SetAlignment(B_ALIGN_LEFT); fErrorMessage->SetFont(be_bold_font); fErrorMessage->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); layout->AddView(fErrorMessage, 1, 9); // button group (TODO: move to window, but take care of // enabling/disabling) BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL); fRevertButton = new BButton(B_TRANSLATE("Revert"), new BMessage(kMsgRevert)); fRevertButton->SetEnabled(false); buttonGroup->GroupLayout()->AddView(fRevertButton); buttonGroup->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(kMsgApply)); fApplyButton->SetEnabled(false); buttonGroup->GroupLayout()->AddView(fApplyButton); rootLayout->AddView(controlsGroup); rootLayout->AddView(buttonGroup); }
MainWindow::MainWindow(const BMessage& settings) : BWindow(BRect(50, 50, 650, 550), B_TRANSLATE_SYSTEM_NAME("HaikuDepot"), B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fScreenshotWindow(NULL), fUserMenu(NULL), fLogInItem(NULL), fLogOutItem(NULL), fModelListener(new MessageModelListener(BMessenger(this)), true), fTerminating(false), fSinglePackageMode(false), fModelWorker(B_BAD_THREAD_ID) { BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu")); _BuildMenu(menuBar); BMenuBar* userMenuBar = new BMenuBar(B_TRANSLATE("User Menu")); _BuildUserMenu(userMenuBar); set_small_font(userMenuBar); userMenuBar->SetExplicitMaxSize(BSize(B_SIZE_UNSET, menuBar->MaxSize().height)); fFilterView = new FilterView(); fFeaturedPackagesView = new FeaturedPackagesView(); fPackageListView = new PackageListView(fModel.Lock()); fPackageInfoView = new PackageInfoView(fModel.Lock(), this); fSplitView = new BSplitView(B_VERTICAL, 5.0f); BGroupView* featuredPackagesGroup = new BGroupView(B_VERTICAL); BStringView* featuredPackagesTitle = new BStringView( "featured packages title", B_TRANSLATE("Featured packages")); BFont font(be_bold_font); font.SetSize(font.Size() * 1.3f); featuredPackagesTitle->SetFont(&font); featuredPackagesGroup->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BLayoutBuilder::Group<>(featuredPackagesGroup) .Add(featuredPackagesTitle) .Add(fFeaturedPackagesView) ; BView* listArea = new BView("list area", 0); fListLayout = new BCardLayout(); listArea->SetLayout(fListLayout); listArea->AddChild(featuredPackagesGroup); listArea->AddChild(fPackageListView); BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) .AddGroup(B_HORIZONTAL, 0.0f) .Add(menuBar, 1.0f) .Add(userMenuBar, 0.0f) .End() .Add(fFilterView) .AddSplit(fSplitView) .AddGroup(B_VERTICAL) .Add(listArea) .SetInsets( B_USE_DEFAULT_SPACING, 0.0f, B_USE_DEFAULT_SPACING, 0.0f) .End() .Add(fPackageInfoView) .End() ; fSplitView->SetCollapsible(0, false); fSplitView->SetCollapsible(1, false); fModel.AddListener(fModelListener); // Restore settings BMessage columnSettings; if (settings.FindMessage("column settings", &columnSettings) == B_OK) fPackageListView->LoadState(&columnSettings); bool showOption; if (settings.FindBool("show featured packages", &showOption) == B_OK) fModel.SetShowFeaturedPackages(showOption); if (settings.FindBool("show available packages", &showOption) == B_OK) fModel.SetShowAvailablePackages(showOption); if (settings.FindBool("show installed packages", &showOption) == B_OK) fModel.SetShowInstalledPackages(showOption); if (settings.FindBool("show develop packages", &showOption) == B_OK) fModel.SetShowDevelopPackages(showOption); if (settings.FindBool("show source packages", &showOption) == B_OK) fModel.SetShowSourcePackages(showOption); if (fModel.ShowFeaturedPackages()) fListLayout->SetVisibleItem((int32)0); else fListLayout->SetVisibleItem(1); _RestoreUserName(settings); _RestoreWindowFrame(settings); // start worker threads BPackageRoster().StartWatching(this, B_WATCH_PACKAGE_INSTALLATION_LOCATIONS); _StartRefreshWorker(); _InitWorkerThreads(); }
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)); }
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); }
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("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(); }