Copyright: Copyright © 1998-2007 Developer Express Inc.,  ALL RIGHTS RESERVED
Citation: Copyright © 1998-2007 Developer Express Inc.,  ALL RIGHTS RESERVED  This program and all its contents are protected by US Copyright Laws and International Treaties.  Any unauthorized duplication, distribution and reproduction are prohibited.


Unit DxOrgChr

Controls

TdxCustomOrgChart

TdxOrgChart

TdxOcInplaceEdit

Objects

TdxOcNode


TdxCustomOrgChart

Hierarchy          Properties           Methods           Events

Unit

DxOrgChr

Description

TdxCustomOrgChart is an abstract class for the display and editing of hierarchical tree data structures. It contains the base protected properties and methods published in their direct descendants: TdxOrgChart and TdxDbOrgChart.


Hierarchy

TObject

     |

TPersistent

     |

TComponent

     |

TControl

     |

TWinControl

     |

TCustomControl

     |


TdxCustomOrgChart Properties

TdxCustomOrgChart

BorderStyle

DefaultImageAlign

DefaultNodeHeight

DefaultNodeWidth

EditMode

Images

IndentX

IndentY

LineColor

LineWidth

Options

Rotated

SelectedNodeColor

SelectedNodeTextColor

AbsoluteItems

Count

Editing

Items

LeftEdge

RootCount

Selected

TopEdge

Zoom


TdxCustomOrgChart Methods

TdxCustomOrgChart

CreateNode

CreateEditor

CreateParams

DblClick

DoChange

DoChanging

DragOver

DrawNode

InternalAdd

InternalMoveTo

KeyDown

KeyPress

MouseDown

MouseMove

NodeChanged

Paint

Loaded

Create

Destroy

Add

AddChild

AddChildFirst

AddFirst

AssignData

BeginUpdate

Clear

Delete

DoZoom

DragDrop

EndUpdate

FullCollapse

FullExpand

FullHeight

FullWidth

GetFirstNode

GetHitTestsAt

GetNodeAt

HideEditor

Insert

Invalidate

IsZoomed

SetLeftTop

ShowEditor


TdxCustomOrgChart Events

TdxCustomOrgChart

OnCreateNode

OnChange

OnChanging

OnCollapsed

OnCollapsing

OnDeletion

OnExpanded

OnExpansion

OnEditing

OnEdited

OnSetFont

OnDrawNode

OnGetText

OnSetText


TdxCustomOrgChart.AbsoluteItems

TdxCustomOrgChart            See Also

Provides indexed access to nodes managed by the control.

property AbsoluteItems[Index: Integer]: TdxOcNode;

Description

Use the AbsoluteItems property to traverse through all the nodes within a control.  The node to be returned is specified by its index via the Index parameter.  The first node’s index is zero, the last node’s index is the Count property value decremented by one.

If you need to access nodes at the root hierarchy level, use the RootCount and Items properties.


TdxCustomOrgChart.Count

TdxCustomOrgChart            See Also

Count represents the number of nodes in a tree structure.

property Count: Integer;

Description

Use Count to determine the total amount of tree nodes owned by the component.  Count alters by deleting or adding nodes.


TdxCustomOrgChart.Editing

TdxCustomOrgChart            See Also

Indicates whether a selected node is currently being edited by a user.

property Editing: Boolean;

Description

Editing = True signifies that a selected node is in text editing mode.  Setting Editing to True or False activates text editing.


TdxCustomOrgChart.Items

TdxCustomOrgChart            See Also

Items is an indexed array of the top-level tree nodes managed by the component.

property Items[Index:Integer]: TdxOcNode;

Description

Use Items to access a top-level node by its index. The first node has an index of 0, the second an index of 1, etc.  Items is a default property for TdxCustomOrgChart, so Chart.Items[I] is equal to Chart[I].

Note: TdxCustomOrgChart.Items allows access to top-level nodes only, having no parents.  In order to access their children you must use the TdxOcNode.Items property.


TdxCustomOrgChart.LeftEdge

TdxCustomOrgChart            See Also

LeftEdge is the position of a window’s left edge relative to the component's left edge.

property Items[Index:Integer]: TdxOcNode;

Description

Read LeftEdge to determine the area of the component which is visible. Set LeftEdge to change this visible area. When LeftEdge is changed, the window scrolls horizontally.


TdxCustomOrgChart.Selected

TdxCustomOrgChart            See Also

Selected contains a reference to the currently selected node in a tree.

property Selected: TdxOcNode;

Description

Read Selected to access a selected node.  Within Options, if ocSelect is set to True, a focus rectangle highlights the selected node.  If Selected=nil, then the component will not include a selected node.  Setting a new value cancels the selection of the previous node and instead selects the pointed node.  Once a node is selected, the OnChanging and OnChanged events are called.


TdxCustomOrgChart.TopEdge

TdxCustomOrgChart            See Also

TopEdge is the position of a window’s upper edge relative to the component's upper edge.

property TopEdge: Integer;

Description

Read TopEdge to determine which area of the component is visible.  Set TopEdge to change this visible area. When TopEdge changes, the window scrolls vertically.


TdxCustomOrgChart.BorderStyle

TdxCustomOrgChart

BorderStyle determines whether the component has a border.

TBorderStyle = (bsNone,bsSingle);

property BorderStyle: TBorderStyle;

Description

Set BorderStyle to specify a border frame around the component.  If BorderStyle=bsSingle, then the component has a border, if it is bsNone, then it has no border.  If Ctl3D=True, then the border is drawn with a three-dimensional effect.


TdxCustomOrgChart.DefaultImageAlign

TdxCustomOrgChart            See Also

DefaultImageAlign is the default value for TdxOcNode.ImageAlign property.

type

  TdxOcImageAlign = (iaNone, iaLT, iaLC, iaLB, iaRT, iaRC, iaRB, aTL, iaTC, iaTR, iaBL, iaBC, iaBR);

property DefaultImageAlign: TdxOcImageAlign;

Description

Set DefaultImageAlign to specify the standard location of tree node’s images. When a new node is added to the tree, its ImageAlign property is set to this value.


TdxCustomOrgChart.DefaultNodeHeight

TdxCustomOrgChart            See Also

DefaultNodeHeight is the default height for tree nodes.

property DefaultNodeHeight: Word;

Description

The DefaultNodeHeight property determines the standard height of nodes in pixels.  This height is adopted by default for all nodes having the Height property equaling 0.  If the component does not have an image list, the minimal value of DefaultNodeHeight is 16, otherwise it is equal to the doubled height of the image.

Setting a new value to the DefaultNodeHeight will change the height of all nodes, except those nodes, whose Height property was explicitly set to a nonzero value.


TdxCustomOrgChart.DefaultNodeWidth

TdxCustomOrgChart            See Also

DefaultNodeWidth is the default width for tree nodes.

property DefaultNodeWidth: Word;

Description

The DefaultNodeWidth property determines the standard width of nodes in pixels. This width is adopted by default for all nodes having the Width property equaling 0.  If the component does not have an image list, the minimal value of DefaultNodeWidth is 16, otherwise it is equal to the doubled width of the image.

Setting a new value to the DefaultNodeWidth will change the width of all nodes, except those nodes, whose Width property was explicitly set to a nonzero value.


TdxCustomOrgChart.EditMode

TdxCustomOrgChart            See Also

EditMode determines the output and text editing modes.

type

  TdxOcEditMode = set of (emLeft, emCenter, emRight, emVCenter, emWrap, emUpper, emLower, emGrow);

property EditMode: TdxOcEditMode;

Description

Set the EditMode flags to determine how text will be displayed within tree nodes.  Additionally, EditMode sets specific properties of the in-place text editor.

Value	Meaning
emLeft	Text is left-justified in the client area of a node.
emCenter	Text is centered within a node.
emRight	Text is right-justified in the client area of a node.
emVCenter	Text is vertically centered within a node. This mode works successfully with single lines only.
emWrap	Text automatically wraps.  When necessary, if this property is set to False, the width of a node increases to the text size.
emUpper	During editing, letters are converted into upper case.
emLower	During editing, letters are converted into lower case.
emGrow	If necessary, the height of nodes grow to the size of appropriate text.


TdxCustomOrgChart.Images

TdxCustomOrgChart            See Also

Determines which image list is associated with the component.

property Images: TImageList;

Description

Use Images to specify the TImageList component containing an image list for all TdxOrgChart nodes. The TdxOcNode.ImageIndex property sets an image from this list.

Note: When Images is set to a non Null value, the DefaultImageAlign property, if set originally to iaNone, automatically converts into iaLT.


TdxCustomOrgChart.IndentX

TdxCustomOrgChart            See Also

IndentX is the width of the blank space separating nodes horizontally.

property IndentX: Word;

Description

Use IndentX to determine by what amount adjacent nodes are separated.


TdxCustomOrgChart.IndentY

TdxCustomOrgChart            See Also

IndentY is the height of the blank space separating nodes vertically.

property IndentY: Word;

Description

Use IndentY to determine by what amount child nodes are separated from their parents.


TdxCustomOrgChart.LineColor

TdxCustomOrgChart          See Also

Specifies the color of lines between nodes and the color of node borders.

property LineColor: TColor;

Description

Use the LineColor property to change the color of lines and node borders.  Note that if the ocRect3D option is enabled, the LineColor property also specifies the color of the shadows painted for rectangular nodes.

The default value of the LineColor property is clBlack.


TdxCustomOrgChart.LineWidth

TdxCustomOrgChart

LineWidth determines the width of all drawn lines.

property LineWidth: Word;

Description

Use LineWidth to set the width of lines for drawn nodes and the connections between them.

Note: In Zoom mode, LineWidth always returns 1, regardless of values set.


TdxCustomOrgChart.Options

TdxCustomOrgChart

Options determines the different runtime properties of the component.

type

  TdxOcOptions = set of (ocSelect, ocFocus, ocButtons, ocDblClick, ocEdit, ocCanDrag, ocShowDrag, ocInsDel, ocRect3D, ocAnimate);

property Options: TdxOcOptions;

Description

Set the flags in Options to determine display features, as well as keyboard and mouse support for your component.

Value	Meaning
ocSelect	Selected item is marked by a focus rectangle.
ocFocus	The focused item is marked by clHighlight color.
ocButtons	Nodes with hildren are displayed with [+] and [-] buttons. In Zoom mode, only [+] buttons are displayed.
ocDblClick	Double click opens and closes the selected node.
ocEdit	Allows text editing in nodes.
ocCanDrag	The component starts Drag & Drop on dragging a node . When ocCanDrag = False the application may still activate Drag & Drop by calling BeginDrag.
ocShowDrag	Displays the location of a node and its connection with the potential parent during node drag operations.
ocInsDel	Inserts and deletes nodes using the Ins, Ctrl-Ins and Del keys on the keyboard.
ocRect3D	Rectangle nodes (Shape = shRectangle) are displayed with the three-dimensional effect. For rectangle nodes only.
ocAnimate	Expands and collapses nodes with an animation effect.


TdxCustomOrgChart.RootCount

TdxCustomOrgChart          See Also

Returns the number of nodes at the root hierarchy level.

property RootCount: Integer;

Description

Use the RootCount property to obtain the number of nodes at the root level.  This property can be used in combination with the Items property to traverse through root nodes.  The latter property provides indexed access to root nodes.  The first node’s index is 0.  The last node’s index is the RootCount property value decremented by one.


TdxCustomOrgChart.Rotated

TdxCustomOrgChart

Rotated controls the orientation of the tree structure layout.

property Rotated: Boolean;

Description

Use Rotated to flip the component’s display 90 degrees.  If Rotated=True, nodes of the same level are positioned vertically and parents are on the left in relation to child nodes.

Set Rotated to False for returning the component to its normal state with a horizontal layout of child nodes.


TdxCustomOrgChart.SelectedNodeColor

TdxCustomOrgChart

Specifies the selected node’s background color.

property SelectedNodeColor: TColor;

Description

If the control’s ocSelect option is enabled, end users can select nodes by clicking them with the mouse.  When a node is selected, its background color is specified by the SelectedNodeColor property value.  The selected node’s text color is set using the SelectedNodeTextColor property.

The default value of the SelectedNodeColor property is clHighlight.


