Home |
Class PegTreeNode HMI (Human-Machine Interface) Classes |
Class PegTreeNodePegTreeNode, derived from PegTextThing, is used to populate a PegTreeView container window. Each PegTreeNode must have an associated text string. Each node may also have a bitmap or thumbnail associated with it. If a bitmap is specified, the bitmap is displayed to the left of the text for that node. The same bitmap can be used for any number of nodes. The bitmaps associated with each node do not have all be the same size. The bitmaps associated with each node are displayed such that they are horizontally centered. Also, the bitmaps can be of any height and width. A pleasing display is usually created using bitmaps of between 12x12 and 20x20 pixels. PegTreeNode objects are displayed in the order they are added to the parent node. The model for programming PegTreeView is very similar to the general PEG programming model, since in both cases you are working with tree structured lists of objects. class PegTreeNode : public PegTextThing { public: PegTreeNode(const PEGCHAR * Text, PegBitmap * map = NULL); void Add(PegTreeNode * Child); void Insert(PegTreeNode * Sib); int BranchHeight(PegTreeView * Parent); int NodeHeight(PegTreeView * Parent); int BranchWidth(PegTreeView * Parent); int NodeWidth(PegTreeView * Parent); void SetMap(PegBitmap * pMap; PegBitmap * GetMap(void); PegTreeNode * First(void); PegTreeNode * Next(void); PegTreeNode * Parent(void); void SetParent(PegTreeNode * pNode); PegTreeNode * Above(void); PegTreeNode * Below(void); PegTreeNode * Bottom(void); void SetFirst(PegTreeNode * pFirst); void SetNext(PegTreeNode * pNext); void MoveToTop(PegTreeNode * pChild); int Count(void); void Open(void); void Close(void); BOOL IsOpen(void); void SetSelected(BOOL bSelected); BOOL IsSelected(void); PegRect mPos; }; Demo program TreeView uses this class. ConstructorThe text string must be valid, while the bitmap is optional. Method AboveReturns a pointer to the node above the current node. This may be the parent of the current node if no higher siblings exist. Method AddAdds Child to the current node. Method BelowReturns a pointer to the node immediately below the current node. This may be the parent of the next group of nodes if no further nodes exist below the current node. Method BottomReturns the last node in the current group of nodes. Method BranchHeightReturns the height of the current branch, factoring in all child node heights if the current branch is open. Method BranchWidthReturns the width, in pixels, of the current branch. This includes the bitmap width (if any) and the text string width. Method CloseCloses the current node. If the node has children, they are not displayed. Method CountReturns the number of children owned by the current node. Method DestroyRemoves and deletes the indicated node. Method FirstReturns the first child node of the current node, or NULL if the current node has no children. Method GetMapReturns the bitmap associated with the node, or NULL. Method InsertInserts a new node beneath the current node. This may push other nodes down. Method IsOpenReturns TRUE if the current node is open and has children, else FALSE. Method IsSelectedReturns TRUE if the current node is selected, else FALSE. Method MoveToTopSlides the current node to the top of its siblings, thus becoming the first child of the parent node. Method NextReturns the following sibling of the current node, or NULL. Method NodeHeightReturns the height of the current node, in pixels. This function does not include the height of any child nodes. Method NodeWidthReturns the width, in pixels, of the current node. This includes the bitmap width (if any) and the text string width. Method OpenForces the node to open and display any children. Method ParentReturns the parent of the current node, or NULL if the current node is the treeview top node. Method RemoveRemoves Child from the current node. Method SetFirstAssigns the first child of the current node to be pFirst. This function is generally only used by PegTreeView. Method SetMapAssigns the bitmap associated with a given node. This function can be called at any time, allowing the system software to change the bitmap associated with a node based on the node state. Method SetNextAssigns the next node associated with the current node. This function is generally only used by PegTreeView. Method SetParentAssigns the parent of the current node. This function is generally only used by PegTreeView. Method SetSelectedForces the current node to become and display itself as selected. ExamplePlease refer to PegTreeView for instance and programming examples.
|