TPolygonShape

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
mendelo
Newbie
Newbie
Posts: 11
Joined: Wed Sep 26, 2007 12:00 am

TPolygonShape

Post by mendelo » Tue Jul 14, 2009 6:29 pm

Is it possible, at this time, to apply an image to a TPolygonShape, with imagealignment of iaCenter and have the image fill out just within the boundaries of the polygon, rather than creating a rectangle?

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

Re: TPolygonShape

Post by Yeray » Thu Jul 16, 2009 3:37 pm

Hi mendelo,

Take a look at the following example:

Code: Select all

uses TeCanvas;

procedure TForm1.FormCreate(Sender: TObject);
begin
  PolygonShape1.ImageAlignment := iaCenter;
  PolygonShape1.Image.LoadFromFile('C:\tmp\yourPicture.bmp');
end;

procedure TForm1.Tree1AfterDraw(Sender: TObject);
begin
  Tree1.Canvas.UnClipRectangle;
end;

procedure TForm1.Tree1BeforeDraw(Sender: TObject);
var i: Integer;
    c: Integer;
    p: array of TPoint;
begin
  c:=PolygonShape1.Points.Count;
  SetLength(p, c);

  for i:=0 To c-1 do
    p[i] := TeePoint(PolygonShape1.Points.Point[i].X,
            PolygonShape1.Points.Point[i].Y);

  Tree1.Canvas.ClipPolygon(p, c);
end;
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

mendelo
Newbie
Newbie
Posts: 11
Joined: Wed Sep 26, 2007 12:00 am

Re: TPolygonShape

Post by mendelo » Thu Jul 16, 2009 8:24 pm

Thank you Yeray

That does work, but only temporarily. If you perform any other change to the TTree, such as turn off the grid etc. then the image reverts back to a rectangle. Additionally it does weird things to other TTreeNodeShapes, such as causing the images not to display within all other shapes.

Thanks

Post Reply