|
Virtual Treeview is "pure VCL" which means it is not based on any of the system controls but was written from scratch. As the name already indicates, this control uses a different paradigm for tree management than other controls of this kind. It does not know anything about the data it manages (except its size), not even the captions of a node. Everything is retrieved from the application via events (or descendants via overridden methods). Virtual Treeview has been carefully designed and thoroughly tested. The control proved its concept as well as everyday fitness already in many commercial products and freeware projects.The following list summarizes in categories the most important features:
|
General |
- Virtual Treeview is extremely fast. Adding one million nodes takes only 700 milliseconds* ! This makes it currently the fastest treeview publicly available on the Delphi/BCB market.
- Virtual Treeview has a very small memory foot print. 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 still interactively.
- Drawing the entire tree to a bitmap or the printer is supported by the central PaintTree method. The messages WM_PRINT and WM_PRINTCLIENT are handled correctly which allow things like 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).
- There is an OnHint event to display node specific hints.
- There is an OnGetHelpContext event to retrieve node specific help context IDs. This includes automatic tree and window parent control traversal as is invoked when the user pressed F1
- There is an OnGetPopupMenu event to retrieve node specific popup menus, includes automatic tree traversal.
- Middle and right mouse buttons can be used in addition to the left button and support everything which is possible with 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 to the caption but cannot be edited, selected etc.
- An auto span column mode is supported which 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 but still allows using multiple columns.
- A node can be selected in every column (this is switchable) as well as edited, 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 call back. 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.
- Incremental search with various options and directions is available too.
- Auto scrolling of the client area happens when the mouse is near the borders while dragging and draw selecting (multi selection).
- Default node height and default node text for string trees can be used to avoid setting many nodes explicitly to the same start value.
|
Newest technologies |
- For smooth animations (e.g. hint fading) Virtual Treeview uses hand optimized MMX assembler routines. This code is also used to draw the translucent selection rectangle in multi selection mode. This is very much like what Windows 2000 and Windows XP support but works also on Windows 95/98/Me.
- An alpha blended image of the tree window is shown while doing drag and drop. On Windows 2000 and Windows XP IDropTargetHelper and IDragSourceHelper interfaces are supported which allow for some very neat effects (as used by Explorer). On older consumer Windows versions the drag image is simulated by the tree but underlies there some minor limitations.
- Virtual Treeview supports Windows XP themes. It acts properly on theme changes and uses for all visual elements which are themed the correct image by using native APIs. Under other Windows systems these styles are supported by separate legacy code. Theme awareness can be switched.
|
Unicode |
- TVirtualStringTree is implemented using Unicode/wide strings exclusively.
- The tree saves and reads all Unicode properties (e.g. column captions, default node text and the like) correctly to/from DFM.
- All Unicode drawing fully supports bidirectionality (i.e. right-to-left drawing), column alignment (left, center, right) and correctly aligned hints. Of course also this feature is available on Windows 95/98/Me.
- On Windows NT/2000/XP multiline captions are fully supported (on Win9x/Me there is limited support).
- In order to have also Unicode editing capabilities Virtual Treeview supports the TNT controls written by Troy Wolbrink. This support can be enabled via a compiler switch named TntSupport. You must download and install the TNT package first, however.
|
Drag'n drop and clipboard support |
- OLE drag and drop and OLE clipboard transfers are supported with the tree as source and target. Alternatively, VCL drag'n drop can still be used for compatibility.
These formats are support by the standard implementation:
- 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.
- Plain ANSI text string format.
- Plain Unicode text string format.
- Rich Text (RTF) string format (with Unicode text).
- HTML text string format (UTF-8). This is the preferred clipboard format for Word 2000 etc. and allows copy and paste tree content to a word document with nearly no application code.
There is a registration scheme which 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. In order to aid processing of the native tree data specialized methods are implemented. See also: ProcessOLEData and ProcessDrop.Dropmarks show during drag'n drop where data will be inserted. This works also with VCL drag'n drop. The drop target model has been extended to allow drop actions above, below or on a node. Meanwhile vendors of other treeview controls have started using this little but powerfull idea too.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 XP 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 become the main column.
- Columns can be shown also 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 consumer systems).
- Each column can have an own color.
- The header as well as the columns collection class and the actual column classes support streaming. This is independant from the treeview streaming.
- Each column can individually be customized by the application. An advance custom draw handling is implemented, which allows for very sophisticated effects, including animations.
|
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 so you can for instance have a node with 10 nodes of which 5 comprise a radio group (where only one of these 5 nodes can be checked) and the other 5 nodes can have a check box (or no check type at all).
- Mixed (tri-state) check boxes with proper handling for partial checking of child nodes are supported (as often used in install and backup programs).
- 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.
- 7 different kinds of check images are possible. Dark and light check marks, dark and light tick marks, flat check images, Windows XP style check images and application defined check images. For an overview see property 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 |
- Custom draw and paint cycles are supported via paint events (for the entire tree and 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.
- Each button in the header can be drawn individually.
- Three different lines styles are available: dotted lines, solid lines and application defined lines.
- Applications and descendants can provide their own node editor (which has not necessarily to be a single control) by handling the OnCreateEditor event or overriding 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
- OnCreateDragManager event or overriding DoCreateDragManager. This allows to customize the entire OLE drag handling of the
- tree. Note: VCL drag'n drop is managed by the VCL so this cannot be customized.
- Applications and descendants can provide their own data object interface by handling the OnCreateDataObject event or overriding DoCreateDataObject. This allows to provide own clipboard formats.
- There is registration function (RegisterVTClipboardFormat) which allows to register tree descendants with own clipboard and/or storage formats. Applications get provide own clipboard formats (without deriving new tree classes) by handling the GetUserClipboardFormats event.
- Applications and descendants can completely modify the tree's key handling by handling the OnKeyAction event or overriding DoKeyAction. This works also for incremental search.
- Applications and descendants can customize the tree's background which is not covered by nodes by handling the OnPaintBackground event or overriding 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 OnShortenString event or overriding DoShortenString.
|
Scrolling |
- Flat scroll bars are supported. But since they conflict with Windows XP this support is switched off by a compiler symbol (UseFlatScrollbars). Enable this symbol if you really want to use flat scroll bars before compiling the tree unit.
- Every scroll operation triggers an OnScroll event. This allows to synchronize trees with other controls.
- There are properties (e.g. OffsetXY) which allow to scroll the tree content to any postion in code without sending messages around.
|
Streaming |
- Sophisticated tree content serialization has been implemented to allow saving and restoring a tree to/from streams. This includes also user data as long as it can be written to a stream.
- Virtual Treeview allows also to add data from stream 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 OnSaveNode event. The data of this user chunk is can be read in 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 powerfull mechanism for descendants writers to allocate their own data on a per node basis. Simply call AllocateInternalData to register your needs. This will not influence existing or future application code if it consequently uses GetNodeData for user data access.
|
Editing |
- Application defined editors are supported via an edit link interface. A generic (non-Unicode) editor implementation is available too.
- Every column in the tree is editable if enabled (see toExtendedFocus).
- By supporting the TNT controls library (see chapter Unicode above) it is also possible to have full Unicode editing capabilities.
|
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.
- DrawTextW: a partial implementation of the DrawText API which supports Unicode. This method is not used on Windows NT/2000/XP machines.
- 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 additionally care for right-to-left alignment and works with Unicode also on Windows 95/98/Me.
* Times given here are taken on a Windws XP professional system running on an Athlon 650 MHz with 256MB RAM. All possible optimization were applied. |
What do you think about this topic? Send feedback!
|