You've already forked lazarus-ccr
NiceChart: Fix clipping for Delphi version. Property setters call NiceChart.Invalidate rather than .DoPaint (properties are not updated in qt5).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8863 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -130,6 +130,9 @@ type
|
|||||||
FSmallMargin: Integer;
|
FSmallMargin: Integer;
|
||||||
FAxisDefSize: Integer;
|
FAxisDefSize: Integer;
|
||||||
FLegendItemSize: Integer;
|
FLegendItemSize: Integer;
|
||||||
|
{$IFNDEF FPC}
|
||||||
|
FClipRgn: HRGN;
|
||||||
|
{$ENDIF}
|
||||||
procedure InternalClear;
|
procedure InternalClear;
|
||||||
procedure InternalPaint(ACanvas: TCanvas);
|
procedure InternalPaint(ACanvas: TCanvas);
|
||||||
procedure Calculate(AWidth, AHeight: Integer);
|
procedure Calculate(AWidth, AHeight: Integer);
|
||||||
@ -185,6 +188,7 @@ type
|
|||||||
procedure Changed;
|
procedure Changed;
|
||||||
procedure ChartToClient(const AX, AY: Double; var X, Y: Integer);
|
procedure ChartToClient(const AX, AY: Double; var X, Y: Integer);
|
||||||
procedure CreateHandle; override;
|
procedure CreateHandle; override;
|
||||||
|
procedure ClipToRect(ACanvas: TCanvas; const ARect: TRect; AEnable: Boolean);
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double); override;
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double); override;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -355,8 +359,8 @@ procedure TNiceSeries.InternalClear;
|
|||||||
var
|
var
|
||||||
x: Integer;
|
x: Integer;
|
||||||
begin
|
begin
|
||||||
for x := 0 to Values.Count-1
|
for x := 0 to Values.Count-1 do
|
||||||
do Dispose(PXYInfo(Values[x]));
|
Dispose(PXYInfo(Values[x]));
|
||||||
Values.Clear;
|
Values.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -399,8 +403,8 @@ var
|
|||||||
x: Integer;
|
x: Integer;
|
||||||
begin
|
begin
|
||||||
Result := -MaxDouble;
|
Result := -MaxDouble;
|
||||||
for x := 0 to Values.Count-1
|
for x := 0 to Values.Count-1 do
|
||||||
do Result := Max(Result, PXYInfo(Values[x])^.X);
|
Result := Max(Result, PXYInfo(Values[x])^.X);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TNiceSeries.GetMinXValue: Double;
|
function TNiceSeries.GetMinXValue: Double;
|
||||||
@ -408,8 +412,8 @@ var
|
|||||||
x: Integer;
|
x: Integer;
|
||||||
begin
|
begin
|
||||||
Result := MaxDouble;
|
Result := MaxDouble;
|
||||||
for x := 0 to Values.Count-1
|
for x := 0 to Values.Count-1 do
|
||||||
do Result := Min(Result, PXYInfo(Values[x])^.X);
|
Result := Min(Result, PXYInfo(Values[x])^.X);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TNiceSeries.GetMaxYValue: Double;
|
function TNiceSeries.GetMaxYValue: Double;
|
||||||
@ -417,8 +421,8 @@ var
|
|||||||
x: Integer;
|
x: Integer;
|
||||||
begin
|
begin
|
||||||
Result := -MaxDouble;
|
Result := -MaxDouble;
|
||||||
for x := 0 to Values.Count-1
|
for x := 0 to Values.Count-1 do
|
||||||
do Result := Max(Result, PXYInfo(Values[x])^.Y);
|
Result := Max(Result, PXYInfo(Values[x])^.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TNiceSeries.GetMinYValue: Double;
|
function TNiceSeries.GetMinYValue: Double;
|
||||||
@ -426,8 +430,8 @@ var
|
|||||||
x: Integer;
|
x: Integer;
|
||||||
begin
|
begin
|
||||||
Result := MaxDouble;
|
Result := MaxDouble;
|
||||||
for x := 0 to Values.Count-1
|
for x := 0 to Values.Count-1 do
|
||||||
do Result := Min(Result, PXYInfo(Values[x])^.Y);
|
Result := Min(Result, PXYInfo(Values[x])^.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TNiceSeries.SetCaption(const Value: string);
|
procedure TNiceSeries.SetCaption(const Value: string);
|
||||||
@ -550,7 +554,7 @@ begin
|
|||||||
if FGridColor <> value then
|
if FGridColor <> value then
|
||||||
begin
|
begin
|
||||||
FGridColor := Value;
|
FGridColor := Value;
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -699,7 +703,7 @@ begin
|
|||||||
if (FShowXAxisLine <> Value) then
|
if (FShowXAxisLine <> Value) then
|
||||||
begin
|
begin
|
||||||
FShowXAxisLine := Value;
|
FShowXAxisLine := Value;
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -708,7 +712,7 @@ begin
|
|||||||
if (FShowXGrid <> Value) then
|
if (FShowXGrid <> Value) then
|
||||||
begin
|
begin
|
||||||
FShowXGrid := Value;
|
FShowXGrid := Value;
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -717,7 +721,7 @@ begin
|
|||||||
if (FShowYAxisLine <> Value) then
|
if (FShowYAxisLine <> Value) then
|
||||||
begin
|
begin
|
||||||
FShowYAxisLine := Value;
|
FShowYAxisLine := Value;
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -726,7 +730,7 @@ begin
|
|||||||
if (FShowYGrid <> Value) then
|
if (FShowYGrid <> Value) then
|
||||||
begin
|
begin
|
||||||
FShowYGrid := Value;
|
FShowYGrid := Value;
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -735,7 +739,7 @@ begin
|
|||||||
if (FTickLength <> Value) and (Value >= 0) then
|
if (FTickLength <> Value) and (Value >= 0) then
|
||||||
begin
|
begin
|
||||||
FTickLength := Value;
|
FTickLength := Value;
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -748,7 +752,7 @@ procedure TNiceChart.EndUpdate;
|
|||||||
begin
|
begin
|
||||||
FUpdating := False;
|
FUpdating := False;
|
||||||
Calculate(ClientWidth, ClientHeight);
|
Calculate(ClientWidth, ClientHeight);
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TNiceChart.Changed;
|
procedure TNiceChart.Changed;
|
||||||
@ -756,7 +760,7 @@ begin
|
|||||||
if not FUpdating then
|
if not FUpdating then
|
||||||
begin
|
begin
|
||||||
Calculate(ClientWidth, ClientHeight);
|
Calculate(ClientWidth, ClientHeight);
|
||||||
DoPaint;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1458,7 +1462,6 @@ end;
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------//
|
//-----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
|
||||||
procedure TNiceChart.DrawSeries(ACanvas: TCanvas; Index: Integer);
|
procedure TNiceChart.DrawSeries(ACanvas: TCanvas; Index: Integer);
|
||||||
var
|
var
|
||||||
x: Integer;
|
x: Integer;
|
||||||
@ -1471,10 +1474,9 @@ begin
|
|||||||
AutoColors(ACanvas, Index, sr.FKind = skBar);
|
AutoColors(ACanvas, Index, sr.FKind = skBar);
|
||||||
with ACanvas do
|
with ACanvas do
|
||||||
begin
|
begin
|
||||||
ClipRect := RcChart;
|
|
||||||
if (sr.FKind = skBar) then
|
if (sr.FKind = skBar) then
|
||||||
begin
|
begin
|
||||||
Clipping := true;
|
ClipToRect(ACanvas, RcChart, true);
|
||||||
try
|
try
|
||||||
Pen.Width := 1;
|
Pen.Width := 1;
|
||||||
for x := 0 to Sr.Values.Count-1 do
|
for x := 0 to Sr.Values.Count-1 do
|
||||||
@ -1483,11 +1485,11 @@ begin
|
|||||||
Rectangle(P^.Rc);
|
Rectangle(P^.Rc);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Clipping := false;
|
ClipToRect(ACanvas, RcChart, false);
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Clipping := true;
|
ClipToRect(ACanvas, RcChart, true);
|
||||||
try
|
try
|
||||||
if (sr.FKind = skLine) then
|
if (sr.FKind = skLine) then
|
||||||
begin
|
begin
|
||||||
@ -1506,7 +1508,7 @@ begin
|
|||||||
sr.Spline.Draw(ACanvas);
|
sr.Spline.Draw(ACanvas);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Clipping := false;
|
ClipToRect(ACanvas, RcChart, false);
|
||||||
end;
|
end;
|
||||||
Pen.Width := 1;
|
Pen.Width := 1;
|
||||||
for x := 0 to Sr.Values.Count-1 do
|
for x := 0 to Sr.Values.Count-1 do
|
||||||
@ -1686,6 +1688,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TNiceChart.ClipToRect(ACanvas: TCanvas; const ARect: TRect; AEnable: Boolean);
|
||||||
|
begin
|
||||||
|
{$IFDEF FPC}
|
||||||
|
if AEnable then
|
||||||
|
ACanvas.ClipRect := ARect;
|
||||||
|
ACanvas.Clipping := AEnable;
|
||||||
|
{$ELSE}
|
||||||
|
if AEnable then
|
||||||
|
begin
|
||||||
|
if FClipRgn <> 0 then
|
||||||
|
DeleteObject(FClipRgn);
|
||||||
|
FClipRgn := CreateRectRgn(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
|
||||||
|
SelectClipRgn(ACanvas.Handle, FClipRgn);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
SelectClipRgn(ACanvas.Handle, HRGN(nil));
|
||||||
|
DeleteObject(FClipRgn);
|
||||||
|
FClipRgn := 0;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
function TNiceChart.CreateMetafile: TMetafile;
|
function TNiceChart.CreateMetafile: TMetafile;
|
||||||
const
|
const
|
||||||
|
Reference in New Issue
Block a user