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;
|
||||
FAxisDefSize: Integer;
|
||||
FLegendItemSize: Integer;
|
||||
{$IFNDEF FPC}
|
||||
FClipRgn: HRGN;
|
||||
{$ENDIF}
|
||||
procedure InternalClear;
|
||||
procedure InternalPaint(ACanvas: TCanvas);
|
||||
procedure Calculate(AWidth, AHeight: Integer);
|
||||
@ -185,6 +188,7 @@ type
|
||||
procedure Changed;
|
||||
procedure ChartToClient(const AX, AY: Double; var X, Y: Integer);
|
||||
procedure CreateHandle; override;
|
||||
procedure ClipToRect(ACanvas: TCanvas; const ARect: TRect; AEnable: Boolean);
|
||||
{$IFDEF FPC}
|
||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double); override;
|
||||
{$ENDIF}
|
||||
@ -355,8 +359,8 @@ procedure TNiceSeries.InternalClear;
|
||||
var
|
||||
x: Integer;
|
||||
begin
|
||||
for x := 0 to Values.Count-1
|
||||
do Dispose(PXYInfo(Values[x]));
|
||||
for x := 0 to Values.Count-1 do
|
||||
Dispose(PXYInfo(Values[x]));
|
||||
Values.Clear;
|
||||
end;
|
||||
|
||||
@ -399,8 +403,8 @@ var
|
||||
x: Integer;
|
||||
begin
|
||||
Result := -MaxDouble;
|
||||
for x := 0 to Values.Count-1
|
||||
do Result := Max(Result, PXYInfo(Values[x])^.X);
|
||||
for x := 0 to Values.Count-1 do
|
||||
Result := Max(Result, PXYInfo(Values[x])^.X);
|
||||
end;
|
||||
|
||||
function TNiceSeries.GetMinXValue: Double;
|
||||
@ -408,8 +412,8 @@ var
|
||||
x: Integer;
|
||||
begin
|
||||
Result := MaxDouble;
|
||||
for x := 0 to Values.Count-1
|
||||
do Result := Min(Result, PXYInfo(Values[x])^.X);
|
||||
for x := 0 to Values.Count-1 do
|
||||
Result := Min(Result, PXYInfo(Values[x])^.X);
|
||||
end;
|
||||
|
||||
function TNiceSeries.GetMaxYValue: Double;
|
||||
@ -417,8 +421,8 @@ var
|
||||
x: Integer;
|
||||
begin
|
||||
Result := -MaxDouble;
|
||||
for x := 0 to Values.Count-1
|
||||
do Result := Max(Result, PXYInfo(Values[x])^.Y);
|
||||
for x := 0 to Values.Count-1 do
|
||||
Result := Max(Result, PXYInfo(Values[x])^.Y);
|
||||
end;
|
||||
|
||||
function TNiceSeries.GetMinYValue: Double;
|
||||
@ -426,8 +430,8 @@ var
|
||||
x: Integer;
|
||||
begin
|
||||
Result := MaxDouble;
|
||||
for x := 0 to Values.Count-1
|
||||
do Result := Min(Result, PXYInfo(Values[x])^.Y);
|
||||
for x := 0 to Values.Count-1 do
|
||||
Result := Min(Result, PXYInfo(Values[x])^.Y);
|
||||
end;
|
||||
|
||||
procedure TNiceSeries.SetCaption(const Value: string);
|
||||
@ -550,7 +554,7 @@ begin
|
||||
if FGridColor <> value then
|
||||
begin
|
||||
FGridColor := Value;
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -699,7 +703,7 @@ begin
|
||||
if (FShowXAxisLine <> Value) then
|
||||
begin
|
||||
FShowXAxisLine := Value;
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -708,7 +712,7 @@ begin
|
||||
if (FShowXGrid <> Value) then
|
||||
begin
|
||||
FShowXGrid := Value;
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -717,7 +721,7 @@ begin
|
||||
if (FShowYAxisLine <> Value) then
|
||||
begin
|
||||
FShowYAxisLine := Value;
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -726,7 +730,7 @@ begin
|
||||
if (FShowYGrid <> Value) then
|
||||
begin
|
||||
FShowYGrid := Value;
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -735,7 +739,7 @@ begin
|
||||
if (FTickLength <> Value) and (Value >= 0) then
|
||||
begin
|
||||
FTickLength := Value;
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -748,7 +752,7 @@ procedure TNiceChart.EndUpdate;
|
||||
begin
|
||||
FUpdating := False;
|
||||
Calculate(ClientWidth, ClientHeight);
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TNiceChart.Changed;
|
||||
@ -756,7 +760,7 @@ begin
|
||||
if not FUpdating then
|
||||
begin
|
||||
Calculate(ClientWidth, ClientHeight);
|
||||
DoPaint;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1458,7 +1462,6 @@ end;
|
||||
|
||||
//-----------------------------------------------------------------------------//
|
||||
|
||||
|
||||
procedure TNiceChart.DrawSeries(ACanvas: TCanvas; Index: Integer);
|
||||
var
|
||||
x: Integer;
|
||||
@ -1471,10 +1474,9 @@ begin
|
||||
AutoColors(ACanvas, Index, sr.FKind = skBar);
|
||||
with ACanvas do
|
||||
begin
|
||||
ClipRect := RcChart;
|
||||
if (sr.FKind = skBar) then
|
||||
begin
|
||||
Clipping := true;
|
||||
ClipToRect(ACanvas, RcChart, true);
|
||||
try
|
||||
Pen.Width := 1;
|
||||
for x := 0 to Sr.Values.Count-1 do
|
||||
@ -1483,11 +1485,11 @@ begin
|
||||
Rectangle(P^.Rc);
|
||||
end;
|
||||
finally
|
||||
Clipping := false;
|
||||
ClipToRect(ACanvas, RcChart, false);
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
Clipping := true;
|
||||
ClipToRect(ACanvas, RcChart, true);
|
||||
try
|
||||
if (sr.FKind = skLine) then
|
||||
begin
|
||||
@ -1506,7 +1508,7 @@ begin
|
||||
sr.Spline.Draw(ACanvas);
|
||||
end;
|
||||
finally
|
||||
Clipping := false;
|
||||
ClipToRect(ACanvas, RcChart, false);
|
||||
end;
|
||||
Pen.Width := 1;
|
||||
for x := 0 to Sr.Values.Count-1 do
|
||||
@ -1686,6 +1688,28 @@ begin
|
||||
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}
|
||||
function TNiceChart.CreateMetafile: TMetafile;
|
||||
const
|
||||
|
Reference in New Issue
Block a user