Creating Objects, Their Styles and a Link between Them

Executing the example requires an existing ws object of the IWxWorkspace type.

Sub UserProc;

Var

ws : IWxWorkspace;

Rect : IWxRectangle;

Ellipse : IWxEllipse;

Style : IWxStyle;

Link : IWxLink;

Begin

ws.BeginUpdate;

 

// create a rectangle

Rect := ws.CreateRectangle;

Rect.PinPosition := New GxPointF.Create(20,10);

Rect.Text := "Rectangle";

Style := ws.CreateStyle;

Style.Id := "MyStyle";

Style.BackgroundBrushForeColor := New GxColor.CreateRGB(153,204,255);

Style.BackgroundBrushForeTransparent := 10;

Style.ShadowBrushForeColor := GxColor.FromName("White");

Style.ShadowBrushBackColor := New GxColor.CreateRGB(204,153,255);

Style.ShadowBrushPattern := GxBrushPattern.Gradient;

Style.TextFontSize := 9;

Style.TextFontBrushColor := GxColor.FromName("Blue");

Rect.Style := Style;

 

// create an ellipse

Ellipse := ws.CreateEllipse;

Ellipse.PinPosition := New GxPointF.Create(80,60);

Ellipse.Text := "Ellipse";

Ellipse.Style := ws.Styles.FindById("MyStyle");

 

// create a link between objects

Link := ws.CreateLink;

Link.Text := "Link";

Link.TextVertOffset := -10;

Style := ws.CreateStyle;

Style.LinePenBeginWxCap := WxLineCap.ArrowRoundedFilled;

Style.LinePenColor := New GxColor.CreateRGB(128,0,255);

Style.LinePenWidth := 0.5;

Link.Style := Style;

 

ws.GlueConnectionPoints(Rect,3,Link,0);

ws.GlueConnectionPoints(Ellipse,0,Link,1);

 

ws.EndUpdate;

End Sub UserProc;

After executing the example a rectangle, an ellipse and a link between them are created in a workspace, and the specified style is applied for each of these objects:

See also:

Examples