TdxCustomOrgChart.SelectedNodeTextColor

TdxCustomOrgChart

Specifies the selected node’s text color.

property SelectedNodeTextColor: TColor;

Description

If the control’s ocSelect option is enabled, end users can select nodes by clicking them with the mouse.  When a node is selected, its background color is specified by the SelectedNodeColor property value.  The selected node’s text color is set using the SelectedNodeTextColor property.

The default value of the SelectedNodeColor property is clHighlightText.


TdxCustomOrgChart.Zoom

TdxCustomOrgChart            See Also

Turns the component’s zooming mode on or off.

property Zoom: Boolean;

Description

Use Zoom to display the entire tree structure within the component window at runtime. When Zoom=True, the component diminishes to the window size (when necessary) and never displays scroll bars. In this mode, a user cannot edit a node’s text. Set Zoom to False for returning the component to its normal size.

Note

Value of the Zoom property does not reflect the real zooming state, because even if Zoom is True, the component size (client area) may be enough so as not to perform zooming.  To know whether Zoom is effect, you should use the IsZoomed function instead of the Zoom property.


TdxCustomOrgChart.CreateNode

TdxCustomOrgChart            See Also

CreateNode creates a new tree node instance.

function CreateNode: TdxOcNode; virtual;

Description

Called from the InternalAdd, to create a new node. By default creates a TdxOcNode object, calls the OnCreateNode event handler and returns a reference to the created object. Descendants of the TdxCustomOrgChart can override the CreateNode for the creation of objects inherited from the TdxOcNode. The overridden CreateNode method must create an object of the demanded class and as a result return a reference to it.

The created node is not a part of the data structure yet, that's why any operations are not available for it, except reading and setting properties.  Do not call the CreateNode directly; use Add or Insert to create new nodes.

TMyNode = class(TdxOcNode)

...

end;

TMyChart = class(TdxCustomOrgChart)

...

  function CreateNode: TdxOcNode; override;

...

end;

function  TMyChart.CreateNode: TdxOcNode;

begin

  Result := TMyNode.Create(Self);  // a node of TmyNode class

  Result.Color := clRed;	   // all the nodes are red

end;


TdxCustomOrgChart.CreateEditor

TdxCustomOrgChart            See Also

function CreateEditor: TdxOcInplaceEdit; virtual;

Description

Called when first entering text editing mode. Creates the TdxOcInplaceEdit object and returns a reference to it. Can be overridden to set some properties of the text editor or to create another editor inherited from the TdxOcInplaceEdit.

TMyChart = class(TdxCustomOrgChart)

...

  function CreateEditor: TdxOcInplaceEdit; override;

...

end;

function  TMyChart.CreateEditor: TdxOcInplaceEdit;

begin

  Result := TdxOcInplaceEdit.Create(Self);

  Result.MaxLength := 40;  // editor with text length restriction

end;


TdxCustomOrgChart.CreateParams

TdxCustomOrgChart            See Also

CreateParams initializes parameters for window creation.

procedure CreateParams(var Params: TCreateParams); override;

Description

Overrides the TWinControl.CreateParams.  Includes scroll bars into the window and sets a border style according to the BorderStyle and Ctl3D properties.


TdxCustomOrgChart.DblClick

TdxCustomOrgChart            See Also

DblClick processes the mouse button double click event.

procedure DblClick; override;

Description

Overrides the TWinControl.DblClick.  If the ocDblClick in Options is True, then changes pointed by the mouse node’s Expanded property to the opposite, i.e. expands or collapses the node.


TdxCustomOrgChart.DoChange

TdxCustomOrgChart            See Also

DoChange notifies that a selected node has changed.

procedure DoChange(Node: TdxOcNode); virtual;

Description

Called after a Node is selected.  By default calls the OnChange event, if it is defined.  Can be overridden to provide reaction to the change of a selected node.


TdxCustomOrgChart.DoChanging

TdxCustomOrgChart            See Also

procedure DoChanging(Node: TdxOcNode; var Allow: Boolean); virtual;

Description

Called before a Node is selected.  By default calls the OnChanging event, if it is defined.  The overridden method must set Allow to True or False based on whether the selection of a Node is allowed or prohibited.  DoChanging is called on selection of a node by the mouse or keys, but is not called on the program setting of the Selected property.


TdxCustomOrgChart.DragOver

TdxCustomOrgChart            See Also

DragOver processes dragging of an object over the component.

procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); override;

Description

Overrides the TControl.DragOver.  Enables or disables Drag and Drop operations depending on cursor location.  Scrolls the window once it approaches its edges.  If the ocShowDrag in Options is True, draws the dragged node's contour and its connections with the potential new parent. Finally calls the OnDragOver event, if it is defined.


TdxCustomOrgChart.DrawNode

TdxCustomOrgChart            See Also

DrawNode draws a tree node on the specified canvas.

procedure DrawNode(Node: TdxOcNode; ACanvas: TCanvas; Rect: TRect); virtual;

Description

Called on drawing a Node on the screen. By default calls the OnDfawNode event.  If undefined, displays the text and the image defined by the Node.Text and Node.ImageIndex properties.  Overriding the DrawNode, the TdxCustomOrgChart descendants can implement another algorithm of node drawing.  Do not use the Canvas property of the component for drawing; use ACanvas parameter instead.  Rect parameter contains the coordinates of a Node’s client area, which must limit the drawing region.  The DfawNode method must not change the properties of the nodes, otherwise endless recursion of component drawing is possible.


TdxCustomOrgChart.InternalAdd

TdxCustomOrgChart            See Also

Adds a new node to the tree data structure.

procedure InternalAdd(AParent: TdxOcNode; Ptr: Pointer; AIndex: Integer): TdxOcNode; virtual;

Description

Called from the Add… and Insert methods.  Creates a new node by calling CreateNode and inserts it in the AParent child list by AIndex. The Data property is set to Ptr.  If AParent =nil, a new node is placed at the top level of the hierarchy.  A reference to the created node returns as a result of a function call.  TdxCustomOrgChart descendants can override InternalAdd for providing additional actions on creating new nodes. The overridden InternalAdd method must always call inherited InternalAdd.  A direct call of the InternalAdd should be used carefully, since incorrect settings of parameters may raise an exception.


TdxCustomOrgChart.InternalMoveTo

TdxCustomOrgChart            See Also

Moves a node to a new location in the tree structure.

procedure InternalMoveTo(AParent,ANode: TdxOcNode; AIndex: Integer); virtual;

Description

Called from MoveTo. Moves the ANode to the AParent children list by AIndex.  If AParent=nil, the node moves to the top level of the hierarchy.  TdxCustomOrgChart descendants can override InternalMoveTo to provide additional actions when moving nodes.  The overridden InternalMoveTo method must always call inherited InternalMoveTo.  A direct call of the InternalMoveTo should be used carefully since incorrect settings of the parameter may raise exceptions.


TdxCustomOrgChart.KeyDown

TdxCustomOrgChart            See Also

Processes keyboard input.

procedure KeyDown(var Key: Word; Shift: TShiftState); override;

Description

Overrides the TWinControl.KeyDown.  Implements cursor key functionality.  If ocInsDel within Options is set to True, it also implements the following key functions: Ins (inserts a new node), Ctrl-Ins (inserts a new child) and Del (deletes a node).


TdxCustomOrgChart.KeyPress

TdxCustomOrgChart            See Also

Processes signals from a keyboard’s alphanumeric keys.

procedure KeyPress(var Key: Char); override;

Description

Overrides the TWinControl.KeyPress. Processes the {+} and {-} keys, used for expanding and collapsing a selected node.


TdxCustomOrgChart.MouseDown

TdxCustomOrgChart            See Also

Processes signals from mouse buttons.

procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X,Y: Integer); override;

Description

Overrides the TControl.MouseDown.  Clicking a node via the left mouse button selects a given node.  Clicking the {+} and {-}  buttons within the chart, expands or collapses a given node.


TdxCustomOrgChart.MouseMove

TdxCustomOrgChart            See Also

Processes mouse movement over the component.

procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;

Description

Overrides the TControl.MouseMove.  If the left button is pressed and the ocCanDrag mode in Options is set to True, MouseMove starts the Drag & Drop process.


TdxCustomOrgChart.NodeChanged

TdxCustomOrgChart

Notifies that one or more node properties have changed.

procedure NodeChanged(Node: TdxOcNode); virtual;

Description

Called on changes made to any of the following properties of a Node: Width, Height, ChildAlign, Color, Shape, ImageIndex, ImageAlign or Text.  By default, this element performs no actions. TdxCustomOrgChart descendants can override this method in order to provide reaction to changes of node properties.


TdxCustomOrgChart.Paint

TdxCustomOrgChart

Draws a component on the screen.

procedure Paint; override;

Description

Overrides the TCustomControl.Paint.  Draws the component by the system message WM_PAINT.


TdxCustomOrgChart.Loaded

TdxCustomOrgChart

Ends the process of component loading from the stream.

procedure Loaded; override;

Description

Overrides the TComponent.Loaded.  At design-time, upon loading of the component, calls FullExpand.


TdxCustomOrgChart.Create

TdxCustomOrgChart

Creates an instance of TdxCustomOrgChart.

constructor Create(AOwner: TComponent); override;

Description

Creates the TdxCustomOrgChart component.  The following values are assigned once a component is created.

Width	320
Height	200
DefaultNodeWidth	64
DefaultNodeHeight	40
IndentX	16
IndentY	16
LineWidth	1
BorderStyle	bsSingle
EditMode	[emWrap]
Options	[ocSelect,ocFocus,ocButtons,ocDblClick, ocEdit,ocCanDrag,ocShowDrag]


TdxCustomOrgChart.Destroy

TdxCustomOrgChart

Destroys an instance of TdxCustomOrgChart.

destructor  Destroy; override;

Description

Destroys the TdxCustomOrgChart component...Before the inherited Destroy call destroys all tree nodes. Do not call Destroy directly; call Free instead.


TdxCustomOrgChart.Add

TdxCustomOrgChart            See Also

Adds a new node to the tree structure.

function  Add(Node: TdxOcNode; Ptr: Pointer): TdxOcNode;

Description

Creates a new node and adds it to the same level as the Node - to the end of the list.  The Ptr parameter sets the Data property value of a new node.  A reference to a new node returns as a result of the function call.


TdxCustomOrgChart.AddChild

TdxCustomOrgChart            See Also

Adds a new node to the tree structure.

function  Add(Node: TdxOcNode; Ptr: Pointer): TdxOcNode;

Description

Creates a new node and makes it the last child of the Node.  The Ptr parameter sets the Data property value of a new node.  A reference to a new node returns as a result of the function call.


TdxCustomOrgChart.AddChildFirst

TdxCustomOrgChart            See Also

Adds a new node to the tree structure.

function AddChildFirst(Node: TdxOcNode; Ptr: Pointer): TdxOcNode;

Description

Creates a new node and makes it the first child of the Node.  The Ptr parameter sets the Data property value of a new node.  A reference to a new node returns as a result of calling the function.


TdxCustomOrgChart.AddFirst

TdxCustomOrgChart            See Also

Adds a new node to the tree structure.

function AddFirst(Node: TdxOcNode; Ptr: Pointer): TdxOcNode;

Description

Creates a new node and adds it to the same level as the Node - to the beginning of the list. The Ptr parameter sets the Data property value of a new node.  A reference to the new node returns as a result of calling the function.


TdxCustomOrgChart.AssignData

TdxCustomOrgChart

Copies the data structure from another component.

procedure AssignData(Source: TdxCustomOrgChart);

Description

Copies data (i.e tree of nodes) from another TdxCustomOrgChart specified by the Source parameter.  In this operation, previous data is lost.


TdxCustomOrgChart.BeginUpdate

TdxCustomOrgChart            See Also

Prevents component redrawing until the EndUpdate method is called.

procedure BeginUpdate;

Description

Prohibits any changes to the screen until an EndUpdate call.  With a large amount of additions and deletions, an application can call BeginUpdate, make some changes and then call EndUpdate for component redraw.  The calls of BeginUpdate are accumulated, that's why each BeginUpdate call must have a corresponding EndUpdate call.


TdxCustomOrgChart.Clear

