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

- Class List
- Class Hierarchy
- Class Members

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

The smjg.libs.sdwf.commoncontrol.TreeView class interfaces a tree-view list box. More...

Inheritance diagram for smjg.libs.sdwf.commoncontrol.TreeView:

List of all members.

## Public Member Functions
| this (Dialog parent, int id)
| Constructs a TreeView object to interface a given tree-view control.
| this (WindowBase parent, int id, Rect position)
| Constructs a tree-view control to be created at runtime.
| this (FrameWindow parent, int id)
| Constructs a tree-view control to be used as the client pane of a FrameWindow.
override void | create ()
| Creates the tree-view interface element.
TreeItem | addAtTop (string label)
| Adds a top-level item displaying the given text, in the top-most position.
TreeItem | addAtTop (TreeItem item)
| Adds the given top-level item at the top-most position.
TreeItem | addAtBottom (string label)
| Adds a top-level item displaying the given text, at the bottom-most position.
TreeItem | addAtBottom (TreeItem item)
| Adds the given top-level item at the bottom-most position.
TreeItem | addSorted (string label)
| Adds a top-level item displaying the given text, in its alphabetical position.
TreeItem | addSorted (TreeItem item)
| Adds the given top-level item in its alphabetical position.
TreeItem | addAfter (TreeItem pos, string label)
| Adds an item at a position in the tree specified by a sibling item.
TreeItem | addAfter (TreeItem pos, TreeItem item)
| Adds an item at a position in the tree specified by a sibling item.
void | endEdit (bool cancel)
| Ends editing of an item in the tree.
void | sort ()
| Sorts siblings at all levels in the tree.
int | processEdit (uint message, uint wParam, int lParam, WindowBase receivedVia, out bool swallow)
| Listener to help with the processing of label editing messages.
Operators
TreeView | opCatAssign (string label)
| Adds an item displaying the given text, as a top-level tree item.
TreeView | opCatAssign (TreeItem item)
| Adds the given item as a top-level tree item.
TreeItem | opIndex (int i)
| Gets the top-level item with the specified index.
TreeItem | opIndex (HTREEITEM h)
| Gets the tree item identified by a handle.
Properties
TreeItem | root ()
| The root of the tree.
TreeItem | selected ()
| The currently selected item in the tree, or `null` if no item is selected.
TreeItem | selected (TreeItem i)
| The currently selected item in the tree, or `null` if no item is selected.
ImageList | imageList ()
| The tree's image list.
ImageList | imageList (ImageList il)
| The tree's image list.
uint | indent ()
| The width of an indentation level in pixels.
void | indent (uint i)
| The width of an indentation level in pixels.
uint | count ()
| The total number of items in the tree.
uint | countVisible ()
| The number of items that are completely visible in this tree.
TreeItem | scrollPosition ()
| The top-most visible item in this tree.
void | scrollPosition (TreeItem i)
| The top-most visible item in this tree.
## Public Attributes
deprecated typedef TreeItem | Item
## Protected Member Functions
Callback Methods
bool | prepareEdit (TreeItem item)
| Prepares to edit the text of an item in the tree.
bool | acceptEdit (TreeItem item, string newText)
| Finishes user editing of an item in the tree.

## Detailed Description

The smjg.libs.sdwf.commoncontrol.TreeView class interfaces a tree-view list box.

Unlike most SDWF control classes, TreeView includes methods designed to be overridden by the programmer in a derived class. These are provided to facilitate handling of edits using the processEdit listener.

Since:
  0.4

Todo:
  support more features, possibly including: state images, drag and drop stuff interfacing the label edit control

## Constructor & Destructor Documentation

smjg.libs.sdwf.commoncontrol.TreeView.this | ( | Dialog | parent,
|  | int | id |
| ) |  |  |

Constructs a TreeView object to interface a given tree-view control.

Parameters:

  | parent | the dialog on which the control is placed.
  | id | numeric ID of the control.

