📄 treeflow.pas
字号:
inherited;
VertTextAlign:=vtaBottom;
end;
{ TTriangleRectRightShape }
function TTriangleRectRightShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
begin
result:=3;
With R do
begin
P[0] :=TopLeft;
P[1] :=BottomRight;
P[2] :=TeePoint(Left,Bottom);
end;
end;
{ TTriangleRectLeftShape }
function TTriangleRectLeftShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
begin
result:=3;
With R do
begin
P[0] :=TeePoint(Right,Top);
P[1] :=BottomRight;
P[2] :=TeePoint(Left,Bottom);
end;
end;
{ THouseShape }
Function THouseShape.InternalWallSize(Const R:TRect):Integer;
begin
result:=Round((R.Bottom-R.Top)*FWallSize*0.01);
end;
Function THouseShape.ClickedMiddle(x,y:Integer):Boolean;
var tmpSize : Integer;
tmpR : TRect;
begin
tmpSize:=Tree.Selected.HandleSize;
tmpR:=Bounds;
result:=(Abs(X-XCenter)<=tmpSize) and
(Abs(Y-(tmpR.Top+InternalWallSize(tmpR)))<=tmpSize);
end;
procedure THouseShape.DrawHandles;
begin
inherited;
TTreeAccess(Tree).DrawHandle(Self,rcCustom,XCenter,Y0+InternalWallSize(Bounds));
end;
function THouseShape.GetHandleCursor(x, y: Integer): TCursor;
begin
result:=inherited GetHandleCursor(x,y);
if (result=crDefault) and ClickedMiddle(x,y) then
result:=crSizeNS;
end;
function THouseShape.GetResizingHandle(x, y: Integer): TTreeShapeHandle;
begin
result:=inherited GetResizingHandle(x,y);
if (result=rcNone) and ClickedMiddle(x,y) then
result:=rcCustom;
end;
function THouseShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
var tmp : Integer;
begin
result:=5;
With R do
begin
P[0]:=TeePoint((Left+Right) div 2,Top);
tmp:=Top+InternalWallSize(R);
P[1]:=TeePoint(Right,tmp);
P[2]:=BottomRight;
P[3]:=TeePoint(Left,Bottom);
P[4]:=TeePoint(Left,tmp);
end;
end;
procedure THouseShape.Resize(ACorner: TTreeShapeHandle; DeltaX,
DeltaY: Integer);
var tmp : Integer;
begin
if ACorner=rcCustom then
begin
if DeltaY<>0 then
begin
tmp:=InternalWallSize(Bounds)+DeltaY;
FWallSize:=100.0*(tmp/Height);
Repaint;
end;
end
else inherited;
end;
constructor THouseShape.Create(AOwner: TComponent);
begin
inherited;
FWallSize:=50;
end;
procedure THouseShape.SetWallSize(const Value: Double);
begin
SetDoubleProperty(FWallSize,Value);
end;
{ TEnvelopeShape }
Constructor TEnvelopeShape.Create(AOwner: TComponent);
begin
inherited;
FOffsetY:=33;
end;
Function TEnvelopeShape.MiddlePoint(Const R:TRect):TPoint;
begin
with R do
begin
result.X:=(Left+Right) div 2;
result.Y:=Top+Round((Bottom-Top)*FOffsetY*0.01);
end;
end;
procedure TEnvelopeShape.DrawHandles;
begin
inherited;
with MiddlePoint(Bounds) do
TTreeAccess(Tree).DrawHandle(Self,rcCustom,X,Y);
end;
procedure TEnvelopeShape.DrawShapeCanvas(ACanvas: TCanvas3D;
const R: TRect);
begin
inherited;
With R do
begin
ACanvas.MoveTo3D(Left,Top,TeeTreeZ);
with MiddlePoint(R) do ACanvas.LineTo3D(X,Y,TeeTreeZ);
ACanvas.LineTo3D(Right,Top,TeeTreeZ);
end;
end;
Function TEnvelopeShape.ClickedMiddle(x,y:Integer):Boolean;
var tmp : TPoint;
tmpSize : Integer;
begin
tmpSize:=Tree.Selected.HandleSize;
tmp:=MiddlePoint(Bounds);
result:=(Abs(X-tmp.X)<=tmpSize) and (Abs(Y-tmp.Y)<=tmpSize);
end;
function TEnvelopeShape.GetHandleCursor(x, y: Integer): TCursor;
begin
result:=inherited GetHandleCursor(x,y);
if (result=crDefault) and ClickedMiddle(x,y) then
result:=crSizeNS;
end;
procedure TEnvelopeShape.Resize(ACorner: TTreeShapeHandle; DeltaX,
DeltaY: Integer);
var tmp : Double;
begin
if ACorner=rcCustom then
begin
if DeltaY<>0 then
begin
tmp:=(FOffsetY*Height*0.01)+DeltaY;
FOffsetY:=Round(tmp*100/Height);
Repaint;
end;
end
else inherited;
end;
procedure TEnvelopeShape.SetOffsetY(const Value: Integer);
begin
SetIntegerProperty(FOffsetY,Value);
end;
function TEnvelopeShape.GetResizingHandle(x, y: Integer): TTreeShapeHandle;
begin
result:=inherited GetResizingHandle(x,y);
if (result=rcNone) and ClickedMiddle(x,y) then
result:=rcCustom;
end;
{ TRingShape }
constructor TRingShape.Create(AOwner: TComponent);
begin
inherited;
Style:=tssCircle;
end;
procedure TRingShape.DrawShapeCanvas(ACanvas: TCanvas3D; const R: TRect);
var tmpX : Integer;
tmpY : Integer;
begin
inherited;
With R do
begin
tmpX:=(Right-Left) div 4;
tmpY:=(Bottom-Top) div 4;
ACanvas.EllipseWithZ(Left+tmpX,Top+tmpY,Right-tmpX,Bottom-tmpY,TeeTreeZ);
end;
end;
{ TArrowShape }
constructor TTreeCustomArrowShape.Create(AOwner: TComponent);
begin
inherited;
FPercentHoriz:=25;
FPercentVert:=33;
end;
procedure TTreeCustomArrowShape.SetHoriz(const Value: Integer);
begin
SetIntegerProperty(FPercentHoriz,Value);
end;
procedure TTreeCustomArrowShape.SetVert(const Value: Integer);
begin
SetIntegerProperty(FPercentVert,Value);
end;
{ TArrowUpShape }
function TArrowUpShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
var tmpX : Integer;
tmpY : Integer;
begin
result:=7;
With R do
begin
tmpX:=Round((Right-Left)*FPercentHoriz*0.01);
tmpY:=Top+Round((Bottom-Top)*FPercentVert*0.01);
P[0]:=TeePoint((Left+Right) div 2,Top);
P[1]:=TeePoint(Right,tmpY);
P[2]:=TeePoint(Right-tmpX,tmpY);
P[3]:=TeePoint(Right-tmpX,Bottom);
P[4]:=TeePoint(Left+tmpX,Bottom);
P[5]:=TeePoint(Left+tmpX,tmpY);
P[6]:=TeePoint(Left,tmpY);
end;
end;
{ TArrowDownShape }
function TArrowDownShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
var tmpX : Integer;
tmpY : Integer;
begin
result:=7;
With R do
begin
tmpX:=Round((Right-Left)*FPercentHoriz*0.01);
tmpY:=Bottom-Round((Bottom-Top)*FPercentVert*0.01);
P[0]:=TeePoint((Left+Right) div 2,Bottom);
P[1]:=TeePoint(Right,tmpY);
P[2]:=TeePoint(Right-tmpX,tmpY);
P[3]:=TeePoint(Right-tmpX,Top);
P[4]:=TeePoint(Left+tmpX,Top);
P[5]:=TeePoint(Left+tmpX,tmpY);
P[6]:=TeePoint(Left,tmpY);
end;
end;
{ TArrowRightShape }
function TArrowRightShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
var tmpX : Integer;
tmpY : Integer;
begin
result:=7;
With R do
begin
tmpX:=Right-Round((Right-Left)*FPercentHoriz*0.01);
tmpY:=Round((Bottom-Top)*FPercentVert*0.01);
P[0]:=TeePoint(Right,(Top+Bottom) div 2);
P[1]:=TeePoint(tmpX,Bottom);
P[2]:=TeePoint(tmpX,Bottom-tmpY);
P[3]:=TeePoint(Left,Bottom-tmpY);
P[4]:=TeePoint(Left,Top+tmpY);
P[5]:=TeePoint(tmpX,Top+tmpY);
P[6]:=TeePoint(tmpX,Top);
end;
end;
{ TArrowLeftShape }
function TArrowLeftShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
var tmpX : Integer;
tmpY : Integer;
begin
result:=7;
With R do
begin
tmpX:=Left+Round((Right-Left)*FPercentHoriz*0.01);
tmpY:=Round((Bottom-Top)*FPercentVert*0.01);
P[0]:=TeePoint(Left,(Top+Bottom) div 2);
P[1]:=TeePoint(tmpX,Bottom);
P[2]:=TeePoint(tmpX,Bottom-tmpY);
P[3]:=TeePoint(Right,Bottom-tmpY);
P[4]:=TeePoint(Right,Top+tmpY);
P[5]:=TeePoint(tmpX,Top+tmpY);
P[6]:=TeePoint(tmpX,Top);
end;
end;
{ TCallOutShape }
Function TCallOutShape.CallOutPoint(Const R:TRect):TPoint;
begin
result:=TeePoint( R.Left+Round(FPosX*(R.Right-R.Left)*0.01),
R.Top+Round(FPosY*(R.Bottom-R.Top)*0.01));
end;
procedure TCallOutShape.DrawHandles;
begin
inherited;
with CallOutPoint(Bounds) do
TTreeAccess(Tree).DrawHandle(Self,rcCustom,X,Y);
end;
Function TCallOutShape.ClickedCallOut(x,y:Integer):Boolean;
var P : TPoint;
tmpSize : Integer;
begin
P:=CallOutPoint(Bounds);
tmpSize:=Tree.Selected.HandleSize;
result:=(Abs(X-P.X)<=tmpSize) and (Abs(Y-P.Y)<=tmpSize);
end;
function TCallOutShape.GetHandleCursor(x, y: Integer): TCursor;
begin
result:=inherited GetHandleCursor(x,y);
if (result=crDefault) and ClickedCallOut(x,y) then
result:=crSizeAll;
end;
function TCallOutShape.GetResizingHandle(x, y: Integer): TTreeShapeHandle;
begin
result:=inherited GetResizingHandle(x,y);
if (result=rcNone) and ClickedCallOut(x,y) then
result:=rcCustom;
end;
function TCallOutShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
var tmp : Integer;
begin
result:=7;
With R do
begin
tmp:=(Bottom-Top) div 6;
P[0] :=TopLeft;
P[1] :=TeePoint(Right,Top);
P[2] :=TeePoint(Right,Bottom-tmp);
P[3] :=TeePoint((Left+Right) div 2,Bottom-tmp);
P[4] :=CallOutPoint(R);
P[5] :=TeePoint(Left+((Right-Left) div 3),Bottom-tmp);
P[6] :=TeePoint(Left,Bottom-tmp);
end;
end;
procedure TCallOutShape.Resize(ACorner: TTreeShapeHandle; DeltaX,
DeltaY: Integer);
begin
if ACorner=rcCustom then
begin
if DeltaX<>0 then
begin
FPosX:=Round(100.0*((Width*FPosX*0.01)+DeltaX)/Width);
Repaint;
end;
if DeltaY<>0 then
begin
FPosY:=Round(100.0*((Height*FPosY*0.01)+DeltaY)/Height);
Repaint;
end;
end
else inherited;
end;
constructor TCallOutShape.Create(AOwner: TComponent);
begin
inherited;
FPosX:=25;
FPosY:=100;
end;
{ TStarShape }
function TStarShape.GetShapePoints(const R: TRect;
var P: TShapePoints): Integer;
var tmpXC : Integer;
tmpYC : Integer;
tmpX : Integer;
tmpY : Integer;
Function PointAtAngle(Angle:Integer):TPoint;
var tmpSin : Extended;
tmpCos : Extended;
begin
SinCos(Angle*TeePiStep,tmpSin,tmpCos);
result.X:=tmpXC+Round(tmpX*tmpSin);
result.Y:=tmpYC-Round(tmpY*tmpCos);
end;
var tmpX2 : Integer;
tmpY2 : Integer;
tmpX3 : Integer;
tmpY3 : Integer;
begin
result:=10;
With R do
begin
tmpX:=(Right-Left) div 2;
tmpY:=Math.Max(1,(Bottom-Top) div 2);
tmpXC:=(Right+Left) div 2;
tmpYC:=(Top+Bottom) div 2;
tmpX2:=(2*tmpX) div 7;
tmpY2:=(Bottom-Top) div 3;
tmpX3:=tmpX div 2;
tmpY3:=tmpY div 2;
P[0]:=TeePoint((Left+Right) div 2,Top);
P[2]:=PointAtAngle(72);
P[1].X:=tmpXC+tmpX2;
P[1].Y:=P[2].Y;
P[3].X:=tmpXC+tmpX3;
P[3].Y:=Bottom-tmpY2;
P[4].X:=tmpXC+((Right-Left) div 3);
P[4].Y:=Bottom;
P[5].X:=tmpXC;
P[5].Y:=Bottom-tmpY3;
P[6].X:=tmpXC-((Right-Left) div 3);
P[6].Y:=Bottom;
P[7].X:=tmpXC-tmpX3;
P[7].Y:=P[3].Y;
P[8]:=PointAtAngle(288);
P[9].X:=tmpXC-tmpX2;
P[9].Y:=P[8].Y;
end;
end;
{ TGridShape }
Constructor TGridShape.Create(AOwner: TComponent);
begin
inherited;
Width:=100;
Height:=100;
FGridLines:=TTreePen.Create(CanvasChanged);
FGridLines.Color:=clGray;
FGridLines.SmallDots:=True;
FSelectedCol:=-1;
FSelectedRow:=-1;
Columns:=3;
Rows:=3;
Transparent:=True;
end;
Destructor TGridShape.Destroy;
begin
FGridLines.Free;
inherited;
end;
procedure TGridShape.AddColumn;
begin
Inc(FColumns);
end;
procedure TGridShape.AddRow;
begin
Inc(FRows);
end;
procedure TGridShape.DeleteColumn(Column: Integer);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -