TAChart: Limit pointer size in the legend. Update demo.

git-svn-id: trunk@27462 -
This commit is contained in:
ask 2010-09-26 02:58:39 +00:00
parent ec692bc033
commit f4763dd494
3 changed files with 20 additions and 10 deletions

View File

@ -1,20 +1,19 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<Version Value="8"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<Title Value="TAChart legend demo"/>
<ResourceType Value="res"/>
</General>
<VersionInfo>
<StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/>
<StringTable ProductVersion=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
@ -56,7 +55,7 @@
<Version Value="9"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)\"/>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>

View File

@ -194,12 +194,15 @@ end;
procedure TLegendItemLinePointer.Draw(ACanvas: TCanvas; const ARect: TRect);
var
c: TPoint;
c, sz: TPoint;
begin
inherited Draw(ACanvas, ARect);
if FPointer = nil then exit;
c := CenterPoint(ARect);
FPointer.Draw(ACanvas, c, clTAColor);
// Max width slightly narrower then ARect to leave place for the line.
sz.X := Min(FPointer.HorizSize, (ARect.Right - ARect.Left) div 3);
sz.Y := Min(FPointer.VertSize, (ARect.Bottom - ARect.Top) div 2);
FPointer.DrawSize(ACanvas, c, sz, clTAColor);
end;
{ TLegendItemBrushRect }

View File

@ -220,6 +220,8 @@ type
procedure Assign(Source: TPersistent); override;
procedure Draw(ACanvas: TCanvas; ACenter: TPoint; AColor: TColor);
procedure DrawSize(
ACanvas: TCanvas; ACenter, ASize: TPoint; AColor: TColor);
published
property Brush: TBrush read FBrush write SetBrush;
property HorizSize: Integer read FHorizSize write SetHorizSize default DEF_POINTER_SIZE;
@ -666,6 +668,12 @@ begin
end;
procedure TSeriesPointer.Draw(ACanvas: TCanvas; ACenter: TPoint; AColor: TColor);
begin
DrawSize(ACanvas, ACenter, Point(HorizSize, VertSize), AColor);
end;
procedure TSeriesPointer.DrawSize(
ACanvas: TCanvas; ACenter, ASize: TPoint; AColor: TColor);
function PointByIndex(AIndex: Char): TPoint;
// 7--8--9
@ -676,8 +684,8 @@ procedure TSeriesPointer.Draw(ACanvas: TCanvas; ACenter: TPoint; AColor: TColor)
H: array ['1'..'9'] of -1..1 = (-1, 0, 1, -1, 0, 1, -1, 0, 1);
begin
Result := ACenter;
Result.X += H[AIndex] * HorizSize;
Result.Y += V[AIndex] * VertSize;
Result.X += H[AIndex] * ASize.X;
Result.Y += V[AIndex] * ASize.Y;
end;
procedure DrawByString(const AStr: String);
@ -718,8 +726,8 @@ begin
if FStyle = psCircle then
ACanvas.Ellipse(
ACenter.X - HorizSize, ACenter.Y - VertSize,
ACenter.X + HorizSize, ACenter.Y + VertSize)
ACenter.X - ASize.X, ACenter.Y - ASize.Y,
ACenter.X + ASize.X, ACenter.Y + ASize.Y)
else
DrawByString(DRAW_STRINGS[FStyle] + ' ');
end;