A tree list control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree list control are referenced by wxTreeItemId handles, which may be tested for validity by calling wxTreeItemId::IsOk().
To intercept events from a tree list control, use the event table macros described in wxTreeEvent (see below for a detailed description of events).
wxControl
wxWindow
wxEvtHandler
wxObject
wxListCtrl
wxTreeCtrl
<wx/treelistctrl.h>
wxTR_EDIT_LABELS | Use this style if you wish the user to be able to edit labels in the tree list control. |
wxTR_NO_BUTTONS | For convenience to document that no buttons are to be drawn. |
wxTR_HAS_BUTTONS | Use this style to show + and - buttons to the left of parent items. |
wxTR_TWIST_BUTTONS | Use this style to show Mac-style twister buttons to the left of parent items. If both wxTR_HAS_BUTTONS and wxTR_TWIST_BUTTONS are given, twister buttons are generated. |
wxTR_NO_LINES | Use this style to hide vertical level connectors. |
wxTR_FULL_ROW_HIGHLIGHT | Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree list control window. (This flag is ignored under Windows unless you specify wxTR_NO_LINES as well.) |
wxTR_LINES_AT_ROOT | Use this style to show lines between root nodes. Only applicable if wxTR_HIDE_ROOT is set and wxTR_NO_LINES is not set. |
wxTR_HIDE_ROOT | Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes. |
wxTR_ROW_LINES | Use this style to draw a contrasting border between displayed rows. |
xTR_HAS_VARIABLE_ROW_HEIGHT | Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset. |
wxTR_SINGLE | For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default. |
wxTR_MULTIPLE | Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected. |
wxTR_EXTENDED | Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases.) |
wxTR_DEFAULT_STYLE | The set of flags that are closest to the defaults for the native control for a particular toolkit. |
wxTR_VIRTUAL | The application provides items text on demand. |
See also window styles overview.
To process input from a tree list control, use these event handler macros to direct input to member functions that take a wxTreeEvent argument. In addition to the methods documented for wxTreeEvent, the method GetInt() will return the relevant column for mouse events (and -1 otherwise).
The sample program includes a log pane reporting events as they are fired.
EVT_TREE_BEGIN_DRAG(id, func) | Begin dragging with the left mouse button (see also note below). |
EVT_TREE_BEGIN_RDRAG(id, func) | Begin dragging with the right mouse button (see also note below). |
EVT_TREE_END_DRAG(id, func) | End dragging with the left or right mouse button (see also note below). |
EVT_TREE_BEGIN_LABEL_EDIT(id, func) | Begin editing a label. This can be prevented by calling Veto(). |
EVT_TREE_END_LABEL_EDIT(id, func) | Finish editing a label. This can be prevented by calling Veto(). |
EVT_TREE_DELETE_ITEM(id, func) | Delete an item. |
EVT_TREE_GET_INFO(id, func) | -----NOT IMPLEMENTED----- |
EVT_TREE_SET_INFO(id, func) | -----NOT IMPLEMENTED----- |
EVT_TREE_ITEM_ACTIVATED(id, func) | The item has been activated, i.e. chosen by double clicking it with mouse or from keyboard. |
EVT_TREE_ITEM_COLLAPSED(id, func) | The item has been collapsed. |
EVT_TREE_ITEM_COLLAPSING(id, func) | The item is being collapsed. This can be prevented by calling Veto(). |
EVT_TREE_ITEM_EXPANDED(id, func) | The item has been expanded. |
EVT_TREE_ITEM_EXPANDING(id, func) | The item is being expanded. This can be prevented by calling Veto(). |
EVT_TREE_ITEM_RIGHT_CLICK(id, func) | The user has clicked the item with the right mouse button (changes selection unless item is already selected or CTRL is pressed). |
EVT_TREE_ITEM_MIDDLE_CLICK(id, func) | The user has clicked the item with the middle mouse button (this does not change the selection). |
EVT_TREE_SEL_CHANGED(id, func) | Selection has changed. |
EVT_TREE_SEL_CHANGING(id, func) | Selection is changing. This can be prevented by calling Veto(). |
EVT_TREE_KEY_DOWN(id, func) | A key has been pressed. |
EVT_TREE_ITEM_GETTOOLTIP(id, func) | -----NOT IMPLEMENTED----- |
EVT_TREE_ITEM_MENU(id, func) | The context menu for the selected item has been requested by a right click (by using the menu key is untested). |
EVT_TREE_STATE_IMAGE_CLICK(id, func) | -----NOT IMPLEMENTED----- |
Note on drag & drop in the current implementation:
each control generates its own drag begin and end events;
when the mouse leaves the control, a drag end is fired;
when the mouse enters a control whilst already dragging, a drag begin is also fired
(this is just reflecting wxMouseEvent behavior).
To implement drag & drop over multiple windows, the application shoud only
process the first drag begin event and then wait for the mouse button to be
released.
wxTreeCtrl, wxTreeItemData, wxTreeEvent, wxListBox, wxListCtrl, wxImageList
wxTreeListCtrl::wxTreeListCtrl
wxTreeListCtrl::~wxTreeListCtrl
wxTreeListCtrl::AddRoot
wxTreeListCtrl::AppendItem
wxTreeListCtrl::AssignButtonsImageList
wxTreeListCtrl::AssignImageList
wxTreeListCtrl::AssignStateImageList
wxTreeListCtrl::Collapse
wxTreeListCtrl::CollapseAndReset
wxTreeListCtrl::Create
wxTreeListCtrl::Delete
wxTreeListCtrl::DeleteChildren
wxTreeListCtrl::DeleteRoot
wxTreeListCtrl::Edit
wxTreeListCtrl::EditLabel
wxTreeListCtrl::EnsureVisible
wxTreeListCtrl::Expand
wxTreeListCtrl::ExpandAll
wxTreeListCtrl::FindItem
wxTreeListCtrl::GetBoundingRect
wxTreeListCtrl::GetButtonsImageList
wxTreeListCtrl::GetChildrenCount
wxTreeListCtrl::GetCount
wxTreeListCtrl::GetFirstChild
wxTreeListCtrl::GetFirstVisibleItem
wxTreeListCtrl::GetHeaderWindow
wxTreeListCtrl::GetImageList
wxTreeListCtrl::GetIndent
wxTreeListCtrl::GetItemBackgroundColour
wxTreeListCtrl::GetItemData
wxTreeListCtrl::GetItemFont
wxTreeListCtrl::GetItemImage
wxTreeListCtrl::GetItemParent
wxTreeListCtrl::GetItemText
wxTreeListCtrl::GetItemTextColour
wxTreeListCtrl::GetLastChild
wxTreeListCtrl::GetLineSpacing
wxTreeListCtrl::GetMainWindow
wxTreeListCtrl::GetNext
wxTreeListCtrl::GetNextChild
wxTreeListCtrl::GetNextExpanded
wxTreeListCtrl::GetNextSibling
wxTreeListCtrl::GetNextVisible
wxTreeListCtrl::GetPrev
wxTreeListCtrl::GetPrevChild
wxTreeListCtrl::GetPrevSibling
wxTreeListCtrl::GetPrevVisible
wxTreeListCtrl::GetRootItem
wxTreeListCtrl::GetSelection
wxTreeListCtrl::GetSelections
wxTreeListCtrl::GetStateImageList
wxTreeListCtrl::GetWindowStyle
wxTreeListCtrl::GetWindowStyleFlag
wxTreeListCtrl::HasChildren
wxTreeListCtrl::HitTest
wxTreeListCtrl::InsertItem
wxTreeListCtrl::IsBold
wxTreeListCtrl::IsExpanded
wxTreeListCtrl::IsSelected
wxTreeListCtrl::IsVisible
wxTreeListCtrl::ItemHasChildren
wxTreeListCtrl::OnCompareItems
wxTreeListCtrl::OnGetItemText
wxTreeListCtrl::PrependItem
wxTreeListCtrl::Refresh
wxTreeListCtrl::SetBackgroundColour
wxTreeListCtrl::SetDragItem
wxTreeListCtrl::SetFocus
wxTreeListCtrl::SetFont
wxTreeListCtrl::SetForegroundColour
wxTreeListCtrl::SetWindowStyle
wxTreeListCtrl::ScrollTo
wxTreeListCtrl::SelectItem
wxTreeListCtrl::SetButtonsImageList
wxTreeListCtrl::SetImageList
wxTreeListCtrl::SetIndent
wxTreeListCtrl::SetItemBackgroundColour
wxTreeListCtrl::SetItemBold
wxTreeListCtrl::SetItemData
wxTreeListCtrl::SetItemFont
wxTreeListCtrl::SetItemHasChildren
wxTreeListCtrl::SetItemImage
wxTreeListCtrl::SetItemText
wxTreeListCtrl::SetItemTextColour
wxTreeListCtrl::SetLineSpacing
wxTreeListCtrl::SetStateImageList
wxTreeListCtrl::SortChildren
wxTreeListCtrl::Toggle
wxTreeListCtrl::Unselect
wxTreeListCtrl::UnselectAll
wxTreeListCtrl::AddColumn
wxTreeListCtrl::GetColumn
wxTreeListCtrl::GetColumnAlignment
wxTreeListCtrl::GetColumnCount
wxTreeListCtrl::GetColumnImage
wxTreeListCtrl::GetColumnText
wxTreeListCtrl::GetColumnWidth
wxTreeListCtrl::GetMainColumn
wxTreeListCtrl::InsertColumn
wxTreeListCtrl::IsColumnShown
wxTreeListCtrl::RemoveColumn
wxTreeListCtrl::SetColumn
wxTreeListCtrl::SetColumnAlignment
wxTreeListCtrl::SetColumnImage
wxTreeListCtrl::SetColumnText
wxTreeListCtrl::SetColumnWidth
wxTreeListCtrl::SetMainColumn
wxTreeListCtrl::ShowColumn
wxTreeListCtrl::GetItemBold
wxTreeListCtrl()
Default constructor.
wxTreeListCtrl (wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "treelistctrl")
Constructor, creating and showing a tree list control.
Parameters
parent
id
pos
size
style
validator
name
See also
wxTreeListCtrl::Create, wxValidator
void ~wxTreeListCtrl()
Destructor, destroying the list control.
wxTreeItemId AddRoot (const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
Adds the root node to the tree, returning the new item.
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
wxTreeItemId AppendItem (const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
Appends an item to the end of the branch identified by parent, return a new item id.
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
void AssignButtonsImageList (wxImageList* imageList)
Sets the buttons image list. The button images assigned with this method will be automatically deleted by wxTreeListCtrl as appropriate (i.e. it takes ownership of the list).
Setting or assigning the button image list enables the display of image buttons. Once enabled, the only way to disable the display of button images is to set the button image list to NULL.
This function is only available in the generic version.
See also SetButtonsImageList.
void AssignImageList (wxImageList* imageList)
Sets the normal image list. Image list assigned with this method will be automatically deleted by wxTreeListCtrl as appropriate (i.e. it takes ownership of the list).
See also SetImageList.
void AssignStateImageList (wxImageList* imageList)
Sets the state image list. Image list assigned with this method will be automatically deleted by wxTreeListCtrl as appropriate (i.e. it takes ownership of the list).
See also SetStateImageList.
void Collapse (const wxTreeItemId& item)
Collapses the given item.
void CollapseAndReset (const wxTreeItemId& item)
Collapses the given item and removes all children.
bool wxTreeListCtrl (wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
Creates the tree list control. See wxTreeListCtrl::wxTreeListCtrl for further details.
void Delete (const wxTreeItemId& item)
Deletes the specified item (except the root). EVT_TREE_DELETE_ITEM events will be generated.
This function may cause a subsequent call to GetNextChild() to fail.
void DeleteChildren (const wxTreeItemId& item)
Deletes all children of the given item (but not the item itself). EVT_TREE_DELETE_ITEM events will be generated.
If you have called SetItemHasChildren(), you may need to call it again since DeleteChildren() does not automatically clear the setting.
void DeleteRoot()
Deletes the root node of the tree and all its children. EVT_TREE_DELETE_ITEM events will be generated.
void Edit (const wxTreeItemId& item)
The same as EditLabel().
void EditLabel (const wxTreeItemId& item)
Starts editing the label of the given item. This function generates a EVT_TREE_BEGIN_LABEL_EDIT event which can be vetoed so that no text control will appear for in-place editing.
If the user changed the label, i.e. s/he does not press ESC or leave the text control without changes, a EVT_TREE_END_LABEL_EDIT event will be sent which can be vetoed as well.
See also
wxTreeEvent
void EnsureVisible (const wxTreeItemId& item)
Scrolls and/or expands items to ensure that the given item is visible.
void Expand (const wxTreeItemId& item)
Expands the given item.
void ExpandAll (const wxTreeItemId& item)
Expands the given item and all subitems recursively.
wxTreeItemId FindItem (const wxTreeItemId& item, const wxString& str, intflags=0)
Returns the next visible item in the tree which matches the entered string, starting from the entered item. If no item the find starts a the beginning of the tree. If no item found an empty item (NULL) is returned.
The flags have the following meaning:
Modes for navigation
wxTL_MODE_NAV_FULLTREE | Searches within the full tree (default). |
wxTL_MODE_NAV_EXPANDED | Searches within the expanded tree. |
wxTL_MODE_NAV_VISIBLE | Searches within all visible items. |
wxTL_MODE_NAV_LEVEL | Searches within only the current level. |
Modes for find match
wxTL_MODE_FIND_EXACT | Matches exact the submitted text (default). |
wxTL_MODE_FIND_PARTIAL | Matches only partial up to the submitted text length. |
wxTL_MODE_FIND_NOCASE | Matches case insensitive. |
bool GetBoundingRect (const wxTreeItemId& item, wxRect& rect, bool textOnly = false) const
Retrieves the rectangle bounding the item. If textOnly is TRUE, only the rectangle around the item's label will be returned, otherwise the item's image is also taken into account.
The return value is TRUE if the rectangle was successfully retrieved or false if it was not (in this case rect is not changed) - for example, if the item is currently invisible.
wxPython note: The wxPython version of this method requires only the item and textOnly parameters. The return value is either a wxRect object or None.
wxPerl note: In wxPerl this method only takes the parameters item and textOnly, and returns a Wx::Rect ( or undef ).
wxImageList* GetButtonsImageList() const
Returns the buttons image list (from which application-defined button images are taken).
size_t GetChildrenCount (const wxTreeItemId& item, bool recursively = TRUE) const
Returns the number of items in the branch. If recursively is TRUE, returns the total number of descendants, otherwise only one level of children is counted.
size_t GetCount() const
Returns the number of items in the control.
wxTreeItemId GetFirstChild (const wxTreeItemId& item, long& cookie) const
Returns the first child.
For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to GetFirstChild and GetNextChild should be the same variable.
Returns an invalid tree item if there are no further children.
See also
wxTreeItemId GetFirstExpandedItem() const
Returns the first expanded item.
wxTreeItemId GetFirstVisibleItem (bool fullRow = false) const
Returns the first visible item. If fullRow is true, visiblity test considers the full row, else only within the left/right limits.
wxTreeListHeaderWindow* GetHeaderWindow() const
Returns the pointer to the header window.
wxImageList* GetImageList() const
Returns the normal image list.
int GetIndent() const
Returns the current tree list control indentation.
wxColour GetItemBackgroundColour (const wxTreeItemId& item) const
Returns the background colour of the item.
wxTreeItemData* GetItemData (const wxTreeItemId& item) const
Returns the tree item data associated with the item.
See also
wxTreeItemData
wxPython note: wxPython provides the following shortcut method:
GetPyData(item) | Returns the Python Object associated with the wxTreeItemData for the given item Id. |
wxPerl note: wxPerl provides the following shortcut method:
GetPlData( item ) | Returns the Perl data associated with the Wx::TreeItemData ( it is just the same as tree->GetItemData( item )->GetData(); ). |
wxFont GetItemFont (const wxTreeItemId& item) const
Returns the font of the item label.
int GetItemImage (const wxTreeItemId& item, wxTreeItemIcon which = wxTreeItemIcon_Normal) const
Gets the specified item image of the main column.
int GetItemImage (const wxTreeItemId& item, int column, wxTreeItemIcon which = wxTreeItemIcon_Normal) const
Gets the specified item image of the entered column.
The value of which may be:
wxTreeItemId GetItemParent (const wxTreeItemId& item) const
Returns the item's parent.
wxString GetItemText (const wxTreeItemId& item) const
Returns the item text of the main column.
wxString GetItemText (const wxTreeItemId& item, int column) const
Returns the item text of the entered column.
wxColour GetItemTextColour (const wxTreeItemId& item) const
Returns the colour of the item label.
wxTreeItemId GetLastChild (const wxTreeItemId& item, long& cookie) const
Returns the last child of the item (or an invalid tree item if this item has no children).
See also
GetFirstChild, wxTreeListCtrl::GetNextSibling, GetLastChild
int GetLineSpacing() const
Returns the space above and below the text on each line.
wxTreeListMainWindow* GetMainWindow() const
Returns the pointer to the main window.
wxPython note: In wxPython the returned wxTreeItemId and the new cookie value are both returned as a tuple containing the two values.
wxPerl note: In wxPerl this method only takes the item parameter, and returns a 2-element list ( item, cookie ).
wxTreeItemId GetNext (const wxTreeItemId& item) const
Returns the next item in the full tree. This could be either the next child, the next sibling or the next parent.
wxTreeItemId GetNextChild (const wxTreeItemId& item, long& cookie) const
Don't use GetNextChild anymore, it's deprecated, instead use GetNextSibling.
Returns the next child; call wxTreeListCtrl::GetFirstChild for the first child.
For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to GetFirstChild and GetNextChild should be the same.
Returns an invalid tree item if there are no further children.
See also
wxTreeListCtrl::GetFirstChild, wxTreeListCtrl::GetPrevChild
wxPython note: In wxPython the returned wxTreeItemId and the new cookie value are both returned as a tuple containing the two values.
wxPerl note: In wxPerl this method returns a 2-element list ( item, cookie ), instead of modifying its parameters.
wxTreeItemId GetNextExpanded (const wxTreeItemId& item) const
Returns the next expanded item.
wxTreeItemId GetNextSibling (const wxTreeItemId& item) const
Returns the next sibling of the specified item; call wxTreeListCtrl::GetPrevSibling for the previous sibling.
Returns an invalid tree item if there are no further siblings.
See also
wxTreeListCtrl::GetPrevSibling
wxTreeItemId GetNextVisible (const wxTreeItemId& item, bool fullRow = false) const
Returns the next visible item. If fullRow is true, visiblity test considers the full row, else only within the left/right limits.
wxTreeItemId GetPrev (const wxTreeItemId& item) const
Returns the previous item in the full tree. This could be either the previous child, the previous sibling or the previous parent.
wxTreeItemId GetPrevChild (const wxTreeItemId& item, long& cookie) const
Don't use GetPrevChild anymore, it's deprecated, instead use GetPrevSibling.
Returns the previous child.
For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to GetFirstChild,GetNextChild and GetPrevChild should be the same.
Returns an invalid tree item if there are no further children.
See also
wxTreeListCtrl::GetFirstChild, wxTreeListCtrl::GetNextChild
wxPython note: In wxPython the returned wxTreeItemId and the new cookie value are both returned as a tuple containing the two values.
wxPerl note: In wxPerl this method returns a 2-element list ( item, cookie ), instead of modifying its parameters.
wxTreeItemId GetPrevSibling (const wxTreeItemId& item) const
Returns the previous sibling of the specified item; call wxTreeListCtrl::GetNextSibling for the next sibling.
Returns an invalid tree item if there are no further children.
See also
wxTreeListCtrl::GetNextSibling
wxTreeItemId GetPrevExpanded (const wxTreeItemId& item) const
Returns the previous expanded item.
wxTreeItemId GetPrevVisible (const wxTreeItemId& item, bool fullRow = false) const
Returns the previous visible item. If fullRow is true, visiblity test considers the full row, else only within the left/right limits.
wxTreeItemId GetRootItem() const
Returns the root item for the tree list control.
wxTreeItemId GetSelection() const
Returns the selection, or an invalid item if there is no selection. This function only works with the controls without wxTR_MULTIPLE style, use GetSelections for the controls which do have this style.
size_t GetSelections (wxArrayTreeItemIds& selection) const
Fills the array of tree items passed in with the currently selected items. This function can be called only if the control has the wxTR_MULTIPLE style.
Returns the number of selected items.
wxPython note: The wxPython version of this method accepts no parameters and returns a Python list of wxTreeItemIds.
wxPerl note: In wxPerl this method takes no parameters and returns a list of Wx::TreeItemIds.
wxImageList* GetStateImageList() const
Returns the state image list (from which application-defined state images are taken).
long GetWindowStyle() const
???
long GetWindowStyleFlag() const
???
bool HasChildren (const wxTreeItemId& item) const
Returns TRUE if the item has children.
wxTreeItemId HitTest (const wxPoint& point)
wxTreeItemId HitTest (const wxPoint& point, int& flags)
wxTreeItemId HitTest (const wxPoint& point, int& flags, int& column)
Calculates which (if any) item is under the given point, returning the tree item id at this point plus extra information flags. flags is a bitlist of the following:
wxTREE_HITTEST_ABOVE | Above the client area. |
wxTREE_HITTEST_BELOW | Below the client area. |
wxTREE_HITTEST_NOWHERE | In the client area but below the last item. |
wxTREE_HITTEST_ONITEMBUTTON | On the button associated with an item. |
wxTREE_HITTEST_ONITEMCOLUMN | On a normal item column (not main column). |
wxTREE_HITTEST_ONITEMICON | On the bitmap associated with an item. |
wxTREE_HITTEST_ONITEMINDENT | In the indentation associated with an item. |
wxTREE_HITTEST_ONITEMLABEL | On the label (string) associated with an item. |
wxTREE_HITTEST_ONITEMRIGHT | In the area to the right of an item. |
wxTREE_HITTEST_ONITEMSTATEICON | On the state icon for a tree view item that is in a user-defined state. |
wxTREE_HITTEST_TOLEFT | To the right of the client area. |
wxTREE_HITTEST_TORIGHT | To the left of the client area. |
wxPython note: in wxPython both the wxTreeItemId and the flags are returned as a tuple.
wxPerl note: In wxPerl this method only takes the point parameter and returns a 2-element list ( item, flags ).
wxTreeItemId InsertItem (const wxTreeItemId& parent, const wxTreeItemId& previous, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
wxTreeItemId InsertItem (const wxTreeItemId& parent, size_t index, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
Inserts an item after a given one (previous) or before one identified by its position (before). before must be less than the number of children.
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
wxPython note: The second form of this method is called InsertItemBefore in wxPython.
bool IsBold (const wxTreeItemId& item) const
Returns TRUE if the given item is in bold state.
See also: SetItemBold
bool IsExpanded (const wxTreeItemId& item) const
Returns TRUE if the item is expanded (only makes sense if it has children).
bool IsSelected (const wxTreeItemId& item) const
Returns TRUE if the item is selected.
bool IsVisible (const wxTreeItemId& item, bool fullRow = false) const
Returns TRUE if the item is visible (it might be outside the view, or not expanded). If fullRow is true, visiblity test considers the full row, else only within the left/right limits.
bool ItemHasChildren (const wxTreeItemId& item) const
Returns TRUE if the item has children.
int OnCompareItems (const wxTreeItemId& item1, const wxTreeItemId& item2)
Override this function in the derived class to change the sort order of the items in the tree list control. The function should return a negative, zero or positive value if the first item is less than, equal to or greater than the second one.
The base class version compares items alphabetically.
See also: SortChildren
wxString OnGetItemText (wxTreeItemData* item, long column) const
This function must be overloaded in the derived class for a control with wxTR_VIRTUAL style. It should return the string containing the text of the given column for the specified item.
wxTreeItemId PrependItem (const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
Appends an item as the first child of parent, return a new item id.
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
bool Refresh (bool erase=TRUE, wxRect* rect=NULL)
Refreshes the drawing of the tree.
Parameter???
void SetBackgroundColour (const wxColour& colour)
???
void SetDragItem (const wxTreeItemId& item = (wxTreeItemId*)NULL})
Marks the item where the dragged item will be dropped if the drag is currently ended.
void SetFocus()
???
void SetFont (const wxFont& font)
???
void SetForegroundColour (const wxColour& colour)
???
void SetWindowStyle (const long styles)
???
void ScrollTo (const wxTreeItemId& item)
Scrolls the specified item into view.
bool SelectItem (const wxTreeItemId& item, const wxTreeItemId& last = (wxTreeItemId*)NULL, bool unselect_others = true)
Selects the given item.
Parameter???
void SetButtonsImageList (wxImageList* imageList)
Sets the buttons image list (from which application-defined button images are taken). The button images assigned with this method will not be deleted by wxTreeListCtrl's destructor, you must delete it yourself.
Setting or assigning the button image list enables the display of image buttons. Once enabled, the only way to disable the display of button images is to set the button image list to NULL.
See also AssignButtonsImageList.
void SetImageList (wxImageList* imageList)
Sets the normal image list. Image list assigned with this method will not be deleted by wxTreeListCtrl's destructor, you must delete it yourself.
See also AssignImageList.
void SetIndent (int indent)
Sets the indentation for the tree list control.
void SetItemBackgroundColour (const wxTreeItemId& item, const wxColour& colour)
Sets the colour of the item's background.
void SetItemBold (const wxTreeItemId& item, bool bold = TRUE)
Makes item appear in bold font if bold parameter is TRUE or resets it to the normal state.
See also: IsBold
void SetItemData (const wxTreeItemId& item, wxTreeItemData* data)
Sets the item client data.
wxPython note: wxPython provides the following shortcut method:
SetPyData(item, obj) | Associate the given Python Object with the wxTreeItemData for the given item Id. |
wxPerl note: wxPerl provides the following shortcut method:
SetPlData( item, data ) | Sets the Perl data associated with the Wx::TreeItemData ( it is just the same as tree->GetItemData( item )->SetData( data ); ). |
void SetItemFont (const wxTreeItemId& item, const wxFont& font)
Sets the item's font. All items in the tree should have the same height to avoid text clipping, so the fonts height should be the same for all of them, although font attributes may vary.
See also
void SetItemHasChildren (const wxTreeItemId& item, bool has = TRUE)
Force appearance of the button next to the item. This is useful to allow the user to expand the items which don't have any children now, but instead adding them only when needed, thus minimizing memory usage and loading time.
void SetItemImage (const wxTreeItemId& item, int image, wxTreeItemIcon which = wxTreeItemIcon_Normal)
Sets the specified item image of the main column. See GetItemImage for the description of the which parameter.
void SetItemImage (const wxTreeItemId& item, int column, int image, wxTreeItemIcon which = wxTreeItemIcon_Normal)
Sets the specified item image of the entered column. See GetItemImage for the description of the which parameter.
void SetItemText (const wxTreeItemId& item, const wxString& text)
Sets the item text of the main column.
void SetItemText (const wxTreeItemId& item, int column, const wxString& text)
Sets the item text of the entered column.
void SetItemTextColour (const wxTreeItemId& item, const wxColour& colour)
Sets the colour of the item's text.
void SetLineSpacing (unsigned int spacing)
Sets the space above and below the text on each line.
void SetStateImageList (wxImageList* imageList)
Sets the state image list (from which application-defined state images are taken). Image list assigned with this method will not be deleted by wxTreeListCtrl's destructor, you must delete it yourself.
See also AssignStateImageList.
void SetWindowStyle (longstyles)
Sets the mode flags associated with the display of the tree list control. The new mode takes effect immediately.
void SortChildren (const wxTreeItemId& item)
Sorts the children of the given item using OnCompareItems method of wxTreeListCtrl. You should override that method to change the sort order (the default is ascending case-sensitive alphabetical order).
See also
wxTreeItemData, OnCompareItems
void Toggle (const wxTreeItemId& item)
Toggles the given item between collapsed and expanded states.
void Unselect()
Removes the selection from the currently selected item (if any).
void UnselectAll()
This function either behaves the same as Unselect if the control doesn't have wxTR_MULTIPLE style, or removes the selection from all items if it does have this style.
Members (column specific
void AddColumn (const wxString& text)
void AddColumn (const wxString& text, int width, wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT)
void AddColumn (const wxTreeListColumnInfo& colInfo)
Adds a column. At least one column (the main) has to be added to any tree.
wxTreeListColumnInfo& GetColumn (int column)
wxTreeListColumnInfo& GetColumn (int column) const
Returns the infos of the columns.
wxTreeListColumnAlign GetColumnAlignment (int column) const
Returns the alignment of the columns.
int GetColumnCount() const
Returns the number of columns.
int GetColumnImage (int column) const
Returns the image of the columns.
wxString GetColumnText (int column) const
Returns the text of the columns.
int GetColumnWidth (int column) const
Returns the width of the columns.
int GetMainColumn() const
Returns the number of the main column.
void InsertColumn (int before, const wxString& text)
void InsertColumn (int before, const wxString& text, int width, wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT)
void InsertColumn (int before, const wxTreeListColumnInfo& colInfo)
Inserts a column before the entered column.
bool IsColumnShown (int column) const
Returns if the columns is shown.
void RemoveColumn (int column)
Removes the entered column.
void SetColumn (int column, const wxTreeListColumnInfo& info)
Sets the infos of the column.
void SetColumnAlignment (int column, const wxTreeListColumnAlign align)
Sets the alignment of the column.
void SetColumnImage (int column, int image)
Sets the image of the column.
void SetColumnText (int column, const wxString& text)
Sets the text of the column.
void SetColumnWidth (int column, int width)
Sets the width of the column.
void SetMainColumn (int column)
Set the main column.
void ShowColumn (int column, bool shown)
Shows/hides the column.
Members (item specific
bool GetItemBold (const wxTreeItemId& item) const
Returns the item bold status.