TreeItem, Base item that can be added to a TreeList
A TreeItem is an item that can be displayed in a TreeList. A TreeItem is heavily dependent on the TreeList class. TreeItems control the behaviours that vary from item to item. List wide behaviours are the perogative of the TreeList class.TreeList assumes all it's items are TreeItems, but you can derive from this to get notifications, add your own data and overide methods. It is done this way so that trees that contain different types of items do not have to spend time switching on the item type.
I could achieve the same with Addchild, but AddSibling is often useful when the only context is that I want to add an item after the current one (as happens often when adding items to a list).
As an example, by calling "item->FindChild(&TreeItem::isCollapsed)" one can get a pointer to the first collapsed child.
A good size of icon to return is a MiniIcon, although other sizes are fine and may be used to good effect if the item height is changed.
If this function returns 0 no icon will be displayed and the item text will be moved over to fill the space that would have been occupied otherwise.
Normally selection is displayed using a dimmed form of the icon, a static helper function, CreateDimBitmap is available to create such a bitmap.
The important subtlety here is that by overiding this you can display a sparse tree. This is a tree where not all the children are actually held in the tree, only the visbile childre need be around. This may be very useful when displaying a very large list, for example a file tree. As long as this function tells whether the item <I>may</I> have children or not, the actual TreeItem children need only be created when the item is exploded, and the children can be freed again when the item is collapsed.
This is virtual for a mainly internal reason. A TreeList control accesses all its items through a special internal derivation of a TreeItem (this is a little like the root view that is part of a BWindow I guess). Base class TreeItems return the Parents Owner, of NIL if they do not have a Parent. The special root Item in the TreeList "knows" to return a pointer to the TreeList.
I cannot think of a good reason for user derived classes to overide this function.
This does NOT clear the list before the addition. This function only considers descendants, not the item itself.
In derived items that have custom drawing routines, this method will probably need to be overridden to ensure that mouse-clicks work correctly.
The base class implementation simply invokes TreeList::Notify to pass on the event, so be careful when overiding to decide whether or not you want to send these notification.
The integer parameter defines what happened. Values are defined in the enumeration TreeList::EventTypes. You will only see selection events right now. Derived classes can augment this with other values.
The TreeList Control Documentation, HTML Edition, for Release 1.1d8 of the Be OS.
Copyright © 1996 Designer Logic (xyzzy). All rights reserved.
Be, the Be logo, BeBox, Be OS, Be Operating System, and GeekPort are trademarks of Be, Inc.
Last modified December 31, 1996.
generated by doc++