TAChart/ChartEditorDemo: Move controls of LegendDlg to a new TChartLegendFrame unit.

git-svn-id: trunk@65033 -
This commit is contained in:
wp 2021-04-20 20:30:58 +00:00
parent 8bf5d3e924
commit c1f7659285
6 changed files with 789 additions and 723 deletions

2
.gitattributes vendored
View File

@ -5166,6 +5166,8 @@ components/tachart/demo/charteditor/cefontframe.lfm svneol=native#text/plain
components/tachart/demo/charteditor/cefontframe.pas svneol=native#text/pascal components/tachart/demo/charteditor/cefontframe.pas svneol=native#text/pascal
components/tachart/demo/charteditor/celegenddlg.lfm svneol=native#text/plain components/tachart/demo/charteditor/celegenddlg.lfm svneol=native#text/plain
components/tachart/demo/charteditor/celegenddlg.pas svneol=native#text/pascal components/tachart/demo/charteditor/celegenddlg.pas svneol=native#text/pascal
components/tachart/demo/charteditor/celegendframe.lfm svneol=native#text/plain
components/tachart/demo/charteditor/celegendframe.pas svneol=native#text/pascal
components/tachart/demo/charteditor/cemain.lfm svneol=native#text/plain components/tachart/demo/charteditor/cemain.lfm svneol=native#text/plain
components/tachart/demo/charteditor/cemain.pas svneol=native#text/pascal components/tachart/demo/charteditor/cemain.pas svneol=native#text/pascal
components/tachart/demo/charteditor/cepenframe.lfm svneol=native#text/plain components/tachart/demo/charteditor/cepenframe.lfm svneol=native#text/plain

View File

