ArpAboutWindow::ArpAboutWindow(BWindow* inwin, const char* appname, const char* verstr, const char* build, const char* text) : BWindow(inwin ? inwin->Frame() : BScreen().Frame(), appname, B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, //inwin ? B_FLOATING_SUBSET_WINDOW_FEEL : B_FLOATING_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS ) { if( inwin ) AddToSubset(inwin); ArpAboutView *aView; // set up a rectangle and instantiate a new view BRect aRect( Bounds() ); aView = new ArpAboutView(aRect, "AnimView", text, appname, verstr, text); // add view to window AddChild(aView); BRect frm = Frame(); float w=0, h=0; aView->GetPreferredSize(&w, &h); ResizeTo(w, h); BRect cfrm = Frame(); ArpD(cdb << ADH << "Resized frame = " << cfrm << endl); MoveTo( frm.left + (frm.Width()-cfrm.Width())/2, frm.top + (frm.Height()-cfrm.Height())/2); ArpD(cdb << ADH << "Moved frame = " << Frame() << endl); }
HDialog::HDialog(BRect frame, const char *name, window_type type, int flags, BWindow *owner, BPositionIO* data) : BWindow(frame, name, type, flags) , fOwner(owner) , fPlacement(H_PLACE_LAST_POS) { frame.OffsetTo(0, 0); AddChild(fMainView = new HDlogView(frame, "main")); if (data) _BuildIt(*data); AddCommonFilter(new BMessageFilter(B_KEY_DOWN,KeyDownFilter)); if (fOwner) { BMessage m(msg_AddDialog); m.AddPointer("dialog", this); fOwner->PostMessage(&m); // [zooey]: let dialog float above owner: SetFeel(B_FLOATING_SUBSET_WINDOW_FEEL); AddToSubset(fOwner); } } /* HDialog::HDialog */
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(); }
NamePanel::NamePanel(const char* label, const char* text, BWindow* window, BHandler* target, BMessage* message, const BSize& size) : Panel(BRect(B_ORIGIN, size), B_TRANSLATE("Name Panel"), B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS), fWindow(window), fTarget(target), fMessage(message) { BButton* defaultButton = new BButton(B_TRANSLATE("OK"), new BMessage(MSG_PANEL_OK)); BButton* cancelButton = new BButton(B_TRANSLATE("Cancel"), new BMessage(MSG_PANEL_CANCEL)); fNameTC = new BTextControl(label, text, NULL); BLayoutItem* inputItem = fNameTC->CreateTextViewLayoutItem(); inputItem->SetExplicitMinSize( BSize(fNameTC->StringWidth("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), B_SIZE_UNSET)); BLayoutBuilder::Group<>(this, B_VERTICAL, 10) .AddGlue() // controls .AddGroup(B_HORIZONTAL, 5) .AddStrut(5) // text control .Add(fNameTC->CreateLabelLayoutItem()) .Add(inputItem) .AddStrut(5) .End() .AddGlue() // buttons .AddGroup(B_HORIZONTAL, 5) .AddGlue() .Add(cancelButton) .Add(defaultButton) .AddStrut(5) .End() .AddGlue(); SetDefaultButton(defaultButton); fNameTC->MakeFocus(true); if (fWindow && fWindow->Lock()) { fSavedTargetWindowFeel = fWindow->Feel(); if (fSavedTargetWindowFeel != B_NORMAL_WINDOW_FEEL) fWindow->SetFeel(B_NORMAL_WINDOW_FEEL); fWindow->Unlock(); } AddToSubset(fWindow); }
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(); }
ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color, SelectedColorMode mode, BWindow* window, BMessage* message, BHandler* target) : Panel(frame, "Pick a color", B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE | B_AUTO_UPDATE_SIZE_LIMITS), fWindow(window), fMessage(message), fTarget(target) { SetTitle(B_TRANSLATE("Pick a color")); fColorPickerView = new ColorPickerView("color picker", color, mode); SetLayout(new BGroupLayout(B_VERTICAL)); BButton* defaultButton = new BButton("ok button", B_TRANSLATE("OK"), new BMessage(MSG_DONE)); BButton* cancelButton = new BButton("cancel button", B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL)); BView* topView = new BGroupView(B_VERTICAL); const float inset = be_control_look->DefaultLabelSpacing(); BLayoutBuilder::Group<>(topView, B_VERTICAL, 0.0f) .Add(fColorPickerView) .Add(new BSeparatorView(B_HORIZONTAL)) .AddGroup(B_HORIZONTAL) .AddGlue() .Add(cancelButton) .Add(defaultButton) .SetInsets(inset, inset, inset, inset) .End() ; SetDefaultButton(defaultButton); if (fWindow != NULL) AddToSubset(fWindow); else SetFeel(B_FLOATING_APP_WINDOW_FEEL); AddChild(topView); }
PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions* options, BWindow* listener) : BWindow(BRect(at.x, at.y, at.x + 300, at.y + 200), B_TRANSLATE("Print options"), B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS), fPrintOptions(options), fCurrentOptions(*options), fListener(listener), fStatus(B_ERROR) { AddToSubset(listener); Setup(); Show(); }
BComboBox::ComboBoxWindow::ComboBoxWindow(BComboBox *box) : BWindow(BRect(0, 0, 10, 10), NULL, B_BORDERED_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS) { fParent = box; DoPosition(); BWindow *parentWin = fParent->Window(); if (parentWin) AddToSubset(parentWin); BRect rect(Bounds()); rect.right -= B_V_SCROLL_BAR_WIDTH; fListView = new ChoiceListView(rect, fParent); AddChild(fListView); rect.left = rect.right; rect.right += B_V_SCROLL_BAR_WIDTH; fScrollBar = new BScrollBar(rect, "_popup_scroll_bar_", fListView, 0, 1000, B_VERTICAL); AddChild(fScrollBar); fListView->AdjustScrollBar(); }
RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame) : BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Your rating"), B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fRatingText() { AddToSubset(parent); CenterIn(parent->Frame()); TextDocumentView* textView = new TextDocumentView(); ScrollView* textScrollView = new ScrollView( "rating scroll view", textView); MarkupParser parser; fRatingText = parser.CreateDocumentFromMarkup( "Here is where you ''could'' type your awesome rating comment, " "if only this were already implemented."); textView->SetInsets(10.0f); textView->SetTextDocument(fRatingText); textView->SetTextEditor(TextEditorRef(new TextEditor(), true)); fSendButton = new BButton("send", B_TRANSLATE("Send"), new BMessage(MSG_SEND)); // Build layout BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(textScrollView) .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fSendButton) .End() .SetInsets(B_USE_DEFAULT_SPACING) ; }
GenesisCopyWindow::GenesisCopyWindow(CustomListView *list, PanelView *destpanel, const char *destination, BLooper* looper, BWindow *mainwindow) : BWindow(BRect(0,0,320,140), "Copy...", B_TITLED_WINDOW , B_WILL_DRAW) //////////////////////////////////////////////////////////////////////// { BRect rect; m_CustomListView = list; m_DestPanel = destpanel; m_DestPath.SetTo(destination); m_Looper = looper; m_Window = mainwindow; m_SingleCopy = false; m_Paused = false; m_SkipAllCopyError = false; m_OverwriteAll = false; m_SkipSymLinkCreationError = false; // After the delete process we have to select an item if no item selected... m_Selection = GetFirstSelection(); // First we have to remove the parent selection if selected... // RemoveParentSelection(); m_FileCount = m_CustomListView->CountSelectedEntries(CT_WITHOUTPARENT); if (m_FileCount == 1) m_SingleCopy = true; SetType(B_FLOATING_WINDOW); SetFeel(B_MODAL_SUBSET_WINDOW_FEEL); SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE); AddToSubset(mainwindow); m_View = new BView(Bounds(), "copyview", B_FOLLOW_ALL, B_WILL_DRAW); m_View->SetViewColor(216, 216, 216, 0); AddChild(m_View); // Bottom View rect = Bounds(); rect.top = rect.bottom-44; BView *BottomView = new BView(rect, "infobottomview", B_FOLLOW_BOTTOM, B_WILL_DRAW); BottomView->SetViewColor(180, 190, 200, 0); m_View->AddChild(BottomView); /* // More checkbox rect = BottomView->Bounds(); rect.top = rect.bottom-30; rect.bottom = rect.bottom-14; rect.left = 20; rect.right = rect.left+40; m_MoreCB = new BCheckBox(rect,"more","Show more",new BMessage(COPY_MORE), B_FOLLOW_BOTTOM, B_WILL_DRAW); m_MoreCB->ResizeToPreferred(); BottomView->AddChild(m_MoreCB); */ // OK Button rect = BottomView->Bounds(); rect.top = rect.bottom-34; rect.bottom = rect.bottom-14; rect.left = rect.right-80; rect.right = rect.right-20; m_CopyButton = new BButton(rect,"copy","Copy",new BMessage(BUTTON_MSG_COPY),B_FOLLOW_BOTTOM,B_WILL_DRAW); BottomView->AddChild(m_CopyButton); //Cancel Button rect = BottomView->Bounds(); rect.top = rect.bottom-34; rect.bottom = rect.bottom-14; rect.left = rect.right-160; rect.right = rect.right-100; m_CancelButton = new BButton(rect,"cancel","Cancel",new BMessage(BUTTON_MSG_CANCELCOPY),B_FOLLOW_BOTTOM,B_WILL_DRAW); BottomView->AddChild(m_CancelButton); SetDefaultButton(m_CopyButton); // Info string rect = Bounds(); rect.left += 24; rect.right -= 24; if (m_SingleCopy) rect.top += 8; else rect.top += 16; rect.bottom = rect.top+20; m_Label = new BStringView(rect,"filename","Copy"); m_Label->SetAlignment(B_ALIGN_CENTER); m_Label->SetViewColor(216,216,216); m_Label->SetLowColor(216,216,216); m_Label->SetHighColor(0,0,0); AddChild(m_Label); // Edit field rect = BottomView->Bounds(); if (m_SingleCopy) rect.top = rect.top+36; else rect.top = rect.top+56; rect.bottom = rect.top+32; rect.left += 20; rect.right -= 20; m_DirName = new BTextControl( rect, "destname", "to", "", NULL ); m_DirName->SetDivider(m_View->StringWidth("to")+4); m_DirName->SetModificationMessage(new BMessage(COPYNAME_CHANGED)); m_DirName->SetText(m_DestPath.String()); m_View->AddChild(m_DirName); // "as" field if (m_SingleCopy) { rect = BottomView->Bounds(); rect.top = rect.top+64; rect.bottom = rect.top+32; rect.left += 20; rect.right -= 20; m_FileAsName = new BTextControl( rect, "destfilename", "as", "", NULL ); m_FileAsName->SetDivider(m_View->StringWidth("to")+4); m_FileAsName->SetModificationMessage(new BMessage(COPYNAME_CHANGED)); if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT) m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName.String() ); else m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName.String() ); m_View->AddChild(m_FileAsName); } m_DirName->MakeFocus(true); // Ctrl + Q closes the window... AddShortcut('Q', 0, new BMessage(BUTTON_MSG_CANCELCOPY)); // Set copy label... if (m_SingleCopy) { BString text; text.SetTo("Copy '"); if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT) text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName; else text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName; text << "'"; m_Label->SetText(text.String()); } else { BString text; text.SetTo("Copy "); text << m_FileCount << " files"; m_Label->SetText(text.String()); } AddCommonFilter(new EscapeFilter(this, new BMessage(BUTTON_MSG_CANCELCOPY))); // If there is a given window, let's align our window to its center... if (mainwindow) { BRect myrect = Bounds(); rect = mainwindow->Frame(); float w = rect.right - rect.left; float h = rect.bottom - rect.top; MoveTo(rect.left + w/2 - (myrect.right-myrect.left)/2, rect.top + h/2 - (myrect.bottom-myrect.top)/2); } }
// -------------------------------------------------------------- ControlsWindow::ControlsWindow ( MainWindow * parent_window ) : BWindow(BRect(50, 50, 300, 500), "Controls", B_TITLED_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS) { m_device = NULL; m_device_info = NULL; m_parent_window = parent_window; m_devices_roster_thread_id = -1; m_scan_thread_id = -1; m_tooltip = new ToolTip(this, "controls_tooltip"); BRect r; float w, h; r = Bounds(); // Add a scan panel m_panel = new BBox(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); r.OffsetBy(4, 4); // First child view : Device PopUpMenu #define DEVICE_LABEL "Device:" m_devices_menu = new BPopUpMenu("<none available>"); m_devices_menu->SetRadioMode(true); m_devices_field = new BMenuField(r, "device_menu", DEVICE_LABEL, m_devices_menu, B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); m_devices_field->SetDivider(be_plain_font->StringWidth(DEVICE_LABEL "##")); m_panel->AddChild(m_devices_field); m_tooltip->SetText(m_devices_field, "Please select a device."); m_devices_field->ResizeToPreferred(); m_devices_field->GetPreferredSize(&w, &h); m_scan_button = new BButton(r, NULL, "Scan", new BMessage(SCAN_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); m_scan_button->MakeDefault(true); m_scan_button->ResizeToPreferred(); m_scan_button->GetPreferredSize(&w, &h); r.right -= (w + 12); m_scan_button->MoveTo(r.right, 40); m_panel->AddChild(m_scan_button); m_tooltip->SetText(m_scan_button, B_TRANSLATE("Start the scan process")); r.right -= 8; r.left += 8; r.top += 40; m_status_bar = new BStatusBar(r, NULL, "Scanning...", "1.58 Mb"); // m_status_bar->ResizeToPreferred(); m_status_bar->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); m_status_bar->SetFlags(m_status_bar->Flags() | (B_WILL_DRAW | B_FRAME_EVENTS)); m_status_bar->Hide(); m_panel->AddChild(m_status_bar); r = m_panel->Bounds(); r.top = 80; r.right -= B_V_SCROLL_BAR_WIDTH; r.InsetBy(4,4); // m_options_lv = new BListView(r, "options_lv", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES ); // m_options_sv = new BScrollView("options_sv", m_options_lv, // B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, false, true); // view->AddChild(m_options_sv); AddChild(m_panel); AddToSubset(parent_window); m_devices_roster_thread_id = spawn_thread(_DevicesRosterThread, "devices_roster", B_NORMAL_PRIORITY, this); resume_thread(m_devices_roster_thread_id); }
void CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, off_t size) { // Setup the controls fSizeSlider = new SizeSlider("Slider", TR("Partition size"), NULL, offset, offset + size); fSizeSlider->SetPosition(1.0); fNameTextControl = new BTextControl("Name Control", TR("Partition name:"), "", NULL); if (!parent->SupportsChildName()) fNameTextControl->SetEnabled(false); fTypePopUpMenu = new BPopUpMenu("Partition Type"); int32 cookie = 0; BString supportedType; while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) { BMessage* message = new BMessage(MSG_PARTITION_TYPE); message->AddString("type", supportedType); BMenuItem* item = new BMenuItem(supportedType, message); fTypePopUpMenu->AddItem(item); if (strcmp(supportedType, kPartitionTypeBFS) == 0) item->SetMarked(true); } fTypeMenuField = new BMenuField(TR("Partition type:"), fTypePopUpMenu, NULL); const float spacing = be_control_look->DefaultItemSpacing(); BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing); layout->SetInsets(spacing, spacing, spacing, spacing); SetLayout(layout); AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) .Add(fSizeSlider) .Add(BGridLayoutBuilder(0.0, 5.0) .Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0) .Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0) .Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1) .Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1) ) ); parent->GetChildCreationParameterEditor(NULL, &fEditor); if (fEditor) AddChild(fEditor->View()); BButton* okButton = new BButton(TR("Create"), new BMessage(MSG_OK)); AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .AddGlue() .Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL))) .Add(okButton) ); SetDefaultButton(okButton); AddToSubset(fWindow); layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); }
SelectionWindow::SelectionWindow(BContainerWindow *window) : BWindow(BRect(0, 0, 270, 0), "Select", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE | B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS | B_NOT_ANCHORED_ON_ACTIVATE), fParentWindow(window) { if (window->Feel() & kPrivateDesktopWindowFeel) // The window will not show up if we have B_FLOATING_SUBSET_WINDOW_FEEL // and use it with the desktop window since it's never in front. SetFeel(B_NORMAL_WINDOW_FEEL); AddToSubset(fParentWindow); BRect backgroundRect = Bounds(); backgroundRect.InsetBy(-1, -1); BView *backgroundView = new BBox(backgroundRect, "bgView", B_FOLLOW_ALL); AddChild(backgroundView); BMenu *menu = new BPopUpMenu(""); menu->AddItem(new BMenuItem("starts with", NULL)); menu->AddItem(new BMenuItem("ends with", NULL)); menu->AddItem(new BMenuItem("contains", NULL)); menu->AddItem(new BMenuItem("matches wildcard expression", NULL)); menu->AddItem(new BMenuItem("matches regular expression", NULL)); menu->SetLabelFromMarked(true); menu->ItemAt(3)->SetMarked(true); // Set wildcard matching to default. // Set up the menu field fMatchingTypeMenuField = new BMenuField(BRect(7, 6, Bounds().right - 5, 0), NULL, "Name", menu); backgroundView->AddChild(fMatchingTypeMenuField); fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth("Name") + 8); fMatchingTypeMenuField->ResizeToPreferred(); // Set up the expression text control fExpressionTextControl = new BTextControl(BRect(7, fMatchingTypeMenuField-> Bounds().bottom + 11, Bounds().right - 6, 0), NULL, NULL, NULL, NULL, B_FOLLOW_LEFT_RIGHT); backgroundView->AddChild(fExpressionTextControl); fExpressionTextControl->ResizeToPreferred(); fExpressionTextControl->MakeFocus(true); // Set up the Invert checkbox fInverseCheckBox = new BCheckBox(BRect(7, fExpressionTextControl->Frame().bottom + 6, 6, 6), NULL, "Invert", NULL); backgroundView->AddChild(fInverseCheckBox); fInverseCheckBox->ResizeToPreferred(); // Set up the Ignore Case checkbox fIgnoreCaseCheckBox = new BCheckBox(BRect(fInverseCheckBox->Frame().right + 10, fInverseCheckBox->Frame().top, 6, 6), NULL, "Ignore case", NULL); fIgnoreCaseCheckBox->SetValue(1); backgroundView->AddChild(fIgnoreCaseCheckBox); fIgnoreCaseCheckBox->ResizeToPreferred(); // Set up the Select button fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL, "Select", new BMessage(kSelectButtonPressed), B_FOLLOW_RIGHT); backgroundView->AddChild(fSelectButton); fSelectButton->ResizeToPreferred(); fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right, fExpressionTextControl->Frame().bottom + 9); fSelectButton->MakeDefault(true); #if !B_BEOS_VERSION_DANO fSelectButton->SetLowColor(backgroundView->ViewColor()); fSelectButton->SetViewColor(B_TRANSPARENT_COLOR); #endif font_height fh; be_plain_font->GetHeight(&fh); // Center the checkboxes vertically to the button float topMiddleButton = (fSelectButton->Bounds().Height() / 2 - (fh.ascent + fh.descent + fh.leading + 4) / 2) + fSelectButton->Frame().top; fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton); fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left, topMiddleButton); float bottomMinWidth = 32 + fSelectButton->Bounds().Width() + fInverseCheckBox->Bounds().Width() + fIgnoreCaseCheckBox->Bounds().Width(); float topMinWidth = be_plain_font->StringWidth("Name matches wildcard expression:###"); float minWidth = bottomMinWidth > topMinWidth ? bottomMinWidth : topMinWidth; Run(); Lock(); ResizeTo(minWidth, fSelectButton->Frame().bottom + 6); SetSizeLimits( /* Minimum Width */ minWidth, /* Maximum Width */ 1280, /* Minimum Height */ Bounds().bottom, /* Maximum Height */ Bounds().bottom); MoveCloseToMouse(); Unlock(); }
void CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, off_t size) { // Setup the controls fSizeSlider = new SizeSlider("Slider", B_TRANSLATE("Partition size"), NULL, offset, offset + size); fSizeSlider->SetPosition(1.0); fSizeSlider->SetModificationMessage(new BMessage(MSG_SIZE_SLIDER)); fSizeTextControl = new BTextControl("Size Control", "", "", NULL); for(int32 i = 0; i < 256; i++) fSizeTextControl->TextView()->DisallowChar(i); for(int32 i = '0'; i <= '9'; i++) fSizeTextControl->TextView()->AllowChar(i); _UpdateSizeTextControl(); fSizeTextControl->SetModificationMessage( new BMessage(MSG_SIZE_TEXTCONTROL)); fNameTextControl = new BTextControl("Name Control", B_TRANSLATE("Partition name:"), "", NULL); if (!parent->SupportsChildName()) fNameTextControl->SetEnabled(false); fTypePopUpMenu = new BPopUpMenu("Partition Type"); int32 cookie = 0; BString supportedType; while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) { BMessage* message = new BMessage(MSG_PARTITION_TYPE); message->AddString("type", supportedType); BMenuItem* item = new BMenuItem(supportedType, message); fTypePopUpMenu->AddItem(item); if (strcmp(supportedType, kPartitionTypeBFS) == 0) item->SetMarked(true); } fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"), fTypePopUpMenu); const float spacing = be_control_look->DefaultItemSpacing(); BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing); layout->SetInsets(spacing, spacing, spacing, spacing); SetLayout(layout); AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) .Add(fSizeSlider) .Add(fSizeTextControl) .Add(BGridLayoutBuilder(0.0, 5.0) .Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0) .Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0) .Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1) .Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1) ) ); status_t err = parent->GetParameterEditor(B_CREATE_PARAMETER_EDITOR, &fEditor); if (err == B_OK && fEditor != NULL) AddChild(fEditor->View()); else fEditor = NULL; BButton* okButton = new BButton(B_TRANSLATE("Create"), new BMessage(MSG_OK)); AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .AddGlue() .Add(new BButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL))) .Add(okButton) ); SetDefaultButton(okButton); AddToSubset(fWindow); layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); }
RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame, Model& model) : BWindow(frame, B_TRANSLATE("Rate package"), B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fModel(model), fRatingText(), fTextEditor(new TextEditor(), true), fRating(-1.0f), fCommentLanguage(fModel.PreferredLanguage()), fWorkerThread(-1) { AddToSubset(parent); BStringView* ratingLabel = new BStringView("rating label", B_TRANSLATE("Your rating:")); fSetRatingView = new SetRatingView(); fTextView = new TextDocumentView(); ScrollView* textScrollView = new ScrollView( "rating scroll view", fTextView); // Get a TextDocument with default paragraph and character style MarkupParser parser; fRatingText = parser.CreateDocumentFromMarkup(""); fTextView->SetInsets(10.0f); fTextView->SetTextDocument(fRatingText); fTextView->SetTextEditor(fTextEditor); // Construct stability rating popup BPopUpMenu* stabilityMenu = new BPopUpMenu(B_TRANSLATE("Stability")); fStabilityField = new BMenuField("stability", B_TRANSLATE("Stability:"), stabilityMenu); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Not specified"), "unspecified")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Stable"), "stable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Mostly stable"), "mostlystable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Unstable but usable"), "unstablebutusable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Very unstable"), "veryunstable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Does not start"), "nostart")); add_stabilities_to_menu(fStabilityCodes, stabilityMenu); stabilityMenu->SetTargetForItems(this); fStability = fStabilityCodes.ItemAt(0).Name(); stabilityMenu->ItemAt(0)->SetMarked(true); // Construct languages popup BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language")); fCommentLanguageField = new BMenuField("language", B_TRANSLATE("Comment language:"), languagesMenu); add_languages_to_menu(fModel.SupportedLanguages(), languagesMenu); languagesMenu->SetTargetForItems(this); BMenuItem* defaultItem = languagesMenu->ItemAt( fModel.SupportedLanguages().IndexOf(fCommentLanguage)); if (defaultItem != NULL) defaultItem->SetMarked(true); fRatingActiveCheckBox = new BCheckBox("rating active", B_TRANSLATE("Other users can see this rating"), new BMessage(MSG_RATING_ACTIVE_CHANGED)); // Hide the check mark by default, it will be made visible when // the user already made a rating and it is loaded fRatingActiveCheckBox->Hide(); // Construct buttons fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); fSendButton = new BButton("send", B_TRANSLATE("Send"), new BMessage(MSG_SEND)); // Build layout BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGrid() .Add(ratingLabel, 0, 0) .Add(fSetRatingView, 1, 0) .AddMenuField(fStabilityField, 0, 1) .AddMenuField(fCommentLanguageField, 0, 2) .End() .Add(textScrollView) .AddGroup(B_HORIZONTAL) .Add(fRatingActiveCheckBox) .AddGlue() .Add(fCancelButton) .Add(fSendButton) .End() .SetInsets(B_USE_WINDOW_INSETS) ; // NOTE: Do not make Send the default button. The user might want // to type line-breaks instead of sending when hitting RETURN. CenterIn(parent->Frame()); }
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, AttributeItem* attributeItem) : BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE | B_ASYNCHRONOUS_CONTROLS), fTarget(target), fMimeType(mimeType.Type()) { if (attributeItem != NULL) fAttribute = *attributeItem; BRect rect = Bounds(); BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); rect.InsetBy(8.0f, 8.0f); fPublicNameControl = new BTextControl(rect, "public", "Attribute name:", fAttribute.PublicName(), NULL, B_FOLLOW_LEFT_RIGHT); fPublicNameControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); float labelWidth = fPublicNameControl->StringWidth(fPublicNameControl->Label()) + 2.0f; fPublicNameControl->SetDivider(labelWidth); fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); float width, height; fPublicNameControl->GetPreferredSize(&width, &height); fPublicNameControl->ResizeTo(rect.Width(), height); topView->AddChild(fPublicNameControl); rect = fPublicNameControl->Frame(); rect.OffsetBy(0.0f, rect.Height() + 5.0f); fAttributeControl = new BTextControl(rect, "internal", "Internal name:", fAttribute.Name(), NULL, B_FOLLOW_LEFT_RIGHT); fAttributeControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); fAttributeControl->SetDivider(labelWidth); fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); // filter out invalid characters that can't be part of an attribute BTextView* textView = fAttributeControl->TextView(); const char* disallowedCharacters = "/"; for (int32 i = 0; disallowedCharacters[i]; i++) { textView->DisallowChar(disallowedCharacters[i]); } topView->AddChild(fAttributeControl); fTypeMenu = new BPopUpMenu("type"); BMenuItem* item = NULL; for (int32 i = 0; kTypeMap[i].name != NULL; i++) { BMessage* message = new BMessage(kMsgTypeChosen); message->AddInt32("type", kTypeMap[i].type); item = new BMenuItem(kTypeMap[i].name, message); fTypeMenu->AddItem(item); if (kTypeMap[i].type == fAttribute.Type()) item->SetMarked(true); } rect.OffsetBy(0.0f, rect.Height() + 4.0f); BMenuField* menuField = new BMenuField(rect, "types", "Type:", fTypeMenu); menuField->SetDivider(labelWidth); menuField->SetAlignment(B_ALIGN_RIGHT); menuField->GetPreferredSize(&width, &height); menuField->ResizeTo(rect.Width(), height); topView->AddChild(menuField); rect.OffsetBy(0.0f, rect.Height() + 4.0f); rect.bottom = rect.top + fAttributeControl->Bounds().Height() * 2.0f + 18.0f; BBox* box = new BBox(rect, "", B_FOLLOW_LEFT_RIGHT); topView->AddChild(box); fVisibleCheckBox = new BCheckBox(rect, "visible", "Visible", new BMessage(kMsgVisibilityChanged)); fVisibleCheckBox->SetValue(fAttribute.Visible()); fVisibleCheckBox->ResizeToPreferred(); box->SetLabel(fVisibleCheckBox); labelWidth -= 8.0f; BMenu* menu = new BPopUpMenu("display as"); for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) { BMessage* message = new BMessage(kMsgDisplayAsChosen); if (kDisplayAsMap[i].identifier != NULL) { message->AddString("identifier", kDisplayAsMap[i].identifier); for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) { message->AddInt32("supports", kDisplayAsMap[i].supported[j]); } } item = new BMenuItem(kDisplayAsMap[i].name, message); menu->AddItem(item); if (compare_display_as(kDisplayAsMap[i].identifier, fAttribute.DisplayAs())) item->SetMarked(true); } rect.OffsetTo(8.0f, fVisibleCheckBox->Bounds().Height()); rect.right -= 18.0f; fDisplayAsMenuField = new BMenuField(rect, "display as", "Display as:", menu); fDisplayAsMenuField->SetDivider(labelWidth); fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT); fDisplayAsMenuField->ResizeTo(rect.Width(), height); box->AddChild(fDisplayAsMenuField); fEditableCheckBox = new BCheckBox(rect, "editable", "Editable", new BMessage(kMsgAttributeUpdated), B_FOLLOW_RIGHT); fEditableCheckBox->SetValue(fAttribute.Editable()); fEditableCheckBox->ResizeToPreferred(); fEditableCheckBox->MoveTo(rect.right - fEditableCheckBox->Bounds().Width(), rect.top + (fDisplayAsMenuField->Bounds().Height() - fEditableCheckBox->Bounds().Height()) / 2.0f); box->AddChild(fEditableCheckBox); rect.OffsetBy(0.0f, menuField->Bounds().Height() + 4.0f); rect.bottom = rect.top + fPublicNameControl->Bounds().Height(); fSpecialControl = new BTextControl(rect, "special", "Special:", display_as_parameter(fAttribute.DisplayAs()), NULL, B_FOLLOW_LEFT_RIGHT); fSpecialControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); fSpecialControl->SetDivider(labelWidth); fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fSpecialControl->SetEnabled(false); box->AddChild(fSpecialControl); char text[64]; snprintf(text, sizeof(text), "%ld", fAttribute.Width()); rect.OffsetBy(0.0f, fSpecialControl->Bounds().Height() + 4.0f); fWidthControl = new BTextControl(rect, "width", "Width:", text, NULL, B_FOLLOW_LEFT_RIGHT); fWidthControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); fWidthControl->SetDivider(labelWidth); fWidthControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); // filter out invalid characters that can't be part of a width textView = fWidthControl->TextView(); for (int32 i = 0; i < 256; i++) { if (!isdigit(i)) textView->DisallowChar(i); } textView->SetMaxBytes(4); box->AddChild(fWidthControl); const struct alignment_map { int32 alignment; const char* name; } kAlignmentMap[] = { {B_ALIGN_LEFT, "Left"}, {B_ALIGN_RIGHT, "Right"}, {B_ALIGN_CENTER, "Center"}, {0, NULL} }; menu = new BPopUpMenu("alignment"); for (int32 i = 0; kAlignmentMap[i].name != NULL; i++) { BMessage* message = new BMessage(kMsgAlignmentChosen); message->AddInt32("alignment", kAlignmentMap[i].alignment); item = new BMenuItem(kAlignmentMap[i].name, message); menu->AddItem(item); if (kAlignmentMap[i].alignment == fAttribute.Alignment()) item->SetMarked(true); } rect.OffsetBy(0.0f, menuField->Bounds().Height() + 1.0f); fAlignmentMenuField = new BMenuField(rect, "alignment", "Alignment:", menu); fAlignmentMenuField->SetDivider(labelWidth); fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT); fAlignmentMenuField->ResizeTo(rect.Width(), height); box->AddChild(fAlignmentMenuField); box->ResizeBy(0.0f, fAlignmentMenuField->Bounds().Height() * 2.0f + fVisibleCheckBox->Bounds().Height()); fAcceptButton = new BButton(rect, "add", item ? "Done" : "Add", new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fAcceptButton->ResizeToPreferred(); fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(), Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height()); fAcceptButton->SetEnabled(false); topView->AddChild(fAcceptButton); BButton* button = new BButton(rect, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(), fAcceptButton->Frame().top); topView->AddChild(button); ResizeTo(labelWidth * 4.0f + 24.0f, box->Frame().bottom + button->Bounds().Height() + 20.0f); SetSizeLimits(fEditableCheckBox->Bounds().Width() + button->Bounds().Width() + fAcceptButton->Bounds().Width() + labelWidth + 24.0f, 32767.0f, Frame().Height(), Frame().Height()); fAcceptButton->MakeDefault(true); fPublicNameControl->MakeFocus(true); target->PlaceSubWindow(this); AddToSubset(target); }
// constructor ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color, selected_color_mode mode, BWindow* window, BMessage* message, BHandler* target) : Panel(frame, "Pick Color", B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE), fWindow(window), fMessage(message), fTarget(target) { SetTitle(B_TRANSLATE("Pick a color")); fColorPickerView = new ColorPickerView("color picker", color, mode); #if LIB_LAYOUT MButton* defaultButton = new MButton(B_TRANSLATE("OK"), new BMessage(MSG_DONE), this); // interface layout BView* topView = new VGroup ( fColorPickerView, new MBorder ( M_RAISED_BORDER, 5, "buttons", new HGroup ( new Space(minimax(0.0, 0.0, 10000.0, 10000.0, 5.0)), new MButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL), this), new Space(minimax(5.0, 0.0, 10.0, 10000.0, 1.0)), defaultButton, new Space(minimax(2.0, 0.0, 2.0, 10000.0, 0.0)), 0 ) ), 0 ); #else // LIB_LAYOUT frame = BRect(0, 0, 40, 15); BButton* defaultButton = new BButton(frame, "ok button", B_TRANSLATE("OK"), new BMessage(MSG_DONE), B_FOLLOW_RIGHT | B_FOLLOW_TOP); defaultButton->ResizeToPreferred(); BButton* cancelButton = new BButton(frame, "cancel button", B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_TOP); cancelButton->ResizeToPreferred(); frame.bottom = frame.top + (defaultButton->Frame().Height() + 16); frame.right = frame.left + fColorPickerView->Frame().Width(); BBox* buttonBox = new BBox(frame, "button group", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); ResizeTo(frame.Width(), fColorPickerView->Frame().Height() + frame.Height() + 1); frame = Bounds(); BView* topView = new BView(frame, "bg", B_FOLLOW_ALL, 0); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); buttonBox->MoveTo(frame.left, frame.bottom - buttonBox->Frame().Height()); defaultButton->MoveTo(frame.right - defaultButton->Frame().Width() - 10, frame.top + 8); buttonBox->AddChild(defaultButton); cancelButton->MoveTo(defaultButton->Frame().left - 10 - cancelButton->Frame().Width(), frame.top + 8); buttonBox->AddChild(cancelButton); topView->AddChild(fColorPickerView); topView->AddChild(buttonBox); #endif // LIB_LAYOUT SetDefaultButton(defaultButton); if (fWindow) AddToSubset(fWindow); else SetFeel(B_FLOATING_APP_WINDOW_FEEL); AddChild(topView); }
ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type, const char* extension) : BWindow(BRect(100, 100, 350, 200), "Extension", B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE | B_ASYNCHRONOUS_CONTROLS), fTarget(target), fMimeType(type.Type()), fExtension(extension) { BRect rect = Bounds(); BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); rect.InsetBy(8.0f, 8.0f); fExtensionControl = new BTextControl(rect, "extension", "Extension:", extension, NULL, B_FOLLOW_LEFT_RIGHT); float labelWidth = fExtensionControl->StringWidth(fExtensionControl->Label()) + 2.0f; fExtensionControl->SetModificationMessage(new BMessage(kMsgExtensionUpdated)); fExtensionControl->SetDivider(labelWidth); fExtensionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); // filter out invalid characters that can't be part of an extension BTextView* textView = fExtensionControl->TextView(); const char* disallowedCharacters = "/:"; for (int32 i = 0; disallowedCharacters[i]; i++) { textView->DisallowChar(disallowedCharacters[i]); } float width, height; fExtensionControl->GetPreferredSize(&width, &height); fExtensionControl->ResizeTo(rect.Width(), height); topView->AddChild(fExtensionControl); fAcceptButton = new BButton(rect, "add", extension ? "Done" : "Add", new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fAcceptButton->ResizeToPreferred(); fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(), Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height()); fAcceptButton->SetEnabled(false); topView->AddChild(fAcceptButton); BButton* button = new BButton(rect, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(), fAcceptButton->Frame().top); topView->AddChild(button); ResizeTo(labelWidth * 4.0f + 24.0f, fExtensionControl->Bounds().Height() + fAcceptButton->Bounds().Height() + 28.0f); SetSizeLimits(button->Bounds().Width() + fAcceptButton->Bounds().Width() + 26.0f, 32767.0f, Frame().Height(), Frame().Height()); // omit the leading dot if (fExtension.ByteAt(0) == '.') fExtension.Remove(0, 1); fAcceptButton->MakeDefault(true); fExtensionControl->MakeFocus(true); target->PlaceSubWindow(this); AddToSubset(target); }
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, AttributeItem* attributeItem) : BWindow(BRect(100, 100, 350, 200), B_TRANSLATE("Attribute"), B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS), fTarget(target), fMimeType(mimeType.Type()) { float padding = be_control_look->DefaultItemSpacing(); if (attributeItem != NULL) fAttribute = *attributeItem; fPublicNameControl = new BTextControl(B_TRANSLATE("Attribute name:"), fAttribute.PublicName(), NULL); fPublicNameControl->SetModificationMessage( new BMessage(kMsgAttributeUpdated)); fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fAttributeControl = new BTextControl(B_TRANSLATE("Internal name:"), fAttribute.Name(), NULL); fAttributeControl->SetModificationMessage( new BMessage(kMsgAttributeUpdated)); fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); // filter out invalid characters that can't be part of an attribute BTextView* textView = fAttributeControl->TextView(); const char* disallowedCharacters = "/"; for (int32 i = 0; disallowedCharacters[i]; i++) { textView->DisallowChar(disallowedCharacters[i]); } fTypeMenu = new BPopUpMenu("type"); BMenuItem* item = NULL; for (int32 i = 0; kTypeMap[i].name != NULL; i++) { BMessage* message = new BMessage(kMsgTypeChosen); message->AddInt32("type", kTypeMap[i].type); item = new BMenuItem(kTypeMap[i].name, message); fTypeMenu->AddItem(item); if (kTypeMap[i].type == fAttribute.Type()) item->SetMarked(true); } BMenuField* typeMenuField = new BMenuField("types" , B_TRANSLATE("Type:"), fTypeMenu); typeMenuField->SetAlignment(B_ALIGN_RIGHT); // we must set the color manually when adding a menuField directly // into a window. typeMenuField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); typeMenuField->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fVisibleCheckBox = new BCheckBox("visible", B_TRANSLATE("Visible"), new BMessage(kMsgVisibilityChanged)); fVisibleCheckBox->SetValue(fAttribute.Visible()); BMenu* menu = new BPopUpMenu("display as"); for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) { BMessage* message = new BMessage(kMsgDisplayAsChosen); if (kDisplayAsMap[i].identifier != NULL) { message->AddString("identifier", kDisplayAsMap[i].identifier); for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) { message->AddInt32("supports", kDisplayAsMap[i].supported[j]); } } item = new BMenuItem(kDisplayAsMap[i].name, message); menu->AddItem(item); if (compare_display_as(kDisplayAsMap[i].identifier, fAttribute.DisplayAs())) item->SetMarked(true); } fDisplayAsMenuField = new BMenuField("display as", B_TRANSLATE_COMMENT("Display as:", "Tracker offers different display modes for attributes."), menu); fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT); fEditableCheckBox = new BCheckBox("editable", B_TRANSLATE_COMMENT("Editable", "If Tracker allows to edit this attribute."), new BMessage(kMsgAttributeUpdated)); fEditableCheckBox->SetValue(fAttribute.Editable()); fSpecialControl = new BTextControl(B_TRANSLATE("Special:"), display_as_parameter(fAttribute.DisplayAs()), NULL); fSpecialControl->SetModificationMessage( new BMessage(kMsgAttributeUpdated)); fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fSpecialControl->SetEnabled(false); char text[64]; snprintf(text, sizeof(text), "%ld", fAttribute.Width()); fWidthControl = new BTextControl(B_TRANSLATE_COMMENT("Width:", "Default column width in Tracker for this attribute."), text, NULL); fWidthControl->SetModificationMessage( new BMessage(kMsgAttributeUpdated)); fWidthControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); // filter out invalid characters that can't be part of a width textView = fWidthControl->TextView(); for (int32 i = 0; i < 256; i++) { if (!isdigit(i)) textView->DisallowChar(i); } textView->SetMaxBytes(4); const struct alignment_map { int32 alignment; const char* name; } kAlignmentMap[] = { {B_ALIGN_LEFT, B_TRANSLATE_COMMENT("Left", "Attribute column alignment in Tracker")}, {B_ALIGN_RIGHT, B_TRANSLATE_COMMENT("Right", "Attribute column alignment in Tracker")}, {B_ALIGN_CENTER, B_TRANSLATE_COMMENT("Center", "Attribute column alignment in Tracker")}, {0, NULL} }; menu = new BPopUpMenu("alignment"); for (int32 i = 0; kAlignmentMap[i].name != NULL; i++) { BMessage* message = new BMessage(kMsgAlignmentChosen); message->AddInt32("alignment", kAlignmentMap[i].alignment); item = new BMenuItem(kAlignmentMap[i].name, message); menu->AddItem(item); if (kAlignmentMap[i].alignment == fAttribute.Alignment()) item->SetMarked(true); } fAlignmentMenuField = new BMenuField("alignment", B_TRANSLATE("Alignment:"), menu); fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT); fAcceptButton = new BButton("add", item ? B_TRANSLATE("Done") : B_TRANSLATE("Add"), new BMessage(kMsgAccept)); fAcceptButton->SetEnabled(false); BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); BBox* visibleBox; BLayoutBuilder::Group<>(this, B_VERTICAL, padding) .SetInsets(padding, padding, padding, padding) .AddGrid(padding, padding / 2) .Add(fPublicNameControl->CreateLabelLayoutItem(), 0, 0) .Add(fPublicNameControl->CreateTextViewLayoutItem(), 1, 0) .Add(fAttributeControl->CreateLabelLayoutItem(), 0, 1) .Add(fAttributeControl->CreateTextViewLayoutItem(), 1, 1) .Add(typeMenuField->CreateLabelLayoutItem(), 0, 2) .Add(typeMenuField->CreateMenuBarLayoutItem(), 1, 2) .End() .Add(visibleBox = new BBox(B_FANCY_BORDER, BLayoutBuilder::Grid<>(padding, padding / 2) .Add(fDisplayAsMenuField->CreateLabelLayoutItem(), 0, 0) .Add(fDisplayAsMenuField->CreateMenuBarLayoutItem(), 1, 0) .Add(fEditableCheckBox, 2, 0) .Add(fSpecialControl->CreateLabelLayoutItem(), 0, 1) .Add(fSpecialControl->CreateTextViewLayoutItem(), 1, 1, 2) .Add(fWidthControl->CreateLabelLayoutItem(), 0, 2) .Add(fWidthControl->CreateTextViewLayoutItem(), 1, 2, 2) .Add(fAlignmentMenuField->CreateLabelLayoutItem(), 0, 3) .Add(fAlignmentMenuField->CreateMenuBarLayoutItem(), 1, 3, 2) .SetInsets(padding, padding, padding, padding) .View()) ) .AddGroup(B_HORIZONTAL, padding) .Add(BSpaceLayoutItem::CreateGlue()) .Add(cancelButton) .Add(fAcceptButton); visibleBox->SetLabel(fVisibleCheckBox); fAcceptButton->MakeDefault(true); fPublicNameControl->MakeFocus(true); target->PlaceSubWindow(this); AddToSubset(target); _CheckDisplayAs(); _CheckAcceptable(); }
// constructor NavigationInfoPanel::NavigationInfoPanel(BWindow* parent, const BMessage& message, const BMessenger& target) : BWindow(BRect(0, 0, 200, 30), "Navigation Info", B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE) , fMessage(message) , fTarget(target) { // create the interface and resize to fit BRect frame = Bounds(); frame.InsetBy(5, 5); frame.bottom = frame.top + 15; // label string view fLabelView = new BStringView(frame, "label", kLabel, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fLabelView->ResizeToPreferred(); frame = fLabelView->Frame(); // target clip text control frame.OffsetBy(0, frame.Height() + 5); fTargetClipTC = new BTextControl(frame, "clip id", "Target Playlist ID", "", new BMessage(MSG_INVOKE), B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); fTargetClipTC->ResizeToPreferred(); frame = fTargetClipTC->Frame(); // help string view frame.OffsetBy(0, frame.Height() + 5); BStringView* helpView = new BStringView(frame, "help", "Drag and drop a playlist clip here.", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); BFont font; helpView->GetFont(&font); font.SetFace(B_ITALIC_FACE); font.SetSize(font.Size() * 0.9); helpView->SetFont(&font); helpView->SetAlignment(B_ALIGN_CENTER); helpView->ResizeToPreferred(); // parent view frame = fLabelView->Frame() | fTargetClipTC->Frame() | helpView->Frame(); frame.InsetBy(-5, -5); fInfoView = new InfoView(frame, this); fInfoView->AddChild(fLabelView); fInfoView->AddChild(fTargetClipTC); fInfoView->AddChild(helpView); // resize to fit and adjust size limits ResizeTo(fInfoView->Frame().Width(), fInfoView->Frame().Height()); AddChild(fInfoView); float minWidth, maxWidth, minHeight, maxHeight; GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); minWidth = Frame().Width(); minHeight = maxHeight = Frame().Height(); SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight); // modify the high color after the help view is attached to a window helpView->SetHighColor(tint_color(helpView->LowColor(), B_DISABLED_LABEL_TINT)); helpView->SetFlags(helpView->Flags() | B_FULL_UPDATE_ON_RESIZE); // help the buggy BeOS BStringView (when text alignment != left...) fInfoView->SetEventMask(B_POINTER_EVENTS); // resize controls to the same (maximum) width float maxControlWidth = fLabelView->Frame().Width(); maxControlWidth = max_c(maxControlWidth, fTargetClipTC->Frame().Width()); maxControlWidth = max_c(maxControlWidth, helpView->Frame().Width()); fLabelView->ResizeTo(maxControlWidth, fLabelView->Frame().Height()); fTargetClipTC->ResizeTo(maxControlWidth, fTargetClipTC->Frame().Height()); helpView->ResizeTo(maxControlWidth, helpView->Frame().Height()); // center above parent window BAutolock _(parent); frame = Frame(); BRect parentFrame = parent->Frame(); MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2, (parentFrame.top + parentFrame.bottom - frame.Height()) / 2); AddToSubset(parent); }
SelectionWindow::SelectionWindow(BContainerWindow* window) : BWindow(BRect(0, 0, 270, 0), B_TRANSLATE("Select"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE | B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS | B_NOT_ANCHORED_ON_ACTIVATE), fParentWindow(window) { if (window->Feel() & kDesktopWindowFeel) { // The window will not show up if we have // B_FLOATING_SUBSET_WINDOW_FEEL and use it with the desktop window // since it's never in front. SetFeel(B_NORMAL_WINDOW_FEEL); } AddToSubset(fParentWindow); BView* backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW); backgroundView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); AddChild(backgroundView); BMenu* menu = new BPopUpMenu(""); menu->AddItem(new BMenuItem(B_TRANSLATE("starts with"), NULL)); menu->AddItem(new BMenuItem(B_TRANSLATE("ends with"), NULL)); menu->AddItem(new BMenuItem(B_TRANSLATE("contains"), NULL)); menu->AddItem(new BMenuItem(B_TRANSLATE("matches wildcard expression"), NULL)); menu->AddItem(new BMenuItem(B_TRANSLATE("matches regular expression"), NULL)); menu->SetLabelFromMarked(true); menu->ItemAt(3)->SetMarked(true); // Set wildcard matching to default. // Set up the menu field fMatchingTypeMenuField = new BMenuField(BRect(7, 6, Bounds().right - 5, 0), NULL, B_TRANSLATE("Name"), menu); backgroundView->AddChild(fMatchingTypeMenuField); fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth( B_TRANSLATE("Name")) + 8); fMatchingTypeMenuField->ResizeToPreferred(); // Set up the expression text control fExpressionTextControl = new BTextControl(BRect(7, fMatchingTypeMenuField->Bounds().bottom + 11, Bounds().right - 6, 0), NULL, NULL, NULL, NULL, B_FOLLOW_LEFT_RIGHT); backgroundView->AddChild(fExpressionTextControl); fExpressionTextControl->ResizeToPreferred(); fExpressionTextControl->MakeFocus(true); // Set up the Invert checkbox fInverseCheckBox = new BCheckBox( BRect(7, fExpressionTextControl->Frame().bottom + 6, 6, 6), NULL, B_TRANSLATE("Invert"), NULL); backgroundView->AddChild(fInverseCheckBox); fInverseCheckBox->ResizeToPreferred(); // Set up the Ignore Case checkbox fIgnoreCaseCheckBox = new BCheckBox( BRect(fInverseCheckBox->Frame().right + 10, fInverseCheckBox->Frame().top, 6, 6), NULL, B_TRANSLATE("Ignore case"), NULL); fIgnoreCaseCheckBox->SetValue(1); backgroundView->AddChild(fIgnoreCaseCheckBox); fIgnoreCaseCheckBox->ResizeToPreferred(); // Set up the Select button fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL, B_TRANSLATE("Select"), new BMessage(kSelectButtonPressed), B_FOLLOW_RIGHT); backgroundView->AddChild(fSelectButton); fSelectButton->ResizeToPreferred(); fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right, fExpressionTextControl->Frame().bottom + 9); fSelectButton->MakeDefault(true); #if !B_BEOS_VERSION_DANO fSelectButton->SetLowColor(backgroundView->ViewColor()); fSelectButton->SetViewColor(B_TRANSPARENT_COLOR); #endif font_height fh; be_plain_font->GetHeight(&fh); // Center the checkboxes vertically to the button float topMiddleButton = (fSelectButton->Bounds().Height() / 2 - (fh.ascent + fh.descent + fh.leading + 4) / 2) + fSelectButton->Frame().top; fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton); fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left, topMiddleButton); float bottomMinWidth = 32 + fSelectButton->Bounds().Width() + fInverseCheckBox->Bounds().Width() + fIgnoreCaseCheckBox->Bounds().Width(); float topMinWidth = be_plain_font->StringWidth( B_TRANSLATE("Name matches wildcard expression:###")); float minWidth = bottomMinWidth > topMinWidth ? bottomMinWidth : topMinWidth; class EscapeFilter : public BMessageFilter { public: EscapeFilter(BWindow* target) : BMessageFilter(B_KEY_DOWN), fTarget(target) { } virtual filter_result Filter(BMessage* message, BHandler** _target) { int8 byte; if (message->what == B_KEY_DOWN && message->FindInt8("byte", &byte) == B_OK && byte == B_ESCAPE) { fTarget->Hide(); return B_SKIP_MESSAGE; } return B_DISPATCH_MESSAGE; } private: BWindow* fTarget; }; AddCommonFilter(new(std::nothrow) EscapeFilter(this)); Run(); Lock(); ResizeTo(minWidth, fSelectButton->Frame().bottom + 6); SetSizeLimits(minWidth, 1280, Bounds().bottom, Bounds().bottom); MoveCloseToMouse(); Unlock(); }