Home > Back-end >  Delphi treeview control how data vertical center like binary tree top neutron in the first node in t
Delphi treeview control how data vertical center like binary tree top neutron in the first node in t

Time:11-08

Delphi treeview control how data vertical center like binary tree top neutron in the first node in turn below
As shown in figure:


Or any third party controls can

CodePudding user response:

Or redraw can realize also ok, is there any and some thoughts!

CodePudding user response:

No one know?

CodePudding user response:

His painting, is a few round, arrow

CodePudding user response:

Agree with upstairs, yourself. The idea is as follows:
 
//1, to determine the root node location (rectangle), defined as ParentRect
//the width of the rectangle
W:=ParentRect. Right - Parent. Left;
//height
H:=ParentRect. Bottom - Parent. Top;
//for ease of calculation and understanding, declare a variable tmpW, said half the width of the
TmpW: W div=2;

//2, calculate child node position, defined as ChildRect, if child node number is n, the location of the node number as the index, is:
//(1) the calculation of rectangular Top, Bottom
ChildRect. Top:=ParentRect. Bottom;
ChildRect. Bottom:=ChildRect. Top + H;

//(2) to calculate the most all child nodes on the left side of the position L
L:=ParentRect. Left - ((n - 1) * tmpW);
//(3) calculate all child nodes Left and Right
For the Index: do the begin=0 to n - 1
ChildRect [index]. Left:=L + W * index;
ChildRect [index]. Right:=ChildRect [index] Left + W;
The end;
//3, recursive calls to step 2, can calculate the rectangular area of all the node
//4, recalculate all nodes actually draw area, leave space position, such as:
ChildDrawRect:=ChildRect;
With ChildDrawRect do begin
Top: Top +=(H div 6);
Bottom:=Bottom - H div (6);
Left:=Left + div 6 (W);
Right:=Right - W div (6);
The end;
//5, draw the child nodes and the parent node connection link (abbreviated)

CodePudding user response:

  • Related