void MainView::FixupScrollbars() { return; BRect bounds=(Bounds()).InsetBySelf(5, 5); bounds.right -= B_V_SCROLL_BAR_WIDTH; bounds.bottom -= B_H_SCROLL_BAR_HEIGHT; BScrollBar *sb; BListView* listView = (BListView*)this->FindView("list"); float ratio=1, realRectWidth=1, realRectHeight=1; if (!listView || !scrollView) { return; } listView->GetPreferredSize(&realRectWidth, &realRectHeight); realRectHeight = listView->CountItems() * 18; realRectWidth += 15 + B_V_SCROLL_BAR_WIDTH; sb = scrollView->ScrollBar(B_HORIZONTAL); if (sb) { ratio = bounds.Width() / (float)realRectWidth; sb->SetRange(0, realRectWidth-bounds.Width()); if (ratio >= 1) { sb->SetProportion(1); } else { sb->SetProportion(ratio); } } sb = scrollView->ScrollBar(B_VERTICAL); if (sb) { ratio = bounds.Height() / (float)realRectHeight; sb->SetRange(0, realRectHeight+2); if (ratio >= 1) { sb->SetProportion(1); } else { sb->SetProportion(ratio); } } }
status_t PListView::GetProperty(const char *name, PValue *value, const int32 &index) const { if (!name || !value) return B_ERROR; BString str(name); PProperty *prop = FindProperty(name,index); if (!prop) return B_NAME_NOT_FOUND; BListView *backend = (BListView*)fView; if (backend->Window()) backend->Window()->Lock(); if (str.ICompare("PreferredWidth") == 0) { if (backend->CountItems() == 0) ((FloatProperty*)prop)->SetValue(100); else { float pw, ph; backend->GetPreferredSize(&pw, &ph); if (pw < 10) pw = 100; if (ph < 10) ph = 30; ((FloatProperty*)prop)->SetValue(pw); } } else if (str.ICompare("ItemCount") == 0) ((IntProperty*)prop)->SetValue(backend->CountItems()); else if (str.ICompare("SelectionMessage") == 0) ((IntProperty*)prop)->SetValue(backend->SelectionCommand()); else if (str.ICompare("PreferredHeight") == 0) { if (backend->CountItems() == 0) ((FloatProperty*)prop)->SetValue(30); else { float pw, ph; backend->GetPreferredSize(&pw, &ph); if (pw < 10) pw = 100; if (ph < 10) ph = 30; ((FloatProperty*)prop)->SetValue(ph); } } else if (str.ICompare("InvocationMessage") == 0) ((IntProperty*)prop)->SetValue(backend->InvocationCommand()); else if (str.ICompare("SelectionType") == 0) ((EnumProperty*)prop)->SetValue(backend->ListType()); else { if (backend->Window()) backend->Window()->Unlock(); return PView::GetProperty(name, value, index); } if (backend->Window()) backend->Window()->Unlock(); return prop->GetValue(value); }