Package wx :: Package lib :: Package mixins :: Module treemixin :: Class VirtualTree

[frames | no frames]

## Type VirtualTree

           object --+
                    |
    TreeAPIHarmonizer --+
                        |
           object --+   |
                    |   |
           TreeHelper --+
                        |
                       VirtualTree

    This is a mixin class that can be used to allow for virtual tree
    controls. It can be mixed in with wx.TreeCtrl, wx.gizmos.TreeListCtrl,
    wx.lib.customtree.CustomTreeCtrl.

    To use it derive a new class from this class and one of the tree
    controls, e.g.:
    class MyTree(VirtualTree, wx.TreeCtrl):
        ...

    VirtualTree uses several callbacks (such as OnGetItemText) to
    retrieve information needed to construct the tree and render the
    items. To specify what item the callback needs information about,
    the callback passes an item index. VirtualTree supports two types of
    indices: a tuple-based index (the default) and an integer based index.
    See below for a more detailed explanation of the two index types.

    Note that VirtualTree forces the wx.TR_HIDE_ROOT style.

    In your subclass you *must* override OnGetItemText and either
    OnGetChildrenCount if you use the tuple-based index or
    OnGetChildrenIndices if you use the integer-based index. These
    methods are the minimum needed to construct the tree and render
    the item labels. If you want to add images, change fonts our colours,
    etc., you need to override the appropriate OnGetXXX method as well.

    About the index types: VirtualTree supports two types of indices that
    are passed to the several callbacks to retrieve information about
    items in the tree.  The default index type is tuple-based, the second
    type is integer-based.

    If you use tuple-based indices, your callbacks are passed a tuple of
    integers that identifies the item the VirtualTree wants information
    about. An empty tuple, i.e. (), represents the hidden root item.
    A tuple with one integer, e.g. (3,), represents a visible root item,
    in this case the fourth one. A tuple with two integers, e.g. (3,0),
    represents a child of a visible root item, in this case the first
    child of the fourth root item. The tuple-based index is best suited
    if your underlying data structure is organized as a tree and allows
    for easy navigation to the right object in your tree data structure.

    If you use integer-based indices, your callbacks are passed a simple
    integer (or None) that identifies the item the VirtualTree wants
    information about. None represents the hidden root item. Zero (0)
    represents the first visible root item. If the first visible root
    item has children 1 represents the first child of the first visible
    root item. If that child has children 2 represents the first grand
    child of the first visible root item. If the first child has no
    children, 2 would represent the second child of the first visible
    root item, etc. Basically, the integer is the row number of the item
    (when the tree is completely expanded). Integer-based indices are
    more convenient when your underlying data structure is organized as
    a list that is in the same order as the tree items in the tree need
    to be.

Method Summary
| `__init__(self, *args, **kwargs)`
| `ChildIndices(self, itemIndex)`
| ``OnGetChildrenCount`(self, tupleIndex)` This function must be overloaded in the derived class, if you use the tuple-based indices.
| ``OnGetChildrenIndices`(self, integerIndex)` This function must be overloaded in the derived class, if you want to use the integer-based index.
| ``OnGetItemBackgroundColour`(self, index)` This function may be overloaded in the derived class.
| ``OnGetItemChecked`(self, index)` This function may be overloaded in the derived class, but that only makes sense when this class is mixed in with a tree control that supports checkable items, i.e.
| ``OnGetItemFont`(self, index)` This function may be overloaded in the derived class.
| ``OnGetItemImage`(self, index, which, column)` This function may be overloaded in the derived class.
| ``OnGetItemText`(self, index, column)` This function must be overloaded in the derived class.
| ``OnGetItemTextColour`(self, index)` This function may be overloaded in the derived class.
| ``OnGetItemType`(self, index)` This function may be overloaded in the derived class, but that only makes sense when this class is mixed in with a tree control that supports checkable items, i.e.
| `OnItemCollapsed(self, event)`
| `OnItemExpanding(self, event)`
| `RefreshBackgroundColour(self, item, index)`
| `RefreshCheckedState(self, item, index)`
| ``RefreshChildrenRecursively`(self, item, itemIndex)` Refresh the children of item, reusing as much of the existing items in the tree as possible.
| `RefreshColumns(self, item, index)`
| ``RefreshItem`(self, item, index, hasChildren)` Refresh one item.
| `RefreshItemFont(self, item, index)`
| `RefreshItemImage(self, item, index, hasChildren)`
| ``RefreshItemRecursively`(self, item, itemIndex)` Refresh the item and its children recursively.
| ``RefreshItems`(self)` Redraws all visible items.
| `RefreshItemText(self, item, index)`
| `RefreshItemType(self, item, index)`
| `RefreshTextColour(self, item, index)`

Method Details

### OnGetChildrenCount(self, tupleIndex)

This function must be overloaded in the derived class, if you use the tuple-based indices. It should return the number of child items of the item with the provided tupleIndex. If tupleIndex == () it should return the number of root items.

### OnGetChildrenIndices(self, integerIndex=None)

This function must be overloaded in the derived class, if you want to use the integer-based index. The overridden method should return a list containing the (integer) indices of the children of the specified item.

### OnGetItemBackgroundColour(self, index)

This function may be overloaded in the derived class. It should return the wx.Colour to be used as background colour for the specified item.

### OnGetItemChecked(self, index)

This function may be overloaded in the derived class, but that only makes sense when this class is mixed in with a tree control that supports checkable items, i.e. CustomTreeCtrl. This method should return whether the item is to be checked. Note that OnGetItemType should return 1 (checkbox) or 2 (radiobutton) for this item.

### OnGetItemFont(self, index)

This function may be overloaded in the derived class. It should return the wx.Font to be used for the specified item.

### OnGetItemImage(self, index, which=0, column=0)

This function may be overloaded in the derived class. It should return the index of the image to be used. Don't forget to associate an ImageList with the tree control.

### OnGetItemText(self, index, column=0)

This function must be overloaded in the derived class. It should return the string containing the text of the specified item.

### OnGetItemTextColour(self, index)

This function may be overloaded in the derived class. It should return the wx.Colour to be used as text colour for the specified item.

### OnGetItemType(self, index)

This function may be overloaded in the derived class, but that only makes sense when this class is mixed in with a tree control that supports checkable items, i.e. CustomTreeCtrl. This method should return whether the item is to be normal (0, the default), a checkbox (1) or a radiobutton (2). Note that OnGetItemChecked needs to be implemented as well; it should return whether the item is actually checked.

### RefreshChildrenRecursively(self, item, itemIndex=None)

Refresh the children of item, reusing as much of the existing items in the tree as possible.

### RefreshItem(self, item, index, hasChildren)

Refresh one item.

### RefreshItemRecursively(self, item, itemIndex)

Refresh the item and its children recursively.

### RefreshItems(self)

Redraws all visible items.

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:13:37 2007 | http://epydoc.sf.net