[Previous] [Contents] [Index] [Next]


PtGenTree item structure


typedef struct Pt_gentree_item {
    PtGenListItem_t list;
    struct Pt_gentree_item *father, 
    PhDim_t dim;
    } PtGenTreeItem_t;


This data structure describes an item in a PtGenTree widget.

Note: Applications should view this as a read-only structure; subclasses usually define ways to modify PtGenTreeItem_t members.

The members include at least:

A structure that describes a generic-list item. This structure includes state information for the item (whether or not it's selected, the current item, damaged, out of view, and so on), its size, and links to other generic-list items. For more information, see PtGenListItem_t.

The PtGenTree class defines some new flags that can be set in item->list.flags:

The item can be expanded:
  • It has a [+] or [-] button (unless the widget disables the buttons by setting Pt_TREE_HAS_BUTTONS or Pt_TREE_ROOT_LINES in its Pt_ARG_TREE_FLAGS resource).
  • It reacts to the Right and Left arrow keys by attempting to expand or collapse itself (which, again, can be disabled by a subclass).

The setting of this flag is preserved when the item is added to a widget. This flag is usually set in the parent item automatically when you add a branch to an item.

This flag isn't cleared when all the child items are deleted. You can clear this flag in your code, but:

  • Make sure the item is collapsed before clearing the flag.
  • Call PgGenTreeDamageItem() afterward to cause the item to be redrawn.
The branches of this item are currently on display.

If the Pt_TREE_ITEM_EXPANDABLE flag is set when the item is added to a widget, the setting of Pt_TREE_ITEM_EXPANDED flag is preserved; if Pt_TREE_ITEM_EXPANDABLE isn't set, this flag is cleared.

Once the item is in a widget, don't set or clear this flag; use the convenience functions instead.

father, son, brother
Tree links. You can use them to traverse the tree structure, but don't modify them directly - use the convenience functions to modify the tree structure.
The size of the item, excluding the tree ornaments (lines and button).

When an item is added to the widget, the widget calculates item->list.size based on the size specified in item->dim, the minimum height of the item, and the item's position in the tree. The height of an item in a tree widget is always an even number of pixels - if you specify an odd number for the height in the dim field, a gap of at least one pixel will be displayed between the current item and any other item directly below.



See also:

PtGenList, PtGenListItem_t, PtGenTree, PtTreeItem_t

Building Custom Widgets

[Previous] [Contents] [Index] [Next]