mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-27 20:42:51 +02:00
TAChart/ChartEditorDemo: Move controls of TitleFootDlg to a new TChartTitleFootFrame unit.
git-svn-id: trunk@65035 -
This commit is contained in:
parent
3266c2537c
commit
72963f6adb
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -5180,6 +5180,8 @@ components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.lfm svneol=nativ
|
||||
components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.pas svneol=native#text/pascal
|
||||
components/tachart/demo/charteditor/cetitlefootdlg.lfm svneol=native#text/plain
|
||||
components/tachart/demo/charteditor/cetitlefootdlg.pas svneol=native#text/pascal
|
||||
components/tachart/demo/charteditor/cetitlefootframe.lfm svneol=native#text/plain
|
||||
components/tachart/demo/charteditor/cetitlefootframe.pas svneol=native#text/pascal
|
||||
components/tachart/demo/charteditor/ceutils.pas svneol=native#text/pascal
|
||||
components/tachart/demo/charteditor/charteditordemo.lpi svneol=native#text/xml
|
||||
components/tachart/demo/charteditor/charteditordemo.lpr svneol=native#text/pascal
|
||||
|
@ -1,10 +1,10 @@
|
||||
object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
Left = 0
|
||||
Height = 237
|
||||
Top = 0
|
||||
Width = 263
|
||||
Width = 227
|
||||
ClientHeight = 237
|
||||
ClientWidth = 263
|
||||
ClientWidth = 227
|
||||
TabOrder = 0
|
||||
DesignLeft = 1498
|
||||
DesignTop = 388
|
||||
@ -17,7 +17,7 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 263
|
||||
Width = 227
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
Enabled = False
|
||||
ItemHeight = 15
|
||||
@ -43,14 +43,14 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
Left = 0
|
||||
Height = 54
|
||||
Top = 31
|
||||
Width = 124
|
||||
Width = 106
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Background'
|
||||
ClientHeight = 34
|
||||
ClientWidth = 120
|
||||
ClientWidth = 102
|
||||
TabOrder = 1
|
||||
object cbFilled: TCheckBox
|
||||
AnchorSideLeft.Control = gbBackground
|
||||
@ -60,7 +60,7 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
Left = 10
|
||||
Height = 19
|
||||
Top = 3
|
||||
Width = 62
|
||||
Width = 44
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 10
|
||||
BorderSpacing.Top = 6
|
||||
@ -74,7 +74,7 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
AnchorSideTop.Control = gbBackground
|
||||
AnchorSideRight.Control = gbBackground
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 80
|
||||
Left = 62
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 32
|
||||
@ -97,16 +97,16 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = gbBackground
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 139
|
||||
Left = 121
|
||||
Height = 54
|
||||
Top = 31
|
||||
Width = 124
|
||||
Width = 106
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
Caption = 'Border'
|
||||
ClientHeight = 34
|
||||
ClientWidth = 120
|
||||
ClientWidth = 102
|
||||
TabOrder = 2
|
||||
object cbShowBorder: TCheckBox
|
||||
AnchorSideLeft.Control = gbBorder
|
||||
@ -116,7 +116,7 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
Left = 10
|
||||
Height = 19
|
||||
Top = 3
|
||||
Width = 68
|
||||
Width = 50
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 10
|
||||
BorderSpacing.Top = 6
|
||||
@ -129,7 +129,7 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
AnchorSideTop.Control = gbBorder
|
||||
AnchorSideRight.Control = gbBorder
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 82
|
||||
Left = 64
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 30
|
||||
@ -155,19 +155,19 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
Left = 0
|
||||
Height = 97
|
||||
Top = 93
|
||||
Width = 263
|
||||
Width = 227
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Margins'
|
||||
ClientHeight = 77
|
||||
ClientWidth = 259
|
||||
ClientWidth = 223
|
||||
TabOrder = 3
|
||||
object seTopMargin: TSpinEdit
|
||||
AnchorSideLeft.Control = gbMargins
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = gbMargins
|
||||
Left = 104
|
||||
Left = 86
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 50
|
||||
@ -179,13 +179,13 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
AnchorSideTop.Control = seTopMargin
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = seTopMargin
|
||||
Left = 46
|
||||
Left = 28
|
||||
Height = 23
|
||||
Top = 23
|
||||
Width = 50
|
||||
Alignment = taRightJustify
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 32
|
||||
BorderSpacing.Left = 28
|
||||
BorderSpacing.Right = 8
|
||||
OnChange = seLeftMarginChange
|
||||
TabOrder = 1
|
||||
@ -195,13 +195,13 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = seTopMargin
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 162
|
||||
Left = 144
|
||||
Height = 23
|
||||
Top = 23
|
||||
Width = 50
|
||||
Alignment = taRightJustify
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Right = 32
|
||||
BorderSpacing.Right = 28
|
||||
OnChange = seRightMarginChange
|
||||
TabOrder = 2
|
||||
end
|
||||
@ -212,7 +212,7 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideBottom.Control = gbMargins
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 104
|
||||
Left = 86
|
||||
Height = 23
|
||||
Top = 46
|
||||
Width = 50
|
||||
@ -227,7 +227,7 @@ object ShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = cmbShape
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 131
|
||||
Left = 113
|
||||
Height = 50
|
||||
Top = 23
|
||||
Width = 1
|
||||
|
@ -1,9 +1,8 @@
|
||||
object TitleFootEditor: TChartTitleFootEditor
|
||||
Left = 608
|
||||
object ChartTitleFootEditor: TChartTitleFootEditor
|
||||
Left = 579
|
||||
Height = 357
|
||||
Top = 235
|
||||
Top = 298
|
||||
Width = 561
|
||||
ActiveControl = cbShow
|
||||
Caption = 'Title/footer editor'
|
||||
ClientHeight = 357
|
||||
ClientWidth = 561
|
||||
@ -11,7 +10,6 @@ object TitleFootEditor: TChartTitleFootEditor
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object ButtonPanel: TButtonPanel
|
||||
@ -28,151 +26,8 @@ object TitleFootEditor: TChartTitleFootEditor
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 3
|
||||
TabOrder = 0
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
ShowGlyphs = [pbOK, pbCancel, pbClose]
|
||||
end
|
||||
object ParamsPanel: TPanel
|
||||
Left = 8
|
||||
Height = 187
|
||||
Top = 122
|
||||
Width = 545
|
||||
Align = alBottom
|
||||
BorderSpacing.Around = 8
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 187
|
||||
ClientWidth = 545
|
||||
TabOrder = 2
|
||||
object rgAlignment: TRadioGroup
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 51
|
||||
Top = 0
|
||||
Width = 211
|
||||
AutoFill = True
|
||||
AutoSize = True
|
||||
Caption = 'Alignment'
|
||||
ChildSizing.LeftRightSpacing = 16
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.HorizontalSpacing = 16
|
||||
ChildSizing.EnlargeHorizontal = crsScaleChilds
|
||||
ChildSizing.EnlargeVertical = crsScaleChilds
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 3
|
||||
ClientHeight = 31
|
||||
ClientWidth = 207
|
||||
Columns = 3
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'Left'
|
||||
'Center'
|
||||
'Right'
|
||||
)
|
||||
OnClick = rgAlignmentClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object gbShapeBrushPenMargins: TGroupBox
|
||||
AnchorSideLeft.Control = rgAlignment
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = rgAlignment
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 235
|
||||
Height = 168
|
||||
Top = 0
|
||||
Width = 310
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 24
|
||||
Caption = 'Title/footer background'
|
||||
TabOrder = 2
|
||||
end
|
||||
object gbFont: TGroupBox
|
||||
AnchorSideLeft.Control = rgAlignment
|
||||
AnchorSideTop.Control = rgAlignment
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = rgAlignment
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 61
|
||||
Top = 75
|
||||
Width = 211
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 24
|
||||
Caption = 'Font'
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object MemoPanel: TPanel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 81
|
||||
Top = 33
|
||||
Width = 545
|
||||
Align = alClient
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Right = 8
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 81
|
||||
ClientWidth = 545
|
||||
Constraints.MinHeight = 80
|
||||
TabOrder = 1
|
||||
object lblText: TLabel
|
||||
AnchorSideLeft.Control = MemoPanel
|
||||
AnchorSideTop.Control = MemoPanel
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 0
|
||||
Width = 21
|
||||
Caption = 'Text'
|
||||
ParentColor = False
|
||||
end
|
||||
object mmoText: TMemo
|
||||
AnchorSideLeft.Control = lblText
|
||||
AnchorSideTop.Control = lblText
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = MemoPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = MemoPanel
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 62
|
||||
Top = 19
|
||||
Width = 545
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 4
|
||||
OnChange = mmoTextChange
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object PanelTop: TPanel
|
||||
Left = 0
|
||||
Height = 33
|
||||
Top = 0
|
||||
Width = 561
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 33
|
||||
ClientWidth = 561
|
||||
TabOrder = 0
|
||||
object cbShow: TCheckBox
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 8
|
||||
Width = 49
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Bottom = 6
|
||||
Caption = 'Show'
|
||||
Checked = True
|
||||
OnChange = cbShowChange
|
||||
State = cbChecked
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,9 +5,10 @@ unit ceTitleFootDlg;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel,
|
||||
ExtCtrls, Buttons, ComCtrls, ceShapeBrushPenMarginsFrame,
|
||||
ceFontFrame, TAGraph, TATextElements;
|
||||
Classes, SysUtils, Graphics,
|
||||
Forms, Controls, Dialogs, StdCtrls, ButtonPanel, ExtCtrls, Buttons, ComCtrls,
|
||||
TAGraph, TATextElements,
|
||||
ceTitleFootFrame;
|
||||
|
||||
type
|
||||
|
||||
@ -15,34 +16,16 @@ type
|
||||
|
||||
TChartTitleFootEditor = class(TForm)
|
||||
ButtonPanel: TButtonPanel;
|
||||
cbShow: TCheckBox;
|
||||
gbShapeBrushPenMargins: TGroupBox;
|
||||
gbFont: TGroupBox;
|
||||
lblText: TLabel;
|
||||
mmoText: TMemo;
|
||||
MemoPanel: TPanel;
|
||||
PanelTop: TPanel;
|
||||
ParamsPanel: TPanel;
|
||||
rgAlignment: TRadioGroup;
|
||||
procedure cbShowChange(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure mmoTextChange(Sender: TObject);
|
||||
procedure OKButtonClick(Sender: TObject);
|
||||
procedure rgAlignmentClick(Sender: TObject);
|
||||
private
|
||||
FTitle: TChartTitle;
|
||||
FSavedTitle: TChartTitle;
|
||||
FFontFrame: TChartFontFrame;
|
||||
FShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame;
|
||||
FTitleFootFrame: TChartTitleFootFrame;
|
||||
FOKClicked: boolean;
|
||||
procedure ChangedHandler(Sender: TObject);
|
||||
function GetAlignment: TAlignment;
|
||||
procedure SetAlignment(AValue: TAlignment);
|
||||
procedure ShapeChangedHandler(AShape: TChartLabelShape);
|
||||
protected
|
||||
function GetChart: TChart;
|
||||
public
|
||||
@ -61,38 +44,21 @@ uses
|
||||
TATypes,
|
||||
ceUtils;
|
||||
|
||||
procedure TChartTitleFootEditor.cbShowChange(Sender: TObject);
|
||||
begin
|
||||
FTitle.Visible := cbShow.Checked;
|
||||
lblText.Visible := cbShow.Checked;
|
||||
mmoText.Visible := cbShow.Checked;
|
||||
rgAlignment.Visible := cbShow.Checked;
|
||||
gbShapeBrushPenMargins.Visible := cbShow.Checked;
|
||||
gbFont.Visible := cbShow.Checked;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.FormActivate(Sender: TObject);
|
||||
var
|
||||
h, w: Integer;
|
||||
begin
|
||||
Constraints.MinHeight := PanelTop.Height +
|
||||
MemoPanel.Constraints.MinHeight +
|
||||
ParamsPanel.Height + ParamsPanel.BorderSpacing.Around*2 +
|
||||
ButtonPanel.Height + ButtonPanel.BorderSpacing.Around*2;
|
||||
FTitleFootFrame.GetPreferredSize(w, h);
|
||||
inc(h, FTitleFootFrame.BorderSpacing.Around * 2);
|
||||
inc(w, FTitleFootFrame.BorderSpacing.Around * 2);
|
||||
|
||||
Constraints.MinWidth := gbFont.Width +
|
||||
gbShapeBrushPenMargins.Width + gbShapeBrushPenMargins.BorderSpacing.Left +
|
||||
ParamsPanel.BorderSpacing.Around * 2;
|
||||
Constraints.MinHeight := h + ButtonPanel.Height + ButtonPanel.BorderSpacing.Around*2;
|
||||
Constraints.MinWidth := w;
|
||||
|
||||
Width := 1; // Enforce the constraints.
|
||||
Height := 1;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.ChangedHandler(Sender: TObject);
|
||||
begin
|
||||
GetChart.Invalidate;
|
||||
mmoText.Font.Assign(FTitle.Font);
|
||||
mmoText.Color := FTitle.Brush.Color;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.FormCloseQuery(Sender: TObject;
|
||||
var CanClose: boolean);
|
||||
begin
|
||||
@ -106,29 +72,14 @@ end;
|
||||
procedure TChartTitleFootEditor.FormCreate(Sender: TObject);
|
||||
begin
|
||||
// Insert frames at runtime - this makes life much easier...
|
||||
FFontFrame := TChartFontFrame.Create(self);
|
||||
FFontFrame.Parent := gbFont;
|
||||
FFontFrame.Align := alClient;
|
||||
FFontFrame.BorderSpacing.Left := 8;
|
||||
FFontFrame.BorderSpacing.Right := 8;
|
||||
FFontFrame.BorderSpacing.Bottom := 0;//8;
|
||||
FFontFrame.OnChange := @ChangedHandler;
|
||||
gbFont.AutoSize := true;
|
||||
FTitleFootFrame := TChartTitleFootFrame.Create(self);
|
||||
FTitleFootFrame.Parent := Self;
|
||||
FTitleFootFrame.Name := '';
|
||||
FTitleFootFrame.Align := alClient;
|
||||
FTitleFootFrame.BorderSpacing.Around := 8;
|
||||
FTitleFootFrame.AutoSize := true;
|
||||
|
||||
FShapeBrushPenMarginsFrame := TChartShapeBrushPenMarginsFrame.Create(self);
|
||||
FShapeBrushPenMarginsFrame.Parent := gbShapeBrushPenMargins;
|
||||
FShapeBrushPenMarginsFrame.Align := alClient;
|
||||
FShapeBrushPenMarginsFrame.BorderSpacing.Left := 8;
|
||||
FShapeBrushPenMarginsFrame.BorderSpacing.Right := 8;
|
||||
FShapeBrushPenMarginsFrame.BorderSpacing.Bottom := 8;
|
||||
FShapeBrushPenMarginsFrame.Constraints.MinWidth := 230;
|
||||
FShapeBrushPenMarginsFrame.OnChange := @ChangedHandler;
|
||||
FShapeBrushPenMarginsFrame.OnShapeChange := @ShapeChangedHandler;
|
||||
gbShapeBrushPenMargins.AutoSize := true;
|
||||
|
||||
BoldHeaders(Self);
|
||||
|
||||
ParamsPanel.AutoSize := true;
|
||||
// AutoSize := true;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.FormDestroy(Sender: TObject);
|
||||
@ -136,30 +87,6 @@ begin
|
||||
FSavedTitle.Free;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.FormShow(Sender: TObject);
|
||||
begin
|
||||
(*
|
||||
if cbShow.Checked then begin
|
||||
AutoSize := true;
|
||||
Constraints.MinWidth := Width;
|
||||
Constraints.MinHeight := Height;
|
||||
AutoSize := false;
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.mmoTextChange(Sender: TObject);
|
||||
begin
|
||||
FTitle.Text.Assign(mmoText.Lines);
|
||||
end;
|
||||
|
||||
function TChartTitleFootEditor.GetAlignment: TAlignment;
|
||||
const
|
||||
ALIGNMENTS: array[0..2] of TAlignment = (taLeftJustify, taCenter, taRightJustify);
|
||||
begin
|
||||
Result := ALIGNMENTS[rgAlignment.ItemIndex];
|
||||
end;
|
||||
|
||||
function TChartTitleFootEditor.GetChart: TChart;
|
||||
begin
|
||||
Result := FTitle.GetOwner as TChart;
|
||||
@ -180,31 +107,7 @@ begin
|
||||
if ACaption <> '' then
|
||||
Caption := ACaption;
|
||||
|
||||
cbShow.Checked := ATitle.Visible;
|
||||
mmoText.Lines.Assign(ATitle.Text);
|
||||
SetAlignment(ATitle.Alignment);
|
||||
|
||||
mmoText.Font.Assign(ATitle.Font);
|
||||
mmoText.Font.Orientation := 0;
|
||||
FFontFrame.Prepare(ATitle.Font, false);
|
||||
FShapeBrushPenMarginsFrame.Prepare(ATitle.Shape, ATitle.Brush, ATitle.Frame, ATitle.Margins);
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.rgAlignmentClick(Sender: TObject);
|
||||
begin
|
||||
FTitle.Alignment := GetAlignment;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.SetAlignment(AValue: TAlignment);
|
||||
const
|
||||
ALIGNMENTS: array[TAlignment] of Integer = (0, 2, 1);
|
||||
begin
|
||||
rgAlignment.ItemIndex := ALIGNMENTS[AValue];
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootEditor.ShapeChangedHandler(AShape: TChartLabelShape);
|
||||
begin
|
||||
FTitle.Shape := AShape;
|
||||
FTitleFootFrame.Prepare(ATitle);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
151
components/tachart/demo/charteditor/cetitlefootframe.lfm
Normal file
151
components/tachart/demo/charteditor/cetitlefootframe.lfm
Normal file
@ -0,0 +1,151 @@
|
||||
object ChartTitleFootFrame: TChartTitleFootFrame
|
||||
Left = 0
|
||||
Height = 432
|
||||
Top = 0
|
||||
Width = 423
|
||||
ClientHeight = 432
|
||||
ClientWidth = 423
|
||||
TabOrder = 0
|
||||
DesignLeft = 500
|
||||
DesignTop = 237
|
||||
object PanelTop: TPanel
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 423
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 25
|
||||
ClientWidth = 423
|
||||
TabOrder = 0
|
||||
object cbShow: TCheckBox
|
||||
Left = 0
|
||||
Height = 19
|
||||
Top = 0
|
||||
Width = 49
|
||||
BorderSpacing.Bottom = 6
|
||||
Caption = 'Show'
|
||||
Checked = True
|
||||
OnChange = cbShowChange
|
||||
State = cbChecked
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object ParamsPanel: TPanel
|
||||
Left = 0
|
||||
Height = 187
|
||||
Top = 237
|
||||
Width = 423
|
||||
Align = alBottom
|
||||
BorderSpacing.Top = 16
|
||||
BorderSpacing.Bottom = 8
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 187
|
||||
ClientWidth = 423
|
||||
TabOrder = 1
|
||||
object rgAlignment: TRadioGroup
|
||||
AnchorSideLeft.Control = ParamsPanel
|
||||
AnchorSideTop.Control = ParamsPanel
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 51
|
||||
Top = 0
|
||||
Width = 211
|
||||
AutoFill = True
|
||||
AutoSize = True
|
||||
Caption = 'Alignment'
|
||||
ChildSizing.LeftRightSpacing = 16
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.HorizontalSpacing = 16
|
||||
ChildSizing.EnlargeHorizontal = crsScaleChilds
|
||||
ChildSizing.EnlargeVertical = crsScaleChilds
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 3
|
||||
ClientHeight = 31
|
||||
ClientWidth = 207
|
||||
Columns = 3
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'Left'
|
||||
'Center'
|
||||
'Right'
|
||||
)
|
||||
OnClick = rgAlignmentClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object gbShapeBrushPenMargins: TGroupBox
|
||||
AnchorSideLeft.Control = rgAlignment
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = rgAlignment
|
||||
AnchorSideRight.Control = ParamsPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 235
|
||||
Height = 168
|
||||
Top = 0
|
||||
Width = 188
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 24
|
||||
Caption = 'Title/footer background'
|
||||
TabOrder = 2
|
||||
end
|
||||
object gbFont: TGroupBox
|
||||
AnchorSideLeft.Control = rgAlignment
|
||||
AnchorSideTop.Control = rgAlignment
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = rgAlignment
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 61
|
||||
Top = 67
|
||||
Width = 211
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 16
|
||||
Caption = 'Font'
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object MemoPanel: TPanel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 196
|
||||
Top = 25
|
||||
Width = 423
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 196
|
||||
ClientWidth = 423
|
||||
Constraints.MinHeight = 80
|
||||
TabOrder = 2
|
||||
object lblText: TLabel
|
||||
AnchorSideLeft.Control = MemoPanel
|
||||
AnchorSideTop.Control = MemoPanel
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 0
|
||||
Width = 21
|
||||
Caption = 'Text'
|
||||
ParentColor = False
|
||||
end
|
||||
object mmoText: TMemo
|
||||
AnchorSideLeft.Control = lblText
|
||||
AnchorSideTop.Control = lblText
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = MemoPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = MemoPanel
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 177
|
||||
Top = 19
|
||||
Width = 423
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 4
|
||||
OnChange = mmoTextChange
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
162
components/tachart/demo/charteditor/cetitlefootframe.pas
Normal file
162
components/tachart/demo/charteditor/cetitlefootframe.pas
Normal file
@ -0,0 +1,162 @@
|
||||
unit ceTitleFootFrame;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls,
|
||||
TATextElements, TAGraph,
|
||||
ceFontFrame, ceShapeBrushPenMarginsFrame;
|
||||
|
||||
type
|
||||
|
||||
{ TChartTitleFootFrame }
|
||||
|
||||
TChartTitleFootFrame = class(TFrame)
|
||||
cbShow: TCheckBox;
|
||||
gbFont: TGroupBox;
|
||||
gbShapeBrushPenMargins: TGroupBox;
|
||||
lblText: TLabel;
|
||||
MemoPanel: TPanel;
|
||||
mmoText: TMemo;
|
||||
PanelTop: TPanel;
|
||||
ParamsPanel: TPanel;
|
||||
rgAlignment: TRadioGroup;
|
||||
procedure cbShowChange(Sender: TObject);
|
||||
procedure mmoTextChange(Sender: TObject);
|
||||
procedure rgAlignmentClick(Sender: TObject);
|
||||
private
|
||||
FTitle: TChartTitle;
|
||||
FFontFrame: TChartFontFrame;
|
||||
FShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame;
|
||||
procedure ChangedHandler(Sender: TObject);
|
||||
function GetAlignment: TAlignment;
|
||||
procedure SetAlignment(AValue: TAlignment);
|
||||
procedure ShapeChangedHandler(AShape: TChartLabelShape);
|
||||
protected
|
||||
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
|
||||
WithThemeSpace: Boolean); override;
|
||||
function GetChart: TChart;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Prepare(ATitle: TChartTitle);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
ceUtils;
|
||||
|
||||
constructor TChartTitleFootFrame.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
FFontFrame := TChartFontFrame.Create(self);
|
||||
FFontFrame.Parent := gbFont;
|
||||
FFontFrame.Align := alClient;
|
||||
FFontFrame.BorderSpacing.Left := 8;
|
||||
FFontFrame.BorderSpacing.Right := 8;
|
||||
FFontFrame.OnChange := @ChangedHandler;
|
||||
gbFont.AutoSize := true;
|
||||
|
||||
FShapeBrushPenMarginsFrame := TChartShapeBrushPenMarginsFrame.Create(self);
|
||||
FShapeBrushPenMarginsFrame.Parent := gbShapeBrushPenMargins;
|
||||
FShapeBrushPenMarginsFrame.Align := alClient;
|
||||
FShapeBrushPenMarginsFrame.BorderSpacing.Left := 8;
|
||||
FShapeBrushPenMarginsFrame.BorderSpacing.Right := 8;
|
||||
FShapeBrushPenMarginsFrame.BorderSpacing.Bottom := 8;
|
||||
FShapeBrushPenMarginsFrame.Constraints.MinWidth := 230;
|
||||
FShapeBrushPenMarginsFrame.OnChange := @ChangedHandler;
|
||||
FShapeBrushPenMarginsFrame.OnShapeChange := @ShapeChangedHandler;
|
||||
FShapeBrushPenMarginsFrame.AutoSize := true;
|
||||
gbShapeBrushPenMargins.AutoSize := true;
|
||||
|
||||
BoldHeaders(Self);
|
||||
|
||||
ParamsPanel.AutoSize := true;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootFrame.CalculatePreferredSize(
|
||||
var PreferredWidth, PreferredHeight: integer;
|
||||
WithThemeSpace: Boolean);
|
||||
begin
|
||||
PreferredHeight := PanelTop.Height +
|
||||
MemoPanel.Constraints.MinHeight +
|
||||
ParamsPanel.Height + ParamsPanel.BorderSpacing.Top + ParamsPanel.BorderSpacing.Bottom;
|
||||
|
||||
PreferredWidth := gbFont.Width +
|
||||
gbShapeBrushPenMargins.Width + gbShapeBrushPenMargins.BorderSpacing.Left;
|
||||
end;
|
||||
|
||||
|
||||
procedure TChartTitleFootFrame.cbShowChange(Sender: TObject);
|
||||
begin
|
||||
FTitle.Visible := cbShow.Checked;
|
||||
lblText.Visible := cbShow.Checked;
|
||||
mmoText.Visible := cbShow.Checked;
|
||||
rgAlignment.Visible := cbShow.Checked;
|
||||
gbShapeBrushPenMargins.Visible := cbShow.Checked;
|
||||
gbFont.Visible := cbShow.Checked;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootFrame.ChangedHandler(Sender: TObject);
|
||||
begin
|
||||
GetChart.Invalidate;
|
||||
mmoText.Font.Assign(FTitle.Font);
|
||||
mmoText.Color := FTitle.Brush.Color;
|
||||
end;
|
||||
|
||||
function TChartTitleFootFrame.GetAlignment: TAlignment;
|
||||
const
|
||||
ALIGNMENTS: array[0..2] of TAlignment = (taLeftJustify, taCenter, taRightJustify);
|
||||
begin
|
||||
Result := ALIGNMENTS[rgAlignment.ItemIndex];
|
||||
end;
|
||||
|
||||
function TChartTitleFootFrame.GetChart: TChart;
|
||||
begin
|
||||
Result := FTitle.GetOwner as TChart;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootFrame.mmoTextChange(Sender: TObject);
|
||||
begin
|
||||
FTitle.Text.Assign(mmoText.Lines);
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootFrame.rgAlignmentClick(Sender: TObject);
|
||||
begin
|
||||
FTitle.Alignment := GetAlignment;
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootFrame.Prepare(ATitle: TChartTitle);
|
||||
begin
|
||||
FTitle := ATitle;
|
||||
|
||||
cbShow.Checked := ATitle.Visible;
|
||||
mmoText.Lines.Assign(ATitle.Text);
|
||||
mmoText.Font.Assign(ATitle.Font);
|
||||
mmoText.Font.Orientation := 0;
|
||||
|
||||
SetAlignment(ATitle.Alignment);
|
||||
|
||||
FFontFrame.Prepare(ATitle.Font, false);
|
||||
FShapeBrushPenMarginsFrame.Prepare(ATitle.Shape, ATitle.Brush, ATitle.Frame, ATitle.Margins);
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootFrame.SetAlignment(AValue: TAlignment);
|
||||
const
|
||||
ALIGNMENTS: array[TAlignment] of Integer = (0, 2, 1);
|
||||
begin
|
||||
rgAlignment.ItemIndex := ALIGNMENTS[AValue];
|
||||
end;
|
||||
|
||||
procedure TChartTitleFootFrame.ShapeChangedHandler(AShape: TChartLabelShape);
|
||||
begin
|
||||
FTitle.Shape := AShape;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -129,6 +129,13 @@
|
||||
<ResourceBaseClass Value="Frame"/>
|
||||
<UnitName Value="ceLegendFrame"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="cetitlefootframe.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="ChartTitleFootFrame"/>
|
||||
<ResourceBaseClass Value="Frame"/>
|
||||
<UnitName Value="ceTitleFootFrame"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -7,7 +7,7 @@ uses
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, ceMain, ceSeriesDlg, cePointerFrame;
|
||||
Forms, ceMain, ceSeriesDlg, cePointerFrame, ceTitleFootFrame;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user