* Cleanup, no functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30156 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-04-14 12:43:54 +00:00
parent 199f33248d
commit fc2c8b88a5
+91 -83
View File
@@ -134,8 +134,8 @@ BListView::~BListView()
} }
BArchivable * BArchivable*
BListView::Instantiate(BMessage *archive) BListView::Instantiate(BMessage* archive)
{ {
if (validate_instantiation(archive, "BListView")) if (validate_instantiation(archive, "BListView"))
return new BListView(archive); return new BListView(archive);
@@ -145,7 +145,7 @@ BListView::Instantiate(BMessage *archive)
status_t status_t
BListView::Archive(BMessage *archive, bool deep) const BListView::Archive(BMessage* archive, bool deep) const
{ {
status_t status = BView::Archive(archive, deep); status_t status = BView::Archive(archive, deep);
if (status < B_OK) if (status < B_OK)
@@ -491,7 +491,7 @@ BListView::MakeFocus(bool focused)
fScrollView->SetBorderHighlighted(focused); fScrollView->SetBorderHighlighted(focused);
} }
// AttachedToWindow
void void
BListView::AttachedToWindow() BListView::AttachedToWindow()
{ {
@@ -504,21 +504,21 @@ BListView::AttachedToWindow()
_FixupScrollBar(); _FixupScrollBar();
} }
// FrameResized
void void
BListView::FrameResized(float width, float height) BListView::FrameResized(float width, float height)
{ {
_FixupScrollBar(); _FixupScrollBar();
} }
// FrameMoved
void void
BListView::FrameMoved(BPoint new_position) BListView::FrameMoved(BPoint new_position)
{ {
BView::FrameMoved(new_position); BView::FrameMoved(new_position);
} }
// SetFont
void void
BListView::SetFont(const BFont* font, uint32 mask) BListView::SetFont(const BFont* font, uint32 mask)
{ {
@@ -526,20 +526,21 @@ BListView::SetFont(const BFont* font, uint32 mask)
_FontChanged(); _FontChanged();
} }
// TargetedByScrollView
void void
BListView::TargetedByScrollView(BScrollView *view) BListView::TargetedByScrollView(BScrollView *view)
{ {
fScrollView = view; fScrollView = view;
} }
// ScrollTo
void void
BListView::ScrollTo(BPoint point) BListView::ScrollTo(BPoint point)
{ {
BView::ScrollTo(point); BView::ScrollTo(point);
} }
bool bool
BListView::AddItem(BListItem *item, int32 index) BListView::AddItem(BListItem *item, int32 index)
{ {
@@ -573,6 +574,7 @@ BListView::AddItem(BListItem* item)
{ {
if (!fList.AddItem(item)) if (!fList.AddItem(item))
return false; return false;
// No need to adapt selection, as this item is the last in the list // No need to adapt selection, as this item is the last in the list
if (Window()) { if (Window()) {
@@ -590,7 +592,7 @@ BListView::AddItem(BListItem* item)
return true; return true;
} }
// AddList
bool bool
BListView::AddList(BList* list, int32 index) BListView::AddList(BList* list, int32 index)
{ {
@@ -623,14 +625,14 @@ BListView::AddList(BList* list, int32 index)
return true; return true;
} }
// AddList
bool bool
BListView::AddList(BList* list) BListView::AddList(BList* list)
{ {
return AddList(list, CountItems()); return AddList(list, CountItems());
} }
// RemoveItem
BListItem* BListItem*
BListView::RemoveItem(int32 index) BListView::RemoveItem(int32 index)
{ {
@@ -658,14 +660,14 @@ BListView::RemoveItem(int32 index)
return item; return item;
} }
// RemoveItem
bool bool
BListView::RemoveItem(BListItem *item) BListView::RemoveItem(BListItem *item)
{ {
return BListView::RemoveItem(IndexOf(item)) != NULL; return BListView::RemoveItem(IndexOf(item)) != NULL;
} }
// RemoveItems
bool bool
BListView::RemoveItems(int32 index, int32 count) BListView::RemoveItems(int32 index, int32 count)
{ {
@@ -682,7 +684,7 @@ BListView::RemoveItems(int32 index, int32 count)
return true; return true;
} }
// SetSelectionMessage
void void
BListView::SetSelectionMessage(BMessage* message) BListView::SetSelectionMessage(BMessage* message)
{ {
@@ -690,45 +692,45 @@ BListView::SetSelectionMessage(BMessage* message)
fSelectMessage = message; fSelectMessage = message;
} }
// SetInvocationMessage
void void
BListView::SetInvocationMessage(BMessage* message) BListView::SetInvocationMessage(BMessage* message)
{ {
BInvoker::SetMessage(message); BInvoker::SetMessage(message);
} }
// InvocationMessage
BMessage* BMessage*
BListView::InvocationMessage() const BListView::InvocationMessage() const
{ {
return BInvoker::Message(); return BInvoker::Message();
} }
// InvocationCommand
uint32 uint32
BListView::InvocationCommand() const BListView::InvocationCommand() const
{ {
return BInvoker::Command(); return BInvoker::Command();
} }
// SelectionMessage
BMessage* BMessage*
BListView::SelectionMessage() const BListView::SelectionMessage() const
{ {
return fSelectMessage; return fSelectMessage;
} }
// SelectionCommand
uint32 uint32
BListView::SelectionCommand() const BListView::SelectionCommand() const
{ {
if (fSelectMessage) if (fSelectMessage)
return fSelectMessage->what; return fSelectMessage->what;
else
return 0; return 0;
} }
// SetListType
void void
BListView::SetListType(list_view_type type) BListView::SetListType(list_view_type type)
{ {
@@ -738,20 +740,22 @@ BListView::SetListType(list_view_type type)
fListType = type; fListType = type;
} }
//------------------------------------------------------------------------------
list_view_type BListView::ListType() const
list_view_type
BListView::ListType() const
{ {
return fListType; return fListType;
} }
// ItemAt
BListItem* BListItem*
BListView::ItemAt(int32 index) const BListView::ItemAt(int32 index) const
{ {
return (BListItem*)fList.ItemAt(index); return (BListItem*)fList.ItemAt(index);
} }
// IndexOf
int32 int32
BListView::IndexOf(BListItem *item) const BListView::IndexOf(BListItem *item) const
{ {
@@ -766,7 +770,7 @@ BListView::IndexOf(BListItem *item) const
return fList.IndexOf(item); return fList.IndexOf(item);
} }
// IndexOf
int32 int32
BListView::IndexOf(BPoint point) const BListView::IndexOf(BPoint point) const
{ {
@@ -791,35 +795,35 @@ BListView::IndexOf(BPoint point) const
return -1; return -1;
} }
// FirstItem
BListItem* BListItem*
BListView::FirstItem() const BListView::FirstItem() const
{ {
return (BListItem*)fList.FirstItem(); return (BListItem*)fList.FirstItem();
} }
// LastItem
BListItem* BListItem*
BListView::LastItem() const BListView::LastItem() const
{ {
return (BListItem*)fList.LastItem(); return (BListItem*)fList.LastItem();
} }
// HasItem
bool bool
BListView::HasItem(BListItem *item) const BListView::HasItem(BListItem *item) const
{ {
return IndexOf(item) != -1; return IndexOf(item) != -1;
} }
// CountItems
int32 int32
BListView::CountItems() const BListView::CountItems() const
{ {
return fList.CountItems(); return fList.CountItems();
} }
// MakeEmpty
void void
BListView::MakeEmpty() BListView::MakeEmpty()
{ {
@@ -835,42 +839,42 @@ BListView::MakeEmpty()
} }
} }
// IsEmpty
bool bool
BListView::IsEmpty() const BListView::IsEmpty() const
{ {
return fList.IsEmpty(); return fList.IsEmpty();
} }
// DoForEach
void void
BListView::DoForEach(bool (*func)(BListItem*)) BListView::DoForEach(bool (*func)(BListItem*))
{ {
fList.DoForEach(reinterpret_cast<bool (*)(void*)>(func)); fList.DoForEach(reinterpret_cast<bool (*)(void*)>(func));
} }
// DoForEach
void void
BListView::DoForEach(bool (*func)(BListItem*, void*), void* arg ) BListView::DoForEach(bool (*func)(BListItem*, void*), void* arg)
{ {
fList.DoForEach(reinterpret_cast<bool (*)(void*, void*)>(func), arg); fList.DoForEach(reinterpret_cast<bool (*)(void*, void*)>(func), arg);
} }
// Items
const BListItem** const BListItem**
BListView::Items() const BListView::Items() const
{ {
return (const BListItem**)fList.Items(); return (const BListItem**)fList.Items();
} }
// InvalidateItem
void void
BListView::InvalidateItem(int32 index) BListView::InvalidateItem(int32 index)
{ {
Invalidate(ItemFrame(index)); Invalidate(ItemFrame(index));
} }
// ScrollToSelection
void void
BListView::ScrollToSelection() BListView::ScrollToSelection()
{ {
@@ -916,7 +920,7 @@ BListView::IsItemSelected(int32 index) const
return false; return false;
} }
// CurrentSelection
int32 int32
BListView::CurrentSelection(int32 index) const BListView::CurrentSelection(int32 index) const
{ {
@@ -938,9 +942,9 @@ BListView::CurrentSelection(int32 index) const
return -1; return -1;
} }
// Invoke
status_t status_t
BListView::Invoke(BMessage *message) BListView::Invoke(BMessage* message)
{ {
// Note, this is more or less a copy of BControl::Invoke() and should // Note, this is more or less a copy of BControl::Invoke() and should
// stay that way (ie. changes done there should be adopted here) // stay that way (ie. changes done there should be adopted here)
@@ -1037,7 +1041,7 @@ BListView::SortItems(int (*cmp)(const void *, const void *))
Invalidate(); Invalidate();
} }
// SwapItems
bool bool
BListView::SwapItems(int32 a, int32 b) BListView::SwapItems(int32 a, int32 b)
{ {
@@ -1049,7 +1053,7 @@ BListView::SwapItems(int32 a, int32 b)
return DoMiscellaneous(B_SWAP_OP, &data); return DoMiscellaneous(B_SWAP_OP, &data);
} }
// MoveItem
bool bool
BListView::MoveItem(int32 from, int32 to) BListView::MoveItem(int32 from, int32 to)
{ {
@@ -1061,7 +1065,7 @@ BListView::MoveItem(int32 from, int32 to)
return DoMiscellaneous(B_MOVE_OP, &data); return DoMiscellaneous(B_MOVE_OP, &data);
} }
// ReplaceItem
bool bool
BListView::ReplaceItem(int32 index, BListItem *item) BListView::ReplaceItem(int32 index, BListItem *item)
{ {
@@ -1073,7 +1077,7 @@ BListView::ReplaceItem(int32 index, BListItem *item)
return DoMiscellaneous(B_REPLACE_OP, &data); return DoMiscellaneous(B_REPLACE_OP, &data);
} }
// ItemFrame
BRect BRect
BListView::ItemFrame(int32 index) BListView::ItemFrame(int32 index)
{ {
@@ -1096,8 +1100,10 @@ BListView::ResolveSpecifier(BMessage* message, int32 index,
{ {
BPropertyInfo propInfo(sProperties); BPropertyInfo propInfo(sProperties);
if (propInfo.FindMatch(message, 0, specifier, form, property) < 0) if (propInfo.FindMatch(message, 0, specifier, form, property) < 0) {
return BView::ResolveSpecifier(message, index, specifier, form, property); return BView::ResolveSpecifier(message, index, specifier, form,
property);
}
// TODO: msg->AddInt32("_match_code_", ); // TODO: msg->AddInt32("_match_code_", );
@@ -1122,6 +1128,7 @@ BListView::GetSupportedSuites(BMessage* data)
return err; return err;
} }
status_t status_t
BListView::Perform(perform_code code, void* _data) BListView::Perform(perform_code code, void* _data)
{ {
@@ -1153,7 +1160,7 @@ BListView::Perform(perform_code code, void* _data)
BListView::GetHeightForWidth(data->width, &data->min, &data->max, BListView::GetHeightForWidth(data->width, &data->min, &data->max,
&data->preferred); &data->preferred);
return B_OK; return B_OK;
} }
case PERFORM_CODE_SET_LAYOUT: case PERFORM_CODE_SET_LAYOUT:
{ {
perform_data_set_layout* data = (perform_data_set_layout*)_data; perform_data_set_layout* data = (perform_data_set_layout*)_data;
@@ -1178,37 +1185,36 @@ BListView::Perform(perform_code code, void* _data)
} }
// WindowActivated
void void
BListView::WindowActivated(bool state) BListView::WindowActivated(bool state)
{ {
BView::WindowActivated(state); BView::WindowActivated(state);
} }
// DetachedFromWindow
void void
BListView::DetachedFromWindow() BListView::DetachedFromWindow()
{ {
BView::DetachedFromWindow(); BView::DetachedFromWindow();
} }
// InitiateDrag
bool bool
BListView::InitiateDrag(BPoint point, int32 index, bool wasSelected) BListView::InitiateDrag(BPoint point, int32 index, bool wasSelected)
{ {
return false; return false;
} }
// ResizeToPreferred
void void
BListView::ResizeToPreferred() BListView::ResizeToPreferred()
{ {
BView::ResizeToPreferred(); BView::ResizeToPreferred();
} }
// GetPreferredSize
void void
BListView::GetPreferredSize(float *width, float *height) BListView::GetPreferredSize(float* _width, float* _height)
{ {
int32 count = CountItems(); int32 count = CountItems();
@@ -1220,27 +1226,30 @@ BListView::GetPreferredSize(float *width, float *height)
maxWidth = itemWidth; maxWidth = itemWidth;
} }
*width = maxWidth; if (_width != NULL)
*height = ItemAt(count - 1)->Bottom(); *_width = maxWidth;
if (_height != NULL)
*_height = ItemAt(count - 1)->Bottom();
} else { } else {
BView::GetPreferredSize(width, height); BView::GetPreferredSize(_width, _height);
} }
} }
// AllAttached
void void
BListView::AllAttached() BListView::AllAttached()
{ {
BView::AllAttached(); BView::AllAttached();
} }
// AllDetached
void void
BListView::AllDetached() BListView::AllDetached()
{ {
BView::AllDetached(); BView::AllDetached();
} }
BSize BSize
BListView::MinSize() BListView::MinSize()
{ {
@@ -1266,9 +1275,8 @@ BListView::PreferredSize()
} }
// DoMiscellaneous
bool bool
BListView::DoMiscellaneous(MiscCode code, MiscData *data) BListView::DoMiscellaneous(MiscCode code, MiscData* data)
{ {
if (code > B_SWAP_OP) if (code > B_SWAP_OP)
return false; return false;
@@ -1290,16 +1298,19 @@ BListView::DoMiscellaneous(MiscCode code, MiscData *data)
return false; return false;
} }
void BListView::_ReservedListView2() {} void BListView::_ReservedListView2() {}
void BListView::_ReservedListView3() {} void BListView::_ReservedListView3() {}
void BListView::_ReservedListView4() {} void BListView::_ReservedListView4() {}
BListView &BListView::operator=(const BListView &)
BListView&
BListView::operator=(const BListView& /*other*/)
{ {
return *this; return *this;
} }
// _InitObject
void void
BListView::_InitObject(list_view_type type) BListView::_InitObject(list_view_type type)
{ {
@@ -1314,12 +1325,11 @@ BListView::_InitObject(list_view_type type)
fTrack->item_index = -1; fTrack->item_index = -1;
} }
// _FixupScrollBar
void void
BListView::_FixupScrollBar() BListView::_FixupScrollBar()
{ {
BScrollBar* vertScroller = ScrollBar(B_VERTICAL); BScrollBar* vertScroller = ScrollBar(B_VERTICAL);
if (!vertScroller) if (!vertScroller)
return; return;
@@ -1340,35 +1350,34 @@ BListView::_FixupScrollBar()
vertScroller->SetRange(0.0, itemHeight - bounds.Height() - 1.0); vertScroller->SetRange(0.0, itemHeight - bounds.Height() - 1.0);
vertScroller->SetProportion(bounds.Height () / itemHeight); vertScroller->SetProportion(bounds.Height () / itemHeight);
// scroll up if there is empty room on bottom // scroll up if there is empty room on bottom
if (itemHeight < bounds.bottom) { if (itemHeight < bounds.bottom)
ScrollBy(0.0, bounds.bottom - itemHeight); ScrollBy(0.0, bounds.bottom - itemHeight);
}
} }
if (count != 0) if (count != 0)
vertScroller->SetSteps(ceilf(FirstItem()->Height()), bounds.Height()); vertScroller->SetSteps(ceilf(FirstItem()->Height()), bounds.Height());
} }
// _InvalidateFrom
void void
BListView::_InvalidateFrom(int32 index) BListView::_InvalidateFrom(int32 index)
{ {
// make sure index is behind last valid index // make sure index is behind last valid index
int32 count = CountItems(); int32 count = CountItems();
if (index >= count) { if (index >= count)
index = count; index = count;
}
// take the item before the wanted one, // take the item before the wanted one,
// because that might already be removed // because that might already be removed
index--; index--;
BRect dirty = Bounds(); BRect dirty = Bounds();
if (index >= 0) { if (index >= 0)
dirty.top = ItemFrame(index).bottom + 1; dirty.top = ItemFrame(index).bottom + 1;
}
Invalidate(dirty); Invalidate(dirty);
} }
// _FontChanged
void void
BListView::_FontChanged() BListView::_FontChanged()
{ {
@@ -1381,8 +1390,7 @@ BListView::_FontChanged()
} }
/*! /*! Selects the item at the specified \a index, and returns \c true in
Selects the item at the specified \a index, and returns \c true in
case the selection was changed because of this method. case the selection was changed because of this method.
If \a extend is \c false, all previously selected items are deselected. If \a extend is \c false, all previously selected items are deselected.
*/ */
@@ -1394,7 +1402,7 @@ BListView::_Select(int32 index, bool extend)
// only lock the window when there is one // only lock the window when there is one
BAutolock locker(Window()); BAutolock locker(Window());
if (Window() && !locker.IsLocked()) if (Window() != NULL && !locker.IsLocked())
return false; return false;
bool changed = false; bool changed = false;
@@ -1428,8 +1436,7 @@ BListView::_Select(int32 index, bool extend)
} }
/*! /*! Selects the items between \a from and \a to, and returns \c true in
Selects the items between \a from and \a to, and returns \c true in
case the selection was changed because of this method. case the selection was changed because of this method.
If \a extend is \c false, all previously selected items are deselected. If \a extend is \c false, all previously selected items are deselected.
*/ */
@@ -1545,7 +1552,7 @@ BListView::_DeselectAll(int32 exceptFrom, int32 exceptTo)
return true; return true;
} }
// _TryInitiateDrag
bool bool
BListView::_TryInitiateDrag(BPoint where) BListView::_TryInitiateDrag(BPoint where)
{ {
@@ -1562,7 +1569,7 @@ BListView::_TryInitiateDrag(BPoint where)
return false; return false;
} }
// _CalcFirstSelected
int32 int32
BListView::_CalcFirstSelected(int32 after) BListView::_CalcFirstSelected(int32 after)
{ {
@@ -1597,7 +1604,7 @@ BListView::_CalcLastSelected(int32 before)
void void
BListView::DrawItem(BListItem *item, BRect itemRect, bool complete) BListView::DrawItem(BListItem* item, BRect itemRect, bool complete)
{ {
item->DrawItem(this, itemRect, complete); item->DrawItem(this, itemRect, complete);
} }
@@ -1772,6 +1779,7 @@ BListView::_RescanSelection(int32 from, int32 to)
} }
} }
void void
BListView::_RecalcItemTops(int32 start, int32 end) BListView::_RecalcItemTops(int32 start, int32 end)
{ {