TdxCustomOrgChart            See Also

Deletes all tree nodes managed by a component.

procedure Clear;

Description

Use the Clear method to remove all nodes from a tree structure.


TdxCustomOrgChart.Delete

TdxCustomOrgChart            See Also

Removes a node from the tree structure.

procedure Delete(Node: TdxOcNode); virtual;

Description

Deletes a Node and all its children. Components inherited from TdxCustomOrgChart can override Delete for setting additional actions on deleting the node.  The overridden method Delete must always end with calling the inherited Delete.

On overriding Delete you should take into a account the following: first – the possibility of Delete (nil) call and second – the possibility of recursive calls of Delete via DeleteChildren, but in this case references to some nodes may be invalid.  If the overridden method Delete references other nodes, then you should check the Deleting property as in the example below.

procedure TMyChart.Delete(Node: TdxOcNode);

   var

     N: TdxOcNode;

   begin

     if Node = nil then Exit;	// obligatory!

     Images.Delete(Node.ImageIndex);	// (for example)

     N := GetFirstNode;

     while N <> nil do begin	// a cycle in all nodes

       if N.Deleting then N := Node;	// ignores already deleted nodes!

       if N.ImageIndex > Node.ImageIndex then

         N.ImageIndex := N.ImageIndex - 1;

       N := N.GetNext;

     end;

     inherited Delete(Node);

   end;

N.Deleting = True means, that N is a direct or indirect parent of the Node and all its children foregoing the Node are already deleted.


TdxCustomOrgChart.DoZoom

TdxCustomOrgChart            See Also

Scales the given value in Zoom mode.

function  DoZoom(Value: Integer): Integer;

Description

If Zoom is False, it returns the unchanged value of the Value parameter.  If Zoom is True, returns Value diminished in accordance with a scaling factor.  DoZoom can be used by applications for font scaling in the OnSetFont event, for example.


TdxCustomOrgChart.DragDrop

TdxCustomOrgChart            See Also

Completes a Drag & Drop operation.

procedure DragDrop(Source: TObject; X, Y: Integer); override;

Description

Overrides TControl.DragDrop.  If the OnDragDrop event is defined then calls it; Otherwise having called MoveTo, moves the selected node to that pointed by the mouse position.  This scheme works for inner movements within one TdxOrgChart component only. For Drag & Drop implementation between and among multiple components, the OnDragDrop must be defined.  OnDragOver event is not required if a source of movement belongs to TdxCustomOrgChart class.


TdxCustomOrgChart.EndUpdate

TdxCustomOrgChart            See Also

Re-enables screen repainting after the BeginUpdate call.

procedure EndUpdate;

Description

Cancels BeginUpdate and calls Invalidate for component redrawing.  After this, any changes will be displayed on the screen.  The calls of BeginUpdate are accumulated, that's why each BeginUpdate call must have a corresponding EndUpdate call.


TdxCustomOrgChart.FullCollapse

TdxCustomOrgChart            See Also

Collapses all nodes in the OrgChart.

procedure FullCollapse;

Description

Call FullCollapse to hide all nodes of the tree, leaving visible only the nodes of the top level.


TdxCustomOrgChart.FullExpand

TdxCustomOrgChart            See Also

Expands all nodes in the OrgChart.

procedure FullExpand;

Description

Call FullExpand to display all nodes of the tree, making a data structure completely visible on the screen.  If ocButtons in Options is True, all node buttons will change from {+} to {-}.


TdxCustomOrgChart.FullHeight

TdxCustomOrgChart            See Also

Returns the current OrgChart height.

function  FullHeight: Integer;

Description

Call FullHeight to examine the full height of a component, which may be bigger than the window height.  This value changes upon additions to and deletions from nodes, expanding and collapse, as well as on zooming.  Unlike the TdxOcNode.Height property, FullHeight always returns the actual height, regardless of the Rotated property.


TdxCustomOrgChart.FullWidth

TdxCustomOrgChart            See Also

Returns the current OrgChart width.

function FullWidth: Integer;

Description

Call FullWidth to examine the full width of a component, which may be bigger than the window width.  This value changes upon additions and deletions from nodes, expanding and collapse, as well as zooming.  Unlike the TdxOcNode.Width property, FullWidth always returns the actual Width, regardless of the Rotated property.


TdxCustomOrgChart.GetFirstNode

TdxCustomOrgChart

Returns the first node in a tree.

function GetFirstNode: TdxOcNode;

Description

Use GetFirstNode to retrieve the first node of a tree, i.e. the very left node of the zero level. GetFirstNode is similar to Items[0] but returns nil if there are no nodes.


TdxCustomOrgChart.GetHitTestsAt

TdxCustomOrgChart            See Also

Returns information about the point location in a component's client area.

Type:

TdxOcHitTest = (htNowhere,htOnLeftIndentX,htOnRightIndentX,htOnIndentY,

htUnder,htOnRect,htOnShape,htOnButton);

TdxOcHitTests = set of TdxOcHitTest;

function GetHitTestsAt(X,Y: Integer): TdxOcHitTests;

Description

Returns flag combination, determining the location of a point with (X, Y) coordinates relative to the node returned by GetNodeAt function. Coordinates are set relative to the client area of the component...Usually used while processing the events of a mouse.  Values of the flags are the following:

Value	Location of (X, Y)
htNowhere	Does not belong to any node.
htOnLeftIndentX	In the separating space area to the left of a node. (Rotated=True - above a node.)
htOnRightIndentX	In the separating space area to the right of a node. ( Rotated=True - below a node.)
htOnIndentY	In the separating area above a node. ( Rotated=True – to the left of a node.)
htUnder	Below a closed node or a node without children. ( Rotated=True - to the right of a node.)
htOnRect	Inside a rectangle, limiting the node’s contour.
htOnShape	Inside a node’s contour. For rectangle nodes htOnShape and htOnRect are similar.
htOnButton	On a ({+} - {-}) button.


TdxCustomOrgChart.GetNodeAt

TdxCustomOrgChart            See Also

Returns the node that is found at a specified position.

function GetNodeAt(X,Y: Integer): TdxOcNode;

Description

Returns a reference to the node, containing a point with (X, Y) coordinates.  Coordinates are set relative to the client area of the component...Usually used in handling mouse events. Use the GetHitTestsAt function to determine the point location relative to this node.  If no node is found, GetNodeAt returns nil.

The example below offers an implementation of a simple Drag & Drop interface with an ability of node shifts between components.

procedure TForm1.Chart1DragDrop(Sender,Source: TObject; X,Y: Integer);

   var

     Node,New: TdxOcNode;

     Mode: TdxOcAttachMode;

     HT: TdxOcHitTests;

     Chart: TdxOrgChart;

   begin

     Chart := TdxOrgChart(Sender);	// component-receiver

     Node := Chart.GetNodeAt(X,Y);	// indicated by the mouse node

     HT := Chart.GetHitTestsAt(X,Y);	// or its area

     Mode := naInsert;

     if htUnder in HT then Mode := naAddChild;

     if HT * [htOnRect,htOnRightIndentX] <> []

     then Node := Node.GetNextSibling;	// (insertion after the Node)

     if Node=nil then begin	// (if the Node is the last)

       Node := Chart.GetNodeAt(X,Y).Parent;

       Mode := naAddChild;

     end;

     if Source=Chart

     then Chart.Selected.MoveTo(Node,Mode)	// internal drag

     else begin	// external drag

      if Mode=naInsert then New := Chart.Insert(Node,nil)

       else New := Chart.AddChild(Node,nil);

       Node := TdxOrgChart(Source).Selected;

       New.Text := Node.Text;

       New.ImageIndex := Node.ImageIndex;	// (Sender and Source have one and the same Image list)

       New.ImageAlign := Node.ImageAlign;	//

       Chart.Selected := New;

     end;

     Chart.Selected.MakeExposed;

   end;


TdxCustomOrgChart.HideEditor

TdxCustomOrgChart            See Also

Ends node text editing.

procedure HideEditor(Save: Boolean);

Description

If edit mode is active, finishes the text editing of a node.  The Save parameter indicates whether to save the entered text.  If Save=True, the Text property of the selected node will be set to the entered text; if Save=False, the node's Text property stays unchanged. Setting the Editing property to False is similar to HideEditor(True).


TdxCustomOrgChart.Insert

TdxCustomOrgChart            See Also

Inserts a new node to a tree structure.

function Insert(Node: TdxOcNode; Ptr: Pointer): TdxOcNode;

Description

Creates a new node and adds it to the data structure directly before the Node parameter.  The Ptr parameter sets the Data property value of a new node.  A reference to the new node returns as a result of the function call.


TdxCustomOrgChart.Invalidate

TdxCustomOrgChart

Notifies that a component must be repainted.

procedure Invalidate; override;

Description

Overrides TControl.Invalidate. Calls inherited Invalidate only when necessary.


TdxCustomOrgChart.IsZoomed

TdxCustomOrgChart            See Also

Determines whether zooming is active.

function  IsZoomed: Boolean;

Description

Returns True if Zoom mode is both True and Active, i.e. the linear size of the component is diminished to the window size.


TdxCustomOrgChart.SetLeftTop

TdxCustomOrgChart            See Also

Sets a new component location in its window.

procedure SetLeftTop(ALeft,ATop: Integer);

Description

Use SetLeftTop to set new values for the LeftEdge and TopEdge properties.  This operation scrolls the window in one or both directions.

Note: The set values of the LeftEdge and TopEdge properties might differ from ALeft and ATop parameters due to scrolling restrictions.


TdxCustomOrgChart.ShowEditor

TdxCustomOrgChart            See Also

Begins text editing of a node.

procedure ShowEditor; virtual;

Description

Use ShowEditor to start text editing of a selected node.  ShowEditor is ignored if the ocEdit mode in Options is False or there is no selected item or the component is in the Zoom mode. The ShowEditor call is equal to setting Editing = True.


TdxCustomOrgChart.OnCreateNode

TdxCustomOrgChart            See Also

Enables you to initialize newly added nodes.

TdxOcEvent = procedure(Sender: TObject; Node: TdxOcNode) of object;

property OnCreateNode: TdxOcCreateEvent;

Description

New nodes can be created via code by using a control’s methods such as Add, Insert, AddFirst, etc.  If the coInsDel option is enabled, end users can also add new nodes using the Ins key.  In both cases, the control raises the OnCreateNode event that allows you to initialize the added node.

The Sender parameter identifies the control whose node has been created.  The Node parameter represents the added node and should be used to perform initialization.

The sample below shows how to specify the default appearance for nodes added at runtime.

procedure TForm1.ChartCreateNode(Sender: TObject; Node: TdxOcNode);

begin

  Node.Shape := shEllipse; // all nodes are in the form of an ellipse

  Node.Color := clYellow; //yellow color

end;


TdxCustomOrgChart.OnChange

TdxCustomOrgChart            See Also

Occurs when the selection has changed from one node to another.

TdxOcEvent = procedure(Sender: TObject; Node: TdxOcNode) of object;

property OnChange: TdxOcEvent;

Description

Called after a Node is selected (Selected).  On changing a selected node by the OnChange event can fulfill definite actions.  The example below is taken from the node editor for TdxOrgChart at design-time.  On selection of any node, its properties are displayed in the window and become available for editing.

procedure TEditor.ChartChange(Sender: TObject; Node: TdxOcNode);

   var

     Info: TdxOcNodeInfo;

   begin

     Node.GetNodeInfo(Info);

     WidthEdit.Text := IntToStr(Info.Width);	// (TEdit)

     HeightEdit.Text := IntToStr(Info.Height);	// (TEdit)

     ImIndexEdit.Text := IntToStr(Info.Index);	// (TEdit)

     ImAlignEdit.ItemIndex := Ord(Info.IAlign);	// (TComboBox)

     ChAlignEdit.ItemIndex := Ord(Info.Align);	// (TComboBox)

     ShapeEdit.ItemIndex := Ord(Info.Shape);	// (TComboBox)

     ColorEdit.Text := ColorToString(Info.Color);// (TComboBox)

   end;


TdxCustomOrgChart.OnChanging

TdxCustomOrgChart            See Also

Occurs whenever a selection is about to change from one node to another.