@ -1,9 +1,8 @@
object LegendEditor: TChartLegendEditor object ChartLegendEditor: TChartLegendEditor
Left = 978 Left = 978
Height = 396 Height = 396
Top = 169 Top = 169
Width = 590 Width = 590
ActiveControl = cbShow
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Legend editor' Caption = 'Legend editor'
ClientHeight = 396 ClientHeight = 396
@ -28,516 +27,8 @@ object LegendEditor: TChartLegendEditor
CloseButton.DefaultCaption = True CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton' CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True CancelButton.DefaultCaption = True
TabOrder = 2 TabOrder = 0
ShowButtons = [pbOK, pbCancel] ShowButtons = [pbOK, pbCancel]
ShowGlyphs = [pbOK, pbCancel, pbClose] ShowGlyphs = [pbOK, pbCancel, pbClose]
end end
object ParamsPanel: TPanel
Left = 8
Height = 309
Top = 39
Width = 574
Align = alClient
AutoSize = True
BorderSpacing.Around = 8
BevelOuter = bvNone
ClientHeight = 309
ClientWidth = 574
TabOrder = 1
object gbBackground: TGroupBox
AnchorSideLeft.Control = gbAlignment
AnchorSideTop.Control = gbAlignment
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 83
Top = 128
Width = 140
BorderSpacing.Top = 16
Caption = 'Background'
ClientHeight = 63
ClientWidth = 136
TabOrder = 2
object cbFilled: TCheckBox
AnchorSideLeft.Control = gbBackground
AnchorSideTop.Control = gbBackground
Left = 8
Height = 19
Top = 6
Width = 48
BorderSpacing.Left = 8
BorderSpacing.Top = 6
Caption = 'Filled'
OnChange = cbFilledChange
TabOrder = 0
end
object cbFillColor: TColorBox
AnchorSideLeft.Control = cbFilled
AnchorSideTop.Control = cbFilled
AnchorSideTop.Side = asrBottom
Left = 8
Height = 22
Top = 33
Width = 120
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbPrettyNames, cbCustomColors]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 16
OnChange = cbFillColorChange
TabOrder = 1
end
end
object gbBorder: TGroupBox
AnchorSideLeft.Control = gbBackground
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = gbAlignment
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = gbBackground
AnchorSideBottom.Side = asrBottom
Left = 156
Height = 83
Top = 128
Width = 140
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 16
BorderSpacing.Top = 16
Caption = 'Border'
ClientHeight = 63
ClientWidth = 136
TabOrder = 3
object cbShowBorder: TCheckBox
AnchorSideLeft.Control = gbBorder
AnchorSideTop.Control = gbBorder
Left = 8
Height = 19
Top = 6
Width = 54
BorderSpacing.Left = 8
BorderSpacing.Top = 6
Caption = 'Visible'
OnChange = cbShowBorderChange
TabOrder = 0
end
object cbBorderColor: TColorBox
AnchorSideLeft.Control = cbShowBorder
AnchorSideTop.Control = cbShowBorder
AnchorSideTop.Side = asrBottom
Left = 8
Height = 22
Top = 33
Width = 120
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbPrettyNames]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 6
ItemHeight = 16
OnChange = cbBorderColorChange
TabOrder = 1
Visible = False
end
end
object gbFont: TGroupBox
AnchorSideLeft.Control = gbAlignment
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = gbAlignment
AnchorSideBottom.Control = gbAlignment
AnchorSideBottom.Side = asrBottom
Left = 316
Height = 112
Top = 0
Width = 216
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 20
Caption = 'gbFont'
TabOrder = 1
end
object gbAlignment: TGroupBox
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
AnchorSideBottom.Control = gbFont
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 112
Top = 0
Width = 296
Caption = 'Position'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 92
ClientWidth = 292
TabOrder = 0
object rbTopLeft: TRadioButton
Left = 6
Height = 17
Top = 6
Width = 86
Caption = 'top/left'
OnChange = rbAlignmentChange
TabOrder = 0
end
object rbTopCenter: TRadioButton
Tag = 3
Left = 92
Height = 17
Top = 6
Width = 102
Caption = 'top/center'
OnChange = rbAlignmentChange
TabOrder = 1
end
object rbTopRight: TRadioButton
Tag = 5
Left = 194
Height = 17
Top = 6
Width = 92
Caption = 'top/right'
Checked = True
OnChange = rbAlignmentChange
TabOrder = 2
TabStop = True
end
object rbCenterLeft: TRadioButton
Tag = 1
Left = 6
Height = 46
Top = 23
Width = 86
Caption = 'center/left'
OnChange = rbAlignmentChange
TabOrder = 3
end
object Bevel1: TBevel
Tag = 999
Left = 92
Height = 46
Top = 23
Width = 102
Shape = bsSpacer
end
object rbCenterRight: TRadioButton
Tag = 6
Left = 194
Height = 46
Top = 23
Width = 92
Caption = 'center/right'
OnChange = rbAlignmentChange
TabOrder = 4
end
object rbBottomLeft: TRadioButton
Tag = 2
Left = 6
Height = 17
Top = 69
Width = 86
Caption = 'bottom/left'
OnChange = rbAlignmentChange
TabOrder = 5
end
object rbBottomCenter: TRadioButton
Tag = 4
Left = 92
Height = 17
Top = 69
Width = 102
Caption = 'bottom/center'
OnChange = rbAlignmentChange
TabOrder = 6
end
object rbBottomRight: TRadioButton
Tag = 7
Left = 194
Height = 17
Top = 69
Width = 92
Caption = 'bottom/right'
OnChange = rbAlignmentChange
TabOrder = 7
end
end
object gbMargins: TGroupBox
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = gbBackground
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbBackground
AnchorSideRight.Side = asrBottom
Left = 0
Height = 83
Top = 224
Width = 140
Anchors = [akTop, akRight]
BorderSpacing.Top = 13
Caption = 'Margins'
ClientHeight = 63
ClientWidth = 136
TabOrder = 4
object lblMarginX: TLabel
AnchorSideTop.Control = seMarginX
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seMarginX
Left = 31
Height = 15
Top = 8
Width = 7
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'X'
FocusControl = seMarginX
ParentColor = False
end
object seMarginX: TSpinEdit
AnchorSideTop.Control = gbMargins
AnchorSideRight.Side = asrBottom
Left = 46
Height = 23
Top = 4
Width = 74
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
BorderSpacing.Right = 10
OnChange = seMarginXChange
TabOrder = 0
Value = 1
end
object lblMarginY: TLabel
AnchorSideTop.Control = seMarginY
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seMarginY
Left = 31
Height = 15
Top = 37
Width = 7
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Y'
FocusControl = seMarginY
ParentColor = False
end
object seMarginY: TSpinEdit
AnchorSideTop.Control = seMarginX
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 46
Height = 23
Top = 33
Width = 74
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 10
OnChange = seMarginYChange
TabOrder = 1
Value = 1
end
end
object gbItems: TGroupBox
AnchorSideLeft.Control = gbFont
AnchorSideTop.Control = gbBackground
Left = 316
Height = 179
Top = 128
Width = 222
Caption = 'Items'
ClientHeight = 159
ClientWidth = 218
TabOrder = 5
object cbInverted: TCheckBox
AnchorSideLeft.Control = gbItems
AnchorSideTop.Control = gbItems
Left = 8
Height = 19
Top = 6
Width = 63
BorderSpacing.Left = 8
BorderSpacing.Top = 6
Caption = 'Inverted'
OnChange = cbInvertedChange
TabOrder = 0
end
object seColumns: TSpinEdit
AnchorSideTop.Control = cbInverted
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 33
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
OnChange = seColumnsChange
TabOrder = 1
Value = 1
end
object lblColumns: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = seColumns
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seColumns
Left = 8
Height = 15
Top = 37
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Columns'
FocusControl = seColumns
ParentColor = False
end
object lblItemFillOrder: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = cbItemFillOrder
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbItemFillOrder
Left = 8
Height = 15
Top = 68
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Item fill order'
ParentColor = False
end
object cbItemFillOrder: TComboBox
AnchorSideTop.Control = seColumns
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 64
Width = 96
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'by columns'
'by rows'
)
OnChange = cbItemFillOrderChange
TabOrder = 2
Text = 'by columns'
end
object seSpacing: TSpinEdit
AnchorSideTop.Control = cbItemFillOrder
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 95
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
OnChange = seSpacingChange
TabOrder = 3
Value = 20
end
object lblSpacing: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = seSpacing
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seSpacing
Left = 8
Height = 15
Top = 99
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Spacing'
FocusControl = seSpacing
ParentColor = False
end
object seSymbolWidth: TSpinEdit
AnchorSideTop.Control = seSpacing
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 126
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
OnChange = seSymbolWidthChange
TabOrder = 4
Value = 20
end
object lblSymbolWidth: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = seSymbolWidth
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seSymbolWidth
Left = 8
Height = 15
Top = 130
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Symbol width'
FocusControl = seSymbolWidth
ParentColor = False
end
end
end
object PanelTop: TPanel
Left = 0
Height = 31
Top = 0
Width = 590
Align = alTop
AutoSize = True
BevelOuter = bvNone
ClientHeight = 31
ClientWidth = 590
TabOrder = 0
object cbShow: TCheckBox
Left = 8
Height = 19
Top = 8
Width = 49
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Bottom = 4
Caption = 'Show'
Checked = True
OnChange = cbShowChange
State = cbChecked
TabOrder = 0
end
object cbUseSideBar: TCheckBox
AnchorSideLeft.Control = cbShow
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbShow
AnchorSideRight.Side = asrBottom
Left = 73
Height = 19
Top = 8
Width = 87
Alignment = taLeftJustify
BorderSpacing.Left = 16
Caption = 'Outside axes'
Checked = True
OnChange = cbUseSideBarChange
State = cbChecked
TabOrder = 1
end
end
end end

