TAChart: Don't check class types twice (issue #35614).

git-svn-id: trunk@61263 -
This commit is contained in:
wp 2019-05-21 22:26:14 +00:00
parent 006c5d25d5
commit aa69a266b0
17 changed files with 44 additions and 34 deletions

View File

@ -293,7 +293,7 @@ begin
Canvas.Font.Orientation := FGetFontOrientationFunc(AFont);
Canvas.Font.BGRAColor := BGRAColorOrMono(AFont.FPColor);
if AFont is TFont then
Canvas.Font.Style := (AFont as TFont).Style;
Canvas.Font.Style := TFont(AFont).Style;
Canvas.Font.Opacity := Opacity;
end;
@ -304,8 +304,8 @@ begin
Width := APen.Width;
// TODO: Update for FPC 2.8
if APen is TPen then begin
JoinStyle := (APen as TPen).JoinStyle;
EndCap := (APen as TPen).EndCap;
JoinStyle := TPen(APen).JoinStyle;
EndCap := TPen(APen).EndCap;
end;
BGRAColor := BGRAColorOrMono(APen.FPColor);
Opacity := Self.Opacity;

View File

@ -50,11 +50,11 @@ begin
// skip all the toolbuttons
else
if (AControl is TCustomGroupbox) then
BoldGroup(AControl as TCustomGroupbox)
BoldGroup(TCustomGroupBox(AControl))
else
for i:=0 to AControl.ComponentCount-1 do
if AControl.Components[i] is TControl then
BoldHeaders(AControl.Components[i] as TControl)
BoldHeaders(TControl(AControl.Components[i]))
end;

View File

@ -54,7 +54,7 @@ var
begin
if Memo.Count = 0 then exit;
if (Memo[0] = 'Chart1') and (View is TfrPictureView) then begin
pv := View as TfrPictureView;
pv := TfrPictureView(View);
factor := Max(Printer.XDpi, Printer.YDpi) / Screen.PixelsPerInch;
bmp := TBitmap.Create;
try

View File

@ -30,7 +30,9 @@ object MainForm: TMainForm
Width = 208
BorderSpacing.Left = 8
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'original order'
'Population (descending)'
'Population (ascending)'
'Name'
@ -38,6 +40,7 @@ object MainForm: TMainForm
OnChange = cbSortByChange
Style = csDropDownList
TabOrder = 0
Text = 'original order'
end
object Label1: TLabel
AnchorSideLeft.Control = SettingsPanel

View File

@ -189,14 +189,18 @@ procedure TMainForm.cbSortByChange(Sender: TObject);
begin
case cbSortBy.ItemIndex of
0: begin
ListChartSource.SortBy := sbY;
ListChartSource.SortDir := sdDescending;
ListChartSource.SortBy := sbX;
ListChartSource.SortDir := sdAscending;
end;
1: begin
ListChartSource.SortBy := sbY;
ListChartSource.SortDir := sdAscending;
ListChartSource.SortDir := sdDescending;
end;
2: begin
ListChartSource.SortBy := sbY;
ListChartSource.SortDir := sdAscending;
end;
3: begin
ListChartSource.SortBy := sbText;
ListChartSource.SortDir := sdAscending;
end;

View File

@ -4,6 +4,9 @@
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<Title Value="sort_demo"/>
<Scaled Value="True"/>
@ -13,8 +16,8 @@
<DpiAware Value="True"/>
</XPManifest>
</General>
<BuildModes>
<Item Name="Default" Default="True"/>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
@ -32,18 +35,18 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units>
<Unit>
<Units Count="2">
<Unit0>
<Filename Value="sort_demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
</Unit0>
<Unit1>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -69,7 +69,7 @@ var
begin
for t in ChartToolset1.Tools do
if t is TBasicZoomTool then
(t as TBasicZoomTool).AnimationSteps := IfThen(cbAnimate.Checked, 3, 0);
TBasicZoomTool(t).AnimationSteps := IfThen(cbAnimate.Checked, 3, 0);
end;
procedure TForm1.cbFixedPointChange(Sender: TObject);
@ -78,7 +78,7 @@ var
begin
for t in ChartToolset1.Tools do
if t is TBasicZoomStepTool then
(t as TBasicZoomStepTool).FixedPoint := cbFixedPoint.Checked;
TBasicZoomTool(t).FixedPoint := cbFixedPoint.Checked;
end;
procedure TForm1.Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);

View File

@ -538,9 +538,9 @@ begin
{ in case of radiobutton mode, it is necessary to uncheck the other
series; there can be only one active series in this mode }
if
(ASender is TCustomChartSeries) and (ASender as TCustomChartSeries).Active
(ASender is TCustomChartSeries) and TCustomChartSeries(ASender).Active
then
EnsureSingleChecked(FindSeriesIndex(ASender as TCustomChartSeries))
EnsureSingleChecked(FindSeriesIndex(TCustomChartSeries(ASender)))
else
EnsureSingleChecked;
end;

View File