TdxOcAllowEvent = procedure(Sender: TObject; Node: TdxOcNode; var Allow: Boolean) of object;

property OnChanging: TdxOcAllowEvent;

Description

Called before a Node is selected (Selected).  The processing procedure must set Allow to True or False depending on whether the Node selection is enabled or disabled.  The OnChanging property is called upon selection of a node by the mouse or keys, but not called by the program setting of the Selected property.

procedure TForm1.ChartChanging(Sender: TObject; Node: TdxOcNode; var Allow: Boolean);

begin

  Allow := Node.Color <> clRed;	// not to select the red nodes

end;


TdxCustomOrgChart.OnCollapsed

TdxCustomOrgChart            See Also

TdxOcEvent = procedure(Sender: TObject; Node: TdxOcNode) of object;

property OnCollapsed: TdxOcEvent;

Description

Called after the collapsing the Node by Collapse method.  Use the OnCollapsed event to perform actions while closing nodes.


TdxCustomOrgChart.OnCollapsing

TdxCustomOrgChart            See Also

Occurs after a node has collapsed.

TdxOcAllowEvent = procedure(Sender: TObject; Node: TdxOcNode; var Allow: Boolean) of object;

property OnCollapsing: TdxOcAllowEvent;

Description

Called after collapsing a Node by the Collapse method.  Use the OnCollapsed event to perform actions after collapsing nodes.


TdxCustomOrgChart.OnDeletion

TdxCustomOrgChart            See Also

Occurs when a node in the OrgChart is deleted.

TdxOcEvent = procedure(Sender: TObject; Node: TdxOcNode) of object;

property OnDeletion: TdxOcEvent;

Description

Called on deleting a Node by the Delete method.  Use the OnDeletion event to perform actions when deleting nodes.


TdxCustomOrgChart.OnExpanded

TdxCustomOrgChart            See Also

Occurs after expanding a node.

TdxOcEvent = procedure(Sender: TObject; Node: TdxOcNode) of object;

property OnExpanded: TdxOcEvent;

Description

Called after the expansion of a Node by Expand method.  Use the OnExpand event to perform actions when expanding nodes.


TdxCustomOrgChart.OnExpansion

TdxCustomOrgChart            See Also

Occurs after expanding a node.

TdxOcAllowEvent = procedure(Sender: TObject; Node: TdxOcNode; var Allow: Boolean) of object;

property OnExpansion: TdxOcAllowEvent;

Description

Called before the expansion the a Node by Expand method. The processing procedure must set Allow to True or False depending on whether Node expansion is enabled or disabled.


TdxCustomOrgChart.OnEditing

TdxCustomOrgChart            See Also

Occurs when a user starts to edit the Text property of a node.

TdxOcAllowEvent = procedure(Sender: TObject; Node: TdxOcNode; var Allow: Boolean) of object;

property OnEditing: TdxOcAllowEvent;

Description

Called before the call of the text editor mode for a Node.  The processing procedure can set Allow to False in order to disable editing.


TdxCustomOrgChart.OnEdited

TdxCustomOrgChart            See Also

Occurs after a user edits the Text property of a node.

TdxOcGetTextEvent = procedure(Sender: TObject; Node: TdxOcNode; var Value: String) of object;

property OnEdited: TdxOcGetTextEvent;

Description

Called on ending text editing for a Node.  The Value parameter contains the text entered into the editor.

Before the Node.Text property assigns this value, the processing procedure can alter it.  If editing has been canceled by the Esc key or HideEditor(False) call, OnEdited is not called.


TdxCustomOrgChart.OnSetFont

TdxCustomOrgChart            See Also

Occurs when a node requires drawing its text.

TdxOcFontEvent = procedure(Sender: TObject; Node: TdxOcNode; Font: TFont) of object;

property OnSetFont: TdxOcFontEvent;

Description

Called on drawing a Node on the screen and also on calling the text editor for the Node.  The processing procedure can alter any Font properties, i.e. add individual fonts for any concrete node.


TdxCustomOrgChart.OnDrawNode

TdxCustomOrgChart            See Also

Occurs when a node must be repainted.

TdxOcDrawEvent = procedure(Sender: TObject; Node: TdxOcNode; ACanvas: TCanvas; Rect: TRect) of object;

property OnDrawNode: TdxOcDrawEvent;

Description

Called on drawing a Node on the screen after drawing the node's contour filled with Node.Color.  Using the OnDrawNode event, an application can set its own algorithm of the node internal element drawing instead of using the standard procedure (text and image).

Do not use the Canvas property of the component for drawing; use ACanvas parameter instead.  The Rect parameter contains coordinates of the Node that actually restrict the drawing area.  The OnDrawNode event handler must not alter the node’s properties, otherwise deadlock of component redraw is possible.


TdxCustomOrgChart.OnGetText

TdxCustomOrgChart            See Also

Occurs on reading the text of a node.

TdxOcGetTextEvent = procedure(Sender: TObject; Node: TdxOcNode; var Value: String) of object;

property OnGetText: TdxOcGetTextEvent;

Description

Implements reading the Node.Text property.  The processing procedure must return a text string via Value.  Using the OnGetText event, an application can implement its own unique requirements that differ from the standard access scheme to texts: for example, to create a node's number by its Level and Index properties.

procedure TForm1.ChartGetText(Sender: TObject; Node: TdxOcNode;

var Value: String);

   begin

     Value := IntToStr(Node.Index+1);

     if Node.Parent<>nil then Value := Node.Parent.Text + '.' + Value;

   end;


TdxCustomOrgChart.OnSetText

TdxCustomOrgChart            See Also

Occurs on setting the text of a node.

TdxOcSetTextEvent = procedure(Sender: TObject; Node: TdxOcNode; const Value: String) of object;

property OnSetText: TdxOcSetTextEvent;

Description

Saves the Node.Text property.  Using the OnSetText event, an application can implement its own unique requirements that differ from the standard access scheme to text: for example, store text strings in a TStringList list or in a text file.


TdxOrgChart

Hierarchy            Properties             Methods             Events

Unit

DxOrgChr

Description

TdxOrgChart – is a fully functional component designed for the display and editing of hierarchical tree data structures such as the contents of a book or file system on a disc.  Each node of the tree can have a free number of children, displayed horizontally, directly below a given node.  TdxOrgChart enables an incredibly wide number of possibilities to manage the contents and appearance of both the entire chart structure as well as each individual node.


Hierarchy

TObject

     |

TPersistent

     |

TComponent

     |

TControl

     |

TWinControl

     |

TCustomControl

     |

TdxCustomOrgChart

     |


TdxOrgChart Properties

TdxOrgChart

Derived from TdxCustomOrgChart

AbsoluteItems

Count

Editing

Items

LeftEdge

RootCount

Selected

TopEdge

Zoom

BorderStyle

DefaultImageAlign

DefaultNodeHeight

DefaultNodeWidth

EditMode

Images

IndentX

IndentY

LineColor

LineWidth

Options

Rotated

SelectedNodeColor

SelectedNodeTextColor


TdxOrgChart Methods

TdxOrgChart

In TdxOrgChart

DefineProperties

Derived from TdxCustomOrgChart

CreateNode

CreateEditor

CreateParams

DblClick

DoChange

DoChanging

DragOver

DrawNode

InternalAdd

InternalMoveTo

KeyDown

KeyPress

MouseDown

MouseMove

NodeChanged

Paint

Loaded

Create

Destroy

Add

AddChild

AddChildFirst

AddFirst

AssignData

BeginUpdate

Clear

Delete

DoZoom

DragDrop

EndUpdate

FullCollapse

FullExpand

FullHeight

FullWidth

GetFirstNode

GetHitTestsAt

GetNodeAt

HideEditor

Insert

Invalidate

IsZoomed

SetLeftTop

ShowEditor


TdxOrgChart Events

TdxOrgChart

Derived from TdxCustomOrgChart

OnCreateNode

OnChange

OnChanging

OnCollapsed

OnCollapsing

OnDeletion

OnExpanded

OnExpansion

OnEditing

OnEdited

OnSetFont

OnDrawNode

OnGetText

OnSetText


TdxOrgChart.DefineProperties

TdxOrgChart

procedure DefineProperties(Filer: TFiler); override;

Description

Overrides TWinControl.DefineProperties.  After saving published properties, stores the node structure connected with a component.


TdxOcInplaceEdit

Hierarchy             Methods

Unit

DxOrgChr

Description

TdxOcInplaceEdit is a multiline text editor for text editing of TdxCustomOrgChart nodes. Created and controlled by the TdxCustomOrgChart component, it is not intended for use outside it.


Hierarchy

TObject

     |

TPersistent

     |

TComponent

     |

TControl

     |

TWinControl

     |

TCustomEdit

     |


TdxOcInplaceEdit Methods

TdxOcInplaceEdit

CreateParams

KeyDown

KeyUp

KeyPress

Create

Tree


TdxOcInplaceEdit.CreateParams

TdxOcInplaceEdit            See Also

procedure CreateParams(var Params: TCreateParams); override;

Description

Overrides TCustomEdit.CreateParams. Sets the edit modes according to those set in Tree.EditMode.


TdxOcInplaceEdit.KeyDown

TdxOcInplaceEdit            See Also

procedure KeyDown(var Key: Word; Shift: TShiftState); override;

Description

Overrides TCustomEdit.KeyDown.  Handles the following keys:

F2, Alt-Enter – ends editing.

Esc – cancels editing.

Alt + arrows – stops editing and moves to the next node.


TdxOcInplaceEdit.KeyUp

TdxOcInplaceEdit            See Also

procedure KeyUp(var Key: Word; Shift: TShiftState); override;

Description

Overrides TCustomEdit.KeyUp.  Calls the KeyUp method of its owner.


TdxOcInplaceEdit.KeyPress

TdxOcInplaceEdit            See Also

procedure KeyPress(var Key: Char); override;

Description

Overrides TCustomEdit.KeyPress.  First calls KeyPress of its owner, then if a key is not filtered, calls inherited KeyPress and in case of necessity alters its own size.


TdxOcInplaceEdit.Create

TdxOcInplaceEdit            See Also

constructor Create(AOwner: TComponent); override;

Description

Creates the TdxOcInplaceEdit object.  After calling inherited Create, sets Visible and Ctl3D properties to False and Parent equal to AOwner.


TdxOcInplaceEdit.Tree

TdxOcInplaceEdit

function Tree: TdxCustomOrgChart;

Description

Returns reference to the TdxCustomOrgChart component having a given TdxOcInplaceEdit object.


TdxOcNode

Hierarchy          Properties           Methods

Unit

DxOrgChr

Description

TdxOcNode is a class, describing a single node in the TdxCustomOrgChart tree data structure.  Each node can have its own size, shape, color, text and image.


Hierarchy

TObject

     |


TdxOcNode Properties

TdxOcNode

In TdxOcNode

AbsoluteCount

AbsoluteItems

ChildAlign

Color

Count

Data

Deleting

Expanded

HasChildren

Height

ImageAlign

ImageIndex

Index

IsVisible

Items

Level

Owner

Parent

Selected

Shape

Text

Width


TdxOcNode Methods

TdxOcNode

In TdxOcNode

GetText

ReadData

SetData

SetFont

SetText

WriteData

Create

Destroy

ChildrenHeight

ChildrenWidth

ClientRect

Collapse

DeleteChildren

DisplayRect

Expand

Focused

FullHeight

FullWidth

GetFirstChild

GetLastChild

GetNext

GetNextChild

GetNextSibling

GetNextVisible

GetNodeInfo

GetPrev

GetPrevChild

GetPrevSibling

GetPrevVisible

HasAsParent

IndexOf

MakeVisible

MoveTo


TdxOcNode.AbsoluteCount

TdxOcNode          See Also

Returns the number of nodes within the current node’s child branch.

property AbsoluteCount: Integer;

Description

The AbsoluteCount property lets you determine how many children a node has in total from all hierarchy levels.  You can use this property in combination with the AbsoluteItems property to traverse through the entire child branch of a particular node.


TdxOcNode.AbsoluteItems

TdxOcNode          See Also

Provides indexed access to the current node’s children at all hierarchy levels.

property AbsoluteItems[Index: Integer]: TdxOcNode;

Description