Precondition:
  The parent interface element must already have been created. TreeView objects should be constructed in an overridden Dialog.setup method, not in the constructor of a Dialog subclass.

Status:
  done

Reimplemented from smjg.libs.sdwf.control.Control.

smjg.libs.sdwf.commoncontrol.TreeView.this | ( | WindowBase | parent,
|  | int | id,
|  | Rect | position |
| ) |  |  |

Constructs a tree-view control to be created at runtime.

Parameters:

  | parent | the window or dialog on which the tree-view control will be placed.
  | id | numeric ID that the tree-view control will have.
  | position | the position on the parent window where the tree-view control will be placed.

Status:
  done

smjg.libs.sdwf.commoncontrol.TreeView.this | ( | FrameWindow | parent,
|  | int | id |
| ) |  |  |

Constructs a tree-view control to be used as the client pane of a FrameWindow.

Parameters:

  | parent | the frame window in which this edit box will be framed.
  | id | numeric ID that the edit box will have.

Status:
  done

## Member Function Documentation

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

Adds an item displaying the given text, as a top-level tree 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 TreeView object.

Status:
  done

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

Adds the given item as a top-level tree 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 TreeView object.

Status:
  done

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

Gets the top-level item with the specified index.

(Implementation of `this[i]`.)

This operator is syntactic sugar for `root[i]`.

Parameters:

  | i | index of item to retrieve.

Returns:
  the retrieved item.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeView.opIndex | ( | HTREEITEM | h | ) |

Gets the tree item identified by a handle.

(Implementation of `this[h]`.)

Parameters:

  | h | handle of tree item.

Returns:
  the retrieved item, or `null` if the item doesn't exist in this tree.

Status:
  test

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

The root of the tree.

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

The currently selected item in the tree, or `null` if no item is selected.

Status:
  done

TreeItem smjg.libs.sdwf.commoncontrol.TreeView.selected | ( | TreeItem | i | ) |

The currently selected item in the tree, or `null` if no item is selected.

Status:
  done

ImageList smjg.libs.sdwf.commoncontrol.TreeView.imageList | ( |  | ) |

The tree's image list.

Since:
  0.56

ImageList smjg.libs.sdwf.commoncontrol.TreeView.imageList | ( | ImageList | il | ) |

The tree's image list.

An image list is used to display a graphic in addition to the text for every item in a TreeView. By default, every item shows the first image (index 0) of the list.

See also:
  TreeItem.image, TreeItem.selectedImage

Since:
  0.56

Status:
  test

uint smjg.libs.sdwf.commoncontrol.TreeView.indent | ( |  | ) |

The width of an indentation level in pixels.

void smjg.libs.sdwf.commoncontrol.TreeView.indent | ( | uint | i | ) |

The width of an indentation level in pixels.

uint smjg.libs.sdwf.commoncontrol.TreeView.count | ( |  | ) |

The total number of items in the tree.

uint smjg.libs.sdwf.commoncontrol.TreeView.countVisible | ( |  | ) |

The number of items that are completely visible in this tree.

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

The top-most visible item in this tree.

void smjg.libs.sdwf.commoncontrol.TreeView.scrollPosition | ( | TreeItem | i | ) |

The top-most visible item in this tree.

override void smjg.libs.sdwf.commoncontrol.TreeView.create | ( |  | ) | `[virtual]`

Creates the tree-view interface element.

Precondition:
  Must be a control created using one of the constructors designed for creating controls at runtime, and not already have been created.

Status:
  done

Reimplemented from smjg.libs.sdwf.control.Control.

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

Adds a top-level item displaying the given text, in the top-most position.

This method is syntactic sugar for `root.addAtTop(label)`.

Parameters:

  | label | text of item to add to tree.

Returns:
  TreeItem object representing the newly added item.

Status:
  test

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

Adds the given top-level item at the top-most position.