View File

@ -6,78 +6,26 @@ interface
uses uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel,
ExtCtrls, Buttons, ColorBox, ComCtrls, Spin, ceFontFrame, ExtCtrls, Buttons, ColorBox, ComCtrls, Spin,
TAGraph, TALegend; TAGraph, TALegend,
ceLegendFrame;
type type
{ TChartLegendEditor } { TChartLegendEditor }
TChartLegendEditor = class(TForm) TChartLegendEditor = class(TForm)
Bevel1: TBevel;
ButtonPanel: TButtonPanel; ButtonPanel: TButtonPanel;
cbFilled: TCheckBox;
cbShowBorder: TCheckBox;
cbShow: TCheckBox;
cbFillColor: TColorBox;
cbBorderColor: TColorBox;
cbInverted: TCheckBox;
cbUseSideBar: TCheckBox;
cbItemFillOrder: TComboBox;
gbBackground: TGroupBox;
gbBorder: TGroupBox;
gbFont: TGroupBox;
gbMargins: TGroupBox;
gbItems: TGroupBox;
lblMarginX: TLabel;
lblMarginY: TLabel;
lblItemFillOrder: TLabel;
lblColumns: TLabel;
lblSymbolWidth: TLabel;
lblSpacing: TLabel;
PanelTop: TPanel;
ParamsPanel: TPanel;
rbTopLeft: TRadioButton;
rbTopCenter: TRadioButton;
rbTopRight: TRadioButton;
rbCenterLeft: TRadioButton;
rbCenterRight: TRadioButton;
rbBottomLeft: TRadioButton;
rbBottomCenter: TRadioButton;
rbBottomRight: TRadioButton;
gbAlignment: TGroupBox;
seColumns: TSpinEdit;
seMarginX: TSpinEdit;
seMarginY: TSpinEdit;
seSymbolWidth: TSpinEdit;
seSpacing: TSpinEdit;
procedure cbBorderColorChange(Sender: TObject);
procedure cbFillColorChange(Sender: TObject);
procedure cbInvertedChange(Sender: TObject);
procedure cbItemFillOrderChange(Sender: TObject);
procedure cbFilledChange(Sender: TObject);
procedure cbShowBorderChange(Sender: TObject);
procedure cbShowChange(Sender: TObject);
procedure cbUseSideBarChange(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure OKButtonClick(Sender: TObject); procedure OKButtonClick(Sender: TObject);
procedure rbAlignmentChange(Sender: TObject);
procedure seColumnsChange(Sender: TObject);
procedure seMarginXChange(Sender: TObject);
procedure seMarginYChange(Sender: TObject);
procedure seSpacingChange(Sender: TObject);
procedure seSymbolWidthChange(Sender: TObject);
private private
FLegend: TChartLegend; FLegend: TChartLegend;
FLegendFrame: TChartLegendFrame;
FSavedLegend: TChartLegend; FSavedLegend: TChartLegend;
FOKClicked: Boolean; FOKClicked: Boolean;
FFontFrame: TChartFontFrame;
procedure ChangedHandler(Sender: TObject);
function GetAlignment: TLegendAlignment;
procedure SetAlignment(AValue: TLegendAlignment);
protected protected
function GetChart: TChart; function GetChart: TChart;
public public
@ -95,63 +43,6 @@ implementation
uses uses
ceUtils; ceUtils;
procedure TChartLegendEditor.cbBorderColorChange(Sender: TObject);
begin
FLegend.Frame.Color := cbBorderColor.Selected;
end;
procedure TChartLegendEditor.cbFillColorChange(Sender: TObject);
begin
FLegend.BackgroundBrush.Color := cbFillColor.Selected;
end;
procedure TChartLegendEditor.cbInvertedChange(Sender: TObject);
begin
FLegend.Inverted := cbInverted.Checked;
end;
procedure TChartLegendEditor.cbItemFillOrderChange(Sender: TObject);
begin
FLegend.ItemFillOrder := TLegendItemFillOrder(cbItemFillOrder.ItemIndex);
end;
procedure TChartLegendEditor.cbFilledChange(Sender: TObject);
begin
cbFillColor.Visible := cbFilled.Checked;
if cbFilled.Checked then
FLegend.BackgroundBrush.Style := bsSolid
else
FLegend.BackgroundBrush.Style := bsClear;
end;
procedure TChartLegendEditor.cbShowBorderChange(Sender: TObject);
begin
FLegend.Frame.Visible := cbShowBorder.Checked;
cbBorderColor.Visible := cbShowBorder.Checked;
end;
procedure TChartLegendEditor.cbShowChange(Sender: TObject);
begin
FLegend.Visible := cbShow.Checked;
cbUseSideBar.Visible := cbShow.Checked;
gbAlignment.Visible := cbShow.Checked;
gbFont.Visible := cbShow.Checked;
gbBackground.Visible := cbShow.Checked;
gbBorder.Visible := cbShow.Checked;
gbItems.Visible := cbShow.Checked;
gbMargins.Visible := cbShow.Checked;
end;
procedure TChartLegendEditor.cbUseSideBarChange(Sender: TObject);
begin
FLegend.UseSideBar := cbUseSideBar.Checked;
end;
procedure TChartLegendEditor.ChangedHandler(Sender: TObject);
begin
GetChart.Invalidate;
end;
procedure TChartLegendEditor.FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure TChartLegendEditor.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin begin
if not CanClose then exit; if not CanClose then exit;
@ -163,18 +54,14 @@ end;
procedure TChartLegendEditor.FormCreate(Sender: TObject); procedure TChartLegendEditor.FormCreate(Sender: TObject);
begin begin
FFontFrame := TChartFontFrame.Create(self); FLegendFrame := TChartLegendFrame.Create(self);
FFontFrame.Parent := gbFont; FLegendFrame.Parent := self;
FFontFrame.Name := ''; FLegendFrame.Name := '';
FFontFrame.Align := alClient; FLegendFrame.Align := alClient;
FFontFrame.BorderSpacing.Left := 8; FLegendFrame.BorderSpacing.Around := 8;
FFontFrame.BorderSpacing.Right := 8; FLegendFrame.AutoSize := true;
FFontFrame.AutoSize := true;
FFontFrame.OnChange := @ChangedHandler;
gbFont.AutoSize := true;
gbFont.Caption := 'Font';
BoldHeaders(Self); AutoSize := true;
end; end;
procedure TChartLegendEditor.FormDestroy(Sender: TObject); procedure TChartLegendEditor.FormDestroy(Sender: TObject);
@ -184,32 +71,9 @@ end;
procedure TChartLegendEditor.FormShow(Sender: TObject); procedure TChartLegendEditor.FormShow(Sender: TObject);
begin begin
if cbShow.Checked then begin
AutoSize := true;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
AutoSize := false;
end;
FOKClicked := false; FOKClicked := false;
end; end;
function TChartLegendEditor.GetAlignment: TLegendAlignment;
var
i: Integer;
rb: TRadioButton;
begin
for i := 0 to gbAlignment.ControlCount-1 do
if (gbAlignment.Controls[i] is TRadioButton) then begin
rb := TRadioButton(gbAlignment.Controls[i]);
if rb.Checked then begin
Result := TLegendAlignment(rb.Tag);
exit;
end;
end;
Result := laTopRight;
end;
function TChartLegendEditor.GetChart: TChart; function TChartLegendEditor.GetChart: TChart;
begin begin
Result := FLegend.GetOwner as TChart; Result := FLegend.GetOwner as TChart;
@ -220,51 +84,6 @@ begin
FOKClicked := true; FOKClicked := true;
end; end;
procedure TChartLegendEditor.rbAlignmentChange(Sender: TObject);
begin
FLegend.Alignment := GetAlignment;
end;
procedure TChartLegendEditor.seColumnsChange(Sender: TObject);
begin
FLegend.ColumnCount := seColumns.Value;
end;
procedure TChartLegendEditor.seMarginXChange(Sender: TObject);
begin
FLegend.MarginX := seMarginX.Value;
end;
procedure TChartLegendEditor.seMarginYChange(Sender: TObject);
begin
FLegend.MarginY := seMarginY.Value;
end;
procedure TChartLegendEditor.seSpacingChange(Sender: TObject);
begin
FLegend.Spacing := seSpacing.Value;
end;
procedure TChartLegendEditor.seSymbolWidthChange(Sender: TObject);
begin
FLegend.SymbolWidth := seSymbolWidth.Value;
end;
procedure TChartLegendEditor.SetAlignment(AValue: TLegendAlignment);
var
i: Integer;
rb: TRadioButton;
begin
for i:=0 to gbAlignment.ControlCount-1 do
if (gbAlignment.Controls[i] is TRadioButton) then begin
rb := TRadioButton(gbAlignment.Controls[i]);
if rb.Tag = ord(AValue) then begin
rb.Checked := true;
exit;
end;
end;
end;
procedure TChartLegendEditor.Prepare(ALegend: TChartLegend; procedure TChartLegendEditor.Prepare(ALegend: TChartLegend;
ACaption: String = ''); ACaption: String = '');
begin begin
@ -276,26 +95,7 @@ begin
if ACaption <> '' then if ACaption <> '' then
Caption := ACaption; Caption := ACaption;
cbShow.Checked := ALegend.Visible; FLegendFrame.Prepare(ALegend);
SetAlignment(ALegend.Alignment);
cbFilled.Checked := ALegend.BackgroundBrush.Style <> bsClear;
cbFillColor.Selected := ColorToRGB(ALegend.BackgroundBrush.Color);
cbShowBorder.Checked := (ALegend.Frame.Style <> psClear) and ALegend.Frame.Visible;
cbBorderColor.Selected := ColorToRGB(ALegend.Frame.Color);
seMarginX.Value := ALegend.MarginX;
seMarginY.Value := ALegend.MarginY;
cbUseSideBar.Checked := ALegend.UseSidebar;
cbInverted.Checked := ALegend.Inverted;
seColumns.Value := ALegend.ColumnCount;
seSymbolWidth.Value := ALegend.SymbolWidth;
seSpacing.Value := ALegend.Spacing;
cbItemFillOrder.ItemIndex := ord(ALegend.ItemFillOrder);
FFontFrame.Prepare(ALegend.Font, false);
end; end;
end. end.

View File

@ -0,0 +1,509 @@
object ChartLegendFrame: TChartLegendFrame
Left = 0
Height = 400
Top = 0
Width = 671
ClientHeight = 400
ClientWidth = 671
TabOrder = 0
DesignLeft = 380
DesignTop = 303
object PanelTop: TPanel
Left = 0
Height = 23
Top = 0
Width = 671
Align = alTop
AutoSize = True
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 23
ClientWidth = 671
TabOrder = 0
object cbShow: TCheckBox
Left = 0
Height = 19
Top = 0
Width = 49
BorderSpacing.Bottom = 4
Caption = 'Show'
Checked = True
OnChange = cbShowChange
State = cbChecked
TabOrder = 0
end
object cbUseSideBar: TCheckBox
AnchorSideLeft.Control = cbShow
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbShow
AnchorSideRight.Side = asrBottom
Left = 65
Height = 19
Top = 0
Width = 87
Alignment = taLeftJustify
BorderSpacing.Left = 16
Caption = 'Outside axes'
Checked = True
OnChange = cbUseSideBarChange
State = cbChecked
TabOrder = 1
end
end
object ParamsPanel: TPanel
Left = 0
Height = 369
Top = 31
Width = 671
Align = alClient
AutoSize = True
BevelOuter = bvNone
ClientHeight = 369
ClientWidth = 671
TabOrder = 1
object gbBackground: TGroupBox
AnchorSideLeft.Control = gbAlignment
AnchorSideTop.Control = gbAlignment
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 83
Top = 128
Width = 140
BorderSpacing.Top = 16
Caption = 'Background'
ClientHeight = 63
ClientWidth = 136
TabOrder = 2
object cbFilled: TCheckBox
AnchorSideLeft.Control = gbBackground
AnchorSideTop.Control = gbBackground
Left = 8
Height = 19
Top = 6
Width = 48
BorderSpacing.Left = 8
BorderSpacing.Top = 6
Caption = 'Filled'
OnChange = cbFilledChange
TabOrder = 0
end
object cbFillColor: TColorBox
AnchorSideLeft.Control = cbFilled
AnchorSideTop.Control = cbFilled
AnchorSideTop.Side = asrBottom
Left = 8
Height = 22
Top = 33
Width = 120
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbPrettyNames, cbCustomColors]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
ItemHeight = 16
OnChange = cbFillColorChange
TabOrder = 1
end
end
object gbBorder: TGroupBox
AnchorSideLeft.Control = gbBackground
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = gbAlignment
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = gbBackground
AnchorSideBottom.Side = asrBottom
Left = 156
Height = 83
Top = 128
Width = 140
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 16
BorderSpacing.Top = 16
Caption = 'Border'
ClientHeight = 63
ClientWidth = 136
TabOrder = 3
object cbShowBorder: TCheckBox
AnchorSideLeft.Control = gbBorder
AnchorSideTop.Control = gbBorder
Left = 8
Height = 19
Top = 6
Width = 54
BorderSpacing.Left = 8
BorderSpacing.Top = 6
Caption = 'Visible'
OnChange = cbShowBorderChange
TabOrder = 0
end
object cbBorderColor: TColorBox
AnchorSideLeft.Control = cbShowBorder
AnchorSideTop.Control = cbShowBorder
AnchorSideTop.Side = asrBottom
Left = 8
Height = 22
Top = 33
Width = 120
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbPrettyNames]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 6
ItemHeight = 16
OnChange = cbBorderColorChange
TabOrder = 1
Visible = False
end
end
object gbFont: TGroupBox
AnchorSideLeft.Control = gbAlignment
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = gbAlignment
AnchorSideBottom.Control = gbAlignment
AnchorSideBottom.Side = asrBottom
Left = 316
Height = 112
Top = 0
Width = 216
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 20
Caption = 'gbFont'
TabOrder = 1
end
object gbAlignment: TGroupBox
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
AnchorSideBottom.Control = gbFont
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 112
Top = 0
Width = 296
Caption = 'Position'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 92
ClientWidth = 292
TabOrder = 0
OnClick = gbAlignmentClick
object rbTopLeft: TRadioButton
Left = 6
Height = 17
Top = 6
Width = 86
Caption = 'top/left'
TabOrder = 0
end
object rbTopCenter: TRadioButton
Tag = 3
Left = 92
Height = 17
Top = 6
Width = 102
Caption = 'top/center'
TabOrder = 1
end
object rbTopRight: TRadioButton
Tag = 5
Left = 194
Height = 17
Top = 6
Width = 92
Caption = 'top/right'
Checked = True
TabOrder = 2
TabStop = True
end
object rbCenterLeft: TRadioButton
Tag = 1
Left = 6
Height = 46
Top = 23
Width = 86
Caption = 'center/left'
TabOrder = 3
end
object Bevel1: TBevel
Tag = 999
Left = 92
Height = 46
Top = 23
Width = 102
Shape = bsSpacer
end
object rbCenterRight: TRadioButton
Tag = 6
Left = 194
Height = 46
Top = 23
Width = 92
Caption = 'center/right'
TabOrder = 4
end
object rbBottomLeft: TRadioButton
Tag = 2
Left = 6
Height = 17
Top = 69
Width = 86
Caption = 'bottom/left'
TabOrder = 5
end
object rbBottomCenter: TRadioButton
Tag = 4
Left = 92
Height = 17
Top = 69
Width = 102
Caption = 'bottom/center'
TabOrder = 6
end
object rbBottomRight: TRadioButton
Tag = 7
Left = 194
Height = 17
Top = 69
Width = 92
Caption = 'bottom/right'
TabOrder = 7
end
end
object gbMargins: TGroupBox
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = gbBackground
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbBackground
AnchorSideRight.Side = asrBottom
Left = 0
Height = 83
Top = 224
Width = 140
Anchors = [akTop, akRight]
BorderSpacing.Top = 13
Caption = 'Margins'
ClientHeight = 63
ClientWidth = 136
TabOrder = 4
object lblMarginX: TLabel
AnchorSideTop.Control = seMarginX
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seMarginX
Left = 31
Height = 15
Top = 8
Width = 7
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'X'
FocusControl = seMarginX
ParentColor = False
end
object seMarginX: TSpinEdit
AnchorSideTop.Control = gbMargins
AnchorSideRight.Side = asrBottom
Left = 46
Height = 23
Top = 4
Width = 74
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
BorderSpacing.Right = 10
OnChange = seMarginXChange
TabOrder = 0
Value = 1
end
object lblMarginY: TLabel
AnchorSideTop.Control = seMarginY
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seMarginY
Left = 31
Height = 15
Top = 37
Width = 7
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Y'
FocusControl = seMarginY
ParentColor = False
end
object seMarginY: TSpinEdit
AnchorSideTop.Control = seMarginX
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 46
Height = 23
Top = 33
Width = 74
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 10
TabOrder = 1
Value = 1
end
end
object gbItems: TGroupBox
AnchorSideLeft.Control = gbFont
AnchorSideTop.Control = gbBackground
Left = 316
Height = 179
Top = 128
Width = 222
Caption = 'Items'
ClientHeight = 159
ClientWidth = 218
TabOrder = 5
object cbInverted: TCheckBox
AnchorSideLeft.Control = gbItems
AnchorSideTop.Control = gbItems
Left = 8
Height = 19
Top = 6
Width = 63
BorderSpacing.Left = 8
BorderSpacing.Top = 6
Caption = 'Inverted'
OnChange = cbInvertedChange
TabOrder = 0
end
object seColumns: TSpinEdit
AnchorSideTop.Control = cbInverted
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 33
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
OnChange = seColumnsChange
TabOrder = 1
Value = 1
end
object lblColumns: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = seColumns
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seColumns
Left = 8
Height = 15
Top = 37
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Columns'
FocusControl = seColumns
ParentColor = False
end
object lblItemFillOrder: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = cbItemFillOrder
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbItemFillOrder
Left = 8
Height = 15
Top = 68
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Item fill order'
ParentColor = False
end
object cbItemFillOrder: TComboBox
AnchorSideTop.Control = seColumns
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 64
Width = 96
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'by columns'
'by rows'
)
OnChange = cbItemFillOrderChange
TabOrder = 2
Text = 'by columns'
end
object seSpacing: TSpinEdit
AnchorSideTop.Control = cbItemFillOrder
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 95
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
OnChange = seSpacingChange
TabOrder = 3
Value = 20
end
object lblSpacing: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = seSpacing
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seSpacing
Left = 8
Height = 15
Top = 99
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Spacing'
FocusControl = seSpacing
ParentColor = False
end
object seSymbolWidth: TSpinEdit
AnchorSideTop.Control = seSpacing
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 114
Height = 23
Top = 126
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
OnChange = seSymbolWidthChange
TabOrder = 4
Value = 20
end
object lblSymbolWidth: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideTop.Control = seSymbolWidth
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seSymbolWidth
Left = 8
Height = 15
Top = 130
Width = 98
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
Caption = 'Symbol width'
FocusControl = seSymbolWidth
ParentColor = False
end
end
end
end