Use the AbsoluteItems property to traverse through all the node’s child nodes at any nesting levels.  The child to be returned is identified by its index via the Index parameter.  The first child’s index is zero, the last available index is the AbsoluteCount property value decremented by one.

If you need to access the node’s children at the immediate nesting level, use the Count and Items properties instead.


TdxOcNode.ChildAlign

TdxOcNode

Determines a node's position in its home area.

type

  TdxOcNodeAlign = (caLeft, caCenter, caRight)

property ChildAlign: TdxOcNodeAlign;

Description

Use ChildAlign to set the location of a node on the screen relative to its children.  The following variants are possible:

caLeft

caCenter

caRight


TdxOcNode.Color

TdxOcNode

Background color of a node.

property Color: TColor;

Description

Sets the color of the background for a given node.  If Color = clNone, the color of a node is determined by the Color property of the TdxOrgChart component.  Reading the Color property always returns an actual color instead of clNone.


TdxOcNode.Count

TdxOcNode            See Also

Then number of direct descendants of a node.

property Count: Integer;

Description

Contains the number of direct descendants of a given node.  This number includes direct descendants only.


TdxOcNode.Data

TdxOcNode            See Also

A pointer to application-defined data associated with a node.

property Data: Pointer;

Description

Contains a pointer to data determined by an application and connected with a given node. TdxOcNode and TdxCustomOrgChart methods do not use this property.


TdxOcNode.Deleting

TdxOcNode            See Also

Indicates whether a node is in the process of being Deleted.

property Deleting: Boolean;

Description

The Deleted property is set to True while deleting a node and also (temporarily) while deleting its children by the DeleteChildren method.  Used by Delete and Destroy methods in order to prevent an endless recursion on deleting nodes.


TdxOcNode.Expanded

TdxOcNode            See Also

Specifies whether a tree node is expanded.

property Expanded: Boolean;

Description

Expanded property is True, if a given node is expanded, i.e. its children are visible on the screen.  Setting Expanded to True or False expands or collapses nodes accordingly.  It does not always initiate changes on the screen, since a parent node can be collapsed or invisible. For nodes without children the Expanded property is always equal to False and cannot be set to True.


TdxOcNode.HasChildren

TdxOcNode            See Also

Indicates whether a node has children list.

property HasChildren: Boolean;

Description

HasChildren is True, if a node has a list of children and False otherwise.  Automatically set to True on adding children to the node.  Setting HasChildren = False deletes all the nodes and the list itself.

Note: HasChildren property displays only the presence of the children list which might be also blank.  Use the Count property to determine the actual presence of children.


TdxOcNode.Height

TdxOcNode            See Also

A tree node’s height in screen pixels.

property Height: Word;

Description

Use Height to set the height of a node on the screen.  If Height=0, the height of a node is determined by the Owner.DefaultNodeHeight property.  Reading the Height property always returns the actual height taking into account default and scaling.  On setting Height, however, you should set either 0 or real (non-scaled) height.


TdxOcNode.ImageAlign

TdxOcNode            See Also

Determines image position for a node.

type

  TdxOcImageAlign = (iaNone, iaLT, iaLC, iaLB, iaRT, iaRC, iaRB, iaTL, iaTC, iaTR, iaBL, iaBC, iaBR);

property ImageAlign: TdxOcImageAlign;

Description

Use ImageAlign to set the location of an image within a node.  If ImageAlign=iaNone, the node does not have any image even when setting the ImageIndex property.

iaLT – Left Top

iaLC – Left Center

iaLB – Left Bottom

iaRT – Right Top

iaRC – Right Center

iaRB – Right Bottom

iaTL – Top Left

iaTC – Top Center

iaTR – Top Right

iaBL – Bottom Left

iaBC – Bottom Center

iaBR – Bottom Right


TdxOcNode.ImageIndex

TdxOcNode            See Also

Specifies the image displayed within a tree node.

property ImageIndex: Smallint;

Description

Use ImageIndex to set the index of an image for a node in Owner.Images list.

If ImageIndex = -1, a node does not include an image.  The image is visible when ImageAlign property is not equal to iaNone.


TdxOcNode.Index

TdxOcNode            See Also

Index is the position of a node in the list of child nodes maintained by its parent node.

property Index: Integer;

Description

Use Index to determine the position of a node relative to its sibling nodes.  Numbering begins with 0 from the left to the right, and subsequent children are indexed sequentially.


TdxOcNode.IsVisible

TdxOcNode            See Also

Indicates whether a node is currently visible in the tree structure image.

property IsVisible: Boolean;

Description

IsVisible is True, if a given node is visible on the screen, i.e. both its parent and all parents of the higher levels are expanded.

Note: IsVisible does not specify whether a node is in the window area or outside it.


TdxOcNode.Items

TdxOcNode            See Also

Items is an indexed array of immediate children of a node.

property Items[Index:Integer]: TdxOcNode;

Description

Use Index to access a child of a given node by its index.  This is a default property, so Node.Items[I] is equal to Node[I]. Items and Count properties are usually used to iterate all children of a node, for example:

for I := 0 to Count-1 do

  Items[I].Color := clRed;


TdxOcNode.Level

TdxOcNode

Indicates the total number of parents for the a node.

property Level: Integer;

Description

Use Level to determine a level number of a given node in the hierarchical data structure of a TdxCustomOrgChart object.  Nodes of the top level with no parents are on level 0, their children are on level 1, etc.


TdxOcNode.Owner

TdxOcNode

Owner is the TdxCustomOrgChart object having a tree node.

property Owner: TdxCustomOrgChart;

Description

Use Owner to refer to the TdxCustomOrgChart component which owns a given node.


TdxOcNode.Parent

TdxOcNode

Identifies the parent node of a tree node.

property Parent: TdxOcNode;

Description

Use Parent to refer to the immediate parent of a given node.  The Parent node is one level higher than a given node and includes the node as a child.


TdxOcNode.Selected

TdxOcNode            See Also

Selected determines whether a node is selected.

property Selected: Boolean;

Description

Selected property is True, if a given node is selected in the tree structure.  Set Selected to True or False to make a node selected or to cancel selection.


TdxOcNode.Shape

TdxOcNode

Shape determines the geometric image of the node frame.

type

  TdxOcShape = (shRectangle, shRoundRect, shEllipse, shDiamond);

property Shape: TdxOcShape;

Description

Use Shape to set the form of a node for its display on the screen.

The following options are available:

shRectangle

shRoundRect

shEllipse

shDiamond


TdxOcNode.Text

TdxOcNode            See Also

Represents a text string associated with a node.

property Text: String;

Description

Use Text to set a text string connected with a given node and displayed on the screen.


TdxOcNode.Width

TdxOcNode            See Also

Width of a tree node in screen pixels.

property Width: Word;

Description

Use Width to set the width of a node on the screen.  If Width=0, the width of a node is determined by the Owner.DefaultNodeWidth property.  Reading the Width property always returns the actual width taking into account default and scaling.  On setting Width, however, you should set it to 0 or real (non-scaled) width.


TdxOcNode.GetText

TdxOcNode            See Also

Returns a node's text.

function  GetText: String; virtual;

Description

GetText is a protected implementation of reading the Text property.  By default calls the Owner.OnGetText event handler; and if it is not defined, returns the contents of the private field in TdxOcNode object storing text string.  Overriding GetText and SetText methods, allows descendants of TdxOcNode to implement another scheme of access to text.  Such implementation is also available for applications via the OnGetText and OnSetText events.


TdxOcNode.ReadData

TdxOcNode            See Also

Loads a node's properties from the stream.

procedure ReadData(Stream: TStream); virtual;

Description

Called by reading the TdxCustomOrgChart object from the stream.  By default, reads from the stream values of Width, Height, Color, ChildAlign, Shape, ImageAlign properties.

Descendants of TdxOcNode can override ReadData and WriteData methods for reading and storing additional data. The overridden ReadData method must call inherited ReadData first, and only then it can read values of the additional fields from the stream.

TMyNode = class(TdxOcNode)

  Prop1: Word;

  Prop2: Integer;

  procedure ReadData(Stream: TStream); override;

  procedure WriteData(Stream: TStream); override;

end;

procedure TMyNode.ReadData(Stream: TStream);

begin

  inherited ReadData(Stream);

  Stream.ReadBuffer(Prop1,SizeOf(Prop1));

  Stream.ReadBuffer(Prop2,SizeOf(Prop2));

end;


TdxOcNode.SetData

TdxOcNode            See Also

Sets a value for the Data property.

procedure SetData(Value: Pointer); virtual;

Description

Set data is a protected implementation of writing the Data property.  By default, stores Value to the private field of the TdxocNode object.  It may be overridden in order to set reaction to a change of the Data property.  The overridden SetData method must always call inherited SetData.


TdxOcNode.SetFont

TdxOcNode            See Also

Sets the font properties for a node.

procedure SetFont(Font: TFont); virtual;

Description

Called on drawing a node on the screen and also on calling its text editor.  By default, calls the Owner.OnSetFont event handler if it is defined.  By overriding SetFont, descendants of TdxOcNode can set individual fonts for any node.


TdxOcNode.SetText

TdxOcNode            See Also

Stores the new value of a node's text.

procedure SetText(const Value: String); virtual;

Description

SetText is a protected implementation of writing the Text property.  By default, calls the Owner.OnSetText event handler; and if it is not defined, stores the Value argument to the private field of the TdxOcNode object keeping text string.  By overriding GetText and SetText methods, descendants of the TdxOcNode can implement another scheme of access to text. Such implementation is also available for applications via the OnGetText and OnSetText events.


TdxOcNode.WriteData

TdxOcNode            See Also

Stores a node's properties in the stream.

procedure WriteData(Stream: TStream); virtual;

Description

Called while storing the TdxCustomOrgChart object to the stream.  By default, stores values of Width, Height, Color, ChildAlign, Shape, ImageIndex and ImageAlign properties to the stream.  Descendants of TdxOcNode can override ReadData and WriteData methods for reading and storing additional data.  The overridden WriteData method must call inherited WriteData first, and only then can it record values of the additional fields to the stream.

TMyNode = class(TdxOcNode)

  Prop1: Word;

  Prop2: Integer;

  procedure ReadData(Stream: TStream); override;

  procedure WriteData(Stream: TStream); override;

end;

procedure TMyNode.WriteData(Stream: TStream);

begin

  inherited WriteData(Stream);

  Stream.WriteBuffer(Prop1,SizeOf(Prop1));

  Stream.WriteBuffer(Prop2,SizeOf(Prop2));

end;


TdxOcNode.Create

TdxOcNode            See Also

Creates an instance of TdxOcNode.

constructor Create(AOwner: TdxCustomOrgChart);

Description

Creates the TdxOcNode object belonging to the AOwner object of TdxCustomOrgChart class. Properties of the object get the following values upon creation:

Owner	AOwner
Width	0 (default)
Height	0 (default)
ChildAlign	caCenter
Color	clNone (default)
Shape	shRectangle
ImageIndex	-1
ImageAlign	AOwner.DefaultImageAlign

Applications usually do not need to call Create directly.  For the creation of new nodes, they should use TdxCustomOrgChart methods.  Direct Create calls may be required only for an overridden CreateNode method.


TdxOcNode.Destroy

TdxOcNode            See Also

Destroys an instance of the TdxOcNode object.

destructor Destroy; override;

Description

Deletes a TdxOcNode object.  If the destructor has been called directly (i.e via Free), the object deletes itself from the tree structure calling Owner.Delete.


TdxOcNode.ChildrenHeight

TdxOcNode            See Also

ChildrenHeight returns the height of a node's children.

function ChildrenHeight: Integer;

Description

Returns the total height of the area occupied by all children of a given node.  The returned value depends on scaling.  If Owner.Rotated=True, returns the total width of the children area instead of the height.  If the node is collapsed (Expanded=False), then returns 0.


TdxOcNode.ChildrenWidth

TdxOcNode            See Also

ChildrenWidth returns the width of a node's children.

function ChildrenWidth: Integer;

Description

Returns the total width of the area occupied by all children of a given node.  The returned value depends on the scaling.  If Owner.Rotated=True, returns the total height of the children area instead of the width.  If the node is collapsed (Expanded=False), then returns 0.


TdxOcNode.ClientRect

