void BQueryContainerWindow::CreatePoseView(Model *model) { BRect rect(Bounds()); rect.right -= B_V_SCROLL_BAR_WIDTH; rect.bottom -= B_H_SCROLL_BAR_HEIGHT; fPoseView = NewPoseView(model, rect, kListMode); AddChild(fPoseView); }
OpenWithContainerWindow::OpenWithContainerWindow(BMessage* entriesToOpen, LockingList<BWindow>* windowList, window_look look, window_feel feel, uint32 flags, uint32 workspace) : BContainerWindow(windowList, 0, look, feel, flags, workspace), fEntriesToOpen(entriesToOpen) { AutoLock<BWindow> lock(this); BRect windowRect(85, 50, 718, 296); MoveTo(windowRect.LeftTop()); ResizeTo(windowRect.Width(), windowRect.Height()); // add a background view; use the standard BackgroundView here, the same // as the file panel is using BRect rect(Bounds()); BackgroundView* backgroundView = new BackgroundView(rect); AddChild(backgroundView); rect = Bounds(); // add buttons fLaunchButton = new BButton(rect, "ok", B_TRANSLATE("Open"), new BMessage(kDefaultButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fLaunchButton->ResizeToPreferred(); fLaunchButton->MoveTo(rect.right - 10 - kDocumentKnobWidth - fLaunchButton->Bounds().Width(), rect.bottom - 10.0f - fLaunchButton->Bounds().Height()); backgroundView->AddChild(fLaunchButton); BRect buttonRect = fLaunchButton->Frame(); fLaunchAndMakeDefaultButton = new BButton(buttonRect, "make default", B_TRANSLATE("Open and make preferred"), new BMessage(kOpenAndMakeDefault), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); // wide button, have to resize to fit text fLaunchAndMakeDefaultButton->ResizeToPreferred(); fLaunchAndMakeDefaultButton->MoveBy(-10.0f - fLaunchAndMakeDefaultButton->Bounds().Width(), 0.0f); backgroundView->AddChild(fLaunchAndMakeDefaultButton); fLaunchAndMakeDefaultButton->SetEnabled(false); buttonRect = fLaunchAndMakeDefaultButton->Frame(); BButton* button = new BButton(buttonRect, "cancel", B_TRANSLATE("Cancel"), new BMessage(kCancelButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveBy(-10.0f - button->Bounds().Width(), 0.0f); backgroundView->AddChild(button); fMinimalWidth = button->Bounds().Width() + fLaunchButton->Bounds().Width() + fLaunchAndMakeDefaultButton->Bounds().Width() + kDocumentKnobWidth + 40.0f; fLaunchButton->MakeDefault(true); // add pose view rect.OffsetTo(10.0f, 10.0f); rect.bottom = buttonRect.top - 15.0f; rect.right -= B_V_SCROLL_BAR_WIDTH + 20.0f; rect.bottom -= B_H_SCROLL_BAR_HEIGHT; // make room for scrollbars and a margin fPoseView = NewPoseView(0, rect, kListMode); backgroundView->AddChild(fPoseView); fPoseView->SetFlags(fPoseView->Flags() | B_NAVIGABLE); fPoseView->SetPoseEditing(false); // set the window title if (CountRefs(fEntriesToOpen) == 1) { // if opening just one file, use it in the title entry_ref ref; fEntriesToOpen->FindRef("refs", &ref); BString buffer(B_TRANSLATE("Open %name with:")); buffer.ReplaceFirst("%name", ref.name); SetTitle(buffer.String()); } else { // use generic title SetTitle(B_TRANSLATE("Open selection with:")); } AddCommonFilter(new BMessageFilter(B_KEY_DOWN, &OpenWithContainerWindow::KeyDownFilter)); }