Class XbpTreeViewItem() Foundation

Class function of the XbpTreeViewItem class.

Superclass
Description

Instances of the XbpTreeViewItem class manage a single item within a tree structure (tree view). These objects are highly specialized and can only be used in conjunction with an XbpTreeView object. An XbpTreeViewItem object provides data for displaying an item while the XbpTreeView object manages the screen and lets the user navigate through the tree view.

When an item is displayed, text can be combined with graphic information such as bitmap or icon. If an image is displayed, it must be supplied as a resource linked to an executable file (EXE or DLL). The graphic information is used to visualize three possible states of an XbpTreeViewItem object: normal, marked and expanded. The "expanded" state is given when sub-items of an XbpTreeViewItem object are visible.

Within a tree view, an XbpTreeViewItem object is used for both "node" and "leaf". A node branches to a sub-level in the tree which means that it contains additional XbpTreeViewItem objects which display data of the sub-level.

The creation of an XbpTreeViewItem object can be done using the usual pattern for Xbase Parts: :new(), configuration and :create(). However, the method :addItem() provides a simplified way to create such objects. It accepts as parameters the configuration data for a new XbpTreeViewItem object and executes the methods:new() and :create() implicitly. Therefore, an entire tree view can be build solely by using the :addItem() method.

Class methods
:new()
Creates an instance of the XbpTreeViewItem class.
Configuration
:caption
Text to be displayed as caption.
:dllName
Name of the DLL file containing icons or bitmaps
:expandedImage
Resource ID, XbpBitmap or XbpIcon object of the bitmap or icon which indicates the expanded state.
:image
Resource ID, XbpBitmap or XbpIcon object of the bitmap or icon which indicates the normal state.
:markedImage
Resource ID, XbpBitmap or XbpIcon object of the bitmap or icon which indicates the marked state.
Life cycle
:create()
Requests system resources for the XbpTreeViewItem object.
:destroy()
Releases the system resources of the XbpTreeViewItem object.
Display methods
:expand()
Displays or hides sub-items of an XbpTreeViewItem object.
:isExpanded()
Determines whether or not sub-items are visible.
:setCaption()
Specifies a new caption.
:setExpandedImage()
Specifies a new image representing the expanded state.
:setImage()
Specifies a new image for the tree view item.
:setMarkedImage()
Specifies a new image representing the marked state.
Editing
:getData()
Returns the value associated with an XbpTreeViewItem object
:setData()
Associates a value with the XbpTreeViewItem object.
Item Management
:addItem()
Adds a new item (leaf) to a tree node.
:delItem()
Deletes an item from a sub-level.
:getChildItems()
Returns all items of a sub-level
:getParentItem()
Returns the item of the next-higher level (a node item).
:insItem()
Inserts a new item (leaf) to the next sub-level.
Examples
Building a tree view

// The example demonstrates the basic process for 
// building a tree view. 

#include "Appevent.ch" 

PROCEDURE Main 
   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL oTree, oItem1, oItem2 

   oTree := XbpTreeView():new( ,, {0,0}, {640,400} ) 

   oTree:hasLines   := .T. 
   oTree:hasButtons := .T. 
   oTree:create() 

   oItem1 := oTree:rootItem:addItem( "First level A" ) 
   oTree:rootItem:addItem( "First level B" ) 

   oItem2 := oItem1:addItem( "Second level A" ) 

   oItem1:addItem( "Second level B" ) 

   oItem2:addItem( "Third level A" ) 
   oItem2:addItem( "Third level B" ) 
   oItem2:addItem( "Third level C" ) 

   DO WHILE nEvent <> xbeP_Close 
      nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
      oXbp:handleEvent( nEvent, mp1, mp2 ) 
   ENDDO 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.