Objective Toolkit : Chapter 14 Tree Control & Tree View
Chapter 14 Tree Control & Tree View
Overview
The Objective Toolkit tree control and tree view classes extend the functionality of the CTreeCtrl common tree control. A tree control is a window that displays a hierarchical list of items, such as the files and directories on a disk or the entries in an index.
The Win32 common tree control has some limitations. Because no source code is available, it lacks extensibility. It isn’t object-oriented and no hooks were introduced into the drawing process until Comctl32.dll. It is difficult to implement multiple selection. Additionally, CTreeCtrl is a very thin wrapper to the common tree control so it is difficult to extend as well.
Objective Toolkit’s tree control adds support for multiple selection, an integrated grid with a resizable header row, adjustable cell height, word wrap, tool tips, various font and color options through an architecture designed for extensibility. Options are controlled by styles that permit features to be enabled or disabled at run time.
Objective Toolkit also supports overlay images and state images. Editing labels in a multi column tree is possible if the TVS_EDITLABELS style and LVXS_HILIGHTSUBITEMS extended style is set. See the STATE sample.
Objective Toolkit also includes a view class, SECTreeView. Unlike CTreeView, SECTreeView truly is a tree. You can override any of its virtual functions the same way you would an SECTreeCtrl. You can change the text color in your SECTreeView/Ctrl derived class by overriding PickTextColors(). You can change the font for a particular item in that same class by overriding PickTextFont(). The preceding functions are the same functions that you would overload if you were using SECTreeCtrl.
Painting in the tree control is optimized for performance. The control is not necessarily invalidated after every insertion or deletion of items so that you can add or remove many items in a batch. See “To update the tree control”.