Universal Tree package

 

back to main page

 

What is the Universal Tree package?

 

Universal tree package is a Visual Prolog class which allows programmer to display, navigate, manipulate any trees regardless of the complexity of their nodes.

 

Visual Prolog comes with powerful Tree package, however, it doesn't provide functionality for work with complex trees.

 

Universal tree package goes above this limits and provides programmer with easy to use Visual Prolog classes and objects.

 

Pictures below show various trees, where node processing (display, editing) defined by user callback function.

 

NEW FEATURE: Universal tree supports various tree node statuses:

 

 

Click here if you are user of VP Studio Shell

 

 

 

Visual Prolog users are familiar with such trees.

 

What is new?

 

In this instance of Universal Tree you can draw pictures/icons inside the tree node and program functionality depending on node selection status.

 

For example, if node selected, it has different icon, and if node is closed, it has different border

 

 

 

What is inside this Visual prolog class?

 

The Universal tree class provides user with 3 interface calls:

 

 

How to include object into your program?

 

First, create custom control with class named "cl_xtree_object"

 

 

Second, Universal Tree is a GUI object, so, you need to register it by placing registration code into your Task Window e_create event:

 

...

cl_properties_support::register(),

...

 

Third, you need to prepare some information before Windows will create custom object.

Below is code from window e_create event (note - window, which has custom control):

 

% First  - create system object

_SYSTEM_OBJECT = system_object::new(_Win),

TREE =  tree ("Sample tree",marked,

[

tree("A1",unmarked,[

tree("A11",marked,[],1),

tree("A12",marked,[],1)

],1),

tree("A2",marked,[

tree("A21",marked,[],1),

tree("A22",marked,[],1)

],1),

tree("A3",marked,[

tree("A31",marked,[],1),

tree("A32",marked,[],1)

],1)

],0),

% Store inside Window system object information for Universal Tree Object

cl_xtree_support::object_tree(_Win,TREE),

MENU = menu_GetRes(id_xtree_popup),

cl_xtree_support::object_menu(_Win,MENU),

% Define callback predicate

cl_xtree_support::object_callback(_Win,cl_tree_callback),

% Define class interior - color for background, link, frame

cl_xtree_support::object_background(_Win,0xFF8080),

cl_xtree_support::object_link_color(_Win,color_yellow),

cl_xtree_support::object_frame_color(_Win,color_magenta),

%BEGIN CLASS TREE OBJECT, InitControls,

win_CreateDynControl([customctl(wdef(wc_Custom,rct(3,5,335,156),

"Custom",u_Pixels),

"cl_xtree_object",idc_cl_xtree_object,

[wsf_Group,wsf_TabStop])],_Win),

%END CLASS TREE OBJECT, InitControls

 

What do you need to code inside callback (for more information - consult domains declaration):

 

Callback should provide Univeral Tree package with following parameters:

 

Vertical Size of the Tree nodes (in Pixels):

 

cl_tree_callback(_Win,node_max_height,node_max_height(MAX_NODE_HEIGHT)):-

MAX_NODE_HEIGHT = 25,

!.

 

Node rectangle size:

 

cl_tree_callback(Win,node_rectangle(Selector),selector_size(TEXT_WIDTH,Height)):-

win_GetTextExtent(Win, Selector, -1, Width, Height),

ICON_SIZE = 40,

TEXT_WIDTH = Width + ICON_SIZE,

!.

 

And finally - redraw operations for the node:

 

cl_tree_callback(Win,node_redraw(TEXT_RCT,_TREE_ARROW_TYPE,

TEXT,_CLOSED,_ACTIVE),none):-

% CLOSED = b_true, if this node has been closed - so, draw it as closed

% ACTIVE = b_true. if node is currently selected. Draw it as selected node

....

!.

 

For more samples of Universal Tree package please visit:

 

 

Click here to download test application

 

Price and licensing:

 

Universal tree class is available in sources for one time fee of $69.95 USD

 

You will need license for VP Studio version 5.2.1 and have it installed.

 

Contact: email

 


Copyright 1998-2002 EDMGROUP (Australia)

Last Updated: 03/20/02