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. Whereas for list controls a simple
integer index can be used, for tree controls indicating a specific
item is a little bit more complicated. See below for a more detailed 
explanation of the how index works.

Note that VirtualTree forces the wx.TR_HIDE_ROOT style.

In your subclass you *must* override OnGetItemText and 
OnGetChildrenCount. These two 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 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.

Method Summary
  __init__(self, *args, **kwargs)
  ChildIndices(self, itemIndex)
  DoRefreshItem(self, item, index, hasChildren)
Refresh one item.
  OnGetChildrenCount(self, index)
This function must be overloaded in the derived class.
  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, index)
Redraws the item with the specified index.
  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

DoRefreshItem(self, item, index, hasChildren)

Refresh one item.

OnGetChildrenCount(self, index)

This function must be overloaded in the derived class. It should return the number of child items of the item with the provided index. If index == () it should return the number of root items.

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, index)

Redraws the item with the specified index.

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 Mon Feb 16 12:52:31 2009 http://epydoc.sf.net