View File

@ -0,0 +1,257 @@
unit ceLegendFrame;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Graphics,
Forms, Controls, ExtCtrls, ColorBox, StdCtrls, Spin,
TALegend, TAGraph,
ceFontFrame;
type
{ TChartLegendFrame }
TChartLegendFrame = class(TFrame)
Bevel1: TBevel;
cbBorderColor: TColorBox;
cbFillColor: TColorBox;
cbFilled: TCheckBox;
cbInverted: TCheckBox;
cbItemFillOrder: TComboBox;
cbShow: TCheckBox;
cbShowBorder: TCheckBox;
cbUseSideBar: TCheckBox;
gbAlignment: TGroupBox;
gbBackground: TGroupBox;
gbBorder: TGroupBox;
gbFont: TGroupBox;
gbItems: TGroupBox;
gbMargins: TGroupBox;
lblColumns: TLabel;
lblItemFillOrder: TLabel;
lblMarginX: TLabel;
lblMarginY: TLabel;
lblSpacing: TLabel;
lblSymbolWidth: TLabel;
PanelTop: TPanel;
ParamsPanel: TPanel;
rbBottomCenter: TRadioButton;
rbBottomLeft: TRadioButton;
rbBottomRight: TRadioButton;
rbCenterLeft: TRadioButton;
rbCenterRight: TRadioButton;
rbTopCenter: TRadioButton;
rbTopLeft: TRadioButton;
rbTopRight: TRadioButton;
seColumns: TSpinEdit;
seMarginX: TSpinEdit;
seMarginY: TSpinEdit;
seSpacing: TSpinEdit;
seSymbolWidth: TSpinEdit;
procedure cbBorderColorChange(Sender: TObject);
procedure cbFillColorChange(Sender: TObject);
procedure cbFilledChange(Sender: TObject);
procedure cbInvertedChange(Sender: TObject);
procedure cbItemFillOrderChange(Sender: TObject);
procedure cbShowBorderChange(Sender: TObject);
procedure cbShowChange(Sender: TObject);
procedure cbUseSideBarChange(Sender: TObject);
procedure gbAlignmentClick(Sender: TObject);
procedure seColumnsChange(Sender: TObject);
procedure seMarginXChange(Sender: TObject);
procedure seMarginYChange(Sender: TObject);
procedure seSpacingChange(Sender: TObject);
procedure seSymbolWidthChange(Sender: TObject);
private
FLegend: TChartLegend;
FFontFrame: TChartFontFrame;
procedure ChangedHandler(Sender: TObject);
function GetAlignment: TLegendAlignment;
procedure SetAlignment(AValue: TLegendAlignment);
protected
function GetChart: TChart;
public
constructor Create(AOwner: TComponent); override;
procedure Prepare(ALegend: TChartLegend);
end;
implementation
{$R *.lfm}
uses
ceUtils;
constructor TChartLegendFrame.Create(AOwner: TComponent);
begin
inherited;
FFontFrame := TChartFontFrame.Create(self);
FFontFrame.Parent := gbFont;
FFontFrame.Name := '';
FFontFrame.Align := alClient;
FFontFrame.BorderSpacing.Left := 8;
FFontFrame.BorderSpacing.Right := 8;
FFontFrame.AutoSize := true;
FFontFrame.OnChange := @ChangedHandler;
gbFont.AutoSize := true;
gbFont.Caption := 'Font';
BoldHeaders(Self);
end;
procedure TChartLegendFrame.cbBorderColorChange(Sender: TObject);
begin
FLegend.Frame.Color := cbBorderColor.Selected;
end;
procedure TChartLegendFrame.cbFilledChange(Sender: TObject);
begin
cbFillColor.Visible := cbFilled.Checked;
if cbFilled.Checked then
FLegend.BackgroundBrush.Style := bsSolid
else
FLegend.BackgroundBrush.Style := bsClear;
end;
procedure TChartLegendFrame.cbFillColorChange(Sender: TObject);
begin
FLegend.BackgroundBrush.Color := cbFillColor.Selected;
end;
procedure TChartLegendFrame.cbInvertedChange(Sender: TObject);
begin
FLegend.Inverted := cbInverted.Checked;
end;
procedure TChartLegendFrame.cbItemFillOrderChange(Sender: TObject);
begin
FLegend.ItemFillOrder := TLegendItemFillOrder(cbItemFillOrder.ItemIndex);
end;
procedure TChartLegendFrame.cbShowChange(Sender: TObject);
begin
FLegend.Visible := cbShow.Checked;
cbUseSideBar.Visible := cbShow.Checked;
gbAlignment.Visible := cbShow.Checked;
gbFont.Visible := cbShow.Checked;
gbBackground.Visible := cbShow.Checked;
gbBorder.Visible := cbShow.Checked;
gbItems.Visible := cbShow.Checked;
gbMargins.Visible := cbShow.Checked;
end;
procedure TChartLegendFrame.cbShowBorderChange(Sender: TObject);
begin
FLegend.Frame.Visible := cbShowBorder.Checked;
cbBorderColor.Visible := cbShowBorder.Checked;
end;
procedure TChartLegendFrame.cbUseSideBarChange(Sender: TObject);
begin
FLegend.UseSideBar := cbUseSideBar.Checked;
end;
procedure TChartLegendFrame.ChangedHandler(Sender: TObject);
begin
GetChart.Invalidate;
end;
function TChartLegendFrame.GetChart: TChart;
begin
Result := FLegend.GetOwner as TChart;
end;
procedure TChartLegendFrame.Prepare(ALegend: TChartLegend);
begin
FLegend := ALegend;
cbShow.Checked := ALegend.Visible;
SetAlignment(ALegend.Alignment);
cbFilled.Checked := ALegend.BackgroundBrush.Style <> bsClear;
cbFillColor.Selected := ColorToRGB(ALegend.BackgroundBrush.Color);
cbShowBorder.Checked := (ALegend.Frame.Style <> psClear) and ALegend.Frame.Visible;
cbBorderColor.Selected := ColorToRGB(ALegend.Frame.Color);
seMarginX.Value := ALegend.MarginX;
seMarginY.Value := ALegend.MarginY;
cbUseSideBar.Checked := ALegend.UseSidebar;
cbInverted.Checked := ALegend.Inverted;
seColumns.Value := ALegend.ColumnCount;
seSymbolWidth.Value := ALegend.SymbolWidth;
seSpacing.Value := ALegend.Spacing;
cbItemFillOrder.ItemIndex := ord(ALegend.ItemFillOrder);
FFontFrame.Prepare(ALegend.Font, false);
end;
function TChartLegendFrame.GetAlignment: TLegendAlignment;
var
i: Integer;
rb: TRadioButton;
begin
for i := 0 to gbAlignment.ControlCount-1 do
if (gbAlignment.Controls[i] is TRadioButton) then begin
rb := TRadioButton(gbAlignment.Controls[i]);
if rb.Checked then begin
Result := TLegendAlignment(rb.Tag);
exit;
end;
end;
Result := laTopRight;
end;
procedure TChartLegendFrame.gbAlignmentClick(Sender: TObject);
begin
FLegend.Alignment := GetAlignment;
end;
procedure TChartLegendFrame.seColumnsChange(Sender: TObject);
begin
FLegend.ColumnCount := seColumns.Value;
end;
procedure TChartLegendFrame.seMarginXChange(Sender: TObject);
begin
FLegend.MarginX := seMarginX.Value;
end;
procedure TChartLegendFrame.seMarginYChange(Sender: TObject);
begin
FLegend.MarginY := seMarginY.Value;
end;
procedure TChartLegendFrame.seSpacingChange(Sender: TObject);
begin
FLegend.Spacing := seSpacing.Value;
end;
procedure TChartLegendFrame.seSymbolWidthChange(Sender: TObject);
begin
FLegend.SymbolWidth := seSymbolWidth.Value;
end;
procedure TChartLegendFrame.SetAlignment(AValue: TLegendAlignment);
var
i: Integer;
rb: TRadioButton;
begin
for i:=0 to gbAlignment.ControlCount-1 do
if (gbAlignment.Controls[i] is TRadioButton) then begin
rb := TRadioButton(gbAlignment.Controls[i]);
if rb.Tag = ord(AValue) then begin
rb.Checked := true;
exit;
end;
end;
end;
end.

View File

@ -122,6 +122,13 @@
<ResourceBaseClass Value="Frame"/> <ResourceBaseClass Value="Frame"/>
<UnitName Value="cePointerFrame"/> <UnitName Value="cePointerFrame"/>
</Unit> </Unit>
<Unit>
<Filename Value="celegendframe.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="ChartLegendFrame"/>
<ResourceBaseClass Value="Frame"/>
<UnitName Value="ceLegendFrame"/>
</Unit>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>