* The previous change to reorder item->Update() and _RecalcItemTops() obviously
broke everything. If the added item has no chance to calculate it's height, _RecalcItemTops() won't work of course. Whatever this was supposed to fix, there has to be a correct way. * Override BView::SetFont() to update all the items. I remember wanting to implement this, that's why I refactored a _FontChanged() method, but I obviousy never did... * Moved the AttachedToWindow() and FrameMoved() implementations to a more logical position in the file. * Implement B_PAGE_UP/DOWN key presses. Don't know if that's what the BeOS implementation did, will check later. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28671 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -41,7 +41,11 @@ class BListView : public BView, public BInvoker {
|
|||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
virtual void MakeFocus(bool state = true);
|
virtual void MakeFocus(bool state = true);
|
||||||
|
virtual void AttachedToWindow();
|
||||||
virtual void FrameResized(float newWidth, float newHeight);
|
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 TargetedByScrollView(BScrollView* scroller);
|
||||||
virtual void ScrollTo(BPoint where);
|
virtual void ScrollTo(BPoint where);
|
||||||
inline void ScrollTo(float x, float y);
|
inline void ScrollTo(float x, float y);
|
||||||
@@ -98,9 +102,6 @@ class BListView : public BView, public BInvoker {
|
|||||||
bool MoveItem(int32 from, int32 to);
|
bool MoveItem(int32 from, int32 to);
|
||||||
bool ReplaceItem(int32 index, BListItem* item);
|
bool ReplaceItem(int32 index, BListItem* item);
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void FrameMoved(BPoint newPosition);
|
|
||||||
|
|
||||||
BRect ItemFrame(int32 index);
|
BRect ItemFrame(int32 index);
|
||||||
|
|
||||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||||
|
|||||||
@@ -427,6 +427,25 @@ BListView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
ScrollToSelection();
|
ScrollToSelection();
|
||||||
break;
|
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_RETURN:
|
||||||
case B_SPACE:
|
case B_SPACE:
|
||||||
Invoke();
|
Invoke();
|
||||||
@@ -450,6 +469,19 @@ BListView::MakeFocus(bool focused)
|
|||||||
fScrollView->SetBorderHighlighted(focused);
|
fScrollView->SetBorderHighlighted(focused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AttachedToWindow
|
||||||
|
void
|
||||||
|
BListView::AttachedToWindow()
|
||||||
|
{
|
||||||
|
BView::AttachedToWindow();
|
||||||
|
_FontChanged();
|
||||||
|
|
||||||
|
if (!Messenger().IsValid())
|
||||||
|
SetTarget(Window(), NULL);
|
||||||
|
|
||||||
|
_FixupScrollBar();
|
||||||
|
}
|
||||||
|
|
||||||
// FrameResized
|
// FrameResized
|
||||||
void
|
void
|
||||||
BListView::FrameResized(float width, float height)
|
BListView::FrameResized(float width, float height)
|
||||||
@@ -457,6 +489,21 @@ BListView::FrameResized(float width, float height)
|
|||||||
_FixupScrollBar();
|
_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
|
// TargetedByScrollView
|
||||||
void
|
void
|
||||||
BListView::TargetedByScrollView(BScrollView *view)
|
BListView::TargetedByScrollView(BScrollView *view)
|
||||||
@@ -486,8 +533,8 @@ BListView::AddItem(BListItem *item, int32 index)
|
|||||||
if (Window()) {
|
if (Window()) {
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
_RecalcItemTops(index);
|
|
||||||
item->Update(this, &font);
|
item->Update(this, &font);
|
||||||
|
_RecalcItemTops(index);
|
||||||
|
|
||||||
_FixupScrollBar();
|
_FixupScrollBar();
|
||||||
_InvalidateFrom(index);
|
_InvalidateFrom(index);
|
||||||
@@ -508,9 +555,8 @@ BListView::AddItem(BListItem* item)
|
|||||||
if (Window()) {
|
if (Window()) {
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
_RecalcItemTops(CountItems() - 1);
|
|
||||||
item->Update(this, &font);
|
item->Update(this, &font);
|
||||||
|
_RecalcItemTops(CountItems() - 1);
|
||||||
|
|
||||||
_FixupScrollBar();
|
_FixupScrollBar();
|
||||||
InvalidateItem(CountItems() - 1);
|
InvalidateItem(CountItems() - 1);
|
||||||
@@ -992,26 +1038,6 @@ BListView::ReplaceItem(int32 index, BListItem *item)
|
|||||||
return DoMiscellaneous(B_REPLACE_OP, &data);
|
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
|
// ItemFrame
|
||||||
BRect
|
BRect
|
||||||
BListView::ItemFrame(int32 index)
|
BListView::ItemFrame(int32 index)
|
||||||
|
|||||||
Reference in New Issue
Block a user