[Classes] [Prev] [Next] [Methods]


Methods Index

Protected Data Members
Public Methods
Constructor and Destructor Methods
Access Methods
User Support Methods
Protected Methods



Superclass: CNotifier

Subclass: CTreeNodeItem

Helper Classes : CTreeStringSorter, CTreeSource, CTreeItemInfo


CTreeItem and CTreeNodeItem represent the nodes and leaves of a CTreeView object. CTreeItems share a set of attributes maintained by the CTreeView attribute factory.


All access to CTreeItem attributes are through the Set/Get methods. For example, to set some attributes on the root node of a tree view -

Set methods taking const pointers, such as SetImage, do not assume ownership. Therefore, the objects passed to these methods must be maintained for the life of the tree view and should be destroyed after the tree view is destroyed.

Tree traversal is done with GetParent()/GetChild().

Tree data sources create tree items by populating a CTreeItemInfo and calling one of the CTreeView Factory Methods. Callback tree data sources need only supply a list of CTreeItemInfo when a node is expanded. For example, see . . ./samples/arch/dyntree.

You can also build a static tree by providing all of the tree data up front and not using a tree source. See . . ./samples/arch/stattree for an example of this approach.

Providing an object of type CTreeSorter to SortChildren() sorts the children of the given node and retains the sorter as the rule for adding in children. CTreeStringSorter is a convenience class for sorting items alpha based on any field. (Tree items can optionally use tabbed strings which divide each item into fields.) For example, to sort the entire tree based on the third field of each item (string compare) use the following code.

CStringSorter aSorter(3);

Note that if you set a sorter, the sorter must exist as long as the tree view. In other words, you should not delete the sorter until deleting the tree view.

Protected Data Members

const CTreeAttributes* itsAttributes; Attributes (shared).
CTreeNodeItem* itsParent; The parent node.
RWCollectable* itsUserData; User data, if any.
CStringRW itsString; Tabbed string associated with this item.

Public Methods

Constructor and Destructor Methods

CTreeItem(CTreeNodeItem* theParent, 
const CTreeAttributes* theAttributes);
virtual ~CTreeItem();

Access Methods

virtual const CFont& SetFont(const CFont& theFont);
virtual COLOR SetColor(COLOR theColor);
virtual UNITS SetHeight(UNITS theHeight);
virtual UNITS SetIndent(UNITS theIndent);
virtual CStringRW SetString(
const CStringRW& theString);
virtual const CImage* SetImage(
const CImage* theImage);
virtual const CImage* SetCollapsedImage(
const CImage* theImage);
virtual const CImage* SetExpandedImage(
const CImage* theImage);
virtual const CTabSet* SetTabSet(
const CTabSet* theTabSet);
virtual const CTreeSource* SetSource(
const CTreeSource* theSource);
const CFont& GetFont() const;
COLOR GetColor() const;
UNITS GetHeight() const;
UNITS GetIndent() const;
CStringRW GetString() const;
const CImage* GetImage() const;
virtual const CImage* GetCollapsedImage() const;
virtual const CImage* GetExpandedImage() const;
const CTabSet* GetTabSet() const;
CTabSet* GetTabSet();
const CTreeSource* GetSource() const;
const CTreeNodeItem* GetParent() const;
CTreeNodeItem* GetParent();

User Support Methods

const RWCollectable* GetUserData() const;
RWCollectable* GetUserData();
void SetUserData(RWCollectable* theData);
virtual unsigned long GetNChildren() const;
virtual unsigned long GetNVisibleChildren() const;
virtual const CTreeItem* GetChild(unsigned long i) const;
virtual CTreeItem* GetChild(unsigned long i);
virtual UNITS GetCompositeHeight() const;
virtual void SortChildren(
const CTreeSorter* theSorter,
BOOLEAN theRecursive = TRUE);
virtual int compareTo(const RWCollectable*) const;
virtual void Expand(BOOLEAN theRecurse = FALSE, 
BOOLEAN theRefresh = FALSE);
virtual void Collapse(BOOLEAN theRecurse = FALSE);
virtual BOOLEAN IsTerminal() const;
virtual CTreeItemInfoInfo() const;

Protected Methods

CTreeItem(const CTreeItem& theCopy) { }
CTreeItem& operator=(
const CTreeItem& theCopy) { return *this; }

[Classes] [Prev] [Next] [Methods]


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.