TREEVIEW
A TREEVIEW widget can be used to show a hierarchical view of information like files in a directory or items of an index, whereas each item can be a node or a leaf. Each node can have a number of sub items and can be closed or opened.
A node consists of a button image, which shows a plus sign in closed state or a minus sign in open state, two item images (one for closed and one for open state) and the item text. Pressing the button image or double clicking the item image toggles the state (open or closed) of the node.
A leaf consists of an item image and the item text. The current selection can be marked by highlighting the item text or by highlighting the whole row. All items of a tree are joined by lines per default.
TREEVIEW | |
---|---|
Receives focus | Yes |
Skinnable | No |
OwnerDraw | Yes |
Uses Memory Devices | No |
Attached widgets |
|
Contents
Notification codes
The following events are sent from a TREEVIEW widget to its parent window as part of a WM_NOTIFY_PARENT message:
Message | Description |
---|---|
WM_NOTIFICATION_CLICKED | TREEVIEW has been clicked. |
WM_NOTIFICATION_RELEASED | TREEVIEW has been released. |
WM_NOTIFICATION_MOVED_OUT | TREEVIEW has been clicked and pointer has been moved out of the TREEVIEW widget without releasing. |
WM_NOTIFICATION_SEL_CHANGED | Value (selection) of the TREEVIEW widget has changed. |
Keyboard reaction
The TREEVIEW widget reacts to the following keys if it has the input focus:
Message | Description |
---|---|
GUI_KEY_RIGHT | If the cursor is at a closed node, the node is opened. If the cursor is at an open node the cursor moves to the first child of the node. |
GUI_KEY_DOWN | The cursor moves to the next visible item below the current position. |
GUI_KEY_LEFT | If the cursor is at a leaf the cursor moves to the parent node of the item. If the cursor is at an open node, the node will be closed. If the cursor is at a closed node, the cursor moves to the next parent node. |
GUI_KEY_UP | The cursor moves to the previous visible item above the current position. |
Description of terms
Item
This means a TREEVIEW item which can be a leaf or a node.
Leaf
A leaf is a TREEVIEW item which is not able to have any children. It is represented by the leaf bitmap and the item text.
Node
A node is a TREEVIEW item which is able to have children. It is represented by the button bitmap, the node bitmap and the item text. The state of the node can be toggled by pressing the button bitmap or by double clicking the node bitmap or the selected area of the item. In open state the children are visible below the node at the next level of indentation.
Button bitmap
This means the bitmap visible at nodes which can be pressed to toggle the state of the node.
Item bitmap
Left beside the item text the item bitmap is shown. Which bitmap is shown depends in the item (leaf or node) and in case of a node it also depends on the state, collapsed or expanded.
Expanded state
In expanded state the children of a node are visible and the minus sign is shown in the button bitmap.
Collapsed state
In collapsed state the children of a node are hidden and the plus sign is shown in the button bitmap.
Joining lines
Lines which are used to connect the items of a tree. The lines connect the button bitmaps of the nodes and the item bitmaps of the leafs according to the hierarchy of the tree.
Samples
Below are links to samples that demonstrate how to use TREEVIEW widgets in emWin.