TdxOcNode            See Also

Returns a node's client area.

function ClientRect: TRect;

Description

Returns coordinates of the client area of a node, i.e. of the rectangle inside of which text, image and (possible) additional information is displayed.  The client area coincides with the contour of the node for rectangle nodes (Shape=shRectangle), and for other node types, it is always less.


TdxOcNode.Collapse

TdxOcNode            See Also

Hides all children of a node.

procedure Collapse(Recurse: Boolean);

Description

Collapses the node, i.e. makes its children invisible on the screen.  If Recurse is True, then all the children of a given node are collapsed at all levels.


TdxOcNode.DeleteChildren

TdxOcNode            See Also

Deletes all children of a node.

procedure DeleteChildren;

Description

Deletes all the children of a given node.  The list of children is saved but emptied.  To delete children together with the list, use HasChildren = False.


TdxOcNode.DisplayRect

TdxOcNode            See Also

Returns the bounding rectangle for a node.

function DisplayRect: TRect;

Description

Returns coordinates of the area occupied by a given node on the screen.  Besides the node image itself, it includes a blank space above (or on the left if Owner.Rotated=True) separating the node from nodes of the previous level.


TdxOcNode.Expand

TdxOcNode            See Also

Shows the children of a node.

procedure Expand(Recurse: Boolean);

Description

Expands the node, i.e. makes its children visible on the screen.  If Recurse is True, then all the children of a given node are expanded at all levels.


TdxOcNode.Focused

TdxOcNode            See Also

Indicates whether a node appears to have focus.

function  Focused: Boolean;

Description

Returns True, if a node has input focus.  If ocFocus mode in Owner.Options is True, then the Focusd node is marked by clHighlight color.

Note: Though tree nodes are not windowed controls and cannot have real input focus, they can be edited by a user when their owner has focus.


TdxOcNode.FullHeight

TdxOcNode            See Also

Returns the height of a node's "home" area.

function FullHeight: Integer;

Description

Returns the total height of the area occupied by a node with all its children.  The returned value depends on scaling.  If Owner.Rotated=True, returns the total width of the children area instead of the height.  The value of FullHeight changes by expansion and collapse of a node.


TdxOcNode.FullWidth

TdxOcNode            See Also

Returns the width of node's "home" area.

function FullWidth: Integer;

Description

Returns the total width of the area occupied by a node with all its children.  The returned value depends on scaling.  If Owner.Rotated=True, returns the total height of the children area instead of the width.  The value of FullWidth changes on expansion and collapse of a node.


TdxOcNode.GetFirstChild

TdxOcNode            See Also

Returns the first child node of a tree node.

function GetFirstChild: TdxOcNode;

Description

Call GetFirstChild to refer to the first child of a given node.  GetFirstChild returns the same value as Items[0] or nil if the node has no children.


TdxOcNode.GetLastChild

TdxOcNode            See Also

Returns the last immediate child of a tree node.

function GetLastChild: TdxOcNode;

Description

Call GetLastChild to find the last immediate child of a given node.  GetLastChild returns the same value as Items[Count-1] or nil if the node has no children.


TdxOcNode.GetNext

TdxOcNode            See Also

Returns the next node after the calling node in a tree.

function GetNext: TdxOcNode;

Description

Returns reference to the next node in a tree data structure, including children and invisible nodes.  Use GetNext to iterate all tree nodes, for example:

Node := GetFirstNode;

while Node <> nil do begin

  Node.Color := clGreen;

  Node := Node.GetNext;

end;


TdxOcNode.GetNextChild

TdxOcNode            See Also

Returns the next child node after the value.

function GetNextChild(Value: TdxOcNode): TdxOcNode;

Description

Returns reference to a node coming after Value in the children list of a given node.  If Value is not an immediate child of a given node, it returns nil.


TdxOcNode.GetNextSibling

TdxOcNode            See Also

Returns the next node in the tree at the same level as the calling node.

function GetNextSibling: TdxOcNode;

Description

GetNextSibling will return the next node, regardless of whether it is visible.  If a given node is the last in the children list of its parent, it returns nil.


TdxOcNode.GetNextVisible

TdxOcNode            See Also

Returns the next visible node in a tree after the calling node.

function GetNextVisible: TdxOcNode;

Description

Use GetNextVisible to iterate through visible nodes: for example, in selecting nodes by arrow keys.  The node is visible on the screen if all its parents are expanded.


TdxOcNode.GetNodeInfo

TdxOcNode            See Also

Retrieves the values of a node's properties into the data structure.

TdxOcNodeAlign = (caLeft,caCenter,caRight);

TdxOcShape = (shRectangle,shRoundRect,shEllipse,shDiamond);

TdxOcImageAlign = (iaNone, iaLT, iaLC, iaLB, iaRT, iaRC, iaRB, iaTL, iaTC, iaTR, iaBL, iaBC, iaBR);

TdxOcNodeInfo = packed record

  Width: Word;

  Height: Word;

  Color: TColor;

  Align: TdxOcNodeAlign;

  Shape: TdxOcShape;

  Index: Smallint;

  IAlign: TdxOcImageAlign;

end;

procedure GetNodeInfo(var AInfo: TdxOcNodeInfo);

Description

Fills in the AInfo structure with fields values of the TdxOcNode object.  Used by ReadData and WriteData methods. GetNodeInfo is also helpful when it is required to get non-actual values but a user's settings of Width, Height and Color properties.


TdxOcNode.GetPrev

TdxOcNode            See Also

Returns the previous node before the calling node in a tree.

function  GetPrev: TdxOcNode;

Description

Returns reference to the previous node in a data structure including children and invisible nodes.  If the given node is the first on the 0 level, it returns nil.


TdxOcNode.GetPrevChild

TdxOcNode            See Also

Returns the previous child node before the value.

function GetPrevChild(Value: TdxOcNode): TdxOcNode;

Description

Returns reference to the node previous to Value in the children list of a given node. If Value is not a direct child of a given node, it returns nil.


TdxOcNode.GetPrevSibling

TdxOcNode            See Also

Returns the previous node in a tree at the same level as the calling node.

function GetPrevSibling: TdxOcNode;

Description

Returns the previous sibling node, regardless of whether it is visible.  If a given node is the first in the children list of its parent, it returns nil.


TdxOcNode.GetPrevVisible

TdxOcNode            See Also

Returns the previous visible node in the tree after a calling node.

function GetPrevVisible: TdxOcNode;

Description

Returns reference to the foregoing the given node visible node. The node is visible on the screen if all its owners are expanded.


TdxOcNode.HasAsParent

TdxOcNode            See Also

HasAsParent returns True if Value is a parent node for a given node.

function HasAsParent(Value: TdxOcNode): Boolean;

Description

Use HasAsParent to determine whether Value is direct (or indirect) parent of a given node.


TdxOcNode.IndexOf

TdxOcNode            See Also

IndexOf returns the position of a node's immediate child.

function IndexOf(Value: TdxOcNode): Integer;

Description

Returns index of Value in the children list of a given node.  If Value is not an immediate child of a given node, it returns -1.


TdxOcNode.MakeVisible

TdxOcNode            See Also

Makes a node visible on the screen.

procedure MakeVisible;

Description

The whole node is made visible: expands all its parents and in case of necessity scrolls the component in a way to place the node in the visible area of a window.


TdxOcNode.MoveTo

TdxOcNode            See Also

Moves a node to another location in the tree.

type

  TdxOcNodeAttachMode = (naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert);

procedure MoveTo(Dest: TdxOcNode; Mode: TdxOcNodeAttachMode);

Description

Moves a node with all its children to a new location in the data structure. Dest sets a node relative to which the location of a given node is determined; when Dest=nil, node moves to the very top level.  Mode sets the means by which to move a node:

naAdd - Shifts to the same level as Dest, to the end of the list.

naAddFirst - Shifts to the same level as Dest, to the beginning of the list.

naAddChild - Becomes the last descendant of Dest.

naAddChildFirst - Becomes the first descendant of Dest.

naInsert - Inserted right before Dest, to the same level. Dest cannot be equal to nil.


Unit DxDbOrgC

Controls

TdxDbOrgChart

Objects

TdxDbOcNode

TdxOcDataLink


TdxDbOrgChart

Hierarchy          Properties           Methods           Events

Unit

DxDbOrgC

Description

TdxDbOrgChart is fully functional windowed data-aware component, intended for the display and editing of hierarchical tree data structures.  The component connects to a database via a TDataSet class component, from which it obtains all necessary data for its tree and individual node  formation.  The hierarchy of nodes is defined via the database fields KeyField and ParentField while other (optional) fields may contain properties of separate nodes.  Any changes made by a user are immediately displayed in the database and any changes to the database implemented by your program are immediately displayed in TdxDbOrgChart component.


Hierarchy

TObject

     |

TPersistent

     |

TComponent

     |

TControl

     |

TWinControl

     |

TCustomControl

     |

TdxCustomOrgChart

     |


TdxDbOrgChart Properties

TdxDbOrgChart

In TdxDbOrgChart

DataSet

ChAlignField

ColorField

HeightField

ImageField

ImAlignField

KeyField

KeyOrder

OrderField

OrderFieldName

ParentField

ShapeField

TextField

WidthField

ChAlignFieldName

ColorFieldName

HeightFieldName

ImAlignFieldName

ShapeFieldName

WidthFieldName

DataSource

ImageFieldName

KeyFieldName

ParentFieldName

TextFieldName

Derived from TdxCustomOrgChart

AbsoluteItems

Count

Editing

Items

LeftEdge

RootCount

Selected

TopEdge

BorderStyle

DefaultImageAlign

DefaultNodeHeight

DefaultNodeWidth

EditMode

Images

IndentX

IndentY

LineColor

LineWidth

Options

Rotated

SelectedNodeColor

SelectedNodeTextColor

Zoom


TdxDbOrgChart Methods

TdxDbOrgChart

In TdxDbOrgChart

CreateEditor

CreateNode

DoChange

DoChanging

InternalAdd

InternalMoveTo

NodeChanged

Create

Destroy

Active

Delete

ShowEditor

Derived from TdxCustomOrgChart

CreateParams

DblClick

DragOver

DrawNode

KeyDown

KeyPress

MouseDown

MouseMove

Paint

Loaded

Add

AddChild

AddChildFirst

AddFirst

AssignData

BeginUpdate

Clear

DoZoom

DragDrop

EndUpdate

FullCollapse

FullExpand

FullHeight

FullWidth

GetFirstNode

GetHitTestsAt

GetNodeAt

HideEditor

Insert

Invalidate

IsZoomed

SetLeftTop

ShowEditor


TdxDbOrgChart Events

TdxDbOrgChart

In TdxDbOrgChart

OnLoadNode

OnNewKey

Derived from TdxCustomOrgChart

OnCreateNode

OnChange

OnChanging

OnCollapsed

OnCollapsing

OnDeletion

OnExpanded

OnExpansion

OnEditing

OnEdited

OnSetFont

OnDrawNode

OnGetText

OnSetText


TdxDbOrgChart.DataSet

TdxDbOrgChart            See Also

Specifies the dataset which contains the data for a tree structure.

property DataSet: TDataSet;

Description

The DataSet property contains a reference to the TDataSet component, determining (via DataSource) a database connected with an OrgChart component.


TdxDbOrgChart.ChAlignField

TdxDbOrgChart            See Also

ChAlignField is a data field for the TdxDbOcNode.ChildAlign property.

property ChAlignField: TField;

Description

Contains a reference to the optional integer field of a connected database setting the ChildAlign property of tree nodes.  Can be changed via a setting of ChAlignFieldName.


TdxDbOrgChart.ColorField

TdxDbOrgChart            See Also

ColorField is a data field for TdxDbOcNode.Color property.

property ColorField: TField;

Description

Contains a reference to the optional integer field of a connected database setting the Color property of tree nodes.  Can be changed via a setting of ColorFieldName.


TdxDbOrgChart.HeightField

TdxDbOrgChart            See Also

HeightField is a data field for TdxDbOcNode.Height property.

property HeightField: TField;

Description

Contains a reference to the optional integer field of a connected database setting the Height property of tree nodes.  Can be changed via setting of HeightFieldName.


TdxDbOrgChart.ImageField

