diff --git a/headers/os/interface/ListView.h b/headers/os/interface/ListView.h index 8bed7bfaab..51afb5bf78 100644 --- a/headers/os/interface/ListView.h +++ b/headers/os/interface/ListView.h @@ -41,7 +41,11 @@ class BListView : public BView, public BInvoker { virtual void MouseDown(BPoint where); virtual void KeyDown(const char* bytes, int32 numBytes); virtual void MakeFocus(bool state = true); + virtual void AttachedToWindow(); virtual void FrameResized(float newWidth, float newHeight); + virtual void FrameMoved(BPoint newPosition); + virtual void SetFont(const BFont* font, + uint32 mask = B_FONT_ALL); virtual void TargetedByScrollView(BScrollView* scroller); virtual void ScrollTo(BPoint where); inline void ScrollTo(float x, float y); @@ -98,9 +102,6 @@ class BListView : public BView, public BInvoker { bool MoveItem(int32 from, int32 to); bool ReplaceItem(int32 index, BListItem* item); - virtual void AttachedToWindow(); - virtual void FrameMoved(BPoint newPosition); - BRect ItemFrame(int32 index); virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index 96a095ac75..f4bcd695c5 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -427,6 +427,25 @@ BListView::KeyDown(const char *bytes, int32 numBytes) ScrollToSelection(); break; + case B_PAGE_UP: + { + BPoint scrollOffset(LeftTop()); + scrollOffset.y = max_c(0, scrollOffset.y - Bounds().Height()); + ScrollTo(scrollOffset); + break; + } + case B_PAGE_DOWN: + { + BPoint scrollOffset(LeftTop()); + if (BListItem* item = LastItem()) { + scrollOffset.y += Bounds().Height(); + scrollOffset.y = min_c(item->Bottom() - Bounds().Height(), + scrollOffset.y); + } + ScrollTo(scrollOffset); + break; + } + case B_RETURN: case B_SPACE: Invoke(); @@ -450,6 +469,19 @@ BListView::MakeFocus(bool focused) fScrollView->SetBorderHighlighted(focused); } +// AttachedToWindow +void +BListView::AttachedToWindow() +{ + BView::AttachedToWindow(); + _FontChanged(); + + if (!Messenger().IsValid()) + SetTarget(Window(), NULL); + + _FixupScrollBar(); +} + // FrameResized void BListView::FrameResized(float width, float height) @@ -457,6 +489,21 @@ BListView::FrameResized(float width, float height) _FixupScrollBar(); } +// FrameMoved +void +BListView::FrameMoved(BPoint new_position) +{ + BView::FrameMoved(new_position); +} + +// SetFont +void +BListView::SetFont(const BFont* font, uint32 mask) +{ + BView::SetFont(font, mask); + _FontChanged(); +} + // TargetedByScrollView void BListView::TargetedByScrollView(BScrollView *view) @@ -486,9 +533,9 @@ BListView::AddItem(BListItem *item, int32 index) if (Window()) { BFont font; GetFont(&font); - _RecalcItemTops(index); item->Update(this, &font); - + _RecalcItemTops(index); + _FixupScrollBar(); _InvalidateFrom(index); } @@ -508,9 +555,8 @@ BListView::AddItem(BListItem* item) if (Window()) { BFont font; GetFont(&font); - _RecalcItemTops(CountItems() - 1); item->Update(this, &font); - + _RecalcItemTops(CountItems() - 1); _FixupScrollBar(); InvalidateItem(CountItems() - 1); @@ -992,26 +1038,6 @@ BListView::ReplaceItem(int32 index, BListItem *item) return DoMiscellaneous(B_REPLACE_OP, &data); } -// AttachedToWindow -void -BListView::AttachedToWindow() -{ - BView::AttachedToWindow(); - _FontChanged(); - - if (!Messenger().IsValid()) - SetTarget(Window(), NULL); - - _FixupScrollBar(); -} - -// FrameMoved -void -BListView::FrameMoved(BPoint new_position) -{ - BView::FrameMoved(new_position); -} - // ItemFrame BRect BListView::ItemFrame(int32 index)