Derived from: public BListView
Declared in: be/interface/OutlineListView.h
Library: libbe.so
A BOutlineListView displays a list of items that can be structured like an outline, with items grouped under other items. The levels of the outline are indicated by successive levels of indentation.
If an item has other items under it--that is, if the immediately following item in the list is at a deeper level of the outline--it is a superitem; the items grouped under it are its subitems. Superitems are marked by a triangular icon or latch, in the usual interface for hypertext lists.
The user can collapse or expand sections of the outline by manipulating the latch. When a section is collapsed, only the superitem for that section is visible (and the latch points to the superitem). All items that follow the superitem are hidden, up to the next item that's not at a deeper outline level. When a section is expanded, subitems are visible (and the latch points downward).
The BOutlineListView class inherits most of its functionality from the BListView class. However, inherited functions are concerned only with the expanded sections of the list, not with sections that are hidden because they're collapsed. If an inherited function returns an index or takes an index as an argument, the index counts just the items that are shown on-screen (or could be shown on-screen if they were scrolled into the visible region of the view). DoForEach() skips items that can't be displayed. CountItems() counts items only in the expanded sections of the list.
However, the functions that the BOutlineListView class itself defines are concerned with all sections of the list, expanded or collapsed. For its functions, an index counts all items in the list, whether visible or not.
The class defines some functions that match those it inherits, but its versions prefix FullList... to the function name and don't ignore any items. For example, FullListCountItems() counts every item in the list and FullListDoForEach() doesn't skip items in collapsed sections.
In some cases, BOutlineListView simply overrides an inherited function without adding the FullList... prefix. You should always use the BOutlineListView versions of these functions, not the BListView versions. For example, BOutlineListView's version of MakeEmpty() truly empties the list; BListView's version would remove items from the screen, but not from the real list.
BOutlineListView(BRect frame, const char *name, list_view_type type = B_SINGLE_SELECTION_LIST, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE) BOutlineListView(BMessage *archive)
Initializes the BOutlineListView. This constructor matches the BListView constructor in every detail, including default arguments. All argument values are passed to the BListView constructor without change. The BOutlineListView class doesn't do any initialization of its own.
See also: the BListView constructor
virtual ~BOutlineListView(void)
Does nothing; this class relies on the BListView destructor.
static BOutlineListView *Instantiate(BMessage *archive)
Returns a new BOutlineListView object, allocated by new and created with the version of the constructor that takes a BMessage archive. However, this function returns NULL if the specified archive doesn't contain data for a BOutlineListView object.
See also: BArchivable::Instantiate(), instantiate_object(), Archive()
virtual bool AddItem(BListItem *item) virtual bool AddItem(BListItem *item, int32 index) virtual bool AddUnder(BListItem *item, BListItem *superitem)
These functions add an item to the list. AddItem() adds the item at index--where the index counts all items assigned to the BOutlineListView--or, if an index isn't specified, at the end of the list. The two versions of this function override their BListView counterparts to ensure that the item is correctly entered into the outline. If the item is added to a portion of the list that is collapsed, it won't be visible.
AddUnder() adds an item immediately after another item in the list and at one outline level deeper. The level of the item is modified accordingly. Thus, the item already in the list becomes the superitem for the newly added item. If its new superitem is collapsed or is in a collapsed part of the list, the item will not be visible.
Unlike AddUnder(), AddItem() respects the outline level of the item. By setting the item's level before calling AddItem(), you can add it as a subitem to an item at a higher outline level or insert it as a superitem to items at a lower level.
See also: the BListItem class
virtual bool AddList(BList *newItems) virtual bool AddList(BList *newItems, int32 index)
Adds a group of items to the list just as AddItem() adds a single item. The index counts all items assigned to the BOutlineListView. The newItems BList must contain pointers to BListItem objects.
See also: BListView::AddList()
virtual status_t Archive(BMessage *archive, bool deep = true) const
Archives the BOutlineListView object much as the Archive() function in the BListView class does, but makes sure that all items are archived, including items in collapsed sections of the list, when the deep flag is true.
See also: BListView::Archive(), Instantiate() static function
void Collapse(BListItem *item) void Expand(BListItem *item)
These functions collapse and expand the section of the list controlled by the item superitem. If item isn't a superitem, it is nevertheless flagged as expanded or collapsed so that it will behave appropriately in case it does become a superitem.
See also: BListItem::SetExpanded()
int32 FullListCountItems(void) const int32 FullListCurrentSelection(int32 index = 0) const BListItem *FullListFirstItem(void) const BListItem *FullListLastItem(void) const int32 FullListIndexOf(BPoint point) const int32 FullListIndexOf(BListItem *item) const BListItem *FullListItemAt(int32 index) const bool FullListHasItem(BListItem *item) const bool FullListIsEmpty(void) const void FullListDoForEach(bool (*func)(BListItem *)) void FullListDoForEach(bool (*func)(BListItem *, void *), void *)
These functions parallel a similar set of functions defined in the BListView class. The BListView functions have identical names, but without the FullList... prefix. When applied to a BOutlineListView object, the inherited functions consider only items in sections of the outline that can be displayed on-screen--that is, they skip over items in collapsed portions of the list.
These BOutlineListView functions, on the other hand, consider all items in the list. For example, IndexOf() and FullListIndexOf() both return an index to a given item. However, for IndexOf() the index is to the position of the item in the list that can be currently displayed, but for FullListIndexOf() it's to the item's position in the full list, including collapsed sections.
bool IsExpanded(int32 index)
Returns true if the item at index is marked as controlling an expanded section of the list, and false if it's marked as controlling a collapsed section or if there's no item at that index. If a superitem is expanded, the BOutlineListView can display its subitems; if not, the subitems are hidden.
The index passed to this function is to the full list of items assigned to the BOutlineListView.
See also: BListItem::IsExpanded()
virtual void KeyDown(const char *bytes, int32 numBytes)
Augments the inherited version of KeyDown() to allow users to navigate the outline hierarchy using the arrow keys and to expand or collapse sections of the outline using Control-arrow key combinations.
See also: BListView::KeyDown()
virtual void MakeEmpty(void)
Overrides the BListView version of MakeEmpty() to remove all items from the list. The BListView version of this function won't work as advertised on a BOutlineListView.
See also: BListView::MakeEmpty()
virtual void MouseDown(BPoint point)
Augments the inherited version of MouseDown() to permit users to expand and collapse sections of the outline by clicking on an item's latch.
See also: BView::MouseDown()
virtual bool RemoveItem(BListItem *item) virtual BListItem *RemoveItem(int32 index) virtual bool RemoveItems(int32 index, int32 count)
These functions work like their BListView counterparts, except that:
Note: The BListView versions of these functions will not produce reliable results when applied to a BOutlineListView, even if the item being removed is in an expanded section of the list and is not a superitem.
See also: BListView::RemoveItem()
BListItem *Superitem(const BListItem *item)
Returns the superitem for the item passed as an argument--that is, the item under which the argument item is grouped--or NULL if the item is at the outermost level of the outline (level 0) or isn't in the list.
The Be Book, in lovely HTML, for the BeOS Preview Release.
Copyright © 1997 Be, Inc. All rights reserved.
Be is a registered trademark; BeOS, BeBox, BeWare, GeekPort, the Be logo, and the BeOS logo are trademarks of Be, Inc.
Last modified September 18, 1997.