TdxDbOrgChart            See Also

ImageField is a data field for TdxDbOcNode.ImageIndex property.

property ImageField: TField;

Description

Contains a reference to the optional integer field of a connected database setting the ImageIndex property of tree nodes.  Can be changed via a setting of ImageFieldName.


TdxDbOrgChart.ImAlignField

TdxDbOrgChart            See Also

ImAlignField is a data field for TdxDbOcNode.ImageAlign property.

property ImAlignField: TField;

Description

Contains a reference to the optional integer field of a connected database setting the ImageAlign property of tree nodes.  Can be changed via a setting of ImAlignFieldName.


TdxDbOrgChart.KeyField

TdxDbOrgChart            See Also

KeyField contains a key value for tree nodes corresponding to a given database record.

property KeyField: TField;

Description

Contains a reference to the required field of a connected database setting the Key property of tree nodes.  Can be changed via setting of KeyFieldName.  This field can be of any type, though it is usually defined as an integer.  Values in KeyField field must be unique for each record and must not be empty.  Key value duplication for several records will force only a single node to be built.  Records with blank key value are ignored.


TdxDbOrgChart.OrderField

TdxDbOrgChartTdxDbOrgChart>Main          See Also

Determines the order of sibling tree nodes.

property OrderField: TField;

Description

The TdxDbOrgChart maintains a special integer or float data field that specifies the order of sibling nodes. This field is automatically updated when new nodes are added, or their layout is changed via the MoveTo method.

Use the OrderField property to access the contents and properties of this field.

If the OrderField is not defined, node ordering is determined by key values of nodes.  In this instance, the KeyOrder property enables or disables the automatic updating of KeyField on changing of node order.


TdxDbOrgChart.ParentField

TdxDbOrgChart            See Also

ParentField determines the parent of a tree node corresponding to a given database record.

property ParentField: TField;

Description

Contains a reference to the required field of a connected database setting the ParentKey property of tree nodes.  Can be changed via setting of ParentFieldName.  Parent Field type must match with KeyField type.  This field determines the parent of a node connected with a given record.  Blank ParentField field means, that a given node is at the top level of the hierarchy without a parent.  The same result can be achieved by setting the ParentField value equal to KeyField (the node refers to itself).  Records where the node refers to its child are by definition invalid and as a result are ignored.


TdxDbOrgChart.ShapeField

TdxDbOrgChart            See Also

ShapeField is a data field for TdxDbOcNode.Shape property.

property ShapeField: TField;

Description

Contains a reference to the optional integer field of a connected database setting the Shape property of tree nodes. Can be changed via setting of ShapeFieldName.


TdxDbOrgChart.TextField

TdxDbOrgChart            See Also

TextField is a data field for TdxDbOcNode.Text property.

property TextField: TField;

Description

Contains a reference to the optional  field of a connected database setting the Text property of tree nodes.  Can be changed via setting of TextFieldName.  This field may be of any type, though the TStringField type is more frequently used.


TdxDbOrgChart.WidthField

TdxDbOrgChart            See Also

WidthField is a data field for TdxDbOcNode.Width property.

property WidthField: TField;

Description

Contains a reference to the optional integer field of a connected database setting the Width property of tree nodes.  Can be changed via setting of WidthFieldName.


TdxDbOrgChart.ChAlignFieldName

TdxDbOrgChart            See Also

ChAlignFieldName is the name of field ChAlignField.

property ChAlignFieldName: String;

Description

Sets the name of ChAlignField, defined in a connected database.  If you set a name which does not exist in a database, the component will not have the ChAlignField.


TdxDbOrgChart.ColorFieldName

TdxDbOrgChart            See Also

ColorFieldName is the name of field ColorField.

property ColorFieldName: String;

Description

Sets the name of ColorField, defined in a connected database.  If you set a name which does not exist in a database, the component will not have the ColorField.


TdxDbOrgChart.HeightFieldName

TdxDbOrgChart            See Also

HeightFieldName is the name of field HeightField.

property HeightFieldName: String;

Description

Sets the name of HeightField, defined in a connected database. If you set a name which does not exist in a database, the component will not have the HeightField.


TdxDbOrgChart.ImAlignFieldName

TdxDbOrgChart            See Also

ImAlignFieldName is the name of field ImAlignField.

property ImAlignFieldName: String;

Description

Sets the name of ImAlignField, defined in a connected database. If you set a name which does not exist in a database, the component will not have the ImAlignField.


TdxDbOrgChart.ShapeFieldName

TdxDbOrgChart            See Also

ShapeFieldName is the name of field ShapeField.

property ShapeFieldName: String;

Description

Sets the name of ShapeField, defined in a connected database.  If you set a name which does not exist in a database, the component will not have the ShapeField.


TdxDbOrgChart.WidthFieldName

TdxDbOrgChart            See Also

WidthFieldName is the name of field WidthField.

property WidthFieldName: String;

Description

Sets the name of WidthField, defined in a connected database.  If you set a name which does not exist in a database, the component will not have the WidthField.


TdxDbOrgChart.DataSource

TdxDbOrgChart            See Also

DataSource identifies the link to the dataset from which a component loads its data.

property DataSource: TDataSource;

Description

Set DataSource to the TDataSource object that links to the dataset from which the TdxDbOrgChart component should fetch its data.  DataSource allows the component to read from, write to, and navigate around a dataset, while maintaining record concurrency with other data-aware objects that use the same data source.


TdxDbOrgChart.ImageFieldName

TdxDbOrgChart            See Also

ImageFieldName is the name of field ImageField.

property ImageFieldName: String;

Description

Sets the name of ImageField, defined in a connected database. If you set a name which does not exist in a database, the component will not have the ImageField.


TdxDbOrgChart.KeyFieldName

TdxDbOrgChart            See Also

KeyFieldName is the name of field KeyField.

property KeyFieldName: String;

Description

Sets the name of KeyField, defined in a connected database. If you set a name which does not exist in a database, the component will not have the KeyField nor will it have a database connection.


TdxDbOrgChart.ParentFieldName

TdxDbOrgChart            See Also

ParentFieldName is the name of field ParentField.

property ParentFieldName: String;

Description

Sets the name of ParentField, defined in a connected database. If you set a name which does not exist in a database, the component will not have the ParentField nor will it have a database connection.


TdxDbOrgChart.TextFieldName

TdxDbOrgChart            See Also

TextFieldName is the name of field TextField.

property TextFieldName: String;

Description

Sets the name of TextField, defined in a connected database. If you set a name which does not exist in a database, the component will not have the TextField.


TdxDbOrgChart.CreateEditor

TdxDbOrgChart            See Also

Creates the in-place text editor for tree nodes.

function CreateEditor: TdxOcInplaceEdit; override;

Description

Overrides TdxCustomOrgChart.CreateEditor.  If the TextField is active, restricts the length of the edited text to no more than the length of the TextField.


TdxDbOrgChart.CreateNode

TdxDbOrgChart            See Also

Creates a new tree node.

function CreateNode: TdxOcNode; override;

Description

Overrides TdxCustomOrgChart.CreateNode.  Creates an object of TdxDbOcNode class and sets its Key and ParentKey properties to null.


TdxDbOrgChart.DoChange

TdxDbOrgChart            See Also

DoChange notifies that a selection has changed from one tree node to another.

procedure DoChange(Node: TdxOcNode); override;

Description

Overrides TdxCustomOrgChart.DoChange.  Sets the current record of the database by Key property of the Node, then calls inherited DoChange in a manner as to leave the OnChange event available for applications.


TdxDbOrgChart.DoChanging

TdxDbOrgChart            See Also

DoChanging notifies that a selection is about to be changed from one tree node to another.

procedure DoChanging(Node: TdxOcNode; var Allow: Boolean); override;

Description

Overrides TdxCustomOrgChart.DoChanging.  First calls inherited DoChanging for OnChanging event processing.  If after that Allow =True, sets the current record of the database by the Key property of a Node.  If it fails, disables selection of the Node and returns the database cursor to the previous location.


TdxDbOrgChart.InternalAdd

TdxDbOrgChart            See Also

Adds a new node to the tree structure.

function  InternalAdd(AParent: TdxOcNode; Ptr: Pointer; AIndex: Integer): TdxOcNode; override;

Description

Overrides TdxCustomOrgChart.InternalAdd.  With inactive databases, it immediately returns nil. Otherwise calls inherited InternalAdd and sets Key (creating a new key) and ParentKey (equal AParentKey) properties for the created node.  After this, it adds a record to the database and fills in the fields KeyField,  ParentField and OrderField (if defined).  Finally, where necessary, alters the OrderField (or KeyField) values for all nodes, following the newly created one in the AParent list of children.


TdxDbOrgChart.InternalMoveTo

TdxDbOrgChart            See Also

Moves a tree node to new position in the tree structure.

procedure InternalMoveTo(AParent,ANode: TdxOcNode; AIndex: Integer); override;

Description

Overrides TdxCustomOrgChart.InternalMoveTo.  Calls inherited InternalMoveTo and alters the ANode.ParentKey property indicating changes in the database.  Where necessary, alters the OrderField (or KeyField) value of the ANode and of all following it in the AParent children list.


TdxDbOrgChart.NodeChanged

TdxDbOrgChart            See Also

Notifies that one or more properties of a node have changed.

procedure NodeChanged(ANode: TdxOcNode); override;

Description

Overrides TdxCustomOrgChart.NodeChanged.  On changing the properties of ANode, updates the connected record of the database.


TdxDbOrgChart.Create

TdxDbOrgChart            See Also

constructor Create(AOwner: TComponent); override;

Description

Overrides TdxCustomOrgChart.Create.  Having called inherited Create, creates a TdxOcDataLink object and internal list ordered according to key values.


TdxDbOrgChart.Destroy

TdxDbOrgChart            See Also

Destroys an instance of TdxDbOrgChart.

destructor Destroy; override;

Description

Do not call Destroy directly in an application. Instead, call Free.  Free verifies that the TdxDBOrgChart object is not already freed and only then calls Destroy.  Destroy frees up memory associated with data handling that was allocated in the constructor, before calling the inherited destructor.


TdxDbOrgChart.Active

TdxDbOrgChart            See Also

Active reports whether a component is active.

function  Active: Boolean;

Description

Returns True, if the component is active, i.e. the connected database is opened and the fields KeyField and ParentField are assigned.


TdxDbOrgChart.Delete

TdxDbOrgChart            See Also

Removes a node from the tree structure.

procedure Delete(ANode: TdxOcNode); override;

Description

Overrides TdxCustomOrgChart.Delete. Before calling inherited Delete, removes the connected record with ANode from the database.


TdxDbOrgChart.ShowEditor

TdxDbOrgChart            See Also

Starts the text editing for a selected node.

procedure ShowEditor; override;

Description

Call ShowEditor to start editing the text of a selected node.  Do not call ShowEditor for read only datasets.


TdxDbOrgChart.OnLoadNode

TdxDbOrgChart

OnLoadNode occurs when a node has been created and its properties have been read from the dataset.

TdxOcEvent = procedure(Sender: TObject; Node: TdxOcNode) of object

property OnLoadNode: TdxOcEvent;

Description

Use the OnLoadNode event to perform specific operations after the node has been created based on the data in a linked dataset.

procedure TForm1.ChartLoadNode(Sender: TObject; Node: TdxOcNode);

   begin

     if Node.Parent=nil then Node.Shape := shRoundRect;  // by Node’s properties

     if Chart.DataSet.FieldByName('Flag').AsBoolean then

       Node.Color := clRed;	// by contents of database

   end;

On calling OnLoadNode, the current record in the database corresponds to the Node and the event handler must not change its location (Do not use Locate, Fist, Last and MoveBy methods of the dataset or use bookmark to return to the node that corresponds with the Node).


TdxDbOrgChart.OnNewKey

TdxDbOrgChart            See Also

OnNewKey occurs when a new key value is required.

TdxOcNewKeyEvent = procedure(Sender: TObject; MaxValue: Variant; var KeyValue: Variant) of object;

property OnNewKey: TdxOcNewKeyEvent;

Description

