- Main Page
- Packages
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# smjg.libs.sdwf.commoncontrol.TreeItem Class Reference

The TreeItem class represents an item in a tree-view control. More...

List of all members.

## Public Member Functions
| this (string label, int image=0)
| Constructs a new TreeItem.
TreeItem | addAtTop (string label)
| Adds an item displaying the given text, as the top-most child of this item.
TreeItem | addAtTop (TreeItem item)
| Adds an item as the top-most child of this item.
TreeItem | addAtBottom (string label)
| Adds an item displaying the given text, as the bottom-most child of this item.
TreeItem | addAtBottom (TreeItem item)
| Adds an item as the bottom-most child of this item.
TreeItem | addSorted (string label)
| Adds an item displaying the given text as a child of this item, in its alphabetical position.
TreeItem | addSorted (TreeItem item)
| Adds an item as as a child of this item in its alphabetical position.
TreeItem | addAfter (TreeItem pos, string label)
| Adds an item displaying the given text as a child of this item, at the specified position.
TreeItem | addAfter (TreeItem pos, TreeItem item)
| Adds an item as a child of this item, at the specified position.
void | remove ()
| Removes this item from the tree.
void | ensureVisible ()
| Scrolls the tree and/or expands tree branches as necessary to make this item visible.
void | expand ()
| Expands the child items of this item.
void | collapse ()
| Collapses the child items of this item.
void | toggleExpanded ()
| Toggles the expanded/collapsed state of this tree item.
void | removeChildren ()
| Removes all child items from this item.
void | edit ()
| Starts editing of this item's text.
void | sortChildren ()
| Sorts the children of this item alphabetically.
void | sort ()
| Sorts the children of this item alphabetically, and recursively sorts descendants at each level.
void | refreshChildren ()
| Refreshes the child list in the TreeItem object.
void | refresh ()
| Refreshes the child lists of this TreeItem object and all its children.
Properties
HTREEITEM | handle ()
| The Windows handle of this tree item.
TV_ITEMA | info ()
| Information about this tree item, as a Windows `TV_ITEMA` structure.
TreeView | container ()
| The TreeView of which this item is a member.
TreeItem | parent ()
| The parent item of this one in the tree.
bool | isRoot ()
| Whether this item is the root of a TreeView.
char[] | text ()
| The text of this tree item.
string | text (string t)
| The text of this tree item.
int | image ()
| The zero-based index in the image list of the image that is displayed with this tree item when it is not selected.
int | image (int i)
| The zero-based index in the image list of the image that is displayed with this tree item when it is not selected.
int | selectedImage ()
| The zero-based index in the image list of the image that is displayed with this tree item when it is selected.
int | selectedImage (int i)
| The zero-based index in the image list of the image that is displayed with this tree item when it is selected.
string | toString ()
| Returns a string representation of this TreeItem.
int | length ()
| Returns the number of children the item has.
Operators
TreeItem | opCatAssign (string label)
| Adds an item displaying the given text, as a child of this item.
TreeItem | opCatAssign (TreeItem item)
| Adds the given item as a child of this item.
TreeItem | opIndex (int i)
| Gets the child of this item with the specified index.
final int | opEquals (Object o)
| Determines whether this TreeItem is equal to another object.
final int | opEquals (TreeItem a)
| Determines whether this TreeItem is equal to another TreeItem.
final int | opCmp (Object o)
| Compares this TreeItem object with another Object.
final int | opCmp (TreeItem it)
| Compares this TreeItem object with another, by comparing their text strings.

## Detailed Description

The TreeItem class represents an item in a tree-view control.

Prior to SDWF 0.52, this class was TreeView.Item. Item objects were created only by the TreeView class, and automatically destructed when removed from the tree. TreeItem objects can, on the other hand, be constructed by the application programmer and are not automatically destructed. This also makes it possible to use a class derived from TreeItem to hold additional information about the entities represented by tree items.

A single TreeItem can be in only one place at a time. A TreeItem that is not present in any TreeView is a limbo item, and holds no connections with any other items.

## Constructor & Destructor Documentation

smjg.libs.sdwf.commoncontrol.TreeItem.this | ( | string | label,
|  | int | image = `0` |
| ) |  |  |

Constructs a new TreeItem.

Parameters:

  | label | the item's display text.
  | image | (since 0.56) the zero-based index in the image list of the image to display for this item.

Since:
  0.52

## Member Function Documentation

HTREEITEM smjg.libs.sdwf.commoncontrol.TreeItem.handle | ( |  | ) |

The Windows handle of this tree item.

