mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 06:39:31 +01:00 
			
		
		
		
	TAChart: Add TZoomDragTool.Proportional property
git-svn-id: trunk@24535 -
This commit is contained in:
		
							parent
							
								
									532005624d
								
							
						
					
					
						commit
						a2fbc46d03
					
				@ -103,11 +103,14 @@ type
 | 
			
		||||
 | 
			
		||||
  TZoomDragTool = class(TChartTool)
 | 
			
		||||
  private
 | 
			
		||||
    FProportional: Boolean;
 | 
			
		||||
    FSelectionRect: TRect;
 | 
			
		||||
  public
 | 
			
		||||
    procedure MouseDown(APoint: TPoint); override;
 | 
			
		||||
    procedure MouseMove(APoint: TPoint); override;
 | 
			
		||||
    procedure MouseUp(APoint: TPoint); override;
 | 
			
		||||
  published
 | 
			
		||||
    property Proportional: Boolean read FProportional write FProportional default false;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  { TZoomClickTool }
 | 
			
		||||
@ -526,6 +529,25 @@ end;
 | 
			
		||||
procedure TZoomDragTool.MouseUp(APoint: TPoint);
 | 
			
		||||
var
 | 
			
		||||
  ext: TDoubleRect;
 | 
			
		||||
 | 
			
		||||
  procedure CheckProportions;
 | 
			
		||||
  var
 | 
			
		||||
    newSize, oldSize: TDoublePoint;
 | 
			
		||||
    coeff: Double;
 | 
			
		||||
  begin
 | 
			
		||||
    if not Proportional then exit;
 | 
			
		||||
    newSize := ext.b - ext.a;
 | 
			
		||||
    oldSize := FChart.LogicalExtent.b - FChart.LogicalExtent.a;
 | 
			
		||||
    coeff := newSize.Y * oldSize.X;
 | 
			
		||||
    if coeff = 0 then exit;
 | 
			
		||||
    coeff := newSize.X * oldSize.Y / coeff;
 | 
			
		||||
    if coeff = 0 then exit;
 | 
			
		||||
    if coeff > 1 then
 | 
			
		||||
      ExpandRange(ext.a.Y, ext.b.Y, (coeff - 1) / 2)
 | 
			
		||||
    else
 | 
			
		||||
      ExpandRange(ext.a.X, ext.b.X, (1 / coeff  - 1) / 2);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  Unused(APoint);
 | 
			
		||||
  Deactivate;
 | 
			
		||||
@ -546,6 +568,7 @@ begin
 | 
			
		||||
    if a.Y > b.Y then
 | 
			
		||||
      Exchange(a.Y, b.Y);
 | 
			
		||||
  end;
 | 
			
		||||
  CheckProportions;
 | 
			
		||||
  FChart.LogicalExtent := ext;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
@ -584,14 +607,14 @@ begin
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{ TZoomClickTool }
 | 
			
		||||
 | 
			
		||||
constructor TZoomClickTool.Create(AOwner: TComponent);
 | 
			
		||||
begin
 | 
			
		||||
  inherited Create(AOwner);
 | 
			
		||||
  FZoomFactor := 1.0;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{ TZoomClickTool }
 | 
			
		||||
 | 
			
		||||
procedure TZoomClickTool.MouseDown(APoint: TPoint);
 | 
			
		||||
var
 | 
			
		||||
  sz, center: TDoublePoint;
 | 
			
		||||
@ -613,6 +636,8 @@ begin
 | 
			
		||||
  Result := FZoomFactor <> 1.0;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{ TPanDragTool }
 | 
			
		||||
 | 
			
		||||
constructor TPanDragTool.Create(AOwner: TComponent);
 | 
			
		||||
begin
 | 
			
		||||
  inherited Create(AOwner);
 | 
			
		||||
@ -620,8 +645,6 @@ begin
 | 
			
		||||
  FDirections := PAN_DIRECTIONS_ALL;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{ TPanDragTool }
 | 
			
		||||
 | 
			
		||||
procedure TPanDragTool.MouseDown(APoint: TPoint);
 | 
			
		||||
begin
 | 
			
		||||
  Activate;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user