Key
Properties |
ClipboardFormats: TGraphClipboardFormats
TGraphClipboardFormats = set of (cfNative, cfMetafile, cfBitmap)
Determines which formats should be used for copying graph contents in to the Windows clipboard.
cfNative |
|
CF_SIMPLEGRAPH |
|
Graph copies in to the clipboard as native format. PasteFromClipboard only supports this format. |
cfMetafile |
|
CF_ENHMETAFILE |
|
Graph copies in to the clipboard as an enhanced metafile. |
cfBitmap |
|
CF_BITMAP |
|
Graph copies in to the clipboard as a device dependent bitmap. |
|
CommandMode:
TGraphCommandMode
TGraphCommandMode = (cmViewOnly, cmEdit, cmInsertNode, cmLinkNodes)
Determines which kind of commands are available to the user.
cmViewOnly |
|
The
user cannot modify placement of the objects. |
cmPan |
|
The user can pan the graph by dragging mouse. |
cmEdit |
|
The
user can modify objects by mouse and/or keyboard. |
cmInsertNode |
|
The user can insert a new node object. When user inserted a node, this mode automaticalley changes to cmEdit. |
cmInsertLink |
|
The
user can insert a new link object. When user inserted a link, this mode automaticalley changes to cmEdit. |
|
CursorPos: TPoint
Determines the current mouse cursor position in graph coordinates. |
DefaultLinkClass:
TGraphLinkClass (Read-Only)
Determines the class that should be used for a new link object. |
DefaultNodeClass:
TGraphNodeClass (Read-Only)
Determines the class that should be used for a new node object. |
DefaultKeyMap: Boolean
Indicates whether the control internally handle the keyboard shortcuts entered by the user. See Keyboard Shortcuts for the default key mapping. |
DraggingBounds: TRect (Read-Only)
Specifies the smallest visual bounding rectangle of the graph objects being dragged in graph coordinates. |
DraggingObjects: TGraphObjectList
Contains the list of graph objects being dragged. The first object in the list is source of the drag, and the rest are objects following the drag. |
DragSource: TGraphObject (Read-Only)
Specifies the object being dragged. |
DrawOrder: TGraphDrawOrder
TDrawOrder = (doDefault, doNodesOnTop, doLinksOnTop)
Determines the z-order of objects.
doDefault |
|
The objects draw as they ordered in the Objects list. |
doNodesOnTop |
|
The nodes appear on top of the links. |
doLinksOnTop |
|
The links appear on top of the nodes. |
|
FixedScrollBars: Boolean
Determines how range of scroll bars should be calculated. When FixedScrollBars is False, the range of scroll bars determines using the graph bounding rectangle, otherwise the range is calculated using graph constraints bounding rectangle. |
GraphBounds:
TRect (Read-Only)
Specifies
the smallest visual bounding rectangle of the all visible graph objects
in graph coordinates. |
GraphConstraints: TGraphConstraints
Specifies the minimum and maximum coordinates of the objects in the graph. |
GridColor:
TColor
Determines the color of the grid. |
GridSize:
TGridSize
TGridSize = 4..128
Determines the grid spacing in graph's unit along the x- and
y-axis. |
HideSelection:
Boolean
Determines whether the visual indication of the selected grpah
objects remains when focus shifts to another control. |
HorzScrollBar:
TGraphScrollBar
Represents the horizontal scroll bar for the scrolling the graph.
|
LockLinks: Boolean
Indicates whether the user can move graph links by mouse or keyboard. |
LockNodes:
Boolean
Indicates whether the user can move or resize graph nodes by
mouse or keyboard. |
ObjectAtCursor: TGraphObject (Read-Only)
Specifies the last object found under the mouse cursor. |
Objects:
TGraphObjectList
Contains
the list of graph objects in the graph. |
ObjectPopupMenu:
TPopupMenu
Identifies the pop-up menu associated with the graph's objects.
|
MarkerColor:
TColor
Determines the color of the selection marker.
|
MarkerSize:
TMarkerSize
TMarkerSize = 3..9
Determines the size of the selection marker in pixels. |
MinNodeSize:
Word
Specifies the minimum nodes' with and height in pixels. |
Modified:
Boolean
Indicates whether the graph is modified. |
SelectedObjects:
TGraphObjectList
Contains
the list of selected graph objects in the graph. |
SelectionBounds:
TRect (Read-Only)
Specifies
the smallest visual bounding rectangle of the selected graph objects
in graph coordinates. |
ShowGrid:
Boolean
Indicates whether the control shows dot grids on the designer. |
ShowHiddenObjects:
Boolean
Indicates whether the control shows graph objects, which are not
vissible. |
SnapToGrid:
Boolean
Indicates whether the control automatically aligns graph objects
on the designer with the nearest gridline. |
Transparent: Boolean
Specifies whether the background of the control is transparent. |
VertScrollBar:
TGraphScrollBar
Represents the vertical scroll bar for the scrolling the graph.
|
VisibleBounds:
TRect (Read-Only)
Specifies the bounding rectangle of the visible part of the graph
in graph's unit. |
Zoom:
TZoom
TZoom = 5..36863
Specifies the control's zoom factor in percent. |
Key
Events |
OnAfterDraw: TGraphDrawEvent;
TGraphDrawEvent = procedure(Graph: TSimpleGraph; Canvas: TCanvas) of object;
Occurs after drawing the graph on the canvas. |
OnBeforeDraw: TGraphDrawEvent;
TGraphDrawEvent = procedure(Graph: TSimpleGraph; Canvas: TCanvas) of object;
Occurs just before the graph being drawn on the canvas. |
OnCanHookLink: TGraphCanHookEvent;
TGraphCanHookEvent = procedure(Graph: TSimpleGraph; Link: TGraphLink; GraphObject: TGraphObject; Index: Integer; var CanHook: Boolean) of object;
Occurs when an attempt is made to hook a point of the link to an object. |
OnCanLinkObjects:
TGraphCanLinkEvent;
TGraphCanLinkEvent = procedure(Graph: TSimpleGraph; Link: TGraphLink; Source,
Target: TGraphObject; var CanLink: Boolean) of object;
Occurs when an attempt is made to connect two objects together. |
OnCanMoveResizeNode:
TCanMoveResizeNodeEvent;
TCanMoveResizeNodeEvent = procedure(Graph: TSimpleGraph; Node:
TGraphNode; var NewLeft, NewTop, NewWidth, NewHeight: Integer;
var CanMove, CanResize: Boolean) of object;
Occurs when an attempt is made to resize or move a node. |
OnCanRemoveObject: TGraphCanRemoveEvent;
TGraphCanRemoveEvent: procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; var CanRemove: Boolean);
Occurs just before object being removed. |
OnCommandModeChange:
TNotifyEvent;
Occurs when CommandMode is changed. |
OnGraphChange:
TNotifyEvent;
Occurs when the graph is changed. |
OnInfoTip: TGraphInfoTipEvent;
TGraphInfoTipEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject;
var InfoTip: String) of object;
Occurs when the user pauses the mouse over an object in the graph. |
OnMoveResizeNode = TGraphNodeResizeEvent;
TGraphNodeResizeEvent = procedure(Graph: TSimpleGraph; Node: TGraphNode) of object;
Occurs when a node is moved or resized. |
OnObjectAfterDraw: TGraphObjectDrawEvent;
TGraphObjectDrawEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Canvas: TCanvas) of object;
Occurs after drawing the graph object on the canvas. |
OnObjectBeforeDraw: TGraphObjectDrawEvent;
TGraphObjectDrawEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Canvas: TCanvas) of object;
Occurs just before the graph object being drawn on the canvas. |
OnObjectBeginDrag: TGraphBeginDragEvent;
TGraphBeginDragEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; HT: DWORD) of object;
Occurs just after the graph object is initiated to drag. Consider that other selected object may follow the drag operation, however this event occurs only for the drag source. |
OnObjectEndDrag: TGraphEndDragEvent;
TGraphEndDragEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; HT: DWORD; Cancelled: Boolean) of object;
Occurs just after the graph object finished to drag. Consider that other selected object may follow the drag operation, however this event occurs only for the drag source. |
OnObjectContextPopup:
TGraphContextPopupEvent;
TGraphContextPopupEvent = procedure(Graph: TSimpleGraph; GraphObject:
TGraphObject; const MousePos: TPoint; var Handled: Boolean) of
object;
Occurs when the user right-clicks on a graph object. |
OnObjectClick: TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object;
Occurs when user clicks on a graph object. |
OnObjectDblClick:
TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject:
TGraphObject) of object;
Occurs when user double clicks on a graph object. |
OnObjectHook: TGraphHookEvent;
TGraphHookEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Link: TGraphLink; Index: Integer) of object;
Occurs when a link is hooked to a graph object. |
OnObjectUnhook: TGraphHookEvent;
TGraphHookEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Link: TGraphLink; Index: Integer) of object;
Occurs when a link is unhooked from a graph object. |
OnObjectInitInstance: TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object;
Occurs when a new graph object is being created. In this stage, the graph object is not inserted on the graph yet. |
OnObjectInsert:
TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject:
TGraphObject) of object;
Occurs when a new graph object is added to the graph. |
OnObjectRemove:
TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject:
TGraphObject) of object;
Occurs when a graph object is removed from the graph. |
OnObjectChange: TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object;
Occurs when a graph object is changed. |
OnObjectSelect:
TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject:
TGraphObject) of object;
Occurs when a graph object is selected/deselected in the graph. Use Selected property of the object to determine whether it is selected or deselected. |
OnObjectRead: TGraphStreamEvent;
TGraphStreamEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Stream: TStream) of object;
Occurs when property settings of a graph object is being read, and the graph object has some custom data. The event handler can read custom data from the stream passed as parameter. |
OnObjectWrite: TGraphStreamEvent;
TGraphStreamEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject; Stream: TStream) of object;
Occurs when property settings of a graph object is being written, and HasCustomData property of the graph object is True. The event handler can write custom data in to the stream passed as parameter. |
OnObjectMouseEnter: TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object;
Occurs when the mouse pointer moves over the graph object. |
OnObjectMouseLeave: TGraphNotifyEvent;
TGraphNotifyEvent = procedure(Graph: TSimpleGraph; GraphObject: TGraphObject) of object;
Occurs when the mouse pointer moves off from over the graph object. |
OnZoomChange: TNotifyEvent;
Occurs when zoom property changes. |
Key
Methods |
procedure
BeginUpdate;
Suspends screen repainting. |
procedure
EndUpdate;
Re-enables screen repainting. |
procedure
Draw(Canvas: TCanvas);
Draws the graph in its actual size on the given canvas. |
procedure
Print(Canvas: TCanvas; const Rect: TRect);
Draws the graph on the canvas in the rectangle specified by
the Rect parameter. The Print method maintains the original aspect
ratio of the graph. |
procedure ToggleSelection(const Rect: TRect; KeepOld: Boolean; GraphObjectClass: TGraphObjectClass = nil);
Toggles selection state of the objects that intersects the given rectangle. If GraphObjectClass parameter is not nil, the function only toggles selection of graph objects in the specified class type. When KeepOld is True, the function keeps the previous selected objects still selected, otherwise it deselects them. |
function FindObjectAt(X, Y: Integer; LookAfter: TGraphObject = nil ): TGraphObject;
Returns the graph object that contains the specified point. If no graph object found, the return value is nil. The function starts searching from the graph objects behind the graph object specified by the LookAfter parameter. If LookAfter parameter is nil, the search starts from the top most graph object. |
function FindObjectByID(ID: DWORD): TGraphObject;
Returns graph object, which its UniqueID is equal to the value specified by the ID parameter. The function returns nil if search fails. |
function ForEachObject(Callback: TGraphForEachMethod; UserData: Integer;
Selection: Boolean = False): Integer;
TGraphForEachMethod = function(GraphObject: TGraphObject; UserData: Integer): Boolean of object;
Enumerates all objects (or selected objects) on the graph by passing each object, in turn, to an application-defined callback method specified by the Callback parameter. The function continues until the last object is enumerated or the callback method returns False. The function returns the number of enumerated objects.
If the Selection parameter is True, the callback method enumerates only selected objects; otherwise it enumerates all the objects.
The UserData parameter specifies a 32-bit, application-defined value to be passed to the callback method.
|
function
InsertNode(const Bounds: TRect; ANodeClass: TGraphNodeClass
= nil): TGraphNode;
Inserts a new node object on the graph, and initiates its bounding rectangle with the rectangle specified by the Bounds paraneter. ANodeClass
parameter specifies the node class of the new node object.
If ANodeClass is nil, the function creates the node using DefaultNodeClass property. The function returns the new inserted node, or nil on case of failure. |
function InsertLink(Source, Target: TGraphObject;
ALinkClass: TGraphLinkClass = nil): TGraphLink;
Inserts a new link object to connect the two objects specified by Source and Target parameters. ALinkClass parameter specifies the class
of the new link object. If ALinkClass is nil, the function creates
the link using DefaultLinkClass property. The function returns the new inserted link, or nil on case of failure. |
function InsertLink(Source: TGraphObject; const Pts: array of TPoint; ALinkClass: TGraphLinkClass = nil): TGraphLink;
Inserts a new link object, which its breakpoints and endpoint are specified by the Pts parameter. The startpoint of the link, hooks to the object specified by the Source parameter. ALinkClass parameter specifies the class
of the new link object. If ALinkClass is nil, the function creates
the link using DefaultLinkClass property. The function returns the new inserted link, or nil on case of failure. |
function InsertLink(const Pts: array of TPoint; Target: TGraphObject; ALinkClass: TGraphLinkClass = nil): TGraphLink;
Inserts a new link object, which its startpoint and breakpoints are specified by the Pts parameter. The endpoint of the link, hooks to the object specified by the Target parameter. ALinkClass parameter specifies the class
of the new link object. If ALinkClass is nil, the function creates
the link using DefaultLinkClass property. The function returns the new inserted link, or nil on case of failure. |
function InsertLink(const Pts: array of TPoint; ALinkClass: TGraphLinkClass = nil): TGraphLink;
Inserts a new link object, which its startpoint, breakpoints, and endpoint are specified by the Pts parameter. ALinkClass parameter specifies the class
of the new link object. If ALinkClass is nil, the function creates
the link using DefaultLinkClass property. The function returns the new inserted link, or nil on case of failure. |
procedure Invalidate;
Completely repaints control. |
procedure InvalidateRect(const Rect: TRect);
Repaints a rectangular area of the control. Rectangle coordinates are in graph coordinates. |
procedure ScrollCenter(GraphObject: TGraphObject);
procedure ScrollCenter(const Rect: TRect);
procedure ScrollCenter(const Point: TPoint);
Scrolls a graph object, rectangle, or point into center of the control's client area. |
procedure
ScrollInView(GraphObject: TGraphObject);
procedure ScrollInView(const Rect: TRect);
procedure ScrollInView(const Point: TPoint);
Scrolls a graph object, rectangle, or point into the visible
area of the control. |
function
ZoomRect(const Rect: TRect): Boolean;
Zooms the view, so that the specified rectangle fits the client
area of the control. |
function
ZoomObject(GraphObject: TGraphObject): Boolean;
Zooms the view, so that the specified object fits the client area
of the control. |
function
ZoomSelection: Boolean;
Zooms the view, so that the selected objects fit the client area
of the control. |
function
ZoomGraph: Boolean;
Zooms the view, so that the graph entirly fits the client area
of the control. |
function ChangeZoom(NewZoom: Integer; Origin: TGraphZoomOrigin): Boolean;
TGraphZoomOrigin = (zoTopLeft, zoCenter, zoCursor);
Sets zoom factor to the value specified by the NewZoom parameter. The Origin parameter determines how the zoomed area appears on the client area of the control.
zoTopLeft |
|
Tries to keep top left cornor of the current view visible. |
zoCenter |
|
Tries to keep the center of the current view, still centered. |
zoCursor |
|
Tries to keep the point under cursor, still under cursor. |
zoCursorCenter |
|
Tries to move the point under cursor to the center of view. |
|
function ChangeZoomBy(Delta: Integer; Origin: TGraphZoomOrigin): Boolean;
TGraphZoomOrigin = (zoTopLeft, zoCenter, zoCursor);
Changes zoom factor by the value specified by the Delta parameter. The Origin parameter determines how the zoomed area appears on the client area of the control.
zoTopLeft |
|
Tries to keep top left cornor of the current view visible. |
zoCenter |
|
Tries to keep the center of the current view, still centered. |
zoCursor |
|
Tries to keep the point under cursor, still under cursor. |
zoCursorCenter |
|
Tries to move the point under cursor to the center of view. |
|
function AlignSelection(Horz: THAlignOption; Vert: TVAlignOption): Boolean;
THAlignOption = (haNoChange, haLeft, haCenter, haRight, haSpaceEqually);
TVAlignOption = (vaNoChange, vaTop, vaCenter, vaBottom, vaSpaceEqually);
Lines up selected objects in relation to each other. The function returns True if at least one object resizes, otherwise returns False.
haNoChange |
|
Does not change the alignment of the object. |
haLeft |
|
Lines up the left edges of the selected objects . |
haCenter |
|
Lines up horizontally the centers of the selected objects. |
haRight |
|
Lines up the right edges of the selected objects. |
haSpaceEqually |
|
Lines up the selected objects horizontally equidistant from each other. |
vaNoChange |
|
Does not change the alignment of the object. |
vaTop |
|
Lines up the top edges of the selected objects . |
vaCenter |
|
Lines up vertically the centers of the selected objects. |
vaBottom |
|
Lines up the bottom edges of the selected objects. |
vaSpaceEqually |
|
Lines up the selected objects vertically equidistant from each other. |
|
function ResizeSelection(Horz, Vert: TResizeOption): Boolean;
TResizeOption = (roNoChange, roSmallest, roLargest);
Resizes selected objects to be exactly the same height or width. The function returns True if at least one object resizes, otherwise returns False.
roNoChange |
|
Does not change the size of the components. |
roSmallest |
|
Resizes the selected objects to the height or width of the smallest selected object. |
roLargest |
|
Resizes the selected object to the height or width of the largest selected object. |
|
function SnapPoint(const Pt: TPoint): TPoint;
Returns the closest grid point to the given point. |
procedure SnapOffset(const Pt: TPoint; var dX, dY: Integer);
Adjusts dX and dY parameters in the way that offseting the point specified by the Pt parameter by these values, moves the point on the closest grid point. |
function
ClientToGraph(X, Y: Integer): TPoint;
Converts X and Y pair of values from the client coordinates to
the graph cordinates. |
function
GraphToClient(X, Y: Integer): TPoint;
Converts X and Y pair of values from the graph coordinates to
the client cordinates. |
function ScreenToGraph(X, Y: Integer): TPoint;
Converts X and Y pair of values from the screen coordinates to the graph cordinates. |
function GraphToScreen(X, Y: Integer): TPoint;
Converts X and Y pair of values from the graph coordinates to the screen cordinates. |
function
FindNextObject(StartIndex: Integer; Inclusive, Backward, Wrap:
Boolean; GraphObjectClass: TGraphObjectClass
= nil): TGraphObject;
Call
FindNextObject to search for a graph object as type specified
by the GraphObjectClass parameter. If the Inclusive parameter
is True, the graph object specified by StartIndex is the first
item checked. Otherwise, the search starts on the next object.
If the Wrap parameter is True, the search continues at the top
of z-order if a match has not been found before reaching the
bottom. If Backward is False, FindNextObject searches forward
through the graph objects in z-order, otherwise it searches
backward through the graph objects.
|
function
SelectNextObject(Backward: Boolean; GraphObjectClass: TGraphObjectClass
= nil): Boolean;
Moves the selection to the next selectable graph object as the specified
type in the z-order. If Backward is False, SelectNextObject
searches forward through the graph objects in z-order, otherwise
it searches backward through the graph objects. If SelectNextObject
does not locate an appropriate graph object, the current selection
will remain unchanged and the function returns False. |
function
ObjectsCount(GraphObjectClass: TGraphObjectClass
= nil): Integer;
Returns the number of graph objects as the specified type.
|
function
SelectedObjectsCount(GraphObjectClass: TGraphObjectClass
= nil): Integer;
Returns the number of selected graph objects as the specified
type. |
procedure
SaveAsMetafile(const Filename: String);
Saves the graph to a file as Windows Enhanced Metafile image. |
procedure SaveAsBitmap(const Filename: String);
Saves the graph to a file as a 24bit Bitmap image. |
procedure
LoadFromStream(Stream: TStream);
Loads a graph from a stream in to the control. This function clears the previous content of the control. |
procedure LoadFromFile(const Filename: String);
Loads a graph from a file in to the control. This function clears the previous content of the control. |
procedure
SaveToStream(Stream: TStream);
Saves the graph in to a stream. |
procedure
SaveToFile(const Filename: String);
Saves the graph to a file. |
procedure MergeFromStream(Stream: TStream; OffsetX, OffsetY: Integer);
Loads a graph from a stream and inserts it at the position specified by OffsetX and OffsetY parameters. This functions keeps the old content of the cotrol unchanged. |
procedure MergeFromFile(const FileName: String; OffsetX, OffsetY: Integer);
Loads a graph from a file and inserts it at the position specified by OffsetX and OffsetY parameters. This functions keeps the old content of the cotrol unchanged. |
procedure CopyToGraphic(Graphic: TGraphic);
Copies the graph in to the image specified by the Graphic parameter. |
procedure
CopyToClipboard(Selection: Boolean = True);
Copies the selected graph objects to the Clipboard. When Selection parameter is False, the function copies
all the graph objects to the Clipboard. See ClipboardFormats property for the supported clipboard formats. |
function
PasteFromClipboard: Boolean;
Pastes the contents of the clipboard into the control. If
the Clipboard is empty, or its content is not in
CF_SIMPLEGRAPH format (cfNative), PasteFromClipboard does nothing, and function returns False. |
procedure ClearSelection;
Resets selection state of all objects. |
procedure
Clear;
Removes all the graph objects from the control. |
class
procedure Register(ANodeClass: TGraphNodeClass);
overload;
class procedure Register(ALinkClass: TGraphLinkClass);
overload;
Registers a node or link class type for being use in TSimpleGraph. |
class
procedure Unregister(ANodeClass: TGraphNodeClass);
overload;
class procedure Unregister(ALinkClass: TGraphLinkClass);
overload;
Unregisters a node or link class type from TSimpleGraph.
If an object class type is not registered, loading a graph that
uses that kind of object fails. |
class
function NodeClasses(Index: Integer): TGraphNodeClass;
Returns
the node class type at the specified index. |
class
function LinkClasses(Index: Integer): TGraphLinkClass;
Returns
the link class type at the specified index. |
class
function NodeClassCount: Integer;
Returns the number of registered node class types. |
class
function LinkClassCount: Integer;
Returns the number of registered link class types. |