Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csTreeBox Class Reference

The csTreeBox class is a rectangle which contains a number of subrectangles, each of which is recursively similar to its parent. More...

#include <cstree.h>

Inheritance diagram for csTreeBox:

csComponent List of all members.

Public Methods

 csTreeBox (csComponent *iParent, int iStyle=CSTS_DEFAULTVALUE, csTreeFrameStyle iFrameStyle=cstfsThickRect)
 Create input line object.

virtual ~csTreeBox ()
 Destroy the tree box.

virtual bool HandleEvent (iEvent &Event)
 Handle external events and generate timeouts.

virtual void Draw ()
 Draw the tree.

void PlaceItems (int sbFlags=CSTS_HSCROLL|CSTS_VSCROLL)
 Find a place for each tree item, and optionally set scrollbar parameters.

virtual bool SetRect (int xmin, int ymin, int xmax, int ymax)
 Resize child items on parent window resize.

csTreeItemForEachItem (bool(*func)(csTreeItem *child, void *param), void *param=NULL, bool iOnlyOpen=false)
 For each tree item call a function with a optional arg Function returns the first child on which func returnes 'true'.

virtual void SetState (int mask, bool enable)
 Override SetState method to toggle scrollbars together with CSS_SELECTED.

virtual void Insert (csComponent *comp)
 Set fPlaceItems since a item has been inserted.

virtual void ExpandAll ()
 Expand all items.

virtual void CollapseAll ()
 Collapse all items.

int GetStyle ()
 Query tree box style.

csTreeFrameStyle GetFrameStyle ()
 Query tree box frame style.

void SetStyle (int iStyle, csTreeFrameStyle iFrameStyle)
 Change tree box style.

Protected Methods

void PrepareButton (csButton *iButton, bool iOpen)
 Set the imagess for expand/collapse button.

void MakeItemVisible (csComponent *iItem, bool iChildren=false)
 Make a tree item visible (the functionality for cscmdTreeMakeVisible).

void FocusItem (csTreeItem *iItem)
 Focus a item (and defocus all other items).

void VScroll (int iDelta, bool iMoveCaret)
 Scroll vertically by iDelta pixels, possibly preserving caret's relative Y.

void PlaceScrollbars ()
 Place scrollbars and the csTreeView.


class  csTreeItem

Detailed Description

The csTreeBox class is a rectangle which contains a number of subrectangles, each of which is recursively similar to its parent.

In other words, every tree item can contain a subtree itself. In very other words, the tree is a graph, every vertex of which has one incoming and several outgoing edges. The csTreeBox control can hold several trees at once (e.g. it can have several "roots"). csTreeBox control ALWAYS contains just one selected item at a time; multiple selection mode is not implemented (I don't see why this may be useful anyway).

Every csTreeItem that is inserted into the tree is queried for its preferred size (in particular its preffered height), and the next item is positioned at the bottom of every previous item. Every csTreeItem asks in turn all his child nodes (if the tree node is "open") or just returns its own height without child nodes.

Example code how to create a tree: csTreeBox *tree = new csTreeBox (app); tree->SetRect (0, 0, 200, 400); csTreeItem *item1, *item2, *item3; item1 = new csTreeItem (tree, "My Computer"); item2 = new csTreeItem (item1, "C:\"); item3 = new csTreeItem (item2, "Blindows"); item3 = new csTreeItem (item2, "Suxx"); item2 = new csTreeItem (item1, "D:\"); item3 = new csTreeItem (item2, "My Documents"); item3 = new csTreeItem (item2, "My Toys"); item3 = new csTreeItem (item2, "My Mom Told Me - Dont Run Windows"); item2 = new csTreeItem (item1, "\\SAMBA\RULEZ\FOREVER\"); item3 = new csTreeItem (item2, "Home directory"); item3 = new csTreeItem (item2, "Public stuff"); Keyboard navigation:

Select previous/next tree item
Scroll tree horizontally (if meaningful)
Scroll horizontally in big steps
Go to the previous/next page of the tree.
Show the previous/next page of the tree (does not move the caret).
Go to the first/last tree item
Scroll to left/right margin.
Scroll to the beginning/end of the tree (does not move the caret).
Expand/collapse current branch.
Ctrl+Keypad PLUS/MINUS
Expand/collapse all branches at once.
Shift+Keypad PLUS/MINUS
Expand/collapse all the items contained in the current branch.
Toggle expand/collapse current branch
Any other symbols
Find the next item that starts with given character. For example, pressing 'a' will find the first item following current which starts with 'A' or 'a'; if there is no one until the end of tree, the search is restarted from top; if there is no such item at all, the cursor stays still.

The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000