Called in all cases when it is required to create a new key: on adding new nodes, and also on changing the tree structure by Add… Insert and MoveTo methods.  The event handler must assign to a KeyValue a variable value bigger than of MaxValue.  New keys are created automatically if the KeyField is an integer type. In this case to define the OnNewKey event handler is not required.  If the KeyField type differs from an integer (for example string), the OnNewKey event handler must be defined.

procedure TForm1.ChartNewKey(Sender: TObject; MaxValue: Variant;

     var KeyValue: Variant);

   begin

     if VarIsNull(MaxValue) then KeyValue := '00000000'

     else begin

       KeyValue := IntToStr(StrToInt(MaxValue)+1);

       while Length(KeyValue) < 8 do KeyValue := '0' + KeyValue;

     end;

   end;


TdxDbOrgChart.KeyOrder

TdxDbOrgChart            See Also

KeyOrder enables using KeyField for storing the OrgChart node order.

property KeyOrder: Boolean;

Description

Use KeyOrder to enable automatic updating KeyField field on changes to the order of sibling nodes. If the OrderFieldName is not defined correctly and KeyOrder is True, the values in KeyField may be updated on adding new nodes and changing their layout. If KeyOrder is False (it is the default value), key values are not updated, and in this instance, management of a user-defined tree layout may not be guaranteed.

The KeyOrder property is ignored if the OrderFieldName is defined correctly.


TdxDbOrgChart.OrderFieldName

TdxDbOrgChart            See Also

Specifies the name of the field that stores the order of sibling nodes.

property OrderFieldName: string;

Description

The field referenced by this property is automatically updated when new nodes are added, or their layout is changed via the MoveTo method.  This field must be of Integer or Float type.


TdxDbOcNode

Hierarchy          Properties           Methods

Unit

DxDbOrgC

Description

TdxDbOcNode is a class, describing a separate node in the TdxDbOrgChart data structure, to which corresponds a separate record in connection with a TdxDbOrgChart database. TdxDbOcNode is a direct descendant of TdxOcNode and inherits all its properties and methods.


Hierarchy

TObject

     |

TdxOcNode

     |


TdxDbOcNode Properties

TdxDbOcNode

In TdxDbOcNode

Key

ParentKey

Derived from TdxOcNode

ChildAlign

Color

Count

Data

Deleting

Expanded

HasChildren

Height

ImageAlign

ImageIndex

Index

IsVisible

Items

Level

Owner

Parent

Selected

Shape

Text

Width


TdxDbOcNode Methods

TdxDbOcNode

In TdxDbOcNode

SetText

ReadData

ReadData

Derived from TdxOcNode

GetText

SetData

SetFont

WriteData

Create

Destroy

ChildrenHeight

ChildrenWidth

ClientRect

Collapse

DeleteChildren

DisplayRect

Expand

Focused

FullHeight

FullWidth

GetFirstChild

GetLastChild

GetNext

GetNextChild

GetNextSibling

GetNextVisible

GetNodeInfo

GetPrev

GetPrevChild

GetPrevSibling

GetPrevVisible

HasAsParent

IndexOf

MakeVisible

MoveTo


TdxDbOcNode.Key

TdxDbOcNode            See Also

Represents a KeyField value for a tree node.

property Key: Variant;

Description

Contains the key value of a node equal to the value of KeyField.  Automatically created on creation of a node and (if KeyOrder is True) automatically altered upon changes to its location.  For nodes with common parent the Key values, determines the ordering in the structure, if the OrderField is not defined.


TdxDbOcNode.ParentKey

TdxDbOcNode            See Also

Represents the ParentField value for a tree node.

property ParentKey: Variant;

Description

Run-time and read only. Use ParentKey to determinate the Value of the Parent field, which is associated with a TdxDBOcNode.


TdxDbOcNode.SetText

TdxDbOcNode            See Also

SetText implements writing the node's Text property.

procedure SetText(const Value: String); override;

Description

Overrides TdxOcNode.SetText.  If the Owner.TextField exists and the length of the string Value exceeds the length of this field, then the string is shortened to an acceptable length and then inherited SetText is called.  OnGetText and OnSetText events are still available in TdxDbOrgChart, but it is not recommended to use them when TextField is active.


TdxDbOcNode.ReadData

TdxDbOcNode            See Also

procedure ReadData(Stream: TStream); override;

Description

Overrides TdxOcNode.ReadData. During the call of inherited ReadData, prevents access to a database, then allows it again and calls Owner.NodeChanged to store changes into database.


TdxDbOcNode.DbOwner

TdxDbOcNode            See Also

DbOwner is a TdxDbOrgChart component that owns a given node.

function DbOwner: TdxDbOrgChart;

Description

Use DbOwner to Determine the TdxDbOrgChart component possessing a given node. The returned value coincides with the value of the Owner property but has the type of TdxDbOrgChart.


TdxOcDataLink

Hierarchy           Methods

Unit

DxDbOrgC

Description

Objects of the TdxOcDataLink class are generated on creation of TdxDbOrgChart to enable reaction of the TdxDbOrgChart component to changes in connection with the component database.


Hierarchy

TObject

     |

TPersistent

     |

TDataLink

     |


TdxOcDataLink Methods

TdxOcDataLink

ActiveChanged

DataSetChanged

DataSetScrolled


TdxOcDataLink.ActiveChanged

TdxOcDataLink            See Also

ActiveChanged responds to changes in the DataSet.Active property.

procedure ActiveChanged; override;

Description

Called on changing the DataSet.Active property, on opening and closing of a database in particular.  Additionally, TdxDbOrgChart calls ActiveChanged on any changes to field names: KeyFieldName, TextFieldName and other properties.

ActiveChanged clears data structures by calling Clear and then performs searching of fields in a database by their names.  Further, if a component is active, then DataSetChanged is called to update the data.

Changes to names of any field with an open database leads to complete updating of the TdxDbOrgChart component with scanning of the table.  For this reason, it is best to perform this operation with a closed database if the setting of several fields is required at once.

procedure TForm1.FormCreate(Sender: TObject);

   begin

     with Chart do begin

       DataSet.Close;

       WidthFieldName := 'Width';

       HeightFieldName := 'Height';

       ColorFieldName := 'Color';

       ShapeFieldName := 'Shape';

       DataSet.Open;

     end;

   end;


TdxOcDataLink.DataSetChanged

TdxOcDataLink

DataSetChanged responds to changes in a dataset.

procedure DataSetChanged; override;

Description

Called on any changes of data in the DataSet component. The TdxOcDataLink.DataSetChanged ignores the message if the database is in an edit state (dsEdit or dsInsert).  In all other cases, the TdxDbOrgChart component performs updating of its data by reading the connected DataSet component.


TdxOcDataLink.DataSetScrolled

TdxOcDataLink            See Also

DataSetScrolled allows a response to scrolling the representation of the dataset within the data-aware object.

procedure DataSetScrolled(Distance: Integer); override;

Description

Called on changing the location of the current record in a database.  By this the TdxDbOrgChart component selects (Selected) a node connected with the current record.  If the current record is incorrect, the component will not have a selected node.


Getting Started
Getting Started with the ExpressOrgChart

Upon the installation of the ExpressOrgChart package, your component palette will include an ExpressOrgCharts page with two components:

dxOrgChart: Non-Data Aware version of the ExpressOrgChart.

dxDbOrgChart: Data Aware version of the ExpressOrgChart.

Using the non-data aware version of ExpressOrgChart

1.	Drop a dxOrgChart component onto a form.

2.	If you wish to associate images with individual chart nodes, drop a standard ImageList component onto the form and add all required images using the Image List Editor.

3.	Using the Object Inspector, determine individual properties such as Alignment, Border Style, Color, etc.  If tree nodes are dynamically created in the process of program work, then dxOrgChart is ready for use.

4.	To create a data structure at design-time, call the component editor by double clicking the dxOrgChart component or right click within the component and select the Items Editor menu item to activate the Items Editor dialog window.

5.	Using the Org Chart Item Editor window, you can begin to build the hierarchy and layout of the chart.

A.	To insert a new node, press the Insert New Item command button.

B.	To insert a sub node, first select the parent node to which the new sub node will belong then press the Insert New Sub Item command button.

C.	To delete a node, first select it using your mouse then press the Delete Item command button.

D.	If your node structure exceeds the boundaries of the chart client area, press the Zoom command button to resize it within the Org Chart Item Editor window.

E.	To change the rotation of the chart by a 90 degree angle, use the rotate on/off command button.

F.	To set the properties of individual nodes within the chart, use the Item Properties pane of the Item Editor.  Once you have determined the properties of an individual parent node, you can copy the "template" to all children by pressing the Set Properties for all children command button located in the lower right portion of the Item Editor window.

G.	Using Drag and Drop, you can reorganize the chart nodes as your need require.

H.	Set additional properties of the OrgChart using the Object Inspector.

I.	Press the OK command button to commit your changes and return to the application form.

Using the data aware version of ExpressOrgChart

The data aware version of the ExpressOrgChart is suited for self-referenced tree structures.  In general terms, in order to use the DBOrgChart, developers must assign a KeyField, ParentField, and a Text Field.

Note: Parent and KeyFields must be of the same type.

Additionally, developers may assign an OrderField to the OrgChart so as to manage the ordering of node objects within the tree hierarchy.

1.	Drop a dxDbOrgChart component onto a form.

2.	If you wish to associate images with individual chart nodes, drop a standard ImageList component onto the form and add all required images using the Image List Editor.

3.	In order to activate the dxDbOrgChart, it is necessary to connect it to your database.  Using the appropriate access components (TTable, TQuery, TDataSource) create links to your data.

4.	Set the DataSource property of the dxDbOrgChart to the DataSource component on your form.

5.	Using the Object Inspector, set the KeyFieldName and ParentFieldName properties and optional field names – TextFieldName and ImageFieldName.

6.	Run your application to see the data represented within the OrgChart.

Options

Both components provide a wide set of possibilities to easily add end user functionality without writing code:

•	Setting standard width and height of tree nodes (DefaultNodeWidth and DefaultNodeHeight properties)

•	Setting thickness of contour and connecting lines (LineWidth property)

•	Setting distance between the neighboring nodes horizontally and vertically (IndentX and IndentY properties)

•	Different modes of location and justification of the text inside the nodes and also text editing (EditMode property)

•	Autoscaling (Zoom property)

•	Rotated display (Rotated property)

•	Embedded Drag & Drop interface with dynamic display of the dragging node (ocCanDrag and ocShowDrag in Options modes)

•	Possibility to add and delete nodes by Ins, Ctrl-Ins and Del keys (ocInsDel in Options mode)

•	3-Dimensional display of nodes (ocRect3D in Options mode)

•	Animated expansion and collapse of nodes (ocAnimate in Options mode)


Width and Height

Determines the width and height of individual nodes within the OrgChart.


Color

Determines the color of individual nodes within the OrgChart.


ChildAlign

Determines the alignment of individual nodes within the OrgChart.


Shape

Determines the shape of individual nodes within the OrgChart.

Options include: Rectangle, Round Rectangle, Ellipse, and Diamond.


ImageIndex

Stores the Image Index of individual nodes within the OrgChart.


ImageAlign

Determines image alignment within each node of the OrgChart.

iaLT – Left Top; iaLC – Left Center; iaLB – Left Bottom; iaRT – Right Top; iaRC – Right Center; iaRB – Right Bottom; iaTL – Top Left; iaTC – Top Center; iaTR – Top Right; iaBL – Bottom Left; iaBC – Bottom Center; iaBR – Bottom Right


Text

Determines the text to display within each individual OrgChart node.


Set Properties

Once a parent node is selected, allows you to duplicate the properties of the parent node across all child nodes.


Editor

Displays the working model of an OrgChart.  You can modify the appearance and behavior of the OrgChart by setting individual node properties or by using drag and drop to alter the organization of the tree hierarchy.


Insert

Insert a new root node into the chart hierarchy.


Delete

Deletes the selected node from the chart hierarchy.


Insert Sub Item

Inserts a new sub item below a selected node within the chart hierarchy.


Zoom

Scales the display of the OrgChart so that the contents of the chart fit within the client area of the Editor.

Note: If the OrgChart hierarchy is small enough to fit within the boundaries of the Editor, zooming performs no screen update.


Rotate

Rotates the OrgChart by a 90 degree angle.