mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:39:20 +02:00
TAChart: Add AllowDragNavigation, DragCursor and Shift properties to TChartNavPanel
git-svn-id: trunk@29934 -
This commit is contained in:
parent
f8bd19af4e
commit
5a6afb9cb6
@ -100,10 +100,16 @@ type
|
|||||||
procedure SetLogicalExtentPen(AValue: TPen);
|
procedure SetLogicalExtentPen(AValue: TPen);
|
||||||
procedure SetProportional(AValue: Boolean);
|
procedure SetProportional(AValue: Boolean);
|
||||||
private
|
private
|
||||||
|
FAllowDragNavigation: Boolean;
|
||||||
|
FDragCursor: TCursor;
|
||||||
|
FIsDragging: Boolean;
|
||||||
FLogicalExtentRect: TRect;
|
FLogicalExtentRect: TRect;
|
||||||
FOffset: TDoublePoint;
|
FOffset: TDoublePoint;
|
||||||
|
FOldCursor: TCursor;
|
||||||
FPrevPoint: TDoublePoint;
|
FPrevPoint: TDoublePoint;
|
||||||
FScale: TDoublePoint;
|
FScale: TDoublePoint;
|
||||||
|
FShift: TShiftState;
|
||||||
|
procedure SetDragCursor(AValue: TCursor);
|
||||||
protected
|
protected
|
||||||
procedure MouseDown(
|
procedure MouseDown(
|
||||||
AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer); override;
|
AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer); override;
|
||||||
@ -115,10 +121,14 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
published
|
published
|
||||||
|
property AllowDragNavigation: Boolean
|
||||||
|
read FAllowDragNavigation write FAllowDragNavigation default true;
|
||||||
property Chart: TChart read FChart write SetChart;
|
property Chart: TChart read FChart write SetChart;
|
||||||
|
property DragCursor: TCursor read FDragCursor write SetDragCursor default crSizeAll;
|
||||||
property FullExtentPen: TPen read FFullExtentPen write SetFullExtentPen;
|
property FullExtentPen: TPen read FFullExtentPen write SetFullExtentPen;
|
||||||
property LogicalExtentPen: TPen read FLogicalExtentPen write SetLogicalExtentPen;
|
property LogicalExtentPen: TPen read FLogicalExtentPen write SetLogicalExtentPen;
|
||||||
property Proportional: Boolean read FProportional write SetProportional default false;
|
property Proportional: Boolean read FProportional write SetProportional default false;
|
||||||
|
property Shift: TShiftState read FShift write FShift default [ssLeft];
|
||||||
published
|
published
|
||||||
property Align;
|
property Align;
|
||||||
end;
|
end;
|
||||||
@ -249,6 +259,9 @@ begin
|
|||||||
FLogicalExtentRect := Rect(0, 0, 0, 0);
|
FLogicalExtentRect := Rect(0, 0, 0, 0);
|
||||||
Width := DEF_WIDTH;
|
Width := DEF_WIDTH;
|
||||||
Height := DEF_HEIGHT;
|
Height := DEF_HEIGHT;
|
||||||
|
FAllowDragNavigation := true;
|
||||||
|
FDragCursor := crSizeAll;
|
||||||
|
FShift := [ssLeft];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TChartNavPanel.Destroy;
|
destructor TChartNavPanel.Destroy;
|
||||||
@ -262,12 +275,15 @@ end;
|
|||||||
procedure TChartNavPanel.MouseDown(
|
procedure TChartNavPanel.MouseDown(
|
||||||
AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer);
|
AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer);
|
||||||
begin
|
begin
|
||||||
if Chart = nil then exit;
|
if (Chart <> nil) and AllowDragNavigation then begin
|
||||||
FPrevPoint := (DoublePoint(AX, Height - AY) - FOffset) / FScale;
|
FPrevPoint := (DoublePoint(AX, Height - AY) - FOffset) / FScale;
|
||||||
MouseCapture :=
|
FIsDragging :=
|
||||||
(AShift = [ssLeft]) and IsPointInRect(Point(AX, AY), FLogicalExtentRect);
|
(AShift = Shift) and IsPointInRect(Point(AX, AY), FLogicalExtentRect);
|
||||||
if MouseCapture then
|
if FIsDragging then begin
|
||||||
Cursor := crSizeAll;
|
FOldCursor := Cursor;
|
||||||
|
Cursor := DragCursor;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
inherited MouseDown(AButton, AShift, AX, AY);
|
inherited MouseDown(AButton, AShift, AX, AY);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -276,8 +292,7 @@ var
|
|||||||
p: TDoublePoint;
|
p: TDoublePoint;
|
||||||
le: TDoubleRect;
|
le: TDoubleRect;
|
||||||
begin
|
begin
|
||||||
if Chart = nil then exit;
|
if (Chart <> nil) and FIsDragging then begin
|
||||||
if MouseCapture then begin
|
|
||||||
p := (DoublePoint(AX, Height - AY) - FOffset) / FScale;
|
p := (DoublePoint(AX, Height - AY) - FOffset) / FScale;
|
||||||
le := Chart.LogicalExtent;
|
le := Chart.LogicalExtent;
|
||||||
le.a += p - FPrevPoint;
|
le.a += p - FPrevPoint;
|
||||||
@ -291,8 +306,9 @@ end;
|
|||||||
procedure TChartNavPanel.MouseUp(
|
procedure TChartNavPanel.MouseUp(
|
||||||
AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer);
|
AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer);
|
||||||
begin
|
begin
|
||||||
MouseCapture := false;
|
if FIsDragging then
|
||||||
Cursor := crDefault;
|
Cursor := FOldCursor;
|
||||||
|
FIsDragging := false;
|
||||||
inherited MouseUp(AButton, AShift, AX, AY);
|
inherited MouseUp(AButton, AShift, AX, AY);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -357,6 +373,14 @@ begin
|
|||||||
ChartExtentChanged(Self);
|
ChartExtentChanged(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartNavPanel.SetDragCursor(AValue: TCursor);
|
||||||
|
begin
|
||||||
|
if FDragCursor = AValue then exit;
|
||||||
|
FDragCursor := AValue;
|
||||||
|
if MouseCapture then
|
||||||
|
Cursor := FDragCursor;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChartNavPanel.SetFullExtentPen(AValue: TPen);
|
procedure TChartNavPanel.SetFullExtentPen(AValue: TPen);
|
||||||
begin
|
begin
|
||||||
if FFullExtentPen = AValue then exit;
|
if FFullExtentPen = AValue then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user