mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 19:38:09 +02:00
TAChart: Add TDiaCenterElement
git-svn-id: trunk@41895 -
This commit is contained in:
parent
399b2b89d9
commit
449a06ba80
@ -122,6 +122,7 @@ type
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function DiaPoint(AX, AY: TDiaBoxSide): TDiaPoint; inline;
|
||||
procedure Add(AConnector: TDiaConnector);
|
||||
procedure Changed(ASender: TDiaObject); override;
|
||||
procedure Draw; virtual;
|
||||
@ -160,6 +161,22 @@ type
|
||||
property Value: Double read FValue write SetValue;
|
||||
end;
|
||||
|
||||
TDiaCenterElement = class(TDiaElement)
|
||||
strict private
|
||||
FActualPos: TDiaPoint;
|
||||
FLeft: TDiaPosition;
|
||||
FTop: TDiaPosition;
|
||||
procedure SetLeft(AValue: TDiaPosition);
|
||||
procedure SetTop(AValue: TDiaPosition);
|
||||
public
|
||||
constructor Create;
|
||||
procedure Changed(ASender: TDiaObject); override;
|
||||
public
|
||||
property ActualPos: TDiaPoint read FActualPos;
|
||||
property Left: TDiaPosition read FLeft write SetLeft;
|
||||
property Top: TDiaPosition read FTop write SetTop;
|
||||
end;
|
||||
|
||||
TDiaBox = class(TDiaElement)
|
||||
strict private
|
||||
FBottom: TDiaPosition;
|
||||
@ -216,6 +233,11 @@ type
|
||||
property Position: TDiaPosition read FPosition write SetPosition;
|
||||
end;
|
||||
|
||||
TDiaCenterConnector = class(TDiaConnector)
|
||||
public
|
||||
procedure Changed(ASender: TDiaObject); override;
|
||||
end;
|
||||
|
||||
TDiaBoxConnector = class(TDiaConnector)
|
||||
private
|
||||
FSide: TDiaBoxSide;
|
||||
@ -285,6 +307,16 @@ const
|
||||
DEFAULT_DPI = 72;
|
||||
CM_PER_INCH = 2.54;
|
||||
|
||||
function XY(const AX, AY: TDiaPoint): TDiaPoint;
|
||||
var
|
||||
u: TDiaUnits;
|
||||
begin
|
||||
for u in TDiaUnits do begin
|
||||
Result.X[u] := AX.X[u];
|
||||
Result.Y[u] := AY.Y[u];
|
||||
end;
|
||||
end;
|
||||
|
||||
function DiaPos(
|
||||
AValue: Double; AUnits: TDiaUnits;
|
||||
AReverse: Boolean; APercentage: Boolean): TDiaPosition;
|
||||
@ -313,6 +345,39 @@ begin
|
||||
Result := TDiaPosition.Equals(A, B);
|
||||
end;
|
||||
|
||||
{ TDiaCenterElement }
|
||||
|
||||
procedure TDiaCenterElement.Changed(ASender: TDiaObject);
|
||||
var
|
||||
tl, tr, bl, br: TDiaPoint;
|
||||
begin
|
||||
tl := DiaPoint(dbsLeft, dbsTop);
|
||||
tr := DiaPoint(dbsRight, dbsTop);
|
||||
bl := DiaPoint(dbsLeft, dbsBottom);
|
||||
br := DiaPoint(dbsRight, dbsBottom);
|
||||
if Left.Defined and Top.Defined then
|
||||
FActualPos := XY(Left.Calc(tl, tr), Top.Calc(tl, bl));
|
||||
inherited;
|
||||
end;
|
||||
|
||||
constructor TDiaCenterElement.Create;
|
||||
begin
|
||||
FLeft.Init(Self);
|
||||
FTop.Init(Self);
|
||||
end;
|
||||
|
||||
procedure TDiaCenterElement.SetLeft(AValue: TDiaPosition);
|
||||
begin
|
||||
if FLeft = AValue then exit;
|
||||
FLeft.Assign(AValue);
|
||||
end;
|
||||
|
||||
procedure TDiaCenterElement.SetTop(AValue: TDiaPosition);
|
||||
begin
|
||||
if FTop = AValue then exit;
|
||||
FTop.Assign(AValue);
|
||||
end;
|
||||
|
||||
{ TDiaPoint }
|
||||
|
||||
function TDiaPoint.AsUnits(AUnits: TDiaUnits): TDoublePoint;
|
||||
@ -453,6 +518,15 @@ begin
|
||||
Notify(Self);
|
||||
end;
|
||||
|
||||
{ TDiaCenterConnector }
|
||||
|
||||
procedure TDiaCenterConnector.Changed(ASender: TDiaObject);
|
||||
begin
|
||||
inherited;
|
||||
if Element is TDiaCenterElement then
|
||||
FActualPos := (Element as TDiaCenterElement).ActualPos;
|
||||
end;
|
||||
|
||||
{ TDiaBoxConnector }
|
||||
|
||||
procedure TDiaBoxConnector.Changed(ASender: TDiaObject);
|
||||
@ -545,23 +619,6 @@ end;
|
||||
{ TDiaBox }
|
||||
|
||||
procedure TDiaBox.Changed(ASender: TDiaObject);
|
||||
|
||||
function DiaPoint(AX, AY: TDiaBoxSide): TDiaPoint;
|
||||
begin
|
||||
Result.X := Owner[AX];
|
||||
Result.Y := Owner[AY];
|
||||
end;
|
||||
|
||||
function XY(const AX, AY: TDiaPoint): TDiaPoint;
|
||||
var
|
||||
u: TDiaUnits;
|
||||
begin
|
||||
for u in TDiaUnits do begin
|
||||
Result.X[u] := AX.X[u];
|
||||
Result.Y[u] := AY.Y[u];
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
tl, tr, bl, br: TDiaPoint;
|
||||
begin
|
||||
@ -753,6 +810,12 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TDiaElement.DiaPoint(AX, AY: TDiaBoxSide): TDiaPoint;
|
||||
begin
|
||||
Result.X := Owner[AX];
|
||||
Result.Y := Owner[AY];
|
||||
end;
|
||||
|
||||
procedure TDiaElement.Draw;
|
||||
begin
|
||||
//
|
||||
|
@ -18,8 +18,7 @@ uses
|
||||
|
||||
function MakeBoxSideConnector(
|
||||
ABox: TDiaBox; ASide: TDiaBoxSide): TDiaBoxConnector;
|
||||
function MakeLink(
|
||||
ADia: TDiagram; AConn1, AConn2: TDiaBoxConnector): TDiaLink;
|
||||
function MakeLink(ADia: TDiagram; AConn1, AConn2: TDiaConnector): TDiaLink;
|
||||
|
||||
implementation
|
||||
|
||||
@ -32,8 +31,7 @@ begin
|
||||
ABox.Add(Result);
|
||||
end;
|
||||
|
||||
function MakeLink(
|
||||
ADia: TDiagram; AConn1, AConn2: TDiaBoxConnector): TDiaLink;
|
||||
function MakeLink(ADia: TDiagram; AConn1, AConn2: TDiaConnector): TDiaLink;
|
||||
begin
|
||||
Result := TDiaLink.Create;
|
||||
Result.Start.Connector := AConn1;
|
||||
|
Loading…
Reference in New Issue
Block a user