@ -617,7 +617,7 @@ procedure TCustomChartSeries.ReadState(Reader: TReader);
begin
inherited ReadState(Reader);
if Reader.Parent is TChart then
(Reader.Parent as TChart).AddSeries(Self);
TChart(Reader.Parent).AddSeries(Self);
end;
procedure TCustomChartSeries.SetActive(AValue: Boolean);
@ -1081,7 +1081,7 @@ function TChartSeries.ListSource: TListChartSource;
begin
if not (Source is TListChartSource) then
raise EEditableSourceRequired.Create(rsSourceNotEditable);
Result := Source as TListChartSource;
Result := TListChartSource(Source);
end;
procedure TChartSeries.SetColor(AIndex: Integer; AColor: TColor);

View File

@ -436,7 +436,7 @@ end;
procedure TChartAxisIntervalParams.Changed;
begin
if not (FOwner is TCustomChartSource) then exit;
with FOwner as TCustomChartSource do begin
with TCustomChartSource(FOwner) do begin
BeginUpdate;
EndUpdate;
end;

View File

@ -538,7 +538,7 @@ procedure TDiaCenterConnector.Changed(ASender: TDiaObject);
begin
inherited;
if Element is TDiaCenterElement then
FActualPos := (Element as TDiaCenterElement).ActualPos;
FActualPos := TDiaCenterElement(Element).ActualPos;
end;
{ TDiaBoxConnector }

View File

@ -81,7 +81,7 @@ begin
id.SetBrushColor($FFFFFF);
for d in ASelf.Decorators do
if d is IDiaDrawerDecorator then
(d as IDiaDrawerDecorator).Apply(id);
IDiaDrawerDecorator(d).Apply(id);
with ASelf do
id.Polygon([
ToImage(FTopLeft), ToImage(FTopRight),
@ -103,7 +103,7 @@ begin
ADrawer.SetBrushColor($FFFFFF);
for d in AEndPoint.Decorators do
if d is IDiaDrawerDecorator then
(d as IDiaDrawerDecorator).Apply(ADrawer);
IDiaDrawerDecorator(d).Apply(ADrawer);
da := ArcTan2(AEndPoint.Width.Value, AEndPoint.Length.Value);
diag := -Round(Sqrt(Sqr(AEndPoint.Length.Value) + Sqr(AEndPoint.Width.Value)));
@ -126,7 +126,7 @@ begin
id.PrepareSimplePen($000000);
for d in ASelf.Decorators do
if d is IDiaDrawerDecorator then
(d as IDiaDrawerDecorator).Apply(id);
IDiaDrawerDecorator(d).Apply(id);
startPos := ToImage(ASelf.Start.Connector.ActualPos);
endPos := ToImage(ASelf.Finish.Connector.ActualPos);
case ASelf.Routing of

View File

@ -101,7 +101,7 @@ uses
function CanvasGetFontOrientationFunc(AFont: TFPCustomFont): Integer;
begin
if AFont is TFont then
Result := (AFont as TFont).Orientation
Result := TFont(AFont).Orientation
else
Result := AFont.Orientation; //0;
end;

View File

@ -150,7 +150,7 @@ end;
function SVGGetFontOrientationFunc(AFont: TFPCustomFont): Integer;
begin
if AFont is TFont then
Result := (AFont as TFont).Orientation
Result := TFont(AFont).Orientation
else
Result := AFont.Orientation;
end;

View File

@ -132,7 +132,7 @@ end;
procedure TChartStyle.Assign(Source: TPersistent);
begin
if Source is TChartStyle then
with Source as TChartStyle do begin
with TChartStyle(Source) do begin
Self.Brush := Brush;
Self.Font := Font;
Self.Pen := Pen;

View File

@ -967,7 +967,7 @@ procedure TChartTool.ReadState(Reader: TReader);
begin
inherited ReadState(Reader);
if Reader.Parent is TChartToolset then
Toolset := Reader.Parent as TChartToolset;
Toolset := TChartToolset(Reader.Parent);
end;
procedure TChartTool.RestoreCursor;
@ -2039,7 +2039,7 @@ procedure TDataPointHintTool.MouseMove(APoint: TPoint);
begin
if UseDefaultHintText and (PointIndex > -1) then begin
if Series is TChartSeries then
Result := (Series as TChartSeries).FormattedMark(PointIndex)
Result := TChartSeries(Series).FormattedMark(PointIndex)
else
Result := Format(
'%s: %d', [(Series as TCustomChartSeries).Title, PointIndex]);

View File

@ -423,7 +423,7 @@ procedure TAxisTransform.ReadState(Reader: TReader);
begin
inherited ReadState(Reader);
if Reader.Parent is TChartAxisTransformations then
Transformations := Reader.Parent as TChartAxisTransformations;
Transformations := TChartAxisTransformations(Reader.Parent);
end;
procedure TAxisTransform.SetChart(AChart: TObject);
@ -575,7 +575,7 @@ end;
procedure TLinearAxisTransform.Assign(ASource: TPersistent);
begin
if ASource is TLinearAxisTransform then
with ASource as TLinearAxisTransform do begin
with TLinearAxisTransform(ASource) do begin
Self.FOffset := Offset;
Self.FScale := Scale;
end;