void TMediaTabView::Init() { // NOTE: the order of these need to be kept in sync with the EChildID // enum // Create List View button BBitmap* up = GetIcon16FromResource("ListViewUp"); BBitmap* down = GetIcon16FromResource("ListViewDown"); // Make sure the button is a square, the same width as the scroll bar, // is high. It's top is one scroll bar height away from the bottom BRect buttBounds(0, 0, kScrollHeight, kScrollHeight); fbuttons[0] = new TRadioBitmapButton(buttBounds, "ListViewButton", up, down, this, new BMessage(MEDIA_TAB_LIST_VIEW_MSG), B_FOLLOW_LEFT + B_FOLLOW_BOTTOM); // This button is on by default fbuttons[0]->SetValue(1); // The Thumbnail button goes right next door up = GetIcon16FromResource("ThumbnailUp"); down = GetIcon16FromResource("ThumbnailDown"); buttBounds.left = buttBounds.right; buttBounds.right = buttBounds.left + kScrollHeight; fbuttons[1] = new TRadioBitmapButton(buttBounds, "ThumbnailButton", up, down, this, new BMessage(MEDIA_TAB_THUMBNAIL_VIEW_MSG), B_FOLLOW_LEFT + B_FOLLOW_BOTTOM); // With the icon view button next up = GetIcon16FromResource("IconViewUp"); down = GetIcon16FromResource("IconViewDown"); buttBounds.left = buttBounds.right; buttBounds.right = buttBounds.left + kScrollHeight; fbuttons[2] = new TRadioBitmapButton(buttBounds, "IconViewButton", up, down, this, new BMessage(MEDIA_TAB_ICON_VIEW_MSG), B_FOLLOW_LEFT + B_FOLLOW_BOTTOM); // create the views needed to support list, thumbnail and icon view. // Tell it to make room for the buttons. Hide the non-default views TElementsView* e = new TElementsView(Bounds()); AddChild(e); // move the horizontal scroll bar to make room for our buttons. NOTE: add // in one. The bitmap buttons are allowed to overlap so there is just one // black pixel shared between them. But the scroll bar changes color. It // needs to not share the space. e->MakeRoomForButtons(3 * kScrollHeight + 1); // Default view is list view ActivateView(kElementsView); // Do the other two views BView* sizeScroll = AddSizeScrollChild(new TThumbnailView(Bounds())); sizeScroll->Hide(); sizeScroll = AddSizeScrollChild(new TIconView(Bounds())); sizeScroll->Hide(); }
void CollapsableBox::SetValue(int32 new_value) { if (new_value != Value()) { BRect r = Bounds(); if (!new_value) ResizeTo(r.Width(), m_collapsed_rect.Height()); else ResizeTo(r.Width(), m_expanded_rect.Height()); BView *child; child = ChildAt(0); while (child) { if (new_value) child->Show(); else child->Hide(); child = child->NextSibling(); }; Invalidate(); BControl::SetValue(new_value); Invoke(); }; }
void TrackerSettingsWindow::_HandleChangedSettingsView() { int32 currentSelection = fSettingsTypeListView->CurrentSelection(); if (currentSelection < 0) return; BView* oldView = fSettingsContainerBox->ChildAt(0); if (oldView != NULL) oldView->RemoveSelf(); SettingsItem* selectedItem = dynamic_cast<SettingsItem*>( fSettingsTypeListView->ItemAt(currentSelection)); if (selectedItem != NULL) { fSettingsContainerBox->SetLabel(selectedItem->Text()); BView* view = selectedItem->View(); view->SetViewColor(fSettingsContainerBox->ViewColor()); view->Hide(); fSettingsContainerBox->AddChild(view); view->Show(); } }
void YabTabView::Select(int32 index) { if (index < 0 || index >= CountTabs()) index = Selection(); BView *tab = TabAt(Selection()); if (tab) { Invalidate(); tab->Hide(); } tab = TabAt(index); if (tab) { if (index != 0 && !Bounds().Contains(TabFrame(index))){ if (!Bounds().Contains(TabFrame(index).LeftTop())) fTabOffset += TabFrame(index).left - Bounds().left - 20.0f; else fTabOffset += TabFrame(index).right - Bounds().right + 20.0f; } Invalidate(); tab->Show(); fSelection = index; FocusChanged = index+1; } }
BView* HTabSheet::AddSheet(const char *name, const char *desc) { BView *r = new HDlogView(ClientArea(), name); AddChild(r); fPanes.AddItem(r); fEntries->AddItem(new BStringItem(name)); fDescs.AddItem(desc ? strdup(desc) : strdup(name)); if (fPanes.CountItems() > 1) r->Hide(); else fEntries->Select(0); return r; } /* HTabSheet::AddSheet */
void TMediaTabView::DeactivateView(EChildID which) { // Take away the control buttons BView* view = ChildAt(which); BView* b = view->ChildAt(0); while (b) { BView* next = b->NextSibling(); if (dynamic_cast<TRadioBitmapButton*>(b) != 0) view->RemoveChild(b); b = next; } // Make sure the view is invisible if (!view->IsHidden()) view->Hide(); }
void MainView::ToggleFields(bool on) { Field *child = NULL; BView *field = NULL; child = (Field *)ChildAt(0); while(child) { field = child->GetField(); if(on) { if(field->IsHidden()) field->Show(); } else { if(!field->IsHidden()) field->Hide(); } child = (Field *)child->NextSibling(); } }
void TFilePanel::RestoreState() { BNode defaultingNode; if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode, false)) { AttributeStreamFileNode streamNodeSource(&defaultingNode); RestoreWindowState(&streamNodeSource); PoseView()->Init(&streamNodeSource); } else { RestoreWindowState(NULL); PoseView()->Init(NULL); } // Finish UI creation now that the PoseView is initialized BLayoutItem* item = fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView()); BSize minSize = item->MinSize(); BSize maxSize = item->MaxSize(); item->SetExplicitMinSize(BSize(minSize.Width(), kTitleViewHeight)); item->SetExplicitMaxSize(BSize(maxSize.Width(), kTitleViewHeight)); BRect rect(fBorderedView->Frame()); rect.right = rect.left + kCountViewWidth; rect.top = rect.bottom + 1; rect.bottom = rect.top + PoseView()->HScrollBar()->Bounds().Height() - 1; PoseView()->CountView()->MoveTo(rect.LeftTop()); PoseView()->CountView()->ResizeTo(rect.Size()); PoseView()->CountView()->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); fBackView->AddChild(PoseView()->CountView(), fBorderedView); PoseView()->HScrollBar()->MoveBy(kCountViewWidth + 1, 0); PoseView()->HScrollBar()->ResizeBy(-kCountViewWidth - 1, 0); // The Be Book states that the BTitleView will have a name of "TitleView", // and so some apps will try to grab it by that name and move it around. // They don't need to, because resizing "PoseView" (really the BorderedView) // will resize the BTitleView as well. So just create a dummy view here // so that they don't get NULL when trying to find the view. BView* dummyTitleView = new BView(BRect(), "TitleView", B_FOLLOW_NONE, 0); fBackView->AddChild(dummyTitleView); dummyTitleView->Hide(); }
void ArpConfigurePanel::GetPreferredSize(float* width, float* height) { float maxw=0, maxh=0; size_t i; // Get dimensions of all configuration views. for( i=0; i<mConfigViews->size(); i++ ) { BView* view = 0; if( (view=mConfigViews->at(i)) != 0 ) { ArpD(cdb << ADH << "Processing dimens for view #" << i << ", name=" << view->Name() << endl); float vwidth=0, vheight=0; // If this view is not attached to the window (i.e., it // is not currently displayed by the tab view), then it // may not be able to report correct dimensions. To fix // this, we temporarily add it to your view. if( !view->Window() ) { ArpD(cdb << ADH << "Temporarily attaching view to window." << endl); bool hidden = view->IsHidden(); view->Hide(); AddChild(view); view->GetPreferredSize(&vwidth, &vheight); RemoveChild(view); if( !hidden ) view->Show(); } else { view->GetPreferredSize(&vwidth, &vheight); } ArpD(cdb << ADH << "Preferred width=" << vwidth << ", height=" << vheight << endl); if( vwidth > maxw ) maxw = vwidth; if( vheight > maxh ) maxh = vheight; } } ArpD(cdb << ADH << "Final size=(" << (maxw+mTabWidth) << ", " << (maxh+mTabHeight) << ")" << endl); if( width ) *width = maxw + mTabWidth + 2; if( height ) *height = maxh + mTabHeight + 2; }