You would use this property if you need to call a Windows API function directly on the item.

Returns:
  the handle, or `null` if this is a limbo item.

TV_ITEMA smjg.libs.sdwf.commoncontrol.TreeItem.info | ( |  | ) |

Information about this tree item, as a Windows `TV_ITEMA` structure.

Status:
  test further

TreeView smjg.libs.sdwf.commoncontrol.TreeItem.container | ( |  | ) |

The TreeView of which this item is a member.

Returns:
  the containing TreeView, or `null` if this is a limbo item.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.parent | ( |  | ) |

The parent item of this one in the tree.

Returns:
  the parent item, or `null` if this is a limbo item or the root of a tree.

Status:
  done

bool smjg.libs.sdwf.commoncontrol.TreeItem.isRoot | ( |  | ) |

Whether this item is the root of a TreeView.

Since:
  0.54

char [] smjg.libs.sdwf.commoncontrol.TreeItem.text | ( |  | ) |

The text of this tree item.

Precondition:
  This item must not be the root item of a TreeView.

Status:
  done

string smjg.libs.sdwf.commoncontrol.TreeItem.text | ( | string | t | ) |

The text of this tree item.

Status:
  done

int smjg.libs.sdwf.commoncontrol.TreeItem.image | ( |  | ) |

The zero-based index in the image list of the image that is displayed with this tree item when it is not selected.

Since:
  0.56

int smjg.libs.sdwf.commoncontrol.TreeItem.image | ( | int | i | ) |

The zero-based index in the image list of the image that is displayed with this tree item when it is not selected.

Status:
  test

Since:
  0.56

int smjg.libs.sdwf.commoncontrol.TreeItem.selectedImage | ( |  | ) |

The zero-based index in the image list of the image that is displayed with this tree item when it is selected.

Since:
  0.56

int smjg.libs.sdwf.commoncontrol.TreeItem.selectedImage | ( | int | i | ) |

The zero-based index in the image list of the image that is displayed with this tree item when it is selected.

Status:
  test

Since:
  0.56

string smjg.libs.sdwf.commoncontrol.TreeItem.toString | ( |  | ) |

Returns a string representation of this TreeItem.

Returns:
  the tree item's text.

Status:
  done

int smjg.libs.sdwf.commoncontrol.TreeItem.length | ( |  | ) |

Returns the number of children the item has.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.opCatAssign | ( | string | label | ) |

Adds an item displaying the given text, as a child of this item.

(Implementation of `this ~= label`.)

This operator is identical to addAtBottom(label) except for the return value.

Parameters:

  | label | text of item to add to tree.

Returns:
  this TreeItem object.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.opCatAssign | ( | TreeItem | item | ) |

Adds the given item as a child of this item.

(Implementation of `this ~= item`.)

This operator is identical to addAtBottom(item) except for the return value.

Parameters:

  | label | text of item to add to tree.

Returns:
  this TreeItem object.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.opIndex | ( | int | i | ) |

Gets the child of this item with the specified index.

(Implementation of `this[i]`.)

Parameters:

  | i | index of item to retrieve.

Returns:
  the retrieved item.

Status:
  done

final int smjg.libs.sdwf.commoncontrol.TreeItem.opEquals | ( | Object | o | ) |

Determines whether this TreeItem is equal to another object.

final int smjg.libs.sdwf.commoncontrol.TreeItem.opEquals | ( | TreeItem | a | ) |

Determines whether this TreeItem is equal to another TreeItem.

