ShapeTemplate objects provide the means for defining complex box shapes.
VB6
![]() |
---|
Public Class ShapeTemplate |
C++
![]() |
---|
class ShapeTemplate |
An outline must be defined for each shape template. The outline is used for hit-testing, clipping, filling nodes and finding intersection points with arrows. In addition, shape templates can have optional decorations, text region definitions and anchor point patterns associated with them. The shape elements coordinates passed to the various definition methods must be in the range 0..HorizontalScale for X and 0..VerticalScale for Y. These values specify a scaling transformation from the points of a shape definition to the points of a box' bounding rectangle.
Outlines consist of straight-line segments, arcs and/or Bezier curves. Call the AddOutlineStraight method to add a straight segment to shape's outline. Call AddOutlineBezier to add a Bezier curve to the outline or AddOutlineArc to add an arc. The last point passed to an AddOutline* method is connected using the specified segment type to the first point passed to the next AddOutline* call.
Decorations are visual elements that do not take part in hit-testing and clipping. Straight lines, Bezier curves, arcs and ellipses can be assigned as decorations to a shape template. Call AddDecorationLine, AddDecorationBezier, AddDecorationArc or AddDecorationEllipse to create the respective decoration element.
The text region is part of a shape in which node's text is laid-out and rendered. If text region definition is not provided for a shape, the shape's outline is used instead for text formatting. Text regions are defined via lines (AddTextStraight) arcs (AddTextArc) and Bezier curves (AddTextBezier). If a box' TextStyle is set to tsFitPolyTop, tsFitPolyCenter, or tsFitPolyBottom, the text is formatted in a polygonal shape (curves are approximated to poly-lines). For other text style values, the text is rendered in the smallest rectangle that bounds a text region.
Anchor point patterns define at which points of a node, arrows can start or end. Assign the identifier of an AnchorPattern object to the AnchorPattern property of a shape template. Some of the predefined shape templates have anchor patterns assigned to them, for example the Decision2In2Out anchor pattern is set as default for the Decision shape.
To complete shape definition, call the CompleteDefinition method, passing shape identifier as an argument. The shape outline is automatically closed and the text region is converted to polygon if there are Bezier curves or arcs used in its definition. Additionally the shape is added to the Shapes array.
It is possible to associate an image with a shape definition via the Picture property; that image is displayed in all boxes associated with the shape, unless their own Picture is set. You can also specify the area in which the image is displayed via SetPictureRect.
There are 87 predefined shapes accessible through the Shapes array. The shapes and their string identifiers are listed in the Table of Predefined Shapes.
Here is an example showing how to define a new shape and assign it to a box object:
VB6
![]() |
---|
Private Sub Form_Load() |