This method is syntactic sugar for `root.addAtTop(item)`.

Parameters:

  | item | the item to add to the tree.

Returns:
  the newly added item.

Since:
  0.52

Status:
  test

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

Adds a top-level item displaying the given text, at the bottom-most position.

This method is syntactic sugar for `root.addAtBottom(label)`.

Parameters:

  | label | text of item to add to tree.

Returns:
  TreeItem object representing the newly added item.

Status:
  test

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

Adds the given top-level item at the bottom-most position.

This method is syntactic sugar for `root.addAtBottom(item)`.

Parameters:

  | item | the item to add to the tree.

Returns:
  the newly added item.

Since:
  0.52

Status:
  test

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

Adds a top-level item displaying the given text, in its alphabetical position.

This method is syntactic sugar for `root.addSorted(label)`.

Parameters:

  | label | text of item to add to tree.

Returns:
  TreeItem object representing the newly added item.

Status:
  test

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

Adds the given top-level item in its alphabetical position.

This method is syntactic sugar for `root.addSorted(item)`.

Parameters:

  | item | the item to add to the tree.

Returns:
  the newly added item.

Since:
  0.52

Status:
  test

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

Adds an item at a position in the tree specified by a sibling item.

Parameters:

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

Returns:
  TreeItem object representing the newly added item.

Status:
  done

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

Adds an item at a position in the tree specified by a sibling item.

Parameters:

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

Returns:
  the newly added item.

Since:
  0.52

Status:
  test

void smjg.libs.sdwf.commoncontrol.TreeView.endEdit | ( | bool | cancel | ) |

Ends editing of an item in the tree.

Parameters:

  | cancel | `true` to cancel edit; `false` to save the result.

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

Sorts siblings at all levels in the tree.

This method is syntactic sugar for `root.sort()`.

int smjg.libs.sdwf.commoncontrol.TreeView.processEdit | ( | uint | message,
|  | uint | wParam,
|  | int | lParam,
|  | WindowBase | receivedVia,
|  | out bool | swallow |
| ) |  |  |

Listener to help with the processing of label editing messages.

This listener must be added to the TreeView's parent window or dialog.

This listener handles the Enter and Esc keystrokes while the user is editing the text of a tree item. It also calls the prepareEdit and acceptEdit functions when the user begins or ends editing the text of an item.

Since:
  0.54

Bug:
  In a dialog box that has an ID.CANCEL button but no ID.OK button, pressing either Enter or Esc tends to cancel the edit. A workaround is to define the dialog to have both buttons and make one of them invisible.

bool smjg.libs.sdwf.commoncontrol.TreeView.prepareEdit | ( | TreeItem | item | ) | `[protected]`

Prepares to edit the text of an item in the tree.

This can be overridden e.g. to prevent editing of certain items within the tree.

For this to work, the processEdit listener must have been added to the parent window or dialog.

The default implementation does nothing but returns `true`.

Parameters:

  | item | the item to edit.

Return values:

  | true | to allow the item to be edited.
  | false | to prevent the item from being edited.

Since:
  0.54

Status:
  test

bool smjg.libs.sdwf.commoncontrol.TreeView.acceptEdit | ( | TreeItem | item,
|  | string | newText |
| ) |  |  | `[protected]`

Finishes user editing of an item in the tree.

This can be overridden to validate the user's edit, or to update entities external to the TreeView to reflect the changed text.

For this to work, the processEdit listener must have been added to the parent window or dialog.

The default implementation does nothing but returns `true`.

Parameters:

  | item | the item that has been edit.
  | newText | the newly entered text.

Return values:

  | true | to accept the edit.
  | false | to revert the item's text to what it was before the edit.

Since:
  0.54

Status:
  test

## Member Data Documentation

deprecated typedef TreeItem smjg.libs.sdwf.commoncontrol.TreeView.Item

Deprecated:
  Superseded by TreeItem.

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

- commoncontrol.d