TeeTree Printing

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
David
Newbie
Newbie
Posts: 4
Joined: Mon Jan 31, 2005 5:00 am
Location: Idaho
Contact:

TeeTree Printing

Post by David » Thu Feb 10, 2005 5:12 pm

I am creating a TTree using the TTreeTopBottomAlignChild child manager. On the form the tree balances and other than the known limitation where nodes on the same level overlap it looks good. I'll consider writing my own child manager to correct that later. However, when I use the TTree.Print command the results are not balanced and doesn't look like anything on the screen. The root node starts at the upper left corner its children are placed to the right of the parent node. You might even say the 'far right'. The print function must not use the same child manager or adjusts the X print position differently. I've tried to place the root node in the middle but the tree still slides to the right. I also notice that the crossbox is printed out in never-never land.

Any help on how to print the tree as shown on the form?

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Thu Mar 10, 2005 1:21 am

Hi,

Thanks for the bug report.

Try the following:

In TeeTree.pas

change the code of the respective methods to:

Code: Select all

Function TTreeNodeShape.XCenter:Integer;
begin
  result:=((X0+X1) div 2);
end;

Function TTreeNodeShape.YCenter:Integer;
begin
  result:=((Y0+Y1) div 2);
end;
and in TTreeExplorerAlignChild.DrawConnection change:

Code: Select all

if tmp>0 then
begin
  ....
end
else
begin
      P:=CalcXYCross(ToShape,FromShape);
      Item[0].X:=P.X;
      tmpYC:=FromShape.YCenter;
      Item[0].Y:=tmpYC;

      if Tree.ShowImages and (FromShape.IImageHeight>0) then
         tmpY:=2+(FromShape.IImageHeight div 2)
      else
         With FromShape.Bounds do tmpY:=1+((Bottom-Top) div 2);

      if ToShape.YCenter<tmpYC then Dec(Item[0].Y,tmpY)
                               else Inc(Item[0].Y,tmpY);

      Inc(Item[0].Y, Tree.ChartBounds.Top);            <<<<<<<<<<<
end;
Please, keep in mind that all provided code changes are not fully tested (so other things might brake) and the solution provided in future versions might be different.
Use this at your own risk, you're welcome to provide any information concerning these changes.

Regards,
Tom.

Post Reply