Search
ShapeTemplate Class
Remarks See Also
 



ShapeTemplate objects provide the means for defining complex box shapes.

 Syntax

VB6  Copy Code

Public Class ShapeTemplate

C++  Copy Code

class ShapeTemplate

 Remarks

ShapeTemplate elements

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.

Outline

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

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.

Text region

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 patterns

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.

Completing shape definition

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.

Images

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.

Predefined shapes

There are 87 predefined shapes accessible through the Shapes array. The shapes and their string identifiers are listed in the Table of Predefined Shapes.

 Example

Here is an example showing how to define a new shape and assign it to a box object:

VB6  Copy Code

Private Sub Form_Load()

    Dim shape As New ShapeTemplate
    shape.AddOutlineStraight 0, 0
    shape.AddOutlineStraight 50, 0
    shape.AddOutlineBezier 50, 10, 90, 0, 100, 20
    shape.AddOutlineStraight 100, 100
    shape.AddOutlineStraight 0, 100
    shape.CompleteDefinition "Shape1"

End Sub

Private Sub Command1_Click()

    If fcx.ActiveBox Is Nothing Then

        fcx.BoxStyle = bsShape
        fcx.DefaultShape = fcx.Shapes("Shape1")
        fcx.ShapeOrientation = 0

    Else

        fcx.ActiveBox.Shape = fcx.Shapes("Shape1")
        fcx.ActiveBox.ShapeOrientation = 0

    End If

End Sub

 See Also