Description
===========
CustomTreeCtrl is a class that mimics the behaviour of wx.TreeCtrl, with almost the
same base functionalities plus some more enhancements. This class does not rely on
the native control, as it is a full owner-drawn tree control.
Apart of the base functionalities of CustomTreeCtrl (described below), in addition
to the standard wx.TreeCtrl behaviour this class supports:
* CheckBox-type items: checkboxes are easy to handle, just selected or unselected
state with no particular issues in handling the item's children;
* RadioButton-type items: since I elected to put radiobuttons in CustomTreeCtrl, I
needed some way to handle them, that made sense. So, I used the following approach:
- All peer-nodes that are radiobuttons will be mutually exclusive. In other words,
only one of a set of radiobuttons that share a common parent can be checked at
once. If a radiobutton node becomes checked, then all of its peer radiobuttons
must be unchecked.
- If a radiobutton node becomes unchecked, then all of its child nodes will become
inactive.
* Hyperlink-type items: they look like an hyperlink, with the proper mouse cursor on
hovering.
* Multiline text items.
* Enabling/disabling items (together with their plain or grayed out icons).
* Whatever non-toplevel widget can be attached next to an item.
* Default selection style, gradient (horizontal/vertical) selection style and Windows
Vista selection style.
* Customized drag and drop images built on the fly.
* Setting the CustomTreeCtrl item buttons to a personalized imagelist.
* Setting the CustomTreeCtrl check/radio item icons to a personalized imagelist.
* Changing the style of the lines that connect the items (in terms of wx.Pen styles).
* Using an image as a CustomTreeCtrl background (currently only in "tile" mode).
And a lot more. Check the demo for an almost complete review of the functionalities.
Base Functionalities
====================
CustomTreeCtrl supports all the wx.TreeCtrl styles, except:
- TR_EXTENDED: supports for this style is on the todo list (Am I sure of this?).
Plus it has 2 more styles to handle checkbox-type items:
- TR_AUTO_CHECK_CHILD : automatically checks/unchecks the item children;
- TR_AUTO_TOGGLE_CHILD: automatically toggles the item children.
All the methods available in wx.TreeCtrl are also available in CustomTreeCtrl.
Events
======
All the events supported by wx.TreeCtrl are also available in CustomTreeCtrl, with
a few exceptions:
- EVT_TREE_GET_INFO (don't know what this means);
- EVT_TREE_SET_INFO (don't know what this means);
- EVT_TREE_ITEM_MIDDLE_CLICK (not implemented, but easy to add);
- EVT_TREE_STATE_IMAGE_CLICK: no need for that, look at the checking events below.
Plus, CustomTreeCtrl supports the events related to the checkbutton-type items:
- EVT_TREE_ITEM_CHECKING: an item is being checked;
- EVT_TREE_ITEM_CHECKED: an item has been checked.
And to hyperlink-type items:
- EVT_TREE_ITEM_HYPERLINK: an hyperlink item has been clicked (this event is sent
after the EVT_TREE_SEL_CHANGED event).
Supported Platforms
===================
CustomTreeCtrl has been tested on the following platforms:
* Windows (Windows XP);
* GTK (Thanks to Michele Petrazzo);
* Mac OS (Thanks to John Jackson).
Latest Revision: Andrea Gavana @ 26 May 2006, 11.30 CET
Version 0.7
|
CommandTreeEvent |
CommandTreeEvent is a special subclassing of
wx.PyCommandEvent. |
CustomTreeCtrl |
|
DragImage |
This class handles the creation of a custom image in case of
item drag and drop. |
GenericTreeItem |
This class holds all the information and methods for every
single item in CustomTreeCtrl. |
TreeEvent |
|
TreeFindTimer |
Timer used to clear CustomTreeCtrl._findPrefix if no key was
pressed for a sufficiently long time. |
TreeItemAttr |
Creates the item attributes (text colour, background colour and
font). |
TreeRenameTimer |
Timer used for enabling in-place edit. |
TreeTextCtrl |
Control used for in-place edit. |
|
|
DrawTreeItemButton(win,
dc,
rect,
flags)
A simple replacement of wx.RendererNative.DrawTreeItemButton.
|
|
EventFlagsToSelType(style,
shiftDown=False,
ctrlDown=False)
Translate the key or mouse event flag to the type of selection we
are dealing with.
|
|
GetCheckedBitmap()
|
|
GetCheckedData()
|
|
GetCheckedImage()
|
|
GetFlaggedBitmap()
|
|
GetFlaggedData()
|
|
GetFlaggedImage()
|
|
GetNotCheckedBitmap()
|
|
GetNotCheckedData()
|
|
GetNotCheckedImage()
|
|
GetNotFlaggedBitmap()
|
|
GetNotFlaggedData()
|
|
GetNotFlaggedImage()
|
|
GrayOut(anImage)
Convert the given image (in place) to a grayed-out version,
appropriate for a 'disabled' appearance.
|
|
MakeGray((r, g, b),
factor,
maskColor)
Make a pixel grayed-out.
|
A simple replacement of wx.RendererNative.DrawTreeItemButton.
-
|
EventFlagsToSelType(style,
shiftDown=False,
ctrlDown=False)
| source code |
Translate the key or mouse event flag to the type of selection we are
dealing with.
-
|
Convert the given image (in place) to a grayed-out version,
appropriate for a 'disabled' appearance.
-
|
Make a pixel grayed-out. If the pixel matches the maskcolor, it won't
be changed.
-
|
EVT_TREE_BEGIN_DRAG
-
- Value:
<wx._core.PyEventBinder object at 0x01A28D10>
|
|
EVT_TREE_BEGIN_LABEL_EDIT
-
- Value:
<wx._core.PyEventBinder object at 0x01A28D50>
|
|
EVT_TREE_BEGIN_RDRAG
-
- Value:
<wx._core.PyEventBinder object at 0x01A28D30>
|
|
EVT_TREE_DELETE_ITEM
-
- Value:
<wx._core.PyEventBinder object at 0x01A28D90>
|
|
EVT_TREE_END_DRAG
-
- Value:
<wx._core.PyEventBinder object at 0x01A28F30>
|
|
EVT_TREE_END_LABEL_EDIT
-
- Value:
<wx._core.PyEventBinder object at 0x01A28D70>
|
|
EVT_TREE_GET_INFO
-
- Value:
<wx._core.PyEventBinder object at 0x01A28DB0>
|
|
EVT_TREE_ITEM_ACTIVATED
-
- Value:
<wx._core.PyEventBinder object at 0x01A28ED0>
|
|
EVT_TREE_ITEM_CHECKED
-
- Value:
<wx._core.PyEventBinder object at 0x00C965F0>
|
|
EVT_TREE_ITEM_CHECKING
-
- Value:
<wx._core.PyEventBinder object at 0x00C96430>
|
|
EVT_TREE_ITEM_COLLAPSED
-
- Value:
<wx._core.PyEventBinder object at 0x01A28E30>
|
|
EVT_TREE_ITEM_COLLAPSING
-
- Value:
<wx._core.PyEventBinder object at 0x01A28E50>
|
|
EVT_TREE_ITEM_EXPANDED
-
- Value:
<wx._core.PyEventBinder object at 0x01A28DF0>
|
|
EVT_TREE_ITEM_EXPANDING
-
- Value:
<wx._core.PyEventBinder object at 0x01A28E10>
|
|
EVT_TREE_ITEM_GETTOOLTIP
-
- Value:
<wx._core.PyEventBinder object at 0x01A28F70>
|
|
EVT_TREE_ITEM_HYPERLINK
-
- Value:
<wx._core.PyEventBinder object at 0x00C96730>
|
|
EVT_TREE_ITEM_MENU
-
- Value:
<wx._core.PyEventBinder object at 0x01A28F90>
|
|
EVT_TREE_ITEM_MIDDLE_CLICK
-
- Value:
<wx._core.PyEventBinder object at 0x01A28F10>
|
|
EVT_TREE_ITEM_RIGHT_CLICK
-
- Value:
<wx._core.PyEventBinder object at 0x01A28EF0>
|
|
EVT_TREE_KEY_DOWN
-
- Value:
<wx._core.PyEventBinder object at 0x01A28EB0>
|
|
EVT_TREE_SEL_CHANGED
-
- Value:
<wx._core.PyEventBinder object at 0x01A28E70>
|
|
EVT_TREE_SEL_CHANGING
-
- Value:
<wx._core.PyEventBinder object at 0x01A28E90>
|
|
EVT_TREE_SET_INFO
-
- Value:
<wx._core.PyEventBinder object at 0x01A28DD0>
|
|
EVT_TREE_STATE_IMAGE_CLICK
-
- Value:
<wx._core.PyEventBinder object at 0x01A28F50>
|
|
TREE_HITTEST_ABOVE
-
- Value:
|
TREE_HITTEST_BELOW
-
- Value:
|
TREE_HITTEST_NOWHERE
-
- Value:
|
TREE_HITTEST_ONITEM
-
- Value:
|
TREE_HITTEST_ONITEMBUTTON
-
- Value:
|
TREE_HITTEST_ONITEMCHECKICON
-
- Value:
|
TREE_HITTEST_ONITEMICON
-
- Value:
|
TREE_HITTEST_ONITEMINDENT
-
- Value:
|
TREE_HITTEST_ONITEMLABEL
-
- Value:
|
TREE_HITTEST_ONITEMLOWERPART
-
- Value:
|
TREE_HITTEST_ONITEMRIGHT
-
- Value:
|
TREE_HITTEST_ONITEMSTATEICON
-
- Value:
|
TREE_HITTEST_ONITEMUPPERPART
-
- Value:
|
TREE_HITTEST_TOLEFT
-
- Value:
|
TREE_HITTEST_TORIGHT
-
- Value:
|
TR_AUTO_CHECK_CHILD
-
- Value:
|
TR_AUTO_TOGGLE_CHILD
-
- Value:
|
TR_FULL_ROW_HIGHLIGHT
-
- Value:
|
TR_HAS_VARIABLE_ROW_HEIGHT
-
- Value:
|
TreeItemIcon_Checked
-
- Value:
|
TreeItemIcon_Expanded
-
- Value:
|
TreeItemIcon_Flagged
-
- Value:
|
TreeItemIcon_Normal
-
- Value:
|
TreeItemIcon_NotChecked
-
- Value:
|
TreeItemIcon_NotFlagged
-
- Value:
|
TreeItemIcon_Selected
-
- Value:
|
TreeItemIcon_SelectedExpanded
-
- Value:
|
wxEVT_TREE_BEGIN_DRAG
-
- Value:
|
wxEVT_TREE_BEGIN_LABEL_EDIT
-
- Value:
|
wxEVT_TREE_BEGIN_RDRAG
-
- Value:
|
wxEVT_TREE_DELETE_ITEM
-
- Value:
|
wxEVT_TREE_END_DRAG
-
- Value:
|
wxEVT_TREE_END_LABEL_EDIT
-
- Value:
|
wxEVT_TREE_GET_INFO
-
- Value:
|
wxEVT_TREE_ITEM_ACTIVATED
-
- Value:
|
wxEVT_TREE_ITEM_CHECKED
-
- Value:
|
wxEVT_TREE_ITEM_CHECKING
-
- Value:
|
wxEVT_TREE_ITEM_COLLAPSED
-
- Value:
|
wxEVT_TREE_ITEM_COLLAPSING
-
- Value:
|
wxEVT_TREE_ITEM_EXPANDED
-
- Value:
|
wxEVT_TREE_ITEM_EXPANDING
-
- Value:
|
wxEVT_TREE_ITEM_GETTOOLTIP
-
- Value:
|
wxEVT_TREE_ITEM_HYPERLINK
-
- Value:
|
wxEVT_TREE_ITEM_MENU
-
- Value:
|
wxEVT_TREE_ITEM_MIDDLE_CLICK
-
- Value:
|
wxEVT_TREE_ITEM_RIGHT_CLICK
-
- Value:
|
wxEVT_TREE_KEY_DOWN
-
- Value:
|
wxEVT_TREE_SEL_CHANGED
-
- Value:
|
wxEVT_TREE_SEL_CHANGING
-
- Value:
|
wxEVT_TREE_SET_INFO
-
- Value:
|
wxEVT_TREE_STATE_IMAGE_CLICK
-
- Value:
|