All Features at a Glance
Feature Rich
- There is a TBaseVirtualTree.OnHint event to display node-specific hints.
- There is a TBaseVirtualTree.OnGetHelpContext event to retrieve node-specific help context IDs. This includes automatic tree and window parent control traversal as it is invoked when the user presses F1.
- There is a TBaseVirtualTree.OnGetPopupMenu event to retrieve node specific popup menus, it includes automatic tree traversal.
- Middle and right mouse buttons can be used in addition to the left button and support all functions mappable to the left button (dragging, selection etc.). These alternative buttons can be switched, of course.
- A fixed background image can be used in the tree and can be given a certain offset, e.g. to simulate shared backgrounds.
- Hot style for nodes is supported (just like links in a browser window). A special cursor can be assigned for this task.
- String trees support so-called static text which appears after a node's caption (in every column) and which can be formatted differently than the caption but cannot be edited, selected etc.
- An auto span column mode is supported. It allows a column to take up more space for its caption if there are empty columns to its right. This avoids clipping of long captions while still allowing the use of multiple columns.
- A node can be selected as well as edited in every column (this is switchable), making Virtual Treeview some kind of a grid too. The tabulator key can be used to switch the focus between cells. A special option (toGridExtensions) exist to support grid -specific tasks.
- Nodes can have individual heights and the vertical alignment of a node's images and lines can be adjusted individually.
- Virtual Treeview exposes its internal states like pending drag or edit events, multi selection or expanding in progress. Using this information an application can optimize its code execution (state updates etc.).
- Sorting a node is supported via an application-defined compare callback. Additionally, a tree can be set to "auto sort".
- Hints can contain multiple lines of text and mirror the alignment and directionality of the node or column they are displayed for. For their animation sliding and alpha blending is available.
- TBaseVirtualTree.DefaultNodeHeight and TVirtualStringTree.DefaultText can be used to avoid setting many nodes explicitly to the same start value.
- Virtual Treeview's column implementation also allows fixed columns, making it a good grid replacement.
Optimal Usability
- Virtual Treeview is extremely fast. Adding one million nodes takes only 700 milliseconds!
- Virtual Treeview has a very small memory footprint. By only allocating about 60 bytes per node (in the string tree, the base tree uses only 56 bytes) it is well prepared to hold a million of them.
- Virtual Treeview is optimized for high-speed access. It takes as few as 0.5 seconds to traverse one million nodes depending on needed validation and node validation states.
- Multiselection is supported, including constrained selection so that only nodes of a certain initial level can be selected. A lot of effort has been put into the development of effective algorithms, e.g. to allow for modifying an already large selection set while retaining interactivity.
- Drawing the entire tree to a bitmap or the printer is supported by the central TBaseVirtualTree.PaintTree method. The messages WM_PRINT and WM_PRINTCLIENT are handled correctly. This allows, for example, drawing a tree into a bitmap (e.g. for layered windows or to implement animated drop-down of controls which use VT as drop-down control).
- Incremental search with various options and directions is available.
- Auto-scrolling of the client area happens when the mouse is near the borders while dragging and draw-selecting (multi selection).
Cutting Edge
- An alpha-blended image of the tree window is shown during drag and drop operations.The IDropTargetHelper and IDragSourceHelper interfaces are supported
- Virtual Treeview supports Windows themes. It acts properly on theme changes and uses the correct image for all themed visual elements by utilizing native APIs. Under other Windows systems these styles are supported by separate legacy code. Theme awareness can be switched.
Drag & Drop | Clipboard Support
- OLE drag and drop and OLE clipboard transfers are supported with the tree as source and target. Alternatively, VCL drag and drop can still be used for compatibility.
- The following formats are supported by the standard implementation:
- HTML text string format (UTF-8). This is the preferred clipboard format for MS Word etc. and facilitates copy and paste operations of tree content to a word document with nearly no application code.
- Rich Text (RTF) string format (with Unicode text).
- Plain Unicode text string format.
- Plain ANSI text string format.
- Native serialized format (CF_VIRTUALTREE and CF_VTREFERENCE), which is a compact form to exchange data between Virtual Treeviews (also between applications). Two storage formats are available: HGlobal and IStream.
- A registration scheme (RegisterVTClipboardFormat) allows descendants to specify and implement their own clipboard formats. Via a drop handler the application can accept any OLE format without deriving an own tree class. Specialized methods are implemented to aid processing of the native tree data. See also: TBaseVirtualTree.ProcessOLEData and TBaseVirtualTree.ProcessDrop.
- Dropmarks during drag and drop operations show where data will be inserted. This also works with VCL drag and drop. The drop target model has been extended to allow drop actions above, below, or on a node.
- Auto expand of nodes which are the drop target for more than an adjustable time interval is performed if enabled.
Header and Columns
- Multiple columns are supported by an own header implementation. This header takes up space in the non-client area of the tree control and supports various buttons styles (standard listview thick buttons, flat buttons, plates, Windows style, and owner draw).
- Columns can appear in every order in the tree window.
- Each column can be hidden, including the main column which holds the actual tree.
- Each column can be selected as the main column.
- Columns can also be shown without the header.
- Columns can have various options (visible, clickable, resizable, draggable, etc.).
- You can set individual alignments for each column as well as right-to-left or left-to-right directionality (again: available also on non-middle-east and older Windows systems).
- Each column can have its own color.
- The header as well as the columns collection class and the actual column classes support streaming. This is independent from the treeview streaming.
Check Support
- Each node in the tree can have its own check type. This can either be check box (also tristate), radio button, or node button. These types can freely be mixed.
- Mixed (tri-state, as often used in install and backup programs) check boxes with proper handling for partial checking of child nodes are supported.
- Automatic state change propagation for mixed check button type is possible (if enabled).
- Check events OnChecking and OnCheck events are supplied too.
- For special purposes a small, flat button can be used, which is called a node button.
- Seven different kinds of check images are possible. Dark and light check marks, dark and light tick marks, flat check images, Windows style check images and application defined check images. For an overview see property TBaseVirtualTree.CheckImageKind.
Design Time
- Virtual Treeview's properties and methods are registered with Delphi categories (Delphi 5 and BCB 5 or higher).
- A special property editor for the clipboard formats is included which allows a simple format choice. This is particularly important since the available clipboard formats must be given as strings and it is also quite handy to have a list of available formats, even if they are not enabled yet (to know what can be enabled).
Customization
Tree as grid
- Custom draw and paint cycles are supported via paint events (for the entire tree as well as for each node).
- Apart from the built-in check types a user defined check image can be used which is supported by a separate image list (TBaseVirtualTree.CustomCheckImages).
- Each button in the header can be drawn individually.
- Three different line styles are available: dotted lines, solid lines and application defined lines.
- Applications and descendants can provide their own node editor (which does not necessarily have to be a single control) by handling the TBaseVirtualTree.OnCreateEditor event or overriding TBaseVirtualTree.DoCreateEditor. This allows to completely replace node editing by own (business) rules.
- Applications and descendants can provide their own drag manager interface by handling the TBaseVirtualTree.OnCreateDragManager event or overriding TBaseVirtualTree.DoCreateDragManager. This allows to customize the entire OLE drag handling of the tree. Note: VCL drag and drop is managed by the VCL so this cannot be customized.
- Applications and descendants can provide their own data object interface by handling the TBaseVirtualTree.OnCreateDataObject event or overriding TBaseVirtualTree.DoCreateDataObject. This allows to provide own clipboard formats.
- There is a registration function (RegisterVTClipboardFormat), which allows to register tree descendants with own clipboard and/or storage formats. Applications can provide own clipboard formats (without deriving new tree classes) by handling the TBaseVirtualTree.GetUserClipboardFormats event.
- Applications and descendants can completely modify the tree's key handling by handling the TBaseVirtualTree.OnKeyAction event or overriding TBaseVirtualTree.DoKeyAction. This also works for incremental search.
- Applications and descendants can customize the tree's background which is not covered by nodes, by handling the TBaseVirtualTree.OnPaintbackground event or overriding TBaseVirtualTree.DoPaintbackground. For nodes there are further events for customization.
- Applications and descendants can customize how the string tree shortens too long captions by handling the TCustomVirtualStringTree.OnShortenString event or overriding TCustomVirtualStringTree.DoShortenString.
Scrolling
- Every scroll operation triggers an TBaseVirtualTree.OnScroll event. This allows to synchronize trees with other controls.
- There are properties (e.g. TBaseVirtualTree.OffsetXY) which allow to scroll the tree content to any position in code without sending messages around.
- Wheel panning and scrolling is supported. That is, when clicking the mouse wheel or pressing and holding it while moving the mouse around, the tree window is scrolled smoothly.
Streaming
- Sophisticated tree content serialization has been implemented to allow saving and restoring a tree to/from streams. This also includes user data as long as it can be written to a stream.
- Virtual Treeview also allows to add data from streams instead replacing the entire content.
- The internal format of the stream is chunk based which makes it very flexible for future enhancements but still keeps compatibility with older implementations.
- There is a user chunk which takes data written to the stream in the TBaseVirtualTree.OnSaveNode event. The data of this user chunk can be read in TBaseVirtualTree.OnLoadNode.
Developer support
- Special care has been taken to format the source code of Virtual Treeview consistently.
- A large part of the entire implementation are comments which describe the inner workings.
- Methods and properties are consequently ordered alphabetically within their scope (private, protected, public, published). The only exception are the constructors and destructors which always appear at the top of the public section in the class declaration and are always the first methods in the class implementation.
- For every event there is a virtual method which calls the event handler. This allows descendants to get notice of every event without assigning a handler. The names of these methods correspond directly to the events by using the pattern: DoEventName.
- Many measures have been taken to ensure borland C++ builder compatibility. This is particularly difficult because the automatic translation from Delphi to C++ code in BCB is buggy.
- There is an easy and powerful mechanism for descendants writers to allocate their own data on a per node basis. Simply call TBaseVirtualTree.AllocateInternalData to register your needs. This will not influence existing or future application code if it consequently uses TBaseVirtualTree.GetNodeData for user data access.
Editing
- Application defined editors are supported via an edit link interface. A generic editor implementation is available too.
- Every column in the tree is editable if enabled (see TCustomVirtualTreeOptions.SelectionOptions.toExtendedFocus).
Utilities
For your convenience, some of the internally used functions which are of general interest are exposed.
- Alphablend: a general purpose procedure to blend a source onto a target bitmap using several different modes.
- ShortenString: a general purpose function which makes a given WideString fitting into a given space. This is partially implemented by the Windows DrawText API but takes additional care for right-to-left alignment.