git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19282 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-11-14 18:08:53 +00:00
parent 7837924c49
commit 7f721ea14d
1 changed files with 88 additions and 105 deletions

View File

@ -1,21 +1,17 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2002, OpenBeOS * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
// Distributed under the terms of the OpenBeOS license * Distributed under the terms of the MIT License.
// */
// File: ListView.h
// Author: Axel Doerfler
// Description: BListView represents a one-dimensional list view.
//
//------------------------------------------------------------------------------
#ifndef _LIST_VIEW_H #ifndef _LIST_VIEW_H
#define _LIST_VIEW_H #define _LIST_VIEW_H
#include <Invoker.h> #include <Invoker.h>
#include <View.h> #include <View.h>
#include <List.h> #include <List.h>
#include <ListItem.h> #include <ListItem.h>
struct track_data; struct track_data;
enum list_view_type { enum list_view_type {
@ -23,14 +19,8 @@ enum list_view_type {
B_MULTIPLE_SELECTION_LIST B_MULTIPLE_SELECTION_LIST
}; };
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
//----- BListView class ------------------------------------------ class BListView : public BView, public BInvoker {
class BListView : public BView, public BInvoker
{
public: public:
BListView(BRect frame, const char* name, BListView(BRect frame, const char* name,
list_view_type type = B_SINGLE_SELECTION_LIST, list_view_type type = B_SINGLE_SELECTION_LIST,
@ -79,8 +69,8 @@ class BListView : public BView, public BInvoker
int32 CountItems() const; int32 CountItems() const;
virtual void MakeEmpty(); virtual void MakeEmpty();
bool IsEmpty() const; bool IsEmpty() const;
void DoForEach(bool (*func)(BListItem *)); void DoForEach(bool (*func)(BListItem* item));
void DoForEach(bool (*func)(BListItem *, void *), void *); void DoForEach(bool (*func)(BListItem* item, void* arg), void* arg);
const BListItem** Items() const; const BListItem** Items() const;
void InvalidateItem(int32 index); void InvalidateItem(int32 index);
void ScrollToSelection(); void ScrollToSelection();
@ -89,10 +79,10 @@ class BListView : public BView, public BInvoker
void Select(int32 from, int32 to, bool extend = false); void Select(int32 from, int32 to, bool extend = false);
bool IsItemSelected(int32 index) const; bool IsItemSelected(int32 index) const;
int32 CurrentSelection(int32 index = 0) const; int32 CurrentSelection(int32 index = 0) const;
virtual status_t Invoke(BMessage *msg = NULL); virtual status_t Invoke(BMessage* message = NULL);
void DeselectAll(); void DeselectAll();
void DeselectExcept(int32 except_from, int32 except_to); void DeselectExcept(int32 exceptFrom, int32 exceptTo);
void Deselect(int32 index); void Deselect(int32 index);
virtual void SelectionChanged(); virtual void SelectionChanged();
@ -105,11 +95,11 @@ class BListView : public BView, public BInvoker
bool ReplaceItem(int32 index, BListItem* item); bool ReplaceItem(int32 index, BListItem* item);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void FrameMoved(BPoint new_position); virtual void FrameMoved(BPoint newPosition);
BRect ItemFrame(int32 index); BRect ItemFrame(int32 index);
virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form, const char* property); BMessage* specifier, int32 form, const char* property);
virtual status_t GetSupportedSuites(BMessage* data); virtual status_t GetSupportedSuites(BMessage* data);
@ -117,12 +107,14 @@ class BListView : public BView, public BInvoker
virtual void WindowActivated(bool state); virtual void WindowActivated(bool state);
virtual void MouseUp(BPoint point); virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 code, const BMessage *msg); virtual void MouseMoved(BPoint point, uint32 code,
const BMessage *dragMessage);
virtual void DetachedFromWindow(); virtual void DetachedFromWindow();
virtual bool InitiateDrag(BPoint point, int32 itemIndex, bool initialySelected); virtual bool InitiateDrag(BPoint point, int32 itemIndex,
bool initialySelected);
virtual void ResizeToPreferred(); virtual void ResizeToPreferred();
virtual void GetPreferredSize(float *width, float *height); virtual void GetPreferredSize(float* _width, float* _height);
virtual void AllAttached(); virtual void AllAttached();
virtual void AllDetached(); virtual void AllDetached();
@ -140,8 +132,6 @@ class BListView : public BView, public BInvoker
virtual bool DoMiscellaneous(MiscCode code, MiscData *data); virtual bool DoMiscellaneous(MiscCode code, MiscData *data);
//----- Private or reserved -----------------------------------------
private: private:
friend class BOutlineListView; friend class BOutlineListView;
@ -154,19 +144,20 @@ class BListView : public BView, public BInvoker
void _InitObject(list_view_type type); void _InitObject(list_view_type type);
void _FixupScrollBar(); void _FixupScrollBar();
void _InvalidateFrom(int32 index); void _InvalidateFrom(int32 index);
status_t _PostMessage(BMessage *msg); status_t _PostMessage(BMessage* message);
void _FontChanged(); void _FontChanged();
int32 _RangeCheck(int32 index); int32 _RangeCheck(int32 index);
bool _Select(int32 index, bool extend); bool _Select(int32 index, bool extend);
bool _Select(int32 from, int32 to, bool extend); bool _Select(int32 from, int32 to, bool extend);
bool _Deselect(int32 index); bool _Deselect(int32 index);
// void _Deselect(int32 from, int32 to); // void _Deselect(int32 from, int32 to);
bool _DeselectAll(int32 except_from, int32 except_to); bool _DeselectAll(int32 exceptFrom, int32 exceptTo);
// void PerformDelayedSelect(); // void PerformDelayedSelect();
bool _TryInitiateDrag(BPoint where); bool _TryInitiateDrag(BPoint where);
int32 _CalcFirstSelected(int32 after); int32 _CalcFirstSelected(int32 after);
int32 _CalcLastSelected(int32 before); int32 _CalcLastSelected(int32 before);
virtual void DrawItem(BListItem *item, BRect itemRect, bool complete = false); virtual void DrawItem(BListItem* item, BRect itemRect,
bool complete = false);
bool _SwapItems(int32 a, int32 b); bool _SwapItems(int32 a, int32 b);
bool _MoveItem(int32 from, int32 to); bool _MoveItem(int32 from, int32 to);
@ -186,18 +177,10 @@ class BListView : public BView, public BInvoker
uint32 _reserved[3]; uint32 _reserved[3];
}; };
inline void inline void
BListView::ScrollTo(float x, float y) BListView::ScrollTo(float x, float y)
{ {
/* OK, no private parts */
ScrollTo(BPoint(x, y)); ScrollTo(BPoint(x, y));
} }
/*-------------------------------------------------------------*/
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif /* _LIST_VIEW_H */ #endif /* _LIST_VIEW_H */