1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| PROCEDURE TGraphNode.Draw( Canvas : TCanvas );
VAR R : TRect;
x1, y1, x2, y2 : Integer;
W, H : Integer;
s : STRING;
c: PChar;
BEGIN
IF Visible THEN
BEGIN
W:=Width;
H:=Height;
x1:=x-W DIV 2;
y1:=y-H DIV 2;
x2:=x1+W;
y2:=y1+H;
WITH Canvas DO
BEGIN
Brush.Style:=bsSolid;
IF (FColor<>clNone) THEN
Brush.Color:=FColor;
CASE FShape OF
stRectangle, stSquare : Rectangle(x1, y1, x2, y2);
stRoundRect, stRoundSquare : RoundRect(x1, y1, x2, y2, 16, 16);
stEllipse, stCircle : Ellipse(x1, y1, x2, y2);
END;
IF (FName<>'') THEN
BEGIN
c:=PChar(FName);
DrawText(Canvas.Handle, c, Length(FName), R, DT_CALCRECT);
H:=R.Bottom-R.Top;
W:=R.Right-R.Left;
R.Left:=(x1+x2-W) div 2;
R.Right:=R.Left+W;
R.Top:=(y1+y2-H) div 2;
R.Bottom:=R.Top+H;
Brush.Style:=bsClear;
case FTextAlign of
0 : DrawText(Canvas.Handle, c, Length(FName), R, DT_LEFT);
1 : DrawText(Canvas.Handle, c, Length(FName), R, DT_CENTER);
2 : DrawText(Canvas.Handle, c, Length(FName), R, DT_RIGHT);
else
DrawText(Canvas.Handle, c, Length(FName), R, DT_CENTER);
end;
END;
END;
END;
END; {* PROC .Draw *} |
Partager