TAChart: Extend TChartImageList to work for non-series icons also at designtime.

git-svn-id: trunk@59242 -
This commit is contained in:
wp 2018-10-03 13:12:40 +00:00
parent b94a7193a0
commit e9f492c0d9
3 changed files with 38 additions and 30 deletions

View File

@ -1,16 +1,15 @@
object frmMain: TfrmMain
Left = 261
Height = 434
Height = 459
Top = 153
Width = 484
Caption = 'frmMain'
ClientHeight = 434
ClientHeight = 459
ClientWidth = 484
OnCreate = FormCreate
LCLVersion = '2.1.0.0'
object Chart1: TChart
Left = 0
Height = 223
Height = 217
Top = 38
Width = 484
AxisList = <
@ -21,6 +20,7 @@ object frmMain: TfrmMain
Title.LabelBrush.Style = bsClear
end
item
Intervals.MaxLength = 80
Alignment = calBottom
Marks.LabelBrush.Style = bsClear
Minors = <>
@ -59,17 +59,16 @@ object frmMain: TfrmMain
object ListView1: TListView
Left = 0
Height = 150
Top = 261
Top = 286
Width = 484
Align = alBottom
Color = clBtnFace
Color = clWhite
Columns = <>
Items.LazData = {
940000000400000000000000FFFFFFFFFFFFFFFF000000000F0000006C697374
76696577206974656D203001000000FFFFFFFFFFFFFFFF000000000F0000006C
69737476696577206974656D203102000000FFFFFFFFFFFFFFFF000000000F00
00006C69737476696577206974656D203203000000FFFFFFFFFFFFFFFF000000
000F0000006C69737476696577206974656D2033
6C0000000400000000000000FFFFFFFFFFFFFFFF00000000050000004974656D
3001000000FFFFFFFFFFFFFFFF00000000050000004974656D3102000000FFFF
FFFFFFFFFFFF00000000050000004974656D3203000000FFFFFFFFFFFFFFFF00
000000050000004974656D34
}
SmallImages = ChartImageList
TabOrder = 1
@ -84,7 +83,7 @@ object frmMain: TfrmMain
ButtonWidth = 23
Caption = 'ToolBar1'
EdgeBorders = [ebBottom]
Images = ToolbarImages
Images = ChartImageList
ShowCaptions = True
TabOrder = 2
object tbAdd: TToolButton
@ -112,10 +111,20 @@ object frmMain: TfrmMain
object StatusBar1: TStatusBar
Left = 0
Height = 23
Top = 411
Top = 436
Width = 484
Panels = <>
end
object Label1: TLabel
Left = 0
Height = 15
Top = 271
Width = 484
Align = alBottom
BorderSpacing.Top = 16
Caption = 'This ImageList displays all images contained in the ChartImagelist:'
ParentColor = False
end
object RandomChartSource1: TRandomChartSource
PointsNumber = 10
RandSeed = 1965225964
@ -131,12 +140,6 @@ object frmMain: TfrmMain
OnPopulate = ChartImageListPopulate
left = 192
top = 97
Bitmap = {
}
end
object ToolbarImages: TImageList
left = 328
top = 97
Bitmap = {
4C69020000001000000010000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, TAGraph, TAChartImageList, TASources,
TAFuncSeries, Forms, Controls, Graphics, Dialogs, ComCtrls;
TAFuncSeries, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls;
type
@ -17,7 +17,7 @@ type
Chart1FuncSeries1: TFuncSeries;
Chart1FuncSeries2: TFuncSeries;
ChartImageList: TChartImageList;
ToolbarImages: TImageList;
Label1: TLabel;
ListView1: TListView;
RandomChartSource1: TRandomChartSource;
StatusBar1: TStatusBar;
@ -28,7 +28,6 @@ type
procedure Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
procedure Chart1FuncSeries2Calculate(const AX: Double; out AY: Double);
procedure ChartImageListPopulate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure tbAddClick(Sender: TObject);
procedure tbQuitClick(Sender: TObject);
end;
@ -64,13 +63,6 @@ begin
[Count, SeriesCount, FirstSeriesIndex]);
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
ChartImageList.Chart := nil;
ChartImageList.AddImages(ToolbarImages);
ChartImageList.Chart := Chart1;
end;
procedure TfrmMain.tbAddClick(Sender: TObject);
var
series: TLineSeries;

View File

@ -170,9 +170,14 @@ begin
end;
procedure TChartImageList.ReadData(AStream: TStream);
var
ch: TChart;
begin
Unused(AStream);
ch := Chart;
Chart := nil;
Clear;
inherited ReadData(AStream);
Chart := ch;
end;
// Notification procedure of the listener. Responds to chart broadcasts
@ -202,10 +207,18 @@ begin
end;
procedure TChartImageList.WriteData(AStream: TStream);
var
ch: TChart;
begin
ch := Chart;
Chart := nil;
inherited WriteData(AStream);
Chart := ch;{
// Don't write the series images to stream.
// They will be recreated automatically when the chart is assigned on loading.
Unused(AStream);
}
end;
end.