mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:19:22 +02:00
TAChart: Update tutorial "background" to avoid the deprecated background drawing events.
git-svn-id: trunk@62229 -
This commit is contained in:
parent
a10a0ef35d
commit
d35e17fbdd
@ -1,11 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="9"/>
|
<Version Value="12"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<General>
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<CompatibilityMode Value="True"/>
|
||||||
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
<MainUnit Value="0"/>
|
|
||||||
<Title Value="backimage"/>
|
<Title Value="backimage"/>
|
||||||
<ResourceType Value="res"/>
|
<ResourceType Value="res"/>
|
||||||
<UseXPManifest Value="True"/>
|
<UseXPManifest Value="True"/>
|
||||||
@ -13,9 +15,6 @@
|
|||||||
<i18n>
|
<i18n>
|
||||||
<EnableI18N LFM="False"/>
|
<EnableI18N LFM="False"/>
|
||||||
</i18n>
|
</i18n>
|
||||||
<VersionInfo>
|
|
||||||
<StringTable ProductVersion=""/>
|
|
||||||
</VersionInfo>
|
|
||||||
<BuildModes Count="2">
|
<BuildModes Count="2">
|
||||||
<Item1 Name="Debug" Default="True"/>
|
<Item1 Name="Debug" Default="True"/>
|
||||||
<Item2 Name="Release">
|
<Item2 Name="Release">
|
||||||
@ -49,9 +48,10 @@
|
|||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<FormatVersion Value="2"/>
|
||||||
<FormatVersion Value="1"/>
|
<Modes Count="1">
|
||||||
</local>
|
<Mode0 Name="default"/>
|
||||||
|
</Modes>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="2">
|
<RequiredPackages Count="2">
|
||||||
<Item1>
|
<Item1>
|
||||||
@ -65,7 +65,6 @@
|
|||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="backimage.lpr"/>
|
<Filename Value="backimage.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="backimage"/>
|
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="main.pas"/>
|
<Filename Value="main.pas"/>
|
||||||
@ -73,7 +72,6 @@
|
|||||||
<ComponentName Value="Form1"/>
|
<ComponentName Value="Form1"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="main"/>
|
|
||||||
</Unit1>
|
</Unit1>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
|
@ -8,7 +8,7 @@ object Form1: TForm1
|
|||||||
ClientWidth = 400
|
ClientWidth = 400
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
LCLVersion = '1.3'
|
LCLVersion = '2.1.0.0'
|
||||||
object Chart1: TChart
|
object Chart1: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 300
|
Height = 300
|
||||||
@ -19,6 +19,7 @@ object Form1: TForm1
|
|||||||
Grid.Color = clSkyBlue
|
Grid.Color = clSkyBlue
|
||||||
Grid.Visible = False
|
Grid.Visible = False
|
||||||
Marks.Format = '%.0n'
|
Marks.Format = '%.0n'
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Marks.Style = smsCustom
|
Marks.Style = smsCustom
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Height = -16
|
Title.LabelFont.Height = -16
|
||||||
@ -26,15 +27,18 @@ object Form1: TForm1
|
|||||||
Title.LabelFont.Style = [fsBold]
|
Title.LabelFont.Style = [fsBold]
|
||||||
Title.Visible = True
|
Title.Visible = True
|
||||||
Title.Caption = 'Downloads per year'
|
Title.Caption = 'Downloads per year'
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Grid.Visible = False
|
Grid.Visible = False
|
||||||
Alignment = calBottom
|
Alignment = calBottom
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
Minors = <>
|
Minors = <>
|
||||||
Title.LabelFont.Height = -16
|
Title.LabelFont.Height = -16
|
||||||
Title.LabelFont.Style = [fsBold]
|
Title.LabelFont.Style = [fsBold]
|
||||||
Title.Visible = True
|
Title.Visible = True
|
||||||
Title.Caption = 'Year'
|
Title.Caption = 'Year'
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
end>
|
end>
|
||||||
Foot.Brush.Color = clBtnFace
|
Foot.Brush.Color = clBtnFace
|
||||||
Foot.Font.Color = clBlue
|
Foot.Font.Color = clBlue
|
||||||
@ -47,10 +51,9 @@ object Form1: TForm1
|
|||||||
'Lazarus Downloads'
|
'Lazarus Downloads'
|
||||||
)
|
)
|
||||||
Title.Visible = True
|
Title.Visible = True
|
||||||
OnBeforeDrawBackground = Chart1BeforeDrawBackground
|
OnBeforeCustomDrawBackground = Chart1BeforeCustomDrawBackground
|
||||||
OnBeforeDrawBackWall = Chart1BeforeDrawBackWall
|
OnBeforeCustomDrawBackWall = Chart1BeforeCustomDrawBackWall
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ParentColor = False
|
|
||||||
object Chart1BarSeries1: TBarSeries
|
object Chart1BarSeries1: TBarSeries
|
||||||
Shadow.Color = clNavy
|
Shadow.Color = clNavy
|
||||||
Shadow.OffsetX = 4
|
Shadow.OffsetX = 4
|
||||||
|
@ -5,7 +5,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls,
|
Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls,
|
||||||
Graphics, Dialogs;
|
Graphics, Dialogs, TADrawUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -15,10 +15,12 @@ type
|
|||||||
Chart1: TChart;
|
Chart1: TChart;
|
||||||
Chart1BarSeries1: TBarSeries;
|
Chart1BarSeries1: TBarSeries;
|
||||||
ListChartSource1: TListChartSource;
|
ListChartSource1: TListChartSource;
|
||||||
procedure Chart1BeforeDrawBackground(ASender: TChart; ACanvas: TCanvas;
|
procedure Chart1BeforeCustomDrawBackground(ASender: TChart;
|
||||||
const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
ADrawer: IChartDrawer; const ARect: TRect; var ADoDefaultDrawing: Boolean
|
||||||
procedure Chart1BeforeDrawBackWall(ASender: TChart; ACanvas: TCanvas;
|
);
|
||||||
const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
procedure Chart1BeforeCustomDrawBackWall(ASender: TChart;
|
||||||
|
ADrawer: IChartDrawer; const ARect: TRect; var ADoDefaultDrawing: Boolean
|
||||||
|
);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
private
|
private
|
||||||
@ -35,6 +37,9 @@ implementation
|
|||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
|
uses
|
||||||
|
IntfGraphics;
|
||||||
|
|
||||||
//{$R splash_logo.res}
|
//{$R splash_logo.res}
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
@ -47,22 +52,72 @@ begin
|
|||||||
|
|
||||||
// or, use resources:
|
// or, use resources:
|
||||||
//FBackImage.LoadFromResourceName(HInstance, 'splash_logo');
|
//FBackImage.LoadFromResourceName(HInstance, 'splash_logo');
|
||||||
// Don't forget to active the "{$R" directive above.
|
// Don't forget to activate the "{$R" directive above.
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.Chart1BeforeCustomDrawBackWall(ASender: TChart;
|
||||||
|
ADrawer: IChartDrawer; const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
||||||
|
var
|
||||||
|
bmp: TBitmap;
|
||||||
|
img: TLazIntfImage;
|
||||||
|
begin
|
||||||
|
img := TLazIntfImage.Create(0, 0);
|
||||||
|
try
|
||||||
|
bmp := TBitmap.Create;
|
||||||
|
try
|
||||||
|
bmp.SetSize(ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
||||||
|
bmp.Canvas.StretchDraw(Rect(0, 0, bmp.Width, bmp.Height), FBackImage.Graphic);
|
||||||
|
img.LoadFromBitmap(bmp.Handle, bmp.MaskHandle);
|
||||||
|
finally
|
||||||
|
bmp.Free;
|
||||||
|
end;
|
||||||
|
ADrawer.PutImage(ARect.Left, ARect.Top, img);
|
||||||
|
ADoDefaultDrawing := false;
|
||||||
|
finally
|
||||||
|
img.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
(* --------------- deprecated, was in use before Laz 2.1 -----------------------
|
||||||
procedure TForm1.Chart1BeforeDrawBackWall(ASender: TChart; ACanvas: TCanvas;
|
procedure TForm1.Chart1BeforeDrawBackWall(ASender: TChart; ACanvas: TCanvas;
|
||||||
const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
||||||
begin
|
begin
|
||||||
ACanvas.StretchDraw(ARect, FBackImage.Graphic);
|
ACanvas.StretchDraw(ARect, FBackImage.Graphic);
|
||||||
ADoDefaultDrawing := false;
|
ADoDefaultDrawing := false;
|
||||||
end;
|
end;
|
||||||
|
----------------------------------------------------------------------------- *)
|
||||||
|
|
||||||
|
procedure TForm1.Chart1BeforeCustomDrawBackground(ASender: TChart;
|
||||||
|
ADrawer: IChartDrawer; const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
||||||
|
var
|
||||||
|
bmp: TBitmap;
|
||||||
|
img: TLazIntfImage;
|
||||||
|
begin
|
||||||
|
img := TLazIntfImage.Create(0, 0);
|
||||||
|
try
|
||||||
|
bmp := TBitmap.Create;
|
||||||
|
try
|
||||||
|
bmp.SetSize(ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
||||||
|
bmp.Canvas.GradientFill(Rect(0, 0, bmp.Width, bmp.Height), clSkyBlue, clWhite, gdVertical);
|
||||||
|
img.LoadFromBitmap(bmp.Handle, bmp.MaskHandle);
|
||||||
|
finally
|
||||||
|
bmp.Free;
|
||||||
|
end;
|
||||||
|
ADrawer.PutImage(ARect.Left, ARect.Top, img);
|
||||||
|
ADoDefaultDrawing := false;
|
||||||
|
finally
|
||||||
|
img.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
(* --------------- deprecated, was in use before Laz 2.1 -----------------------
|
||||||
procedure TForm1.Chart1BeforeDrawBackground(ASender: TChart; ACanvas: TCanvas;
|
procedure TForm1.Chart1BeforeDrawBackground(ASender: TChart; ACanvas: TCanvas;
|
||||||
const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
const ARect: TRect; var ADoDefaultDrawing: Boolean);
|
||||||
begin
|
begin
|
||||||
ACanvas.GradientFill(ARect, clSkyBlue, clWhite, gdVertical);
|
ACanvas.GradientFill(ARect, clSkyBlue, clWhite, gdVertical);
|
||||||
ADoDefaultDrawing := false;
|
ADoDefaultDrawing := false;
|
||||||
end;
|
end;
|
||||||
|
----------------------------------------------------------------------------- *)
|
||||||
|
|
||||||
procedure TForm1.FormDestroy(Sender: TObject);
|
procedure TForm1.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user