Package wx :: Package lib :: Module customtreectrl

[frames | no frames]

## Module wx.lib.customtreectrl

    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 3 more styles to handle checkbox-type items:
      - TR_AUTO_CHECK_CHILD : automatically checks/unchecks the item children;
      - TR_AUTO_CHECK_PARENT : automatically checks/unchecks the item parent;
      - 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 @ 02 Mar 2007, 22.30 CET
    Version 0.9

Classes
`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.

Function Summary
| ``DrawTreeItemButton`(win, dc, rect, flags)` A simple replacement of wx.RendererNative.DrawTreeItemButton.
| ``EventFlagsToSelType`(style, shiftDown, ctrlDown)` 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.

Variable Summary
`str` | `__version__` = `'0.8'`
`PyEventBinder` | `EVT_TREE_BEGIN_DRAG` = `<wx._core.PyEventBinder object at ...`
`PyEventBinder` | `EVT_TREE_BEGIN_LABEL_EDIT` = `<wx._core.PyEventBinder obje...`
`PyEventBinder` | `EVT_TREE_BEGIN_RDRAG` = `<wx._core.PyEventBinder object at...`
`PyEventBinder` | `EVT_TREE_DELETE_ITEM` = `<wx._core.PyEventBinder object at...`
`PyEventBinder` | `EVT_TREE_END_DRAG` = `<wx._core.PyEventBinder object at 0x...`
`PyEventBinder` | `EVT_TREE_END_LABEL_EDIT` = `<wx._core.PyEventBinder object...`
`PyEventBinder` | `EVT_TREE_GET_INFO` = `<wx._core.PyEventBinder object at 0x...`
`PyEventBinder` | `EVT_TREE_ITEM_ACTIVATED` = `<wx._core.PyEventBinder object...`
`PyEventBinder` | `EVT_TREE_ITEM_CHECKED` = `<wx._core.PyEventBinder object a...`
`PyEventBinder` | `EVT_TREE_ITEM_CHECKING` = `<wx._core.PyEventBinder object ...`
`PyEventBinder` | `EVT_TREE_ITEM_COLLAPSED` = `<wx._core.PyEventBinder object...`
`PyEventBinder` | `EVT_TREE_ITEM_COLLAPSING` = `<wx._core.PyEventBinder objec...`
`PyEventBinder` | `EVT_TREE_ITEM_EXPANDED` = `<wx._core.PyEventBinder object ...`
`PyEventBinder` | `EVT_TREE_ITEM_EXPANDING` = `<wx._core.PyEventBinder object...`
`PyEventBinder` | `EVT_TREE_ITEM_GETTOOLTIP` = `<wx._core.PyEventBinder objec...`
`PyEventBinder` | `EVT_TREE_ITEM_HYPERLINK` = `<wx._core.PyEventBinder object...`
`PyEventBinder` | `EVT_TREE_ITEM_MENU` = `<wx._core.PyEventBinder object at 0...`
`PyEventBinder` | `EVT_TREE_ITEM_MIDDLE_CLICK` = `<wx._core.PyEventBinder obj...`
`PyEventBinder` | `EVT_TREE_ITEM_RIGHT_CLICK` = `<wx._core.PyEventBinder obje...`
`PyEventBinder` | `EVT_TREE_KEY_DOWN` = `<wx._core.PyEventBinder object at 0x...`
`PyEventBinder` | `EVT_TREE_SEL_CHANGED` = `<wx._core.PyEventBinder object at...`
`PyEventBinder` | `EVT_TREE_SEL_CHANGING` = `<wx._core.PyEventBinder object a...`
`PyEventBinder` | `EVT_TREE_SET_INFO` = `<wx._core.PyEventBinder object at 0x...`
`PyEventBinder` | `EVT_TREE_STATE_IMAGE_CLICK` = `<wx._core.PyEventBinder obj...`
`int` | `TREE_HITTEST_ABOVE` = 1
`int` | `TREE_HITTEST_BELOW` = 2
`int` | `TREE_HITTEST_NOWHERE` = 4
`int` | `TREE_HITTEST_ONITEM` = 16464
`int` | `TREE_HITTEST_ONITEMBUTTON` = 8
`int` | `TREE_HITTEST_ONITEMCHECKICON` = 16384
`int` | `TREE_HITTEST_ONITEMICON` = 16
`int` | `TREE_HITTEST_ONITEMINDENT` = 32
`int` | `TREE_HITTEST_ONITEMLABEL` = 64
`int` | `TREE_HITTEST_ONITEMLOWERPART` = 4096
`int` | `TREE_HITTEST_ONITEMRIGHT` = 128
`int` | `TREE_HITTEST_ONITEMSTATEICON` = 256
`int` | `TREE_HITTEST_ONITEMUPPERPART` = 2048
`int` | `TREE_HITTEST_TOLEFT` = 512
`int` | `TREE_HITTEST_TORIGHT` = 1024
`int` | `wxEVT_TREE_BEGIN_DRAG` = 10019
`int` | `wxEVT_TREE_BEGIN_LABEL_EDIT` = 10021
`int` | `wxEVT_TREE_BEGIN_RDRAG` = 10020
`int` | `wxEVT_TREE_DELETE_ITEM` = 10023
`int` | `wxEVT_TREE_END_DRAG` = 10036
`int` | `wxEVT_TREE_END_LABEL_EDIT` = 10022
`int` | `wxEVT_TREE_GET_INFO` = 10024
`int` | `wxEVT_TREE_ITEM_ACTIVATED` = 10033
`int` | `wxEVT_TREE_ITEM_CHECKED` = 10297
`int` | `wxEVT_TREE_ITEM_CHECKING` = 10296
`int` | `wxEVT_TREE_ITEM_COLLAPSED` = 10028
`int` | `wxEVT_TREE_ITEM_COLLAPSING` = 10029
`int` | `wxEVT_TREE_ITEM_EXPANDED` = 10026
`int` | `wxEVT_TREE_ITEM_EXPANDING` = 10027
`int` | `wxEVT_TREE_ITEM_GETTOOLTIP` = 10038
`int` | `wxEVT_TREE_ITEM_HYPERLINK` = 10298
`int` | `wxEVT_TREE_ITEM_MENU` = 10039
`int` | `wxEVT_TREE_ITEM_MIDDLE_CLICK` = 10035
`int` | `wxEVT_TREE_ITEM_RIGHT_CLICK` = 10034
`int` | `wxEVT_TREE_KEY_DOWN` = 10032
`int` | `wxEVT_TREE_SEL_CHANGED` = 10030
`int` | `wxEVT_TREE_SEL_CHANGING` = 10031
`int` | `wxEVT_TREE_SET_INFO` = 10025
`int` | `wxEVT_TREE_STATE_IMAGE_CLICK` = 10037

Function Details

### 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.

### 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. If the pixel matches the maskcolor, it won't be changed.

Variable Details

### __version__

  Type:
    `str`
  Value:

        '0.8'

### EVT_TREE_BEGIN_DRAG

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb76744ac>

### EVT_TREE_BEGIN_LABEL_EDIT

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767428c>

### EVT_TREE_BEGIN_RDRAG

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb76744cc>

### EVT_TREE_DELETE_ITEM

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb76745cc>

### EVT_TREE_END_DRAG

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767472c>

### EVT_TREE_END_LABEL_EDIT

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767458c>

### EVT_TREE_GET_INFO

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767434c>

### EVT_TREE_ITEM_ACTIVATED

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb76746cc>

### EVT_TREE_ITEM_CHECKED

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb749a1ac>

### EVT_TREE_ITEM_CHECKING

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb749a16c>

### EVT_TREE_ITEM_COLLAPSED

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767462c>

### EVT_TREE_ITEM_COLLAPSING

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767464c>

### EVT_TREE_ITEM_EXPANDED

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb76745ec>

### EVT_TREE_ITEM_EXPANDING

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767460c>

### EVT_TREE_ITEM_GETTOOLTIP

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767476c>

### EVT_TREE_ITEM_HYPERLINK

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb749a1cc>

### EVT_TREE_ITEM_MENU

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767478c>

### EVT_TREE_ITEM_MIDDLE_CLICK

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767470c>

### EVT_TREE_ITEM_RIGHT_CLICK

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb76746ec>

### EVT_TREE_KEY_DOWN

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb76746ac>

### EVT_TREE_SEL_CHANGED

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767466c>

### EVT_TREE_SEL_CHANGING

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767468c>

### EVT_TREE_SET_INFO

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767456c>

### EVT_TREE_STATE_IMAGE_CLICK

  Type:
    `PyEventBinder`
  Value:

        <wx._core.PyEventBinder object at 0xb767474c>

### TREE_HITTEST_ABOVE

  Type:
    `int`
  Value:

        1

### TREE_HITTEST_BELOW

  Type:
    `int`
  Value:

        2

### TREE_HITTEST_NOWHERE

  Type:
    `int`
  Value:

        4

### TREE_HITTEST_ONITEM

  Type:
    `int`
  Value:

        16464

### TREE_HITTEST_ONITEMBUTTON

  Type:
    `int`
  Value:

        8

### TREE_HITTEST_ONITEMCHECKICON

  Type:
    `int`
  Value:

        16384

### TREE_HITTEST_ONITEMICON

  Type:
    `int`
  Value:

        16

### TREE_HITTEST_ONITEMINDENT

  Type:
    `int`
  Value:

        32

### TREE_HITTEST_ONITEMLABEL

  Type:
    `int`
  Value:

        64

### TREE_HITTEST_ONITEMLOWERPART

  Type:
    `int`
  Value:

        4096

### TREE_HITTEST_ONITEMRIGHT

  Type:
    `int`
  Value:

        128

### TREE_HITTEST_ONITEMSTATEICON

  Type:
    `int`
  Value:

        256

### TREE_HITTEST_ONITEMUPPERPART

  Type:
    `int`
  Value:

        2048

### TREE_HITTEST_TOLEFT

  Type:
    `int`
  Value:

        512

### TREE_HITTEST_TORIGHT

  Type:
    `int`
  Value:

        1024

### wxEVT_TREE_BEGIN_DRAG

  Type:
    `int`
  Value:

        10019

### wxEVT_TREE_BEGIN_LABEL_EDIT

  Type:
    `int`
  Value:

        10021

### wxEVT_TREE_BEGIN_RDRAG

  Type:
    `int`
  Value:

        10020

### wxEVT_TREE_DELETE_ITEM

  Type:
    `int`
  Value:

        10023

### wxEVT_TREE_END_DRAG

  Type:
    `int`
  Value:

        10036

### wxEVT_TREE_END_LABEL_EDIT

  Type:
    `int`
  Value:

        10022

### wxEVT_TREE_GET_INFO

  Type:
    `int`
  Value:

        10024

### wxEVT_TREE_ITEM_ACTIVATED

  Type:
    `int`
  Value:

        10033

### wxEVT_TREE_ITEM_CHECKED

  Type:
    `int`
  Value:

        10297

### wxEVT_TREE_ITEM_CHECKING

  Type:
    `int`
  Value:

        10296

### wxEVT_TREE_ITEM_COLLAPSED

  Type:
    `int`
  Value:

        10028

### wxEVT_TREE_ITEM_COLLAPSING

  Type:
    `int`
  Value:

        10029

### wxEVT_TREE_ITEM_EXPANDED

  Type:
    `int`
  Value:

        10026

### wxEVT_TREE_ITEM_EXPANDING

  Type:
    `int`
  Value:

        10027

### wxEVT_TREE_ITEM_GETTOOLTIP

  Type:
    `int`
  Value:

        10038

### wxEVT_TREE_ITEM_HYPERLINK

  Type:
    `int`
  Value:

        10298

### wxEVT_TREE_ITEM_MENU

  Type:
    `int`
  Value:

        10039

### wxEVT_TREE_ITEM_MIDDLE_CLICK

  Type:
    `int`
  Value:

        10035

### wxEVT_TREE_ITEM_RIGHT_CLICK

  Type:
    `int`
  Value:

        10034

### wxEVT_TREE_KEY_DOWN

  Type:
    `int`
  Value:

        10032

### wxEVT_TREE_SEL_CHANGED

  Type:
    `int`
  Value:

        10030

### wxEVT_TREE_SEL_CHANGING

  Type:
    `int`
  Value:

        10031

### wxEVT_TREE_SET_INFO

  Type:
    `int`
  Value:

        10025

### wxEVT_TREE_STATE_IMAGE_CLICK

  Type:
    `int`
  Value:

        10037

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