Two TreeItem objects are equal iff they have the same handle, i.e. they interface the same tree item. (If that's possible....)

final int smjg.libs.sdwf.commoncontrol.TreeItem.opCmp | ( | Object | o | ) |

Compares this TreeItem object with another Object.

Precondition:
  `o` must be another TreeItem.

final int smjg.libs.sdwf.commoncontrol.TreeItem.opCmp | ( | TreeItem | it | ) |

Compares this TreeItem object with another, by comparing their text strings.

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addAtTop | ( | string | label | ) |

Adds an item displaying the given text, as the top-most child of this item.

Parameters:

  | label | text of item to add to tree.

Returns:
  TreeItem object representing the newly added item.

Status:
  test

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addAtTop | ( | TreeItem | item | ) |

Adds an item as the top-most child of this item.

Parameters:

  | item | the item to add to the tree.

Returns:
  the added item.

Since:
  0.52

Status:
  test

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addAtBottom | ( | string | label | ) |

Adds an item displaying the given text, as the bottom-most child of this item.

Parameters:

  | label | text of item to add to tree.

Returns:
  TreeItem object representing the newly added item.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addAtBottom | ( | TreeItem | item | ) |

Adds an item as the bottom-most child of this item.

Parameters:

  | item | the item to add to the tree.

Returns:
  the added item.

Since:
  0.52

Status:
  test

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addSorted | ( | string | label | ) |

Adds an item displaying the given text as a child of this item, in its alphabetical position.

Parameters:

  | label | text of item to add to tree.

Returns:
  TreeItem object representing the newly added item.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addSorted | ( | TreeItem | item | ) |

Adds an item as as a child of this item in its alphabetical position.

Parameters:

  | item | the item to add to the tree.

Returns:
  the added item.

Since:
  0.52

Status:
  test

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addAfter | ( | TreeItem | pos,
|  | string | label |
| ) |  |  |

Adds an item displaying the given text as a child of this item, at the specified position.

Parameters:

  | pos | item after which this one will be added.
  | label | text of item to add to tree.

Precondition:
  `pos` must be a child of this item.

Returns:
  TreeItem object representing the newly added item.

Status:
  test

TreeItem smjg.libs.sdwf.commoncontrol.TreeItem.addAfter | ( | TreeItem | pos,
|  | TreeItem | item |
| ) |  |  |

Adds an item as a child of this item, at the specified position.

Parameters:

  | pos | item after which this one will be added.
  | item | the item to add to the tree.

Returns:
  the added item.

Since:
  0.52

Status:
  test

void smjg.libs.sdwf.commoncontrol.TreeItem.remove | ( |  | ) |

Removes this item from the tree.

The item becomes a limbo item, with no connections to any TreeView object or any other TreeItem.

Precondition:
  This TreeItem must be in a TreeView and not be the root item.

Status:
  done

void smjg.libs.sdwf.commoncontrol.TreeItem.ensureVisible | ( |  | ) |

Scrolls the tree and/or expands tree branches as necessary to make this item visible.

Status:
  test

void smjg.libs.sdwf.commoncontrol.TreeItem.expand | ( |  | ) |

Expands the child items of this item.

Status:
  done

void smjg.libs.sdwf.commoncontrol.TreeItem.collapse | ( |  | ) |

Collapses the child items of this item.

Status:
  test

void smjg.libs.sdwf.commoncontrol.TreeItem.toggleExpanded | ( |  | ) |

Toggles the expanded/collapsed state of this tree item.

Status:
  test

void smjg.libs.sdwf.commoncontrol.TreeItem.removeChildren | ( |  | ) |

Removes all child items from this item.

Status:
  test

void smjg.libs.sdwf.commoncontrol.TreeItem.edit | ( |  | ) |

Starts editing of this item's text.

Status:
  done

void smjg.libs.sdwf.commoncontrol.TreeItem.sortChildren | ( |  | ) |

Sorts the children of this item alphabetically.

Status:
  done

void smjg.libs.sdwf.commoncontrol.TreeItem.sort | ( |  | ) |

Sorts the children of this item alphabetically, and recursively sorts descendants at each level.

Status:
  done

void smjg.libs.sdwf.commoncontrol.TreeItem.refreshChildren | ( |  | ) |

Refreshes the child list in the TreeItem object.

This is primarily for internal use, but applications can also use it in case the tree can be modified by means external to the TreeView and TreeItem SDWF objects.

Status:
  done

void smjg.libs.sdwf.commoncontrol.TreeItem.refresh | ( |  | ) |

Refreshes the child lists of this TreeItem object and all its children.

This is primarily for internal use, but applications can also use it in case the tree can be modified by means external to the TreeView and TreeItem SDWF objects.

Status:
  test

## Member Data Documentation

uint smjg.libs.sdwf.commoncontrol.TreeItem._mask

HTREEITEM smjg.libs.sdwf.commoncontrol.TreeItem._handle

uint smjg.libs.sdwf.commoncontrol.TreeItem._state

uint smjg.libs.sdwf.commoncontrol.TreeItem._stateMask

char* smjg.libs.sdwf.commoncontrol.TreeItem._text

int smjg.libs.sdwf.commoncontrol.TreeItem._textCapacity = 32

int smjg.libs.sdwf.commoncontrol.TreeItem._image

int smjg.libs.sdwf.commoncontrol.TreeItem._selectedImage

int smjg.libs.sdwf.commoncontrol.TreeItem._hasChildren

int smjg.libs.sdwf.commoncontrol.TreeItem._param

TV_ITEMA smjg.libs.sdwf.commoncontrol.TreeItem._info

The documentation for this class was generated from the following file:

- commoncontrol.d