Restrict the shape connection areas

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
Wheb
Newbie
Newbie
Posts: 8
Joined: Fri Jan 25, 2008 12:00 am
Location: Brazil

Restrict the shape connection areas

Post by Wheb » Tue Jul 07, 2009 1:07 pm

Hi guys,

1- I have a need that is dificult to explain. But i'll try.
When connecting squares, it should not allow connections between the square's corners.
The TeeEditor component must only allow to connect at the middle of a square's side (when I move the connection point at this position, I have a small circle around the red dot). That can be in upper, lower, left or right side.
In other words, seeing the image above, lock the possible connection points to the green circles.

2- Other question is to restrict the user to create points over the connection line.

Image:
Image

It's possible to restrict this by code?

Thanks.

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Restrict the shape connection areas

Post by Yeray » Thu Jul 09, 2009 8:14 am

Hi Wheb,

Here is a little piece of code showing how to add a connection and insert a point between the origin and the destination points. I've simply modified a little bit the code from the demo Add Connection from TeeTree demo (Only Tree1, TreeNodeShape1 and TreeNodeShape2 created at design time):

Code: Select all

Connection : TTreeConnection;
//...
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  // Cosmetic. Set all nodes Cursor to HandPoint.
  for i:=0 to Tree1.Shapes.Count-1 do
      Tree1[i].Cursor:=crHandPoint;

  // Example. Create a connection from Node 1 to Node 2
  Connection:=TreeNodeShape1.AddConnection(TreeNodeShape2);
  Connection.Style:=csLine;
  Connection.Border.Style:=psSolid;
  Connection.Border.Color:=clBlue;

  with Connection.Points do
  begin
    Insert(1, 250, 250);
    ChangeXStyle(2,cpsToPercent);
    ChangeYStyle(2,cpsToPercent);
  end;
end;
Note that you can also modify a point from the current list changing its Item.X, Item.Y, Item.XValue, Item.YValue, Item.XStyle and Item.YStyle.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply