From 9ee5e00da71f04b941e958631145183d149b30a4 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Tue, 3 Aug 2021 14:24:57 +0200 Subject: [PATCH] TAChart: Various improvements of ChartEditor demo. --- .../tachart/demo/charteditor/cearrowframe.lfm | 105 +++++++++ .../tachart/demo/charteditor/cearrowframe.pas | 81 +++++++ .../tachart/demo/charteditor/ceaxisframe.lfm | 171 ++++---------- .../tachart/demo/charteditor/ceaxisframe.pas | 182 +++++++-------- .../tachart/demo/charteditor/cebrushframe.lfm | 3 +- .../tachart/demo/charteditor/cebrushframe.pas | 2 - .../demo/charteditor/cecharteditor.lfm | 6 +- .../demo/charteditor/cecharteditor.pas | 33 ++- .../tachart/demo/charteditor/cefontframe.lfm | 11 +- .../tachart/demo/charteditor/cefontframe.pas | 2 - .../demo/charteditor/celegendframe.lfm | 211 ++++++++---------- .../demo/charteditor/celegendframe.pas | 130 ++++++----- .../tachart/demo/charteditor/cemain.lfm | 2 +- .../tachart/demo/charteditor/cemarksform.lfm | 198 ++++++++++++++++ .../tachart/demo/charteditor/cemarksform.pas | 188 ++++++++++++++++ .../tachart/demo/charteditor/cepenframe.lfm | 16 +- .../tachart/demo/charteditor/cepenframe.pas | 2 - .../demo/charteditor/cepointerframe.pas | 1 - .../demo/charteditor/ceseriesframe.lfm | 81 ++++--- .../demo/charteditor/ceseriesframe.pas | 59 ++++- .../ceshapebrushpenmarginsframe.lfm | 134 ++--------- .../ceshapebrushpenmarginsframe.pas | 131 +++++------ .../demo/charteditor/cesimplebrushframe.lfm | 44 ++++ .../demo/charteditor/cesimplebrushframe.pas | 84 +++++++ .../demo/charteditor/cesimplepenframe.lfm | 79 +++++++ .../demo/charteditor/cesimplepenframe.pas | 120 ++++++++++ .../demo/charteditor/cetitlefootframe.lfm | 120 +++++++--- .../demo/charteditor/cetitlefootframe.pas | 59 +++-- .../tachart/demo/charteditor/ceutils.pas | 4 +- .../demo/charteditor/charteditordemo.lpi | 32 +++ .../demo/charteditor/charteditordemo.lpr | 4 +- components/tachart/tatextelements.pas | 6 +- 32 files changed, 1605 insertions(+), 696 deletions(-) create mode 100644 components/tachart/demo/charteditor/cearrowframe.lfm create mode 100644 components/tachart/demo/charteditor/cearrowframe.pas create mode 100644 components/tachart/demo/charteditor/cemarksform.lfm create mode 100644 components/tachart/demo/charteditor/cemarksform.pas create mode 100644 components/tachart/demo/charteditor/cesimplebrushframe.lfm create mode 100644 components/tachart/demo/charteditor/cesimplebrushframe.pas create mode 100644 components/tachart/demo/charteditor/cesimplepenframe.lfm create mode 100644 components/tachart/demo/charteditor/cesimplepenframe.pas diff --git a/components/tachart/demo/charteditor/cearrowframe.lfm b/components/tachart/demo/charteditor/cearrowframe.lfm new file mode 100644 index 0000000000..6b650e23a0 --- /dev/null +++ b/components/tachart/demo/charteditor/cearrowframe.lfm @@ -0,0 +1,105 @@ +object ChartArrowFrame: TChartArrowFrame + Left = 0 + Height = 125 + Top = 0 + Width = 171 + ClientHeight = 125 + ClientWidth = 171 + TabOrder = 0 + DesignLeft = 390 + DesignTop = 154 + object cbArrowVisible: TCheckBox + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner + Left = 0 + Height = 19 + Top = 0 + Width = 54 + Caption = 'Visible' + OnChange = cbArrowVisibleChange + TabOrder = 0 + end + object lblArrowBaseLength: TLabel + AnchorSideLeft.Control = cbArrowVisible + AnchorSideTop.Control = seArrowBaseLength + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 31 + Width = 61 + Caption = 'Base length' + end + object lblArrowLength: TLabel + AnchorSideLeft.Control = cbArrowVisible + AnchorSideTop.Control = seArrowLength + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 62 + Width = 37 + Caption = 'Length' + end + object lblArrowWidth: TLabel + AnchorSideLeft.Control = cbArrowVisible + AnchorSideTop.Control = seArrowWidth + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 93 + Width = 32 + Caption = 'Width' + end + object seArrowBaseLength: TSpinEdit + AnchorSideLeft.Control = lblArrowBaseLength + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cbArrowVisible + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 85 + Height = 23 + Top = 27 + Width = 86 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 24 + BorderSpacing.Top = 8 + MaxValue = 1000 + OnChange = seArrowBaseLengthChange + TabOrder = 1 + end + object seArrowLength: TSpinEdit + AnchorSideLeft.Control = seArrowBaseLength + AnchorSideTop.Control = seArrowBaseLength + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = seArrowBaseLength + AnchorSideRight.Side = asrBottom + Left = 85 + Height = 23 + Top = 58 + Width = 86 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 8 + MaxValue = 1000 + OnChange = seArrowLengthChange + TabOrder = 2 + end + object seArrowWidth: TSpinEdit + AnchorSideLeft.Control = seArrowBaseLength + AnchorSideTop.Control = seArrowLength + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = seArrowBaseLength + AnchorSideRight.Side = asrBottom + Left = 85 + Height = 23 + Top = 89 + Width = 86 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 8 + MaxValue = 1000 + OnChange = seArrowWidthChange + TabOrder = 3 + end +end diff --git a/components/tachart/demo/charteditor/cearrowframe.pas b/components/tachart/demo/charteditor/cearrowframe.pas new file mode 100644 index 0000000000..318a6f7064 --- /dev/null +++ b/components/tachart/demo/charteditor/cearrowframe.pas @@ -0,0 +1,81 @@ +unit ceArrowFrame; + +{$mode ObjFPC}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, StdCtrls, Spin, + TATypes; + +type + + { TChartArrowFrame } + + TChartArrowFrame = class(TFrame) + cbArrowVisible: TCheckBox; + lblArrowBaseLength: TLabel; + lblArrowLength: TLabel; + lblArrowWidth: TLabel; + seArrowBaseLength: TSpinEdit; + seArrowLength: TSpinEdit; + seArrowWidth: TSpinEdit; + procedure cbArrowVisibleChange(Sender: TObject); + procedure seArrowBaseLengthChange(Sender: TObject); + procedure seArrowLengthChange(Sender: TObject); + procedure seArrowWidthChange(Sender: TObject); + private + FArrow: TChartArrow; + procedure DoChange; + public + procedure Prepare(Arrow: TChartArrow); + end; + +implementation + +{$R *.lfm} + +procedure TChartArrowFrame.cbArrowVisibleChange(Sender: TObject); +begin + FArrow.Visible := cbArrowVisible.Checked; + DoChange; +end; + +procedure TChartArrowFrame.DoChange; +begin + lblArrowBaseLength.Enabled := cbArrowVisible.Checked; + seArrowBaseLength.Enabled := cbArrowVisible.Checked; + lblArrowLength.Enabled := cbArrowVisible.Checked; + seArrowLength.Enabled := cbArrowVisible.Checked; + lblArrowWidth.Enabled := cbArrowVisible.Checked; + seArrowWidth.Enabled := cbArrowVisible.Checked; +end; + +procedure TChartArrowFrame.Prepare(Arrow: TChartArrow); +begin + FArrow := Arrow; + cbArrowVisible.Checked := Arrow.Visible; + seArrowBaseLength.Value := Arrow.BaseLength; + seArrowLength.Value := Arrow.Length; + seArrowWidth.Value := Arrow.Width; + DoChange; +end; + +procedure TChartArrowFrame.seArrowBaseLengthChange(Sender: TObject); +begin + FArrow.BaseLength := seArrowBaseLength.Value; +end; + +procedure TChartArrowFrame.seArrowLengthChange(Sender: TObject); +begin + FArrow.Length := seArrowLength.Value; +end; + +procedure TChartArrowFrame.seArrowWidthChange(Sender: TObject); +begin + FArrow.Width := seArrowWidth.Value; +end; + + +end. + diff --git a/components/tachart/demo/charteditor/ceaxisframe.lfm b/components/tachart/demo/charteditor/ceaxisframe.lfm index 84fef1497b..cf93d80045 100644 --- a/components/tachart/demo/charteditor/ceaxisframe.lfm +++ b/components/tachart/demo/charteditor/ceaxisframe.lfm @@ -40,9 +40,9 @@ object ChartAxisFrame: TChartAxisFrame Height = 446 Top = 25 Width = 646 - ActivePage = pgTitle + ActivePage = pgLine Align = alClient - TabIndex = 0 + TabIndex = 3 TabOrder = 1 OnChanging = PageControlChanging object pgTitle: TTabSheet @@ -62,12 +62,13 @@ object ChartAxisFrame: TChartAxisFrame TabOrder = 0 object lblTitle: TLabel AnchorSideLeft.Control = TitleMemoPanel - AnchorSideTop.Control = TitleMemoPanel + AnchorSideTop.Control = cbTitleVisible + AnchorSideTop.Side = asrBottom Left = 0 Height = 15 - Top = 2 + Top = 27 Width = 21 - BorderSpacing.Top = 2 + BorderSpacing.Top = 8 Caption = 'Text' end object mmoTitle: TMemo @@ -79,32 +80,56 @@ object ChartAxisFrame: TChartAxisFrame AnchorSideBottom.Control = TitleMemoPanel AnchorSideBottom.Side = asrBottom Left = 0 - Height = 170 - Top = 21 + Height = 145 + Top = 46 Width = 622 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Top = 4 OnChange = mmoTitleChange ScrollBars = ssAutoBoth TabOrder = 0 + WordWrap = False end object cbTitleVisible: TCheckBox - AnchorSideTop.Control = lblTitle - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = TitleMemoPanel + AnchorSideLeft.Control = TitleMemoPanel + AnchorSideTop.Control = TitleMemoPanel AnchorSideRight.Side = asrBottom - Left = 568 + Left = 0 Height = 19 Top = 0 Width = 54 - Alignment = taLeftJustify - Anchors = [akTop, akRight] Caption = 'Visible' Checked = True OnChange = cbTitleVisibleChange State = cbChecked TabOrder = 1 end + object cbTitleHTML: TCheckBox + AnchorSideLeft.Control = cbTitleWordwrap + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cbTitleVisible + Left = 193 + Height = 19 + Top = 0 + Width = 156 + BorderSpacing.Left = 32 + Caption = 'Support HTML in title text' + OnChange = cbTitleHTMLChange + TabOrder = 2 + end + object cbTitleWordwrap: TCheckBox + AnchorSideLeft.Control = cbTitleVisible + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cbTitleVisible + Left = 86 + Height = 19 + Top = 0 + Width = 75 + BorderSpacing.Left = 32 + Caption = 'Wordwrap' + OnChange = cbTitleWordwrapChange + TabOrder = 3 + end end object TitleParamsPanel: TPanel Left = 8 @@ -598,19 +623,19 @@ object ChartAxisFrame: TChartAxisFrame Left = 8 Height = 119 Top = 8 - Width = 400 + Width = 446 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 BorderSpacing.Top = 8 Caption = 'gbFrame' ClientHeight = 99 - ClientWidth = 396 + ClientWidth = 442 TabOrder = 0 object cbFrameVisible: TCheckBox Left = 16 Height = 19 Top = 8 - Width = 364 + Width = 410 Align = alTop BorderSpacing.Left = 16 BorderSpacing.Top = 8 @@ -630,18 +655,18 @@ object ChartAxisFrame: TChartAxisFrame Left = 8 Height = 137 Top = 143 - Width = 400 + Width = 446 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 16 Caption = 'gbAxisLine' ClientHeight = 117 - ClientWidth = 396 + ClientWidth = 442 TabOrder = 1 object cbAxisLineVisible: TCheckBox Left = 16 Height = 19 Top = 8 - Width = 364 + Width = 410 Align = alTop BorderSpacing.Left = 16 BorderSpacing.Top = 8 @@ -658,113 +683,15 @@ object ChartAxisFrame: TChartAxisFrame AnchorSideTop.Control = gbFrame AnchorSideRight.Control = pgLine AnchorSideRight.Side = asrBottom - Left = 432 - Height = 156 + Left = 478 + Height = 131 Top = 8 - Width = 200 + Width = 152 Anchors = [akTop, akRight] - AutoSize = True BorderSpacing.Left = 24 - BorderSpacing.Right = 6 - Caption = 'Arrow' - ClientHeight = 136 - ClientWidth = 196 + BorderSpacing.Right = 8 + Caption = 'gbArrow' TabOrder = 2 - object cbArrowVisible: TCheckBox - AnchorSideLeft.Control = gbArrow - AnchorSideTop.Control = gbArrow - Left = 16 - Height = 19 - Top = 8 - Width = 54 - BorderSpacing.Left = 16 - BorderSpacing.Top = 8 - Caption = 'Visible' - OnChange = cbArrowVisibleChange - TabOrder = 0 - end - object lblArrowBaseLength: TLabel - AnchorSideLeft.Control = cbArrowVisible - AnchorSideTop.Control = seArrowBaseLength - AnchorSideTop.Side = asrCenter - Left = 16 - Height = 15 - Top = 39 - Width = 61 - Caption = 'Base length' - end - object lblArrowLength: TLabel - AnchorSideLeft.Control = cbArrowVisible - AnchorSideTop.Control = seArrowLength - AnchorSideTop.Side = asrCenter - Left = 16 - Height = 15 - Top = 70 - Width = 37 - Caption = 'Length' - end - object lblArrowWidth: TLabel - AnchorSideLeft.Control = cbArrowVisible - AnchorSideTop.Control = seArrowWidth - AnchorSideTop.Side = asrCenter - Left = 16 - Height = 15 - Top = 101 - Width = 32 - Caption = 'Width' - end - object seArrowBaseLength: TSpinEdit - AnchorSideLeft.Control = lblArrowBaseLength - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = cbArrowVisible - AnchorSideTop.Side = asrBottom - Left = 101 - Height = 23 - Top = 35 - Width = 79 - Alignment = taRightJustify - BorderSpacing.Left = 24 - BorderSpacing.Top = 8 - BorderSpacing.Right = 16 - MaxValue = 1000 - OnChange = seArrowBaseLengthChange - TabOrder = 1 - end - object seArrowLength: TSpinEdit - AnchorSideLeft.Control = seArrowBaseLength - AnchorSideTop.Control = seArrowBaseLength - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = seArrowBaseLength - AnchorSideRight.Side = asrBottom - Left = 101 - Height = 23 - Top = 66 - Width = 79 - Alignment = taRightJustify - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 8 - MaxValue = 1000 - OnChange = seArrowLengthChange - TabOrder = 2 - end - object seArrowWidth: TSpinEdit - AnchorSideLeft.Control = seArrowBaseLength - AnchorSideTop.Control = seArrowLength - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = seArrowBaseLength - AnchorSideRight.Side = asrBottom - Left = 101 - Height = 23 - Top = 97 - Width = 79 - Alignment = taRightJustify - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 8 - BorderSpacing.Bottom = 16 - MaxValue = 1000 - OnChange = seArrowWidthChange - TabOrder = 3 - end end end end diff --git a/components/tachart/demo/charteditor/ceaxisframe.pas b/components/tachart/demo/charteditor/ceaxisframe.pas index f8eed86eb7..381bdcacac 100644 --- a/components/tachart/demo/charteditor/ceaxisframe.pas +++ b/components/tachart/demo/charteditor/ceaxisframe.pas @@ -1,7 +1,6 @@ unit ceAxisFrame; {$MODE ObjFPC}{$H+} -{.$DEFINE WYSIWYG_AXISTITLE} interface @@ -9,7 +8,7 @@ uses Classes, SysUtils, Graphics, Forms, Controls, ExtCtrls, ComCtrls, StdCtrls, Dialogs, Spin, TATextElements, TAChartAxis, TAGraph, - ceFontFrame, cePenFrame, ceShapeBrushPenMarginsFrame; + ceFontFrame, cePenFrame, ceShapeBrushPenMarginsFrame, ceArrowFrame; type TChartAxisEditorPage = (aepTitle, aepLabels, aepGrid, aepLine); @@ -18,7 +17,6 @@ type TChartAxisFrame = class(TFrame) Bevel1: TBevel; Bevel2: TBevel; - cbArrowVisible: TCheckBox; cbAutoMax: TCheckBox; cbAutoMin: TCheckBox; cbAxisLineVisible: TCheckBox; @@ -29,6 +27,8 @@ type cbShow: TCheckBox; cbTickColor: TColorButton; cbTitleVisible: TCheckBox; + cbTitleHTML: TCheckBox; + cbTitleWordwrap: TCheckBox; edLabelFormat: TEdit; gbArrow: TGroupBox; gbAxisLine: TGroupBox; @@ -41,9 +41,6 @@ type gbTicks: TGroupBox; gbTitleFont: TGroupBox; gbTitleShapeBrushPenMargins: TGroupBox; - lblArrowBaseLength: TLabel; - lblArrowLength: TLabel; - lblArrowWidth: TLabel; lblAutomatic: TLabel; lblLabelDistance: TLabel; lblLabelFormat: TLabel; @@ -59,9 +56,6 @@ type pgLine: TTabSheet; pgTitle: TTabSheet; rgTitleAlignment: TRadioGroup; - seArrowBaseLength: TSpinEdit; - seArrowLength: TSpinEdit; - seArrowWidth: TSpinEdit; seLabelDistance: TSpinEdit; seMaximum: TFloatSpinEdit; seMinimum: TFloatSpinEdit; @@ -71,7 +65,6 @@ type Spacer: TBevel; TitleMemoPanel: TPanel; TitleParamsPanel: TPanel; - procedure cbArrowVisibleChange(Sender: TObject); procedure cbAutoMaxChange(Sender: TObject); procedure cbAutoMinChange(Sender: TObject); procedure cbAxisLineVisibleChange(Sender: TObject); @@ -81,14 +74,13 @@ type procedure cbLabelsVisibleChange(Sender: TObject); procedure cbShowChange(Sender: TObject); procedure cbTickColorColorChanged(Sender: TObject); + procedure cbTitleHTMLChange(Sender: TObject); procedure cbTitleVisibleChange(Sender: TObject); + procedure cbTitleWordwrapChange(Sender: TObject); procedure edLabelFormatEditingDone(Sender: TObject); procedure mmoTitleChange(Sender: TObject); procedure PageControlChanging(Sender: TObject; var AllowChange: Boolean); procedure rgTitleAlignmentClick(Sender: TObject); - procedure seArrowBaseLengthChange(Sender: TObject); - procedure seArrowLengthChange(Sender: TObject); - procedure seArrowWidthChange(Sender: TObject); procedure seLabelDistanceChange(Sender: TObject); procedure seMaximumChange(Sender: TObject); procedure seMinimumChange(Sender: TObject); @@ -105,6 +97,7 @@ type FFramePenFrame: TChartPenFrame; FAxisLinePenFrame: TChartPenFrame; FLabelShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame; + FArrowFrame: TChartArrowFrame; function GetAlignment(AItemIndex: Integer): TAlignment; function GetAlignmentIndex(AValue: TAlignment): Integer; @@ -115,8 +108,6 @@ type procedure LabelChangedHandler(Sender: TObject); procedure LabelFontChangedHandler(Sender: TObject); procedure LabelShapeChangedHandler(AShape: TChartLabelShape); - procedure TitleChangedHandler(Sender: TObject); - procedure TitleFontChangedHandler(Sender: TObject); procedure TitleShapeChangedHandler(AShape: TChartLabelShape); protected procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; @@ -124,6 +115,7 @@ type function GetChart: TChart; function GetRealAxisMax: Double; function GetRealAxisMin: Double; + procedure UpdateControlState; public constructor Create(AOwner: TComponent); override; procedure Prepare(Axis: TChartAxis); @@ -136,7 +128,7 @@ implementation {$R *.lfm} uses - Math, + Math, TAChartUtils, ceUtils; constructor TChartAxisFrame.Create(AOwner: TComponent); @@ -144,87 +136,96 @@ begin inherited; FTitleFontFrame := TChartFontFrame.Create(self); - FTitleFontFrame.Parent := gbTitleFont; FTitleFontFrame.Name := ''; FTitleFontFrame.Align := alClient; FTitleFontFrame.BorderSpacing.Left := 8; FTitleFontFrame.BorderSpacing.Right := 8; - FTitleFontFrame.OnChange := @TitleFontChangedHandler; + FTitleFontFrame.Parent := gbTitleFont; gbTitleFont.AutoSize := true; gbTitleFont.Caption := 'Font'; FTitleShapeBrushPenMarginsFrame := TChartShapeBrushPenMarginsFrame.Create(self); - FTitleShapeBrushPenMarginsFrame.Parent := gbTitleShapeBrushPenMargins; FTitleShapeBrushPenMarginsFrame.Name := ''; FTitleShapeBrushPenMarginsFrame.Align := alClient; FTitleShapeBrushPenMarginsFrame.BorderSpacing.Left := 8; FTitleShapeBrushPenMarginsFrame.BorderSpacing.Right := 8; FTitleShapeBrushPenMarginsFrame.BorderSpacing.Bottom := 8; - FTitleShapeBrushPenMarginsFrame.OnChange := @TitleChangedHandler; FTitleShapeBrushPenMarginsFrame.OnShapeChange := @TitleShapeChangedHandler; FTitleShapeBrushPenMarginsFrame.AutoSize := true; + FTitleShapeBrushPenMarginsFrame.Parent := gbTitleShapeBrushPenMargins; gbTitleShapeBrushPenMargins.AutoSize := true; gbTitleShapeBrushPenMargins.Caption := 'Title background'; FLabelFontFrame := TChartFontFrame.Create(self); - FLabelFontFrame.Parent := gbLabelFont; FLabelFontFrame.Name := ''; FLabelFontFrame.Align := alClient; FLabelFontFrame.BorderSpacing.Left := 8; FLabelFontFrame.BorderSpacing.Right := 8; + FLabelFontFrame.Parent := gbLabelFont; FLabelFontFrame.OnChange := @LabelFontChangedHandler; gbLabelFont.AutoSize := true; gbLabelFont.Caption := 'Label font'; FLabelShapeBrushPenMarginsFrame := TChartShapeBrushPenMarginsFrame.Create(self); - FLabelShapeBrushPenMarginsFrame.Parent := gbShapeFillBorder; FLabelShapeBrushPenMarginsFrame.Name := ''; FLabelShapeBrushPenMarginsFrame.Align := alClient; FLabelShapeBrushPenMarginsFrame.BorderSpacing.Left := 8; FLabelShapeBrushPenMarginsFrame.BorderSpacing.Right := 8; FLabelShapeBrushPenMarginsFrame.BorderSpacing.Bottom := 8; - FLabelShapeBrushPenMarginsFrame.OnChange := @LabelChangedHandler; FLabelShapeBrushPenMarginsFrame.OnShapeChange := @LabelShapeChangedHandler; FLabelShapeBrushPenMarginsFrame.AutoSize := true; + FLabelShapeBrushPenMarginsFrame.Parent := gbShapeFillBorder; gbShapeFillBorder.AutoSize := true; gbShapeFillBorder.Caption := 'Label background'; FGridPenFrame := TChartPenFrame.Create(Self); - FGridPenFrame.Parent := gbGrid; FGridPenFrame.Name := ''; FGridPenFrame.Align := alTop; FGridPenFrame.Top := 1000; FGridPenFrame.BorderSpacing.Left := 16; FGridPenFrame.BorderSpacing.Right := 16; FGridPenFrame.BorderSpacing.Bottom := 16; + FGridPenFrame.Parent := gbGrid; FGridPenFrame.OnChange := @ChangedHandler; gbGrid.AutoSize := true; gbGrid.Caption := 'Grid lines'; FFramePenFrame := TChartPenFrame.Create(Self); - FFramePenFrame.Parent := gbFrame; FFramePenFrame.Name := ''; FFramePenFrame.Align := alTop; FFramePenFrame.Top := 1000; FFramePenFrame.BorderSpacing.Left := 16; FFramePenFrame.BorderSpacing.Right := 16; FFramePenFrame.BorderSpacing.Bottom := 16; - FFramePenFrame.OnChange := @ChangedHandler; + FFramePenFrame.Parent := gbFrame; +// FFramePenFrame.OnChange := @ChangedHandler; gbFrame.AutoSize := true; gbFrame.Caption := 'Frame'; FAxisLinePenFrame := TChartPenFrame.Create(Self); - FAxisLinePenFrame.Parent := gbAxisLine; FAxisLinePenFrame.Name := ''; FAxisLinePenFrame.Align := alTop; FAxisLinePenFrame.Top := 1000; FAxisLinePenFrame.BorderSpacing.Left := 16; FAxisLinePenFrame.BorderSpacing.Right := 16; FAxisLinePenFrame.BorderSpacing.Bottom := 16; - FAxisLinePenFrame.OnChange := @ChangedHandler; + FAxisLinePenFrame.Parent := gbAxisLine; +// FAxisLinePenFrame.OnChange := @ChangedHandler; gbAxisLine.AutoSize := true; gbAxisLine.Caption := 'Axis line'; + FArrowFrame := TChartArrowFrame.Create(self); + FArrowFrame.Name := ''; + FArrowFrame.Align := alClient; + FArrowFrame.BorderSpacing.Top := 8; + FArrowFrame.BorderSpacing.Left := 16; + FArrowFrame.BorderSpacing.Right := 16; + FArrowFrame.BorderSpacing.Bottom := 16; + FArrowFrame.AutoSize := true; + FArrowFrame.Parent := gbArrow; + gbArrow.AutoSize := true; + gbArrow.Caption := 'Arrow'; + BoldHeaders(self); TitleParamsPanel.AutoSize := true; @@ -253,11 +254,6 @@ begin PanelTop.Height; end; -procedure TChartAxisFrame.cbArrowVisibleChange(Sender: TObject); -begin - FAxis.Arrow.Visible := cbArrowVisible.Checked; -end; - procedure TChartAxisFrame.cbAutoMaxChange(Sender: TObject); begin FAxis.Range.UseMax := not cbAutoMax.Checked; @@ -273,16 +269,19 @@ end; procedure TChartAxisFrame.cbAxisLineVisibleChange(Sender: TObject); begin FAxis.AxisPen.Visible := cbAxisLineVisible.Checked; + UpdateControlState; end; procedure TChartAxisFrame.cbFrameVisibleChange(Sender: TObject); begin GetChart.Frame.Visible := cbFrameVisible.Checked; + UpdateControlState; end; procedure TChartAxisFrame.cbGridVisibleChange(Sender: TObject); begin FAxis.Grid.Visible := cbGridVisible.Checked; + UpdateControlState; end; procedure TChartAxisFrame.cbInvertedChange(Sender: TObject); @@ -293,11 +292,13 @@ end; procedure TChartAxisFrame.cbLabelsVisibleChange(Sender: TObject); begin FAxis.Marks{%H-}.Visible := cbLabelsVisible.Checked; + UpdateControlState; end; procedure TChartAxisFrame.cbShowChange(Sender: TObject); begin FAxis.Visible := cbShow.Checked; + PageControl.Visible := cbShow.checked; end; procedure TChartAxisFrame.cbTickColorColorChanged(Sender: TObject); @@ -305,9 +306,20 @@ begin FAxis.TickColor := cbTickColor.ButtonColor; end; +procedure TChartAxisFrame.cbTitleHTMLChange(Sender: TObject); +begin + FAxis.Title.TextFormat := TEXT_FORMAT[cbTitleHTML.Checked]; +end; + procedure TChartAxisFrame.cbTitleVisibleChange(Sender: TObject); begin FAxis.Title.Visible := cbTitleVisible.Checked; + UpdateControlState; +end; + +procedure TChartAxisFrame.cbTitleWordwrapChange(Sender: TObject); +begin + FAxis.Title.Wordwrap := cbTitleWordwrap.Checked; end; procedure TChartAxisFrame.ChangedHandler(Sender: TObject); @@ -403,15 +415,9 @@ begin // Page "Title" cbTitleVisible.Checked := Axis.Title.Visible; + cbTitleWordwrap.Checked := Axis.Title.Wordwrap; + cbTitleHTML.Checked := (Axis.Title.TextFormat = tfHTML); mmoTitle.Lines.Text := Axis.Title.Caption; - {$IFDEF WYSIWYG_AXISTITLE} - mmoTitle.Font := Axis.Title.LabelFont; - mmoTitle.Font.Orientation := 0; // Memo has horizontal text only - if Axis.Title.LabelBrush.Style <> bsClear then - mmoTitle.Color := Axis.Title.LabelBrush.Color - else - mmoTitle.Color := GetChart.Color; - {$ENDIF} with Axis.Title do begin rgTitleAlignment.ItemIndex := GetAlignmentIndex(Alignment); seTitleDistance.Value := Distance; @@ -438,49 +444,38 @@ begin end; // Page "Grid" - cbGridVisible.Checked := FAxis.Grid.EffVisible; - FGridPenFrame.Prepare(FAxis.Grid); + cbGridVisible.Checked := Axis.Grid.EffVisible; + FGridPenFrame.Prepare(Axis.Grid); // Page "Line" cbFrameVisible.Checked := GetChart.Frame.EffVisible; FFramePenFrame.Prepare(GetChart.Frame); - cbAxisLineVisible.Checked := FAxis.AxisPen.EffVisible; - FAxisLinePenFrame.Prepare(FAxis.AxisPen); - cbArrowVisible.Checked := FAxis.Arrow.Visible; - seArrowBaseLength.Value := FAxis.Arrow.BaseLength; - seArrowLength.Value := FAxis.Arrow.Length; - seArrowWidth.Value := FAxis.Arrow.Width; + cbAxisLineVisible.Checked := Axis.AxisPen.EffVisible; + FAxisLinePenFrame.Prepare(Axis.AxisPen); + FArrowFrame.Prepare(Axis.Arrow); + + UpdateControlState; end; procedure TChartAxisFrame.rgTitleAlignmentClick(Sender: TObject); begin - FAxis.Title.Alignment := GetAlignment(rgTitleAlignment.ItemIndex); -end; - -procedure TChartAxisFrame.seArrowBaseLengthChange(Sender: TObject); -begin - FAxis.Arrow.BaseLength := seArrowBaseLength.value; -end; - -procedure TChartAxisFrame.seArrowLengthChange(Sender: TObject); -begin - FAxis.Arrow.Length := seArrowLength.Value; -end; - -procedure TChartAxisFrame.seArrowWidthChange(Sender: TObject); -begin - FAxis.Arrow.Width := seArrowWidth.Value; + if Assigned(FAxis) then + FAxis.Title.Alignment := GetAlignment(rgTitleAlignment.ItemIndex); end; procedure TChartAxisFrame.seLabelDistanceChange(Sender: TObject); begin - FAxis.Marks{%H-}.Distance := seLabelDistance.Value; + if Assigned(FAxis) then + FAxis.Marks{%H-}.Distance := seLabelDistance.Value; end; procedure TChartAxisFrame.seMaximumChange(Sender: TObject); begin - FAxis.Range.Max := seMaximum.Value; - cbAutoMax.Checked := false; + if Assigned(FAxis) then + begin + FAxis.Range.Max := seMaximum.Value; + cbAutoMax.Checked := false; + end; end; procedure TChartAxisFrame.seMinimumChange(Sender: TObject); @@ -496,36 +491,20 @@ end; procedure TChartAxisFrame.seTickLengthChange(Sender: TObject); begin - FAxis.TickLength := seTickLength.Value; + if Assigned(FAxis) then + FAxis.TickLength := seTickLength.Value; end; procedure TChartAxisFrame.seTickInnerLengthChange(Sender: TObject); begin - FAxis.TickInnerLength := seTickInnerLength.Value; + if Assigned(FAxis) then + FAxis.TickInnerLength := seTickInnerLength.Value; end; procedure TChartAxisFrame.seTitleDistanceChange(Sender: TObject); begin - FAxis.Title.Distance := seTitleDistance.Value; -end; - -procedure TChartAxisFrame.TitleChangedHandler(Sender: TObject); -begin -{$IFDEF WYSIWYG_AXISTITLE} - if FAxis.Title.LabelBrush.Style <> bsClear then - mmoTitle.Color := FAxis.Title.LabelBrush.Color - else - mmoTitle.Color := GetChart.Color; -{$ENDIF} - GetChart.Invalidate; -end; - -procedure TChartAxisFrame.TitleFontChangedHandler(Sender: TObject); -begin -{$IFDEF WYSIWYG_AXISTITLE} - mmoTitle.Font.Assign(FAxis.Title.LabelFont); - mmoTitle.Font.Orientation := 0; -{$ENDIF} + if Assigned(FAxis) then + FAxis.Title.Distance := seTitleDistance.Value; end; procedure TChartAxisFrame.TitleShapeChangedHandler(AShape: TChartLabelShape); @@ -533,6 +512,29 @@ begin FAxis.Title.Shape := AShape; end; +procedure TChartAxisFrame.UpdateControlstate; +begin + // title + cbTitleWordwrap.Enabled := cbTitleVisible.Checked; + cbTitleHTML.Enabled := cbTitleVisible.Checked; + lblTitle.Enabled := cbTitleVisible.Checked; + mmoTitle.Enabled := cbTitleVisible.Checked; + TitleParamsPanel.Enabled := cbTitleVisible.Checked; + + // labels + lblLabelFormat.Enabled := cbLabelsVisible.Checked; + edlabelFormat.Enabled := cbLabelsVisible.Checked; + lblLabelDistance.Enabled := cbLabelsVisible.Checked; + seLabelDistance.Enabled := cbLabelsVisible.Checked; + + // grid + FGridPenFrame.Enabled := cbGridVisible.Checked; + + // Line + FAxisLinePenFrame.Enabled := cbAxisLineVisible.Checked; + FFramePenFrame.Enabled := cbFrameVisible.Checked; +end; + function TChartAxisFrame.Validate(out AMsg: String; out AControl: TWinControl): Boolean; begin Result := false; diff --git a/components/tachart/demo/charteditor/cebrushframe.lfm b/components/tachart/demo/charteditor/cebrushframe.lfm index 942cd7827e..9cdbe0aa48 100644 --- a/components/tachart/demo/charteditor/cebrushframe.lfm +++ b/components/tachart/demo/charteditor/cebrushframe.lfm @@ -1,4 +1,4 @@ -object BrushFrame: TChartBrushFrame +object ChartBrushFrame: TChartBrushFrame Left = 0 Height = 24 Top = 0 @@ -38,7 +38,6 @@ object BrushFrame: TChartBrushFrame Top = 5 Width = 25 Caption = 'Style' - ParentColor = False end object cbBrushColor: TColorButton AnchorSideLeft.Side = asrBottom diff --git a/components/tachart/demo/charteditor/cebrushframe.pas b/components/tachart/demo/charteditor/cebrushframe.pas index f645cb97ae..142ecb91ea 100644 --- a/components/tachart/demo/charteditor/cebrushframe.pas +++ b/components/tachart/demo/charteditor/cebrushframe.pas @@ -21,12 +21,10 @@ type FBrush: TBrush; FOnChange: TNotifyEvent; procedure DoChanged; - public constructor Create(AOwner: TComponent); override; procedure Prepare(ABrush: TBrush); property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; implementation diff --git a/components/tachart/demo/charteditor/cecharteditor.lfm b/components/tachart/demo/charteditor/cecharteditor.lfm index a35e70f8bb..62b7d08c78 100644 --- a/components/tachart/demo/charteditor/cecharteditor.lfm +++ b/components/tachart/demo/charteditor/cecharteditor.lfm @@ -21,13 +21,11 @@ object ChartEditorForm: TChartEditorForm OKButton.OnClick = OKButtonClick HelpButton.Name = 'HelpButton' HelpButton.DefaultCaption = True - CloseButton.Name = 'ApplyButton' - CloseButton.Caption = 'Apply' - CloseButton.OnClick = ApplyButtonClick + CloseButton.Name = 'CloseButton' CancelButton.Name = 'CancelButton' CancelButton.DefaultCaption = True TabOrder = 0 - ShowButtons = [pbOK, pbCancel, pbClose] + ShowButtons = [pbOK, pbCancel] end object Tree: TTreeView Left = 6 diff --git a/components/tachart/demo/charteditor/cecharteditor.pas b/components/tachart/demo/charteditor/cecharteditor.pas index ad411709bd..2dbfaa836d 100644 --- a/components/tachart/demo/charteditor/cecharteditor.pas +++ b/components/tachart/demo/charteditor/cecharteditor.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, ComCtrls, - ExtCtrls, StdCtrls, + ExtCtrls, StdCtrls, Buttons, TAGraph, TAChartAxis, TACustomSeries, TASeries, TAChartImageList, ceAxisFrame; @@ -15,7 +15,7 @@ type { TChartEditorForm } TChartEditorForm = class(TForm) - ApplyButton: TPanelBitBtn; + CloseButton: TPanelBitBtn; ButtonPanel: TButtonPanel; Image1: TImage; Label1: TLabel; @@ -23,7 +23,6 @@ type TitlePanel: TPanel; Splitter1: TSplitter; Tree: TTreeView; - procedure ApplyButtonClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormCreate(Sender: TObject); @@ -43,8 +42,10 @@ type FAxesNode: TTreeNode; FSeriesNode: TTreeNode; FOKClicked: Boolean; + FApplyButton: TBitBtn; function AddFrame(AParentNode: TTreeNode; ACaption: String; AFrame: TFrame; AImageIndex: Integer): TTreeNode; + procedure ApplyButtonClick(Sender: TObject); procedure FindComponentClass({%H-}AReader: TReader; const AClassName: String; var AClass: TComponentClass); function GetPageIndexOfNode(ANode: TTreeNode): Integer; @@ -213,6 +214,20 @@ begin end; procedure TChartEditorForm.ApplyButtonClick(Sender: TObject); +var + msg: String; + C: TWinControl; +begin + if not Validate(Tree.Selected, msg, C) then + begin + C.SetFocus; + MessageDlg(msg, mtError, [mbOK], 0); + ModalResult := mrNone; + end else + SaveChartToStream; +end; + (* +procedure TChartEditorForm.CloseButtonClick(Sender: TObject); var msg: String; C: TWinControl; @@ -225,7 +240,7 @@ begin end else RestoreChartFromStream; end; - + *) procedure TChartEditorForm.FormActivate(Sender: TObject); var w: Integer = 0; @@ -318,6 +333,15 @@ begin Tree.Items.EndUpdate; end; + FApplyButton := TBitBtn.Create(ButtonPanel); + FApplyButton.Caption := 'Apply'; + FApplyButton.Images := ChartImagesDM.ChartImages; + FApplyButton.ImageIndex := 7; + FApplyButton.AutoSize := true; + FApplyButton.OnClick := @ApplyButtonClick; + FApplyButton.AnchorSideTop.Control := ButtonPanel.OKButton; + FApplyButton.Parent := ButtonPanel; + AutoSize := true; end; @@ -444,6 +468,7 @@ procedure TChartEditorForm.SaveChartToStream; var i: Integer; begin + FSavedChartStream.Position := 0; WriteComponentAsTextToStream(FSavedChartStream, FChart); for i := 0 to FChart.SeriesCount-1 do WriteComponentAsTextToStream(FSavedSeriesStreams[i], FChart.Series[i]); diff --git a/components/tachart/demo/charteditor/cefontframe.lfm b/components/tachart/demo/charteditor/cefontframe.lfm index 99ce455f3c..6347787d2d 100644 --- a/components/tachart/demo/charteditor/cefontframe.lfm +++ b/components/tachart/demo/charteditor/cefontframe.lfm @@ -1,4 +1,4 @@ -object FontFrame: TChartFontFrame +object ChartFontFrame: TChartFontFrame Left = 0 Height = 84 Top = 0 @@ -37,7 +37,7 @@ object FontFrame: TChartFontFrame Font.Style = [fsBold] OnChange = cbBoldChange ParentFont = False - TabOrder = 1 + TabOrder = 2 end object cbItalic: TCheckBox AnchorSideLeft.Control = cbBold @@ -52,7 +52,7 @@ object FontFrame: TChartFontFrame Font.Style = [fsItalic] OnChange = cbItalicChange ParentFont = False - TabOrder = 2 + TabOrder = 3 end object cbUnderline: TCheckBox AnchorSideLeft.Control = cbItalic @@ -69,7 +69,7 @@ object FontFrame: TChartFontFrame Font.Style = [fsUnderline] OnChange = cbUnderlineChange ParentFont = False - TabOrder = 3 + TabOrder = 4 end object Panel2: TPanel AnchorSideLeft.Control = Owner @@ -88,7 +88,7 @@ object FontFrame: TChartFontFrame ChildSizing.ControlsPerLine = 3 ClientHeight = 31 ClientWidth = 301 - TabOrder = 4 + TabOrder = 1 object cmbFontSize: TComboBox AnchorSideLeft.Control = Panel2 AnchorSideTop.Side = asrCenter @@ -127,7 +127,6 @@ object FontFrame: TChartFontFrame Width = 31 Caption = 'Angle' FocusControl = seOrientation - ParentColor = False end object seOrientation: TSpinEdit AnchorSideLeft.Control = lblOrientation diff --git a/components/tachart/demo/charteditor/cefontframe.pas b/components/tachart/demo/charteditor/cefontframe.pas index ed11fbe9a4..7bf5bf3747 100644 --- a/components/tachart/demo/charteditor/cefontframe.pas +++ b/components/tachart/demo/charteditor/cefontframe.pas @@ -34,13 +34,11 @@ type FFont: TFont; FOnChange: TNotifyEvent; procedure DoChanged; - public constructor Create(AOwner: TComponent); override; procedure GetData(AFont: TFont); procedure Prepare(AFont: TFont; WithOrientation: boolean); property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; implementation diff --git a/components/tachart/demo/charteditor/celegendframe.lfm b/components/tachart/demo/charteditor/celegendframe.lfm index ef8e247ae5..1e4e344e2a 100644 --- a/components/tachart/demo/charteditor/celegendframe.lfm +++ b/components/tachart/demo/charteditor/celegendframe.lfm @@ -6,8 +6,8 @@ object ChartLegendFrame: TChartLegendFrame ClientHeight = 400 ClientWidth = 671 TabOrder = 0 - DesignLeft = 380 - DesignTop = 303 + DesignLeft = 1101 + DesignTop = 368 object PanelTop: TPanel Left = 0 Height = 23 @@ -37,18 +37,30 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = cbShow AnchorSideRight.Side = asrBottom - Left = 65 + Left = 81 Height = 19 Top = 0 Width = 87 - Alignment = taLeftJustify - BorderSpacing.Left = 16 + BorderSpacing.Left = 32 Caption = 'Outside axes' Checked = True OnChange = cbUseSideBarChange State = cbChecked TabOrder = 1 end + object cbHTML: TCheckBox + AnchorSideLeft.Control = cbUseSideBar + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PanelTop + Left = 200 + Height = 19 + Top = 0 + Width = 181 + BorderSpacing.Left = 32 + Caption = 'Support HTML in legend items' + OnChange = cbHTMLChange + TabOrder = 2 + end end object ParamsPanel: TPanel Left = 0 @@ -56,7 +68,6 @@ object ChartLegendFrame: TChartLegendFrame Top = 31 Width = 671 Align = alClient - AutoSize = True BevelOuter = bvNone ClientHeight = 369 ClientWidth = 671 @@ -65,94 +76,33 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideLeft.Control = gbAlignment AnchorSideTop.Control = gbAlignment AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Background_Border_Spacer AnchorSideBottom.Side = asrBottom Left = 0 - Height = 83 + Height = 72 Top = 128 - Width = 140 + Width = 127 + Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 16 - Caption = 'Background' - ClientHeight = 63 - ClientWidth = 136 + BorderSpacing.Right = 16 + Caption = 'gbBackground' 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 + AnchorSideLeft.Control = Background_Border_Spacer AnchorSideTop.Control = gbAlignment AnchorSideTop.Side = asrBottom - AnchorSideBottom.Control = gbBackground + AnchorSideRight.Control = gbAlignment + AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom - Left = 156 - Height = 83 + Left = 143 + Height = 88 Top = 128 - Width = 140 - Anchors = [akTop, akLeft, akBottom] - BorderSpacing.Left = 16 + Width = 153 + Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 16 - Caption = 'Border' - ClientHeight = 63 - ClientWidth = 136 + Caption = 'gbBorder' 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 @@ -288,36 +238,39 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideRight.Side = asrBottom Left = 0 Height = 83 - Top = 224 - Width = 140 - Anchors = [akTop, akRight] - BorderSpacing.Top = 13 + Top = 216 + Width = 127 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 16 Caption = 'Margins' ClientHeight = 63 - ClientWidth = 136 + ClientWidth = 123 TabOrder = 4 object lblMarginX: TLabel + AnchorSideLeft.Control = gbMargins AnchorSideTop.Control = seMarginX AnchorSideTop.Side = asrCenter AnchorSideRight.Control = seMarginX - Left = 31 + Left = 16 Height = 15 Top = 8 Width = 7 - Anchors = [akTop, akRight] + BorderSpacing.Left = 16 BorderSpacing.Right = 8 Caption = 'X' FocusControl = seMarginX end object seMarginX: TSpinEdit + AnchorSideLeft.Control = lblMarginX + AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = gbMargins AnchorSideRight.Side = asrBottom - Left = 46 + Left = 31 Height = 23 Top = 4 - Width = 74 + Width = 76 Alignment = taRightJustify - Anchors = [akTop, akRight] + Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 4 BorderSpacing.Right = 10 MaxValue = 1000 @@ -326,30 +279,33 @@ object ChartLegendFrame: TChartLegendFrame Value = 1 end object lblMarginY: TLabel + AnchorSideLeft.Control = lblMarginX AnchorSideTop.Control = seMarginY AnchorSideTop.Side = asrCenter AnchorSideRight.Control = seMarginY - Left = 33 + Left = 16 Height = 15 Top = 37 Width = 7 - Anchors = [akTop, akRight] + Anchors = [akTop, akLeft, akRight] BorderSpacing.Right = 8 Caption = 'Y' FocusControl = seMarginY end object seMarginY: TSpinEdit + AnchorSideLeft.Control = seMarginX AnchorSideTop.Control = seMarginX AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = seMarginX AnchorSideRight.Side = asrBottom - Left = 48 + Left = 31 Height = 23 Top = 33 - Width = 74 + Width = 76 Alignment = taRightJustify - Anchors = [akTop, akRight] + Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 6 - BorderSpacing.Right = 10 + BorderSpacing.Bottom = 8 MaxValue = 1000 OnChange = seMarginYChange TabOrder = 1 @@ -358,14 +314,20 @@ object ChartLegendFrame: TChartLegendFrame end object gbItems: TGroupBox AnchorSideLeft.Control = gbFont - AnchorSideTop.Control = gbBackground + AnchorSideTop.Control = gbFont + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbFont + AnchorSideRight.Side = asrBottom Left = 316 - Height = 179 + Height = 165 Top = 128 - Width = 222 + Width = 216 + Anchors = [akTop, akLeft, akRight] + AutoSize = True + BorderSpacing.Top = 16 Caption = 'Items' - ClientHeight = 159 - ClientWidth = 218 + ClientHeight = 145 + ClientWidth = 212 TabOrder = 5 object cbInverted: TCheckBox AnchorSideLeft.Control = gbItems @@ -385,7 +347,7 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = gbItems AnchorSideRight.Side = asrBottom - Left = 114 + Left = 108 Height = 23 Top = 33 Width = 96 @@ -407,7 +369,7 @@ object ChartLegendFrame: TChartLegendFrame Left = 8 Height = 15 Top = 37 - Width = 98 + Width = 92 Anchors = [akTop, akLeft, akRight] BorderSpacing.Right = 8 Caption = 'Columns' @@ -420,8 +382,8 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideRight.Control = cbItemFillOrder Left = 8 Height = 15 - Top = 68 - Width = 98 + Top = 64 + Width = 92 Anchors = [akTop, akLeft, akRight] BorderSpacing.Right = 8 Caption = 'Item fill order' @@ -431,12 +393,12 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = gbItems AnchorSideRight.Side = asrBottom - Left = 114 + Left = 108 Height = 23 - Top = 64 + Top = 60 Width = 96 Anchors = [akTop, akRight] - BorderSpacing.Top = 8 + BorderSpacing.Top = 4 BorderSpacing.Right = 8 ItemHeight = 15 ItemIndex = 0 @@ -453,13 +415,13 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = gbItems AnchorSideRight.Side = asrBottom - Left = 114 + Left = 108 Height = 23 - Top = 95 + Top = 87 Width = 96 Alignment = taRightJustify Anchors = [akTop, akRight] - BorderSpacing.Top = 8 + BorderSpacing.Top = 4 BorderSpacing.Right = 8 MaxValue = 1000 OnChange = seSpacingChange @@ -473,8 +435,8 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideRight.Control = seSpacing Left = 8 Height = 15 - Top = 99 - Width = 98 + Top = 91 + Width = 92 Anchors = [akTop, akLeft, akRight] BorderSpacing.Right = 8 Caption = 'Spacing' @@ -485,14 +447,15 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = gbItems AnchorSideRight.Side = asrBottom - Left = 114 + Left = 108 Height = 23 - Top = 126 + Top = 114 Width = 96 Alignment = taRightJustify Anchors = [akTop, akRight] - BorderSpacing.Top = 8 + BorderSpacing.Top = 4 BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 MaxValue = 1000 OnChange = seSymbolWidthChange TabOrder = 4 @@ -505,13 +468,23 @@ object ChartLegendFrame: TChartLegendFrame AnchorSideRight.Control = seSymbolWidth Left = 8 Height = 15 - Top = 130 - Width = 98 + Top = 118 + Width = 92 Anchors = [akTop, akLeft, akRight] BorderSpacing.Right = 8 Caption = 'Symbol width' FocusControl = seSymbolWidth end end + object Background_Border_Spacer: TBevel + AnchorSideLeft.Control = gbAlignment + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = gbBorder + Left = 143 + Height = 42 + Top = 128 + Width = 10 + Shape = bsSpacer + end end end diff --git a/components/tachart/demo/charteditor/celegendframe.pas b/components/tachart/demo/charteditor/celegendframe.pas index 6c40041884..b26c02a9ca 100644 --- a/components/tachart/demo/charteditor/celegendframe.pas +++ b/components/tachart/demo/charteditor/celegendframe.pas @@ -8,7 +8,7 @@ uses Classes, SysUtils, Graphics, Forms, Controls, ExtCtrls, ColorBox, StdCtrls, Spin, TALegend, TAGraph, - ceFontFrame; + ceFontFrame, ceSimpleBrushFrame, ceSimplePenFrame; type @@ -16,14 +16,12 @@ type TChartLegendFrame = class(TFrame) Bevel1: TBevel; - cbBorderColor: TColorBox; - cbFillColor: TColorBox; - cbFilled: TCheckBox; + Background_Border_Spacer: TBevel; cbInverted: TCheckBox; cbItemFillOrder: TComboBox; cbShow: TCheckBox; - cbShowBorder: TCheckBox; cbUseSideBar: TCheckBox; + cbHTML: TCheckBox; gbAlignment: TGroupBox; gbBackground: TGroupBox; gbBorder: TGroupBox; @@ -51,12 +49,9 @@ type seMarginY: TSpinEdit; seSpacing: TSpinEdit; seSymbolWidth: TSpinEdit; - procedure cbBorderColorChange(Sender: TObject); - procedure cbFillColorChange(Sender: TObject); - procedure cbFilledChange(Sender: TObject); + procedure cbHTMLChange(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); @@ -68,10 +63,13 @@ type private FLegend: TChartLegend; FFontFrame: TChartFontFrame; - procedure ChangedHandler(Sender: TObject); + FBackgroundFrame: TSimpleChartBrushFrame; + FBorderFrame: TSimpleChartPenFrame; function GetAlignment: TLegendAlignment; procedure SetAlignment(AValue: TLegendAlignment); protected + procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; + {%H-}WithThemeSpace: Boolean); override; function GetChart: TChart; public constructor Create(AOwner: TComponent); override; @@ -84,6 +82,8 @@ implementation {$R *.lfm} uses + Math, + TATypes, TAChartUtils, ceUtils; constructor TChartLegendFrame.Create(AOwner: TComponent); @@ -97,30 +97,51 @@ begin FFontFrame.BorderSpacing.Left := 8; FFontFrame.BorderSpacing.Right := 8; FFontFrame.AutoSize := true; - FFontFrame.OnChange := @ChangedHandler; gbFont.AutoSize := true; gbFont.Caption := 'Font'; + FBackgroundFrame := TSimpleChartBrushFrame.Create(self); + FBackgroundFrame.Name := ''; + FBackgroundFrame.Align := alClient; + FBackgroundFrame.BorderSpacing.Left := 8; + FBackgroundFrame.BorderSpacing.Right := 8; + FBackgroundFrame.BorderSpacing.Bottom := 8; + FBackgroundFrame.Parent := gbBackground; + FBackgroundFrame.AutoSize := true; + gbBackground.AutoSize := true; + gbBackground.Caption := 'Background'; + + FBorderFrame := TSimpleChartPenFrame.Create(self); + FBorderFrame.Name := ''; + FBorderFrame.Align := alClient; + FBorderFrame.BorderSpacing.Left := 8; + FBorderFrame.BorderSpacing.Right := 8; + FBorderFrame.BorderSpacing.Bottom := 8; + FBorderFrame.AutoSize := true; + FBorderFrame.Parent := gbBorder; + gbBorder.AutoSize := true; + gbBorder.Caption := 'Border'; + BoldHeaders(Self); end; -procedure TChartLegendFrame.cbBorderColorChange(Sender: TObject); +procedure TChartLegendFrame.CalculatePreferredSize( + var PreferredWidth, PreferredHeight: integer; + WithThemeSpace: Boolean); begin - FLegend.Frame.Color := cbBorderColor.Selected; + PreferredHeight := PanelTop.Height + PanelTop.BorderSpacing.Bottom + + Max( + gbAlignment.Height + gbBackground.Height + gbBackground.BorderSpacing.Top + + gbMargins.Height + gbMargins.Borderspacing.Top, + gbFont.Height + gbItems.Height + gbItems.BorderSpacing.Top + ); + + PreferredWidth := gbAlignment.Width + gbFont.Width + gbFont.BorderSpacing.Left; end; -procedure TChartLegendFrame.cbFilledChange(Sender: TObject); +procedure TChartLegendFrame.cbHTMLChange(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; + FLegend.TextFormat := TEXT_FORMAT[cbHTML.Checked]; end; procedure TChartLegendFrame.cbInvertedChange(Sender: TObject); @@ -137,6 +158,7 @@ procedure TChartLegendFrame.cbShowChange(Sender: TObject); begin FLegend.Visible := cbShow.Checked; cbUseSideBar.Visible := cbShow.Checked; + cbHTML.Visible := cbShow.Checked; gbAlignment.Visible := cbShow.Checked; gbFont.Visible := cbShow.Checked; gbBackground.Visible := cbShow.Checked; @@ -145,53 +167,16 @@ begin 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; @@ -213,6 +198,29 @@ begin FLegend.Alignment := GetAlignment; end; +procedure TChartLegendFrame.Prepare(ALegend: TChartLegend); +begin + FLegend := ALegend; + + cbShow.Checked := ALegend.Visible; + cbHTML.Checked := (ALegend.TextFormat = tfHTML); + SetAlignment(ALegend.Alignment); + + 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); + FBackgroundFrame.Prepare(ALegend.BackgroundBrush); + FBorderFrame.Prepare(ALegend.Frame); +end; + procedure TChartLegendFrame.seColumnsChange(Sender: TObject); begin FLegend.ColumnCount := seColumns.Value; diff --git a/components/tachart/demo/charteditor/cemain.lfm b/components/tachart/demo/charteditor/cemain.lfm index aaa12bfe99..9e781e7a68 100644 --- a/components/tachart/demo/charteditor/cemain.lfm +++ b/components/tachart/demo/charteditor/cemain.lfm @@ -98,7 +98,7 @@ object MainForm: TMainForm Height = 4 Top = 290 Width = 613 - Anchors = [akTop, akLeft, akRight] + Anchors = [akLeft, akRight, akBottom] Shape = bsBottomLine end object cbDoubleClick: TCheckBox diff --git a/components/tachart/demo/charteditor/cemarksform.lfm b/components/tachart/demo/charteditor/cemarksform.lfm new file mode 100644 index 0000000000..36eb3a0980 --- /dev/null +++ b/components/tachart/demo/charteditor/cemarksform.lfm @@ -0,0 +1,198 @@ +object MarksForm: TMarksForm + Left = 983 + Height = 511 + Top = 279 + Width = 535 + AutoSize = True + BorderStyle = bsDialog + Caption = 'MarksForm' + ClientHeight = 511 + ClientWidth = 535 + OnCreate = FormCreate + LCLVersion = '2.3.0.0' + object ButtonPanel: TButtonPanel + Left = 6 + Height = 34 + Top = 471 + Width = 523 + OKButton.Name = 'OKButton' + OKButton.DefaultCaption = True + HelpButton.Name = 'HelpButton' + HelpButton.DefaultCaption = True + CloseButton.Name = 'CloseButton' + CloseButton.DefaultCaption = True + CancelButton.Name = 'CancelButton' + CancelButton.DefaultCaption = True + TabOrder = 1 + ShowButtons = [pbOK, pbCancel] + end + object Panel1: TPanel + Left = 16 + Height = 439 + Top = 16 + Width = 503 + Align = alClient + AutoSize = True + BorderSpacing.Around = 16 + BevelOuter = bvNone + ClientHeight = 439 + ClientWidth = 503 + TabOrder = 0 + object gbShapeBrushPenMargins: TGroupBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = gbLabelFont + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbLabelFont + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 193 + Top = 178 + Width = 272 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 16 + Caption = 'gbShapeBrushPenMargins' + TabOrder = 1 + end + object gbLinkPen: TGroupBox + AnchorSideLeft.Control = gbShapeBrushPenMargins + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Panel1 + AnchorSideRight.Control = gbArrow + AnchorSideRight.Side = asrBottom + Left = 296 + Height = 105 + Top = 0 + Width = 207 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 24 + Caption = 'gbLinkPen' + TabOrder = 2 + end + object gbArrow: TGroupBox + AnchorSideLeft.Control = gbShapeBrushPenMargins + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = gbLinkPen + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Panel1 + AnchorSideRight.Side = asrBottom + Left = 296 + Height = 138 + Top = 121 + Width = 207 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 24 + BorderSpacing.Top = 16 + Caption = 'gbArrow' + TabOrder = 3 + end + object gbLabelFont: TGroupBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = Panel1 + Left = 0 + Height = 162 + Top = 0 + Width = 272 + Caption = 'gbLabelFont' + TabOrder = 0 + end + object gbPosition: TGroupBox + AnchorSideLeft.Control = gbShapeBrushPenMargins + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = gbArrow + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbArrow + AnchorSideRight.Side = asrBottom + Left = 296 + Height = 113 + Top = 275 + Width = 207 + Anchors = [akTop, akLeft, akRight] + AutoSize = True + BorderSpacing.Left = 24 + BorderSpacing.Top = 16 + Caption = 'Position' + ClientHeight = 93 + ClientWidth = 203 + TabOrder = 4 + object lblDistance: TLabel + AnchorSideLeft.Control = gbPosition + AnchorSideTop.Control = seDistance + AnchorSideTop.Side = asrCenter + Left = 16 + Height = 15 + Top = 8 + Width = 45 + BorderSpacing.Left = 16 + Caption = 'Distance' + end + object seDistance: TSpinEdit + AnchorSideLeft.Control = lblDistance + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = gbPosition + AnchorSideRight.Control = gbPosition + AnchorSideRight.Side = asrBottom + Left = 85 + Height = 23 + Top = 4 + Width = 110 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 24 + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 + MaxValue = 1000 + OnChange = seDistanceChange + TabOrder = 0 + end + object lblPosition: TLabel + AnchorSideLeft.Control = lblDistance + AnchorSideTop.Control = cmbMarkPositions + AnchorSideTop.Side = asrCenter + Left = 16 + Height = 15 + Top = 39 + Width = 43 + Caption = 'Position' + end + object cmbMarkPositions: TComboBox + AnchorSideLeft.Control = seDistance + AnchorSideTop.Control = seDistance + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = seDistance + AnchorSideRight.Side = asrBottom + Left = 85 + Height = 23 + Top = 35 + Width = 110 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + BorderSpacing.Bottom = 8 + ItemHeight = 15 + Items.Strings = ( + 'Outside' + 'Positive' + 'Negative' + 'Inside' + ) + OnChange = cmbMarkPositionsChange + TabOrder = 1 + Text = 'cmbMarkPositions' + end + object cbMarksCentered: TCheckBox + AnchorSideLeft.Control = lblPosition + AnchorSideTop.Control = cmbMarkPositions + AnchorSideTop.Side = asrBottom + Left = 16 + Height = 19 + Top = 66 + Width = 112 + BorderSpacing.Top = 6 + BorderSpacing.Bottom = 8 + Caption = 'Position centered' + OnChange = cbMarksCenteredChange + TabOrder = 2 + end + end + end +end diff --git a/components/tachart/demo/charteditor/cemarksform.pas b/components/tachart/demo/charteditor/cemarksform.pas new file mode 100644 index 0000000000..1e842e2000 --- /dev/null +++ b/components/tachart/demo/charteditor/cemarksform.pas @@ -0,0 +1,188 @@ +unit ceMarksForm; + +{$mode ObjFPC}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, StdCtrls, + ExtCtrls, Spin, + TAGraph, TATextElements, TACustomSeries, + ceFontFrame, ceShapeBrushPenMarginsFrame, ceSimplePenFrame, ceArrowFrame; + +type + + { TMarksForm } + + TMarksForm = class(TForm) + ButtonPanel: TButtonPanel; + cbMarksCentered: TCheckBox; + cmbMarkPositions: TComboBox; + gbArrow: TGroupBox; + gbShapeBrushPenMargins: TGroupBox; + gbLinkPen: TGroupBox; + gbLabelFont: TGroupBox; + gbPosition: TGroupBox; + lblPosition: TLabel; + lblDistance: TLabel; + Panel1: TPanel; + seDistance: TSpinEdit; + procedure cbMarksCenteredChange(Sender: TObject); + procedure cmbMarkPositionsChange(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure seDistanceChange(Sender: TObject); + private + FSeries: TChartSeries; + FShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame; + FLinkPenFrame: TSimpleChartPenFrame; + FFontFrame: TChartFontFrame; + FArrowFrame: TChartArrowFrame; + function GetChart: TChart; + procedure ShapeChangedHandler(AShape: TChartLabelShape); + + public + procedure Prepare(ASeries: TChartSeries); + + end; + +var + MarksForm: TMarksForm; + +implementation + +{$R *.lfm} + +uses + TASeries, + ceUtils; + + +{ TMarksForm } + +procedure TMarksForm.cbMarksCenteredChange(Sender: TObject); +begin + if (FSeries is TBarSeries) then + TBarSeries(FSeries).MarkPositionCentered := cbMarksCentered.Checked; +end; + +procedure TMarksForm.cmbMarkPositionsChange(Sender: TObject); +begin + if (FSeries is TLineSeries) then + TLineSeries(FSeries).MarkPositions := TLinearMarkPositions(cmbMarkPositions.ItemIndex) + else if (FSeries is TAreaSeries) then + TAreaSeries(FSeries).MarkPositions := TLinearMarkPositions(cmbMarkPositions.ItemIndex) + else if (FSeries is TBarSeries) then + TBarSeries(FSeries).MarkPositions := TLinearMarkPositions(cmbMarkPositions.ItemIndex) + else + raise Exception.Create('Series type not supported.'); +end; + +procedure TMarksForm.FormCreate(Sender: TObject); +begin + FFontFrame := TChartFontFrame.Create(self); + FFontFrame.Name := ''; + FFontFrame.Align := alClient; + FFontFrame.BorderSpacing.Left := 16; + FFontFrame.BorderSpacing.Right := 8; + FFontFrame.BorderSpacing.Bottom := 8; + FFontFrame.AutoSize := true; + FFontFrame.Parent := gbLabelFont; + gbLabelFont.AutoSize := true; + gbLabelFont.Caption := 'Marks font'; + + FShapeBrushPenMarginsFrame := TChartShapeBrushPenMarginsFrame.Create(self); + FShapeBrushPenMarginsFrame.Name := ''; + FShapeBrushPenMarginsFrame.Align := alClient; + FShapeBrushPenMarginsFrame.BorderSpacing.Left := 16; + FShapeBrushPenMarginsFrame.BorderSpacing.Right := 8; + FShapeBrushPenMarginsFrame.BorderSpacing.Bottom := 8; +// FShapeBrushPenMarginsFrame.OnChange := @ChangedHandler; + FShapeBrushPenMarginsFrame.OnShapeChange := @ShapeChangedHandler; + FShapeBrushPenMarginsFrame.AutoSize := true; + FShapeBrushPenMarginsFrame.Parent := gbShapeBrushPenMargins; + gbShapeBrushPenMargins.AutoSize := true; + gbShapeBrushPenMargins.Caption := 'Marks shape and background'; + + FLinkPenFrame := TSimpleChartPenFrame.Create(self); + FLinkPenFrame.Name := ''; + FLinkPenFrame.Align := alClient; + FLinkPenFrame.BorderSpacing.Left := 16; + FLinkPenFrame.BorderSpacing.Right := 8; + FLinkPenFrame.BorderSpacing.Bottom := 8; + FLinkPenFrame.AutoSize := true; + FLinkPenFrame.Parent := gbLinkPen; + gbLinkPen.AutoSize := true; + gbLinkPen.Caption := 'Link line'; + + FArrowFrame := TChartArrowFrame.Create(self); + FArrowFrame.Name := ''; + FArrowFrame.Align := alClient; + FArrowFrame.BorderSpacing.Left := 16; + FArrowFrame.BorderSpacing.Right := 8; + FArrowFrame.BorderSpacing.Bottom := 8; + FArrowFrame.AutoSize := true; + FArrowFrame.Parent := gbArrow; + gbArrow.AutoSize := true; + gbArrow.Caption := 'Arrow'; + + AutoSize := true; + + BoldHeaders(self); +end; + +function TMarksForm.GetChart: TChart; +begin + Result := FSeries.ParentChart; +end; + +procedure TMarksForm.Prepare(ASeries: TChartSeries); +begin + FSeries := ASeries; + + with ASeries.Marks do + begin + FFontFrame.Prepare(LabelFont, true); + FShapeBrushPenMarginsFrame.Prepare(Shape, LabelBrush, Frame, Margins); + FLinkPenFrame.Prepare(LinkPen); + FArrowFrame.Prepare(Arrow); + end; + + seDistance.Value := ASeries.Marks.Distance; + if ASeries is TLineSeries then + begin + cmbMarkPositions.ItemIndex := ord(TLineSeries(ASeries).MarkPositions); + cbMarksCentered.Hide; + end else + if ASeries is TBarSeries then + begin + cmbMarkPositions.ItemIndex := ord(TBarSeries(ASeries).MarkPositions); + cbMarksCentered.Checked := TBarSeries(ASeries).MarkPositionCentered; + end else + if ASeries is TAreaSeries then + begin + cmbMarkPositions.ItemIndex := ord(TAreaSeries(ASeries).MarkPositions); + cbMarksCentered.Hide; + end else + begin + cmbMarkPositions.Hide; + lblPosition.Hide; + cbMarksCentered.Hide; + end; + + FLinkPenFrame.WidthLeft := FArrowFrame.seArrowBaseLength.Left; + seDistance.BorderSpacing.Left := FArrowFrame.Left + + FArrowFrame.seArrowBaseLength.Left - lblDistance.Width; +end; + +procedure TMarksForm.seDistanceChange(Sender: TObject); +begin + FSeries.Marks.Distance := seDistance.Value; +end; + +procedure TMarksForm.ShapeChangedHandler(AShape: TChartLabelShape); +begin + FSeries.Marks.Shape := AShape; +end; + +end. + diff --git a/components/tachart/demo/charteditor/cepenframe.lfm b/components/tachart/demo/charteditor/cepenframe.lfm index 2c7ce5a1d3..65f918fb06 100644 --- a/components/tachart/demo/charteditor/cepenframe.lfm +++ b/components/tachart/demo/charteditor/cepenframe.lfm @@ -1,11 +1,11 @@ -object PenFrame: TChartPenFrame +object ChartPenFrame: TChartPenFrame Left = 0 Height = 56 Top = 0 - Width = 212 + Width = 214 AutoSize = True ClientHeight = 56 - ClientWidth = 212 + ClientWidth = 214 TabOrder = 0 DesignLeft = 332 DesignTop = 128 @@ -17,7 +17,7 @@ object PenFrame: TChartPenFrame Left = 48 Height = 22 Top = 0 - Width = 128 + Width = 130 PenPattern = '1|1' PointerStyle = psNone Anchors = [akTop, akLeft, akRight] @@ -36,7 +36,6 @@ object PenFrame: TChartPenFrame Top = 4 Width = 25 Caption = 'Style' - ParentColor = False end object cbPenWidth: TChartComboBox AnchorSideLeft.Control = lblPenWidth @@ -47,7 +46,7 @@ object PenFrame: TChartPenFrame Left = 48 Height = 22 Top = 30 - Width = 128 + Width = 130 Mode = ccmPenWidth PenPattern = '1|1' PointerStyle = psNone @@ -67,7 +66,6 @@ object PenFrame: TChartPenFrame Top = 34 Width = 32 Caption = 'Width' - ParentColor = False end object cbPenColor: TColorButton AnchorSideLeft.Side = asrBottom @@ -75,7 +73,7 @@ object PenFrame: TChartPenFrame AnchorSideTop.Side = asrCenter AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom - Left = 181 + Left = 183 Height = 25 Top = 14 Width = 31 @@ -91,7 +89,7 @@ object PenFrame: TChartPenFrame AnchorSideRight.Control = cbPenColor AnchorSideBottom.Control = cbPenWidth AnchorSideBottom.Side = asrBottom - Left = 176 + Left = 178 Height = 52 Top = 0 Width = 5 diff --git a/components/tachart/demo/charteditor/cepenframe.pas b/components/tachart/demo/charteditor/cepenframe.pas index c53faeb738..55a0e0f9dd 100644 --- a/components/tachart/demo/charteditor/cepenframe.pas +++ b/components/tachart/demo/charteditor/cepenframe.pas @@ -26,12 +26,10 @@ type FPen: TPen; FOnChange: TNotifyEvent; procedure DoChanged; - public constructor Create(AOwner: TComponent); override; procedure Prepare(APen: TPen); property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; implementation diff --git a/components/tachart/demo/charteditor/cepointerframe.pas b/components/tachart/demo/charteditor/cepointerframe.pas index 451d1bf065..f6a5160274 100644 --- a/components/tachart/demo/charteditor/cepointerframe.pas +++ b/components/tachart/demo/charteditor/cepointerframe.pas @@ -32,7 +32,6 @@ type procedure DoChange; protected function GetChart: TChart; - public constructor Create(AOwner: TComponent); override; procedure Prepare(APointer: TSeriesPointer); diff --git a/components/tachart/demo/charteditor/ceseriesframe.lfm b/components/tachart/demo/charteditor/ceseriesframe.lfm index 8ad2a8adbb..791784b1b1 100644 --- a/components/tachart/demo/charteditor/ceseriesframe.lfm +++ b/components/tachart/demo/charteditor/ceseriesframe.lfm @@ -10,14 +10,14 @@ object ChartSeriesFrame: TChartSeriesFrame DesignTop = 344 object PanelTop: TPanel Left = 0 - Height = 134 + Height = 142 Top = 0 Width = 589 Align = alTop AutoSize = True BorderSpacing.Bottom = 12 BevelOuter = bvNone - ClientHeight = 134 + ClientHeight = 142 ClientWidth = 589 TabOrder = 0 object cbShowSeries: TCheckBox @@ -37,14 +37,16 @@ object ChartSeriesFrame: TChartSeriesFrame AnchorSideTop.Control = cbShowSeries AnchorSideTop.Side = asrBottom AnchorSideRight.Control = Bevel4 + AnchorSideBottom.Control = gbMarks + AnchorSideBottom.Side = asrBottom Left = 0 - Height = 109 + Height = 117 Top = 25 Width = 286 - Anchors = [akTop, akLeft, akRight] + Anchors = [akTop, akLeft, akRight, akBottom] AutoSize = True - Caption = 'Legend text' - ClientHeight = 89 + Caption = 'Legend text (Series title)' + ClientHeight = 97 ClientWidth = 282 TabOrder = 1 object edSeriesTitle: TEdit @@ -71,14 +73,14 @@ object ChartSeriesFrame: TChartSeriesFrame Left = 8 Height = 19 Top = 33 - Width = 101 + Width = 133 BorderSpacing.Top = 6 - Caption = 'Show in legend' + Caption = 'Show series in legend' OnChange = cbShowInLegendChange TabOrder = 1 end - object cbLegendMultiplicity: TComboBox - AnchorSideLeft.Control = Label1 + object cmbLegendMultiplicity: TComboBox + AnchorSideLeft.Control = lblLegendItems AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = cbShowInLegend AnchorSideTop.Side = asrBottom @@ -95,42 +97,42 @@ object ChartSeriesFrame: TChartSeriesFrame ItemHeight = 15 ItemIndex = 0 Items.Strings = ( - 'single item per series' - 'marks text per data point' + 'Series title' + 'Marks text per data point' ) - OnChange = cbLegendMultiplicityChange + OnChange = cmbLegendMultiplicityChange Style = csDropDownList TabOrder = 2 - Text = 'single item per series' + Text = 'Series title' end - object Label1: TLabel + object lblLegendItems: TLabel AnchorSideLeft.Control = edSeriesTitle - AnchorSideTop.Control = cbLegendMultiplicity + AnchorSideTop.Control = cmbLegendMultiplicity AnchorSideTop.Side = asrCenter Left = 8 Height = 15 Top = 62 Width = 71 Caption = 'Legend items' - ParentColor = False end end object gbMarks: TGroupBox AnchorSideLeft.Control = Bevel4 AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = gbLegendText + AnchorSideTop.Control = cbShowSeries + AnchorSideTop.Side = asrBottom AnchorSideRight.Control = PanelTop AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = gbLegendText AnchorSideBottom.Side = asrBottom Left = 302 - Height = 109 + Height = 117 Top = 25 Width = 287 - Anchors = [akTop, akLeft, akRight, akBottom] + Anchors = [akTop, akLeft, akRight] AutoSize = True Caption = 'Marks' - ClientHeight = 89 + ClientHeight = 97 ClientWidth = 283 TabOrder = 2 object lblSeriesMarksStyle: TLabel @@ -143,7 +145,6 @@ object ChartSeriesFrame: TChartSeriesFrame Width = 25 BorderSpacing.Left = 8 Caption = 'Style' - ParentColor = False end object cbMarksStyle: TComboBox AnchorSideLeft.Control = edMarksFormat @@ -186,7 +187,6 @@ object ChartSeriesFrame: TChartSeriesFrame Top = 37 Width = 38 Caption = 'Format' - ParentColor = False end object edMarksFormat: TEdit AnchorSideLeft.Control = Label2 @@ -208,18 +208,35 @@ object ChartSeriesFrame: TChartSeriesFrame Text = 'edMarksFormat' end object cbShowMarks: TCheckBox - AnchorSideLeft.Control = edMarksFormat - AnchorSideTop.Control = edMarksFormat - AnchorSideTop.Side = asrBottom - Left = 54 + AnchorSideLeft.Control = lblSeriesMarksStyle + AnchorSideTop.Control = btnMore + AnchorSideTop.Side = asrCenter + Left = 8 Height = 19 - Top = 62 + Top = 67 Width = 156 BorderSpacing.Top = 6 Caption = 'Show at series data points' OnChange = cbShowMarksChange TabOrder = 2 end + object btnMore: TButton + AnchorSideTop.Control = edMarksFormat + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbMarks + AnchorSideRight.Side = asrBottom + Left = 212 + Height = 25 + Top = 64 + Width = 63 + Anchors = [akTop, akRight] + AutoSize = True + BorderSpacing.Around = 8 + Caption = 'More...' + Enabled = False + OnClick = btnMoreClick + TabOrder = 3 + end end object Bevel4: TBevel AnchorSideLeft.Control = PanelTop @@ -233,8 +250,8 @@ object ChartSeriesFrame: TChartSeriesFrame end object nbSeriesTypes: TNotebook Left = 0 - Height = 313 - Top = 146 + Height = 305 + Top = 154 Width = 589 PageIndex = 0 Align = alClient @@ -273,12 +290,12 @@ object ChartSeriesFrame: TChartSeriesFrame AnchorSideRight.Control = pgLineSeries AnchorSideRight.Side = asrBottom Left = 302 - Height = 240 + Height = 88 Top = 0 Width = 287 Anchors = [akTop, akLeft, akRight] Caption = 'gbLineSeriesPointer' - ClientHeight = 220 + ClientHeight = 68 ClientWidth = 283 TabOrder = 1 object cbLineSeriesShowPoints: TCheckBox diff --git a/components/tachart/demo/charteditor/ceseriesframe.pas b/components/tachart/demo/charteditor/ceseriesframe.pas index 7b8c43d267..894ea14fd5 100644 --- a/components/tachart/demo/charteditor/ceseriesframe.pas +++ b/components/tachart/demo/charteditor/ceseriesframe.pas @@ -18,10 +18,11 @@ type Bevel2: TBevel; Bevel3: TBevel; Bevel4: TBevel; + btnMore: TButton; cbAreaShowContourLines: TCheckBox; cbAreaShowDropLines: TCheckBox; cbBarShape: TComboBox; - cbLegendMultiplicity: TComboBox; + cmbLegendMultiplicity: TComboBox; cbLineSeriesShowLines: TCheckBox; cbLineSeriesShowPoints: TCheckBox; cbMarksStyle: TComboBox; @@ -40,7 +41,7 @@ type gbLineSeriesLineStyle: TGroupBox; gbLineSeriesPointer: TGroupBox; gbMarks: TGroupBox; - Label1: TLabel; + lblLegendItems: TLabel; Label2: TLabel; lblSeriesMarksStyle: TLabel; nbSeriesTypes: TNotebook; @@ -48,10 +49,11 @@ type pgAreaSeries: TPage; pgBarSeries: TPage; pgLineSeries: TPage; + procedure btnMoreClick(Sender: TObject); procedure cbAreaShowContourLinesChange(Sender: TObject); procedure cbAreaShowDropLinesChange(Sender: TObject); procedure cbBarShapeChange(Sender: TObject); - procedure cbLegendMultiplicityChange(Sender: TObject); + procedure cmbLegendMultiplicityChange(Sender: TObject); procedure cbLineSeriesShowLinesChange(Sender: TObject); procedure cbLineSeriesShowPointsChange(Sender: TObject); procedure cbMarksStyleChange(Sender: TObject); @@ -85,8 +87,8 @@ implementation {$R *.lfm} uses - ceUtils, - TAChartUtils, TALegend; + TAChartUtils, TALegend, + ceUtils, ceMarksForm; constructor TChartSeriesFrame.Create(AOwner: TComponent); begin @@ -176,7 +178,7 @@ begin { for all } BoldHeaders(self); - cbLegendMultiplicity.DropdownCount := DEFAULT_DROPDOWN_COUNT; + cmbLegendMultiplicity.DropdownCount := DEFAULT_DROPDOWN_COUNT; cbMarksStyle.DropdownCount := DEFAULT_DROPDOWN_COUNT; end; @@ -187,6 +189,30 @@ begin TAreaSeries(FSeries).AreaContourPen.Style := FAreaSeriesContourPenFrame.cbPenStyle.PenStyle else TAreaSeries(FSeries).AreaContourPen.Style := psClear; + FAreaSeriesContourPenFrame.Enabled := cbAreaShowContourLines.Checked; + end; +end; + +procedure TChartSeriesFrame.btnMoreClick(Sender: TObject); +var + F: TMarksForm; + ser: TBasicChartSeries; +begin + if not (FSeries is TChartSeries) then + exit; + + F := TMarksForm.Create(GetParentForm(self)); + try + ser := TSeriesClass(FSeries.ClassType).Create(nil); + ser.Assign(FSeries); + + F.Prepare(TChartSeries(FSeries)); + F.Position := poOwnerFormCenter; + if F.ShowModal <> mrOK then + FSeries.Assign(ser); + finally + ser.Free; + F.Free; end; end; @@ -197,6 +223,7 @@ begin TAreaSeries(FSeries).AreaLinesPen.Style := FAreaSeriesDropLinesPenFrame.cbPenStyle.PenStyle else TAreaSeries(FSeries).AreaLinesPen.Style := psClear; + FAreaSeriesDropLinesPenFrame.Enabled := cbAreaShowDropLines.Checked; end; end; @@ -206,21 +233,25 @@ begin TBarSeries(FSeries).BarShape := TBarShape(cbBarShape.ItemIndex); end; -procedure TChartSeriesFrame.cbLegendMultiplicityChange(Sender: TObject); +procedure TChartSeriesFrame.cmbLegendMultiplicityChange(Sender: TObject); begin - (FSeries as TCustomChartSeries).Legend.Multiplicity := TLegendMultiplicity(cbLegendMultiplicity.ItemIndex); + (FSeries as TCustomChartSeries).Legend.Multiplicity := TLegendMultiplicity(cmbLegendMultiplicity.ItemIndex); end; procedure TChartSeriesFrame.cbLineSeriesShowLinesChange(Sender: TObject); begin if FSeries is TLineSeries then + begin TLineSeries(FSeries).ShowLines := cbLineSeriesShowLines.Checked; + FLineSeriesPenFrame.Enabled := cbLineSeriesShowLines.Checked; + end; end; procedure TChartSeriesFrame.cbLineSeriesShowPointsChange(Sender: TObject); begin if FSeries is TLineSeries then TLineSeries(FSeries).ShowPoints := cbLineSeriesShowPoints.Checked; + FLineSeriesPointerFrame.Enabled := cbLineSeriesShowPoints.Checked; end; procedure TChartSeriesFrame.cbMarksStyleChange(Sender: TObject); @@ -231,23 +262,32 @@ begin series := TChartSeries(FSeries); series.Marks.Style := TSeriesMarksStyle(cbMarksStyle.ItemIndex); edMarksFormat.Text := series.Marks.Format; + btnMore.Enabled := (series.Marks.Style <> smsNone) and cbShowMarks.Checked; end; end; procedure TChartSeriesFrame.cbShowInLegendChange(Sender: TObject); begin (FSeries as TCustomChartSeries).Legend.Visible := cbShowInLegend.Checked; + lblLegendItems.Enabled := cbShowInLegend.Checked; + cmbLegendMultiplicity.Enabled := cbShowInLegend.Checked; end; procedure TChartSeriesFrame.cbShowMarksChange(Sender: TObject); begin if (FSeries is TChartSeries) then + begin TChartSeries(FSeries).Marks.Visible := cbShowMarks.Checked; + btnMore.Enabled := (TChartSeries(FSeries).Marks.Style <> smsNone) and cbShowMarks.Checked; + end; end; procedure TChartSeriesFrame.cbShowSeriesChange(Sender: TObject); begin FSeries.Active := cbShowSeries.Checked; + gbLegendText.Visible := cbShowSeries.Checked; + gbMarks.Visible := cbShowSeries.Checked; + nbSeriesTypes.Visible := cbShowSeries.Checked; end; procedure TChartSeriesFrame.ChangedHandler(Sender: TObject); @@ -285,7 +325,7 @@ begin cbShowSeries.Checked := series.Active; cbShowInLegend.Checked := series.Legend.Visible; edSeriesTitle.Text := series.Title; - cbLegendMultiplicity.ItemIndex := ord(series.Legend.Multiplicity); + cmbLegendMultiplicity.ItemIndex := ord(series.Legend.Multiplicity); gbMarks.Visible := (FSeries is TChartSeries); if (FSeries is TChartSeries) then begin @@ -317,6 +357,7 @@ begin FAreaSeriesContourPenFrame.Prepare(TAreaSeries(ASeries).AreaContourPen); FAreaSeriesDropLinesPenFrame.Prepare(TAreaSeries(ASeries).AreaLinesPen); end; + end; end. diff --git a/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.lfm b/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.lfm index 5fba39c952..b45a23356b 100644 --- a/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.lfm +++ b/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.lfm @@ -2,9 +2,9 @@ object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame Left = 0 Height = 237 Top = 0 - Width = 227 + Width = 276 ClientHeight = 237 - ClientWidth = 227 + ClientWidth = 276 TabOrder = 0 DesignLeft = 1498 DesignTop = 388 @@ -17,7 +17,7 @@ object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame Left = 0 Height = 23 Top = 0 - Width = 227 + Width = 276 Anchors = [akTop, akLeft, akRight] Enabled = False ItemHeight = 15 @@ -37,137 +37,62 @@ object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame AnchorSideLeft.Control = Owner AnchorSideTop.Control = cmbShape AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Spacer AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = gbBorder AnchorSideBottom.Side = asrBottom Left = 0 - Height = 54 + Height = 73 Top = 31 - Width = 106 - Anchors = [akTop, akLeft, akRight] + Width = 83 + Anchors = [akTop, akLeft, akBottom] AutoSize = True BorderSpacing.Top = 8 BorderSpacing.Right = 8 Caption = 'Background' - ClientHeight = 34 - ClientWidth = 102 TabOrder = 1 - object cbFilled: TCheckBox - AnchorSideLeft.Control = gbBackground - AnchorSideTop.Control = cbFillColor - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = cbFillColor - Left = 10 - Height = 19 - Top = 3 - Width = 44 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Left = 10 - BorderSpacing.Top = 6 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 12 - Caption = 'Filled' - OnChange = cbFilledChange - TabOrder = 0 - end - object cbFillColor: TColorButton - AnchorSideTop.Control = gbBackground - AnchorSideRight.Control = gbBackground - AnchorSideRight.Side = asrBottom - Left = 62 - Height = 25 - Top = 0 - Width = 32 - Anchors = [akTop, akRight] - BorderSpacing.Left = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - BorderWidth = 2 - ButtonColorSize = 16 - ButtonColor = clBlack - Margin = 2 - Visible = False - OnColorChanged = cbFillColorColorChanged - end end object gbBorder: TGroupBox - AnchorSideLeft.Control = Spacer - AnchorSideTop.Control = gbBackground + AnchorSideLeft.Control = gbBackground + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cmbShape + AnchorSideTop.Side = asrBottom AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = gbBackground AnchorSideBottom.Side = asrBottom - Left = 121 - Height = 54 + Left = 91 + Height = 73 Top = 31 - Width = 106 - Anchors = [akTop, akLeft, akRight, akBottom] - AutoSize = True + Width = 185 + Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 + BorderSpacing.Top = 8 Caption = 'Border' - ClientHeight = 34 - ClientWidth = 102 TabOrder = 2 - object cbShowBorder: TCheckBox - AnchorSideLeft.Control = gbBorder - AnchorSideTop.Control = cbBorderColor - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = cbBorderColor - Left = 10 - Height = 19 - Top = 3 - Width = 50 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Left = 10 - BorderSpacing.Top = 6 - BorderSpacing.Bottom = 12 - Caption = 'Visible ' - OnChange = cbShowBorderChange - TabOrder = 0 - end - object cbBorderColor: TColorButton - AnchorSideTop.Control = gbBorder - AnchorSideRight.Control = gbBorder - AnchorSideRight.Side = asrBottom - Left = 64 - Height = 25 - Top = 0 - Width = 30 - Anchors = [akTop, akRight] - BorderSpacing.Left = 4 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - BorderWidth = 2 - ButtonColorSize = 16 - ButtonColor = clBlack - Margin = 2 - Visible = False - OnColorChanged = cbBorderColorColorChanged - end end object gbMargins: TGroupBox AnchorSideLeft.Control = gbBackground AnchorSideTop.Control = gbBackground AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = gbBorder + AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom Left = 0 Height = 97 - Top = 93 - Width = 227 + Top = 112 + Width = 276 Anchors = [akTop, akLeft, akRight] AutoSize = True BorderSpacing.Top = 8 Caption = 'Margins' ClientHeight = 77 - ClientWidth = 223 + ClientWidth = 272 TabOrder = 3 object seTopMargin: TSpinEdit AnchorSideLeft.Control = gbMargins AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = gbMargins - Left = 86 + Left = 111 Height = 23 Top = 0 Width = 50 @@ -180,7 +105,7 @@ object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame AnchorSideTop.Control = seTopMargin AnchorSideTop.Side = asrBottom AnchorSideRight.Control = seTopMargin - Left = 28 + Left = 53 Height = 23 Top = 23 Width = 50 @@ -197,7 +122,7 @@ object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = seTopMargin AnchorSideTop.Side = asrBottom - Left = 144 + Left = 169 Height = 23 Top = 23 Width = 50 @@ -215,7 +140,7 @@ object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = gbMargins AnchorSideBottom.Side = asrBottom - Left = 86 + Left = 111 Height = 23 Top = 46 Width = 50 @@ -226,15 +151,4 @@ object ChartShapeBrushPenMarginsFrame: TChartShapeBrushPenMarginsFrame TabOrder = 3 end end - object Spacer: TBevel - AnchorSideLeft.Control = cmbShape - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = cmbShape - AnchorSideTop.Side = asrBottom - Left = 113 - Height = 50 - Top = 23 - Width = 1 - Shape = bsSpacer - end end diff --git a/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.pas b/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.pas index d5ecb43a46..26cc403355 100644 --- a/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.pas +++ b/components/tachart/demo/charteditor/ceshapebrushpenmarginsframe.pas @@ -6,7 +6,8 @@ interface uses Classes, SysUtils, Graphics, Forms, Controls, StdCtrls, Dialogs, Spin, ExtCtrls, - TATypes, TATextElements; + TATypes, TATextElements, + ceSimplePenFrame, ceSimpleBrushFrame; type @@ -15,11 +16,6 @@ type { TChartShapeBrushPenMarginsFrame } TChartShapeBrushPenMarginsFrame = class(TFrame) - Spacer: TBevel; - cbBorderColor: TColorButton; - cbFillColor: TColorButton; - cbFilled: TCheckBox; - cbShowBorder: TCheckBox; cmbShape: TComboBox; gbBackground: TGroupBox; gbBorder: TGroupBox; @@ -28,10 +24,6 @@ type seLeftMargin: TSpinEdit; seRightMargin: TSpinEdit; seTopMargin: TSpinEdit; - procedure cbBorderColorColorChanged(Sender: TObject); - procedure cbFillColorColorChanged(Sender: TObject); - procedure cbFilledChange(Sender: TObject); - procedure cbShowBorderChange(Sender: TObject); procedure cmbShapeChange(Sender: TObject); procedure seBottomMarginChange(Sender: TObject); procedure seLeftMarginChange(Sender: TObject); @@ -45,9 +37,11 @@ type FMargins: TChartLabelMargins; FShape: TChartLabelShape; FLockEvents: Integer; - procedure DoChanged; + FBrushFrame: TSimpleChartBrushFrame; + FPenFrame: TSimpleChartPenFrame; + procedure ChangeHandler(Sender: TObject); + procedure DoChange; procedure DoShapeChanged(AShape: TChartLabelShape); - procedure UpdateControls; protected procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; {%H-}WithThemeSpace: Boolean); override; @@ -74,9 +68,30 @@ uses constructor TChartShapeBrushPenMarginsFrame.Create(AOwner: TComponent); begin inherited; - cbFillColor.Width := cbFillColor.Height; - cbBorderColor.Width := cbBorderColor.Height; + cmbShape.DropdownCount := DEFAULT_DROPDOWN_COUNT; + + FBrushFrame := TSimpleChartBrushFrame.Create(self); + FBrushFrame.Name := ''; + FBrushFrame.BorderSpacing.Left := 8; + FBrushFrame.BorderSpacing.Right := 8; + FBrushFrame.BorderSpacing.Bottom := 8; + FBrushFrame.Align := alClient; + FBrushFrame.OnChange := @ChangeHandler; + FBrushFrame.AutoSize := true; + gbBackground.AutoSize := true; + FBrushFrame.Parent := gbBackground; + + FPenFrame := TSimpleChartPenFrame.Create(self); + FPenFrame.Name := ''; + FPenFrame.BorderSpacing.Left := 8; + FPenFrame.BorderSpacing.Right := 8; + FPenFrame.BorderSpacing.Bottom := 8; + FPenFrame.Align := alClient; + FPenFrame.OnChange := @ChangeHandler; + FPenFrame.AutoSize := true; + gbBorder.AutoSize := true; + FPenFrame.Parent := gbBorder; end; procedure TChartShapeBrushPenMarginsFrame.CalculatePreferredSize( @@ -84,46 +99,26 @@ procedure TChartShapeBrushPenMarginsFrame.CalculatePreferredSize( WithThemeSpace: Boolean); begin PreferredHeight := cmbShape.Height + - gbBackground.BorderSpacing.Top + gbBackground.Height + + gbBorder.BorderSpacing.Top + gbBorder.Height + gbMargins.BorderSpacing.Top + gbMargins.Height; - PreferredWidth := Max( - Max(gbBackground.Width, gbBorder.Width) * 2 + Spacer.Width, - gbMargins.Width - );; + PreferredWidth := + gbBackground.Width + gbBorder.Width + + Max(gbBackground.BorderSpacing.Right, gbBorder.BorderSpacing.Left); end; -procedure TChartShapeBrushPenMarginsFrame.cbBorderColorColorChanged(Sender: TObject); +procedure TChartShapeBrushPenMarginsFrame.ChangeHandler(Sender: TObject); begin - FPen.Color := cbBorderColor.ButtonColor; -// if FPen.Style <> psClear then - DoChanged; -end; - -procedure TChartShapeBrushPenMarginsFrame.cbFillColorColorChanged(Sender: TObject); -var - bs: TBrushStyle; -begin - bs := FBrush.Style; - FBrush.Color := cbFillColor.ButtonColor; - FBrush.Style := bs; -// if FBrush.Style <> bsClear then - DoChanged; -end; - -procedure TChartShapeBrushPenMarginsFrame.cbFilledChange(Sender: TObject); -begin - if cbFilled.Checked then FBrush.Style := bsSolid else FBrush.Style := bsClear; - UpdateControls; - DoChanged; -end; - -procedure TChartShapeBrushPenMarginsFrame.cbShowBorderChange(Sender: TObject); -begin - FPen.Visible := cbShowBorder.Checked; - if FPen.Visible and (FPen.Style = psClear) then FPen.Style := psSolid; - UpdateControls; - DoChanged; + if FLockEvents = 0 then + begin + if (Sender is TChartPen) then + FPen := TChartPen(Sender) + else if (Sender is TBrush) then + FBrush := TBrush(Sender); + cmbShape.Enabled := FPen.EffVisible or (FBrush.Style <> bsClear); + gbMargins.Enabled := cmbShape.Enabled; + DoChange; + end; end; procedure TChartShapeBrushPenMarginsFrame.cmbShapeChange(Sender: TObject); @@ -131,7 +126,7 @@ begin DoShapeChanged(TChartLabelShape(cmbShape.ItemIndex)); end; -procedure TChartShapeBrushPenMarginsFrame.DoChanged; +procedure TChartShapeBrushPenMarginsFrame.DoChange; begin if (FLockEvents = 0) and Assigned(FOnChange) then FOnChange(Self); @@ -146,25 +141,25 @@ end; procedure TChartShapeBrushPenMarginsFrame.seBottomMarginChange(Sender: TObject); begin FMargins.Bottom := seBottomMargin.Value; - DoChanged; + DoChange; end; procedure TChartShapeBrushPenMarginsFrame.seLeftMarginChange(Sender: TObject); begin FMargins.Left := seLeftMargin.Value; - DoChanged; + DoChange; end; procedure TChartShapeBrushPenMarginsFrame.seRightMarginChange(Sender: TObject); begin FMargins.Right := seRightMargin.Value; - DoChanged; + DoChange; end; procedure TChartShapeBrushPenMarginsFrame.seTopMarginChange(Sender: TObject); begin FMargins.Top := seTopMargin.Value; - DoChanged; + DoChange; end; procedure TChartShapeBrushPenMarginsFrame.GetData(out AShape: TChartLabelShape; @@ -173,11 +168,9 @@ begin AShape := TChartLabelShape(cmbShape.ItemIndex); if HandleAllocated then begin - if cbFilled.Checked then ABrush.Style := bsSolid else ABrush.Style := bsClear; - ABrush.Color := cbFillColor.ButtonColor; - APen.Visible := cbShowBorder.Checked; + FBrushFrame.GetData(ABrush); + FPenFrame.GetData(APen); APen.Style := psSolid; - APen.Color := cbBorderColor.ButtonColor; end; AMargins.Top := seTopMargin.Value; AMargins.Left := seLeftMargin.Value; @@ -189,30 +182,24 @@ procedure TChartShapeBrushPenMarginsFrame.Prepare(AShape: TChartLabelShape; ABrush: TBrush; APen: TChartPen; AMargins: TChartLabelMargins); begin inc(FLockEvents); + FShape := AShape; FBrush := ABrush; FPen := APen; FMargins := AMargins; + cmbShape.ItemIndex := ord(AShape); - cbFilled.Checked := ABrush.Style <> bsClear; - cbFillColor.ButtonColor := ColorToRGB(ABrush.Color); - cbShowBorder.Checked := APen.EffVisible; - if APen.Color = clDefault then - cbBorderColor.ButtonColor := ColorToRGB(clWindowText) - else - cbBorderColor.ButtonColor := ColorToRGB(APen.Color); + cmbShape.Enabled := APen.EffVisible or (ABrush.Style <> bsClear); + gbMargins.Enabled := cmbShape.Enabled; + FBrushFrame.Prepare(ABrush); + FPenFrame.Prepare(APen); seTopMargin.Value := AMargins.Top; seLeftMargin.Value := AMargins.Left; seRightMargin.Value := AMargins.Right; seBottomMargin.Value := AMargins.Bottom; - dec(FLockEvents); -end; -procedure TChartShapeBrushPenMarginsFrame.UpdateControls; -begin - cbBorderColor.Visible := cbShowBorder.Checked; - cmbShape.Enabled := cbShowBorder.Checked or cbFilled.Checked; - cbFillColor.Visible := cbFilled.Checked; + dec(FLockEvents); + end; end. diff --git a/components/tachart/demo/charteditor/cesimplebrushframe.lfm b/components/tachart/demo/charteditor/cesimplebrushframe.lfm new file mode 100644 index 0000000000..19b8df7423 --- /dev/null +++ b/components/tachart/demo/charteditor/cesimplebrushframe.lfm @@ -0,0 +1,44 @@ +object SimpleChartBrushFrame: TSimpleChartBrushFrame + Left = 0 + Height = 151 + Top = 0 + Width = 120 + ClientHeight = 151 + ClientWidth = 120 + TabOrder = 0 + DesignLeft = 275 + DesignTop = 131 + object cbFilled: TCheckBox + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = cbFillColor + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = cbFillColor + Left = 0 + Height = 19 + Top = 3 + Width = 80 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + BorderSpacing.Right = 8 + Caption = 'Filled' + OnChange = cbFilledChange + TabOrder = 0 + end + object cbFillColor: TColorButton + AnchorSideTop.Control = Owner + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 88 + Height = 25 + Top = 0 + Width = 32 + Anchors = [akTop, akRight] + BorderSpacing.Left = 8 + BorderWidth = 2 + ButtonColorSize = 16 + ButtonColor = clBlack + Enabled = False + Margin = 2 + OnColorChanged = cbFillColorColorChanged + end +end diff --git a/components/tachart/demo/charteditor/cesimplebrushframe.pas b/components/tachart/demo/charteditor/cesimplebrushframe.pas new file mode 100644 index 0000000000..68158f5b38 --- /dev/null +++ b/components/tachart/demo/charteditor/cesimplebrushframe.pas @@ -0,0 +1,84 @@ +unit ceSimpleBrushFrame; + +{$mode ObjFPC}{$H+} + +interface + +uses + Classes, SysUtils, Graphics, Forms, Controls, StdCtrls, Dialogs; + +type + + { TSimpleChartBrushFrame } + + TSimpleChartBrushFrame = class(TFrame) + cbFillColor: TColorButton; + cbFilled: TCheckBox; + procedure cbFillColorColorChanged(Sender: TObject); + procedure cbFilledChange(Sender: TObject); + private + FBrush: TBrush; + FOnChange: TNotifyEvent; + FOnVisibleChange: TNotifyEvent; + procedure DoChange; + public + constructor Create(AOwner: TComponent); override; + procedure GetData(ABrush: TBrush); + procedure Prepare(ABrush: TBrush); + property OnChange: TNotifyEvent read FOnChange write FOnChange; + end; + +implementation + +{$R *.lfm} + +constructor TSimpleChartBrushFrame.Create(AOwner: TComponent); +begin + inherited; + cbFillColor.Width := cbFillColor.Height; +end; + +procedure TSimpleChartBrushFrame.cbFillColorColorChanged(Sender: TObject); +var + bs: TBrushStyle; +begin + // Be careful: Setting the Brush.Color switches the Style of a transparent brush + // to solid. --> We store the style to reset it and after changing the color. + bs := FBrush.Style; + FBrush.Color := cbFillColor.ButtonColor; + FBrush.Style := bs; + DoChange; +end; + +procedure TSimpleChartBrushFrame.cbFilledChange(Sender: TObject); +begin + if cbFilled.Checked then FBrush.Style := bsSolid else FBrush.Style := bsClear; + cbFillColor.Enabled := cbFilled.Checked; + DoChange; +end; + +procedure TSimpleChartBrushFrame.DoChange; +begin + if Assigned(FOnChange) then FOnChange(FBrush); +end; + +// Transfers the properties of the GUI elements (or the internal brush) to the +// brush provided as parameter. +procedure TSimpleChartBrushFrame.GetData(ABrush: TBrush); +begin + ABrush.Assign(FBrush); +end; + +// Applies the brush properties to the GUI elements +procedure TSimpleChartBrushFrame.Prepare(ABrush: TBrush); +begin + FBrush := ABrush; + cbFilled.Checked := ABrush.Style <> bsClear; + if ABrush.Color = clDefault then + cbFillColor.ButtonColor := ColorToRGB(clWindow) + else + cbFillColor.ButtonColor := ColorToRGB(ABrush.Color); +end; + +end. + diff --git a/components/tachart/demo/charteditor/cesimplepenframe.lfm b/components/tachart/demo/charteditor/cesimplepenframe.lfm new file mode 100644 index 0000000000..e104aeb799 --- /dev/null +++ b/components/tachart/demo/charteditor/cesimplepenframe.lfm @@ -0,0 +1,79 @@ +object SimpleChartPenFrame: TSimpleChartPenFrame + Left = 0 + Height = 62 + Top = 0 + Width = 120 + ClientHeight = 62 + ClientWidth = 120 + OnResize = FrameResize + TabOrder = 0 + DesignLeft = 620 + DesignTop = 210 + object cbVisible: TCheckBox + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = cbPenColor + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 19 + Top = 3 + Width = 54 + BorderSpacing.Top = 8 + Caption = 'Visible' + OnChange = cbVisibleChange + TabOrder = 0 + end + object cbPenColor: TColorButton + AnchorSideLeft.Control = cbVisible + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Owner + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 70 + Height = 25 + Top = 0 + Width = 30 + BorderSpacing.Left = 16 + BorderSpacing.Bottom = 6 + BorderWidth = 2 + ButtonColorSize = 16 + ButtonColor = clBlack + Enabled = False + Margin = 2 + OnColorChanged = cbPenColorColorChanged + end + object cbPenWidth: TChartComboBox + AnchorSideLeft.Control = lblPenWidth + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cbPenColor + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 40 + Height = 22 + Top = 33 + Width = 80 + Mode = ccmPenWidth + Options = [ccoPatternBrush, ccoPatternPen] + PenPattern = '1|1' + PointerStyle = psNone + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Top = 8 + Enabled = False + ItemHeight = 16 + ItemIndex = 0 + TabOrder = 1 + OnChange = cbPenWidthChange + end + object lblPenWidth: TLabel + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = cbPenWidth + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 37 + Width = 32 + Caption = 'Width' + Enabled = False + end +end diff --git a/components/tachart/demo/charteditor/cesimplepenframe.pas b/components/tachart/demo/charteditor/cesimplepenframe.pas new file mode 100644 index 0000000000..811ca3af84 --- /dev/null +++ b/components/tachart/demo/charteditor/cesimplepenframe.pas @@ -0,0 +1,120 @@ +unit ceSimplePenFrame; + +{$mode ObjFPC}{$H+} + +interface + +uses + Classes, SysUtils, Graphics, Forms, Controls, StdCtrls, Dialogs, + TATypes, TAChartCombos; + +type + + { TSimpleChartPenFrame } + + TSimpleChartPenFrame = class(TFrame) + cbPenColor: TColorButton; + cbVisible: TCheckBox; + cbPenWidth: TChartComboBox; + lblPenWidth: TLabel; + procedure cbPenColorColorChanged(Sender: TObject); + procedure cbPenWidthChange(Sender: TObject); + procedure cbVisibleChange(Sender: TObject); + procedure FrameResize(Sender: TObject); + private + FPen: TChartPen; + FOnChange: TNotifyEvent; + FOnVisibleChange: TNotifyEvent; + procedure DoChange; + function GetWidthLeft: Integer; + procedure SetWidthLeft(const AValue: Integer); + public + constructor Create(AOwner: TComponent); override; + procedure GetData(APen: TChartPen); + procedure Prepare(APen: TChartPen); + property WidthLeft: Integer read GetWidthLeft write SetWidthLeft; + property OnChange: TNotifyEvent read FOnChange write FOnChange; + end; + +implementation + +{$R *.lfm} + +uses + LCLIntf, LCLType; + +{ TSimpleChartPenFrame } + +constructor TSimpleChartPenFrame.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + cbPenWidth.DropdownCount := DEFAULT_DROPDOWN_COUNT; + cbPenColor.Width := cbPenColor.Height; +end; + +procedure TSimpleChartPenFrame.cbPenColorColorChanged(Sender: TObject); +begin + FPen.Color := cbPenColor.ButtonColor; + DoChange; +end; + +procedure TSimpleChartPenFrame.cbPenWidthChange(Sender: TObject); +begin + FPen.Width := cbPenWidth.PenWidth; + DoChange; +end; + +procedure TSimpleChartPenFrame.cbVisibleChange(Sender: TObject); +begin + FPen.Visible := cbVisible.Checked; + if FPen.Visible then FPen.Style := psSolid else FPen.Style := psClear; + cbPenColor.Enabled := cbVisible.Checked; + cbPenWidth.Enabled := cbVisible.Checked; + lblPenWidth.Enabled := cbVisible.Checked; + DoChange; +end; + +procedure TSimpleChartPenFrame.DoChange; +begin + if Assigned(FOnChange) then FOnChange(FPen); +end; + +procedure TSimpleChartPenFrame.FrameResize(Sender: TObject); +begin + cbPenWidth.SymbolWidth := cbPenWidth.ClientWidth - GetSystemMetrics(SM_CXVSCROLL) - 16; +end; + +// Transfers the properties of the GUI elements (or the internal pen) to the pen. +procedure TSimpleChartPenFrame.GetData(APen: TChartPen); +begin + APen.Assign(FPen); +end; + +function TSimpleChartPenFrame.GetWidthLeft: Integer; +begin + Result := cbPenWidth.Left; +end; + +// Applies the pen properties to the GUI elements +procedure TSimpleChartPenFrame.Prepare(APen: TChartPen); +begin + FPen := APen; + cbVisible.Checked := APen.EffVisible; + cbPenWidth.PenWidth := APen.Width; + if APen.Color = clDefault then + cbPenColor.ButtonColor := ColorToRGB(clWindowText) + else + cbPenColor.ButtonColor := ColorToRGB(APen.Color); +end; + +procedure TSimpleChartPenFrame.SetWidthLeft(const AValue: Integer); +var + d: Integer; +begin + d := AValue - lblPenWidth.Width; + if d > 0 then + cbPenWidth.BorderSpacing.Left := d; +end; + +end. + diff --git a/components/tachart/demo/charteditor/cetitlefootframe.lfm b/components/tachart/demo/charteditor/cetitlefootframe.lfm index fc6a560714..ed5d3164b6 100644 --- a/components/tachart/demo/charteditor/cetitlefootframe.lfm +++ b/components/tachart/demo/charteditor/cetitlefootframe.lfm @@ -1,10 +1,10 @@ object ChartTitleFootFrame: TChartTitleFootFrame Left = 0 - Height = 432 + Height = 394 Top = 0 - Width = 423 - ClientHeight = 432 - ClientWidth = 423 + Width = 429 + ClientHeight = 394 + ClientWidth = 429 TabOrder = 0 DesignLeft = 500 DesignTop = 237 @@ -12,12 +12,12 @@ object ChartTitleFootFrame: TChartTitleFootFrame Left = 0 Height = 25 Top = 0 - Width = 423 + Width = 429 Align = alTop AutoSize = True BevelOuter = bvNone ClientHeight = 25 - ClientWidth = 423 + ClientWidth = 429 TabOrder = 0 object cbShow: TCheckBox Left = 0 @@ -44,27 +44,42 @@ object ChartTitleFootFrame: TChartTitleFootFrame OnClick = cbWordwrapClick TabOrder = 1 end + object cbHTML: TCheckBox + AnchorSideLeft.Control = cbWordwrap + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PanelTop + Left = 188 + Height = 19 + Top = 0 + Width = 133 + BorderSpacing.Left = 32 + Caption = 'Support HTML in text' + OnChange = cbHTMLChange + TabOrder = 2 + end end object ParamsPanel: TPanel Left = 0 Height = 187 - Top = 237 - Width = 423 + Top = 199 + Width = 429 Align = alBottom BorderSpacing.Top = 16 BorderSpacing.Bottom = 8 BevelOuter = bvNone ClientHeight = 187 - ClientWidth = 423 + ClientWidth = 429 TabOrder = 2 object rgAlignment: TRadioGroup AnchorSideLeft.Control = ParamsPanel AnchorSideTop.Control = ParamsPanel + AnchorSideRight.Control = Bevel1 AnchorSideBottom.Side = asrBottom Left = 0 Height = 51 Top = 0 - Width = 211 + Width = 202 + Anchors = [akTop, akLeft, akRight] AutoFill = True AutoSize = True Caption = 'Alignment' @@ -78,7 +93,7 @@ object ChartTitleFootFrame: TChartTitleFootFrame ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 3 ClientHeight = 31 - ClientWidth = 207 + ClientWidth = 198 Columns = 3 ItemIndex = 0 Items.Strings = ( @@ -90,19 +105,18 @@ object ChartTitleFootFrame: TChartTitleFootFrame TabOrder = 0 end object gbShapeBrushPenMargins: TGroupBox - AnchorSideLeft.Control = rgAlignment + AnchorSideLeft.Control = Bevel1 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = rgAlignment AnchorSideRight.Control = ParamsPanel AnchorSideRight.Side = asrBottom - Left = 235 + Left = 226 Height = 168 Top = 0 - Width = 188 + Width = 203 Anchors = [akTop, akLeft, akRight] - BorderSpacing.Left = 24 - Caption = 'Title/footer background' - TabOrder = 2 + Caption = 'gbShapeBrushPenMargins' + TabOrder = 3 end object gbFont: TGroupBox AnchorSideLeft.Control = rgAlignment @@ -113,23 +127,78 @@ object ChartTitleFootFrame: TChartTitleFootFrame Left = 0 Height = 61 Top = 67 - Width = 211 + Width = 202 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 16 - Caption = 'Font' + Caption = 'gbFont' TabOrder = 1 end + object Bevel1: TBevel + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = rgAlignment + Left = 202 + Height = 50 + Top = 0 + Width = 24 + Shape = bsSpacer + end + object gbMargin: TGroupBox + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = gbFont + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbFont + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 51 + Top = 144 + Width = 202 + Anchors = [akTop, akLeft, akRight] + AutoSize = True + BorderSpacing.Top = 16 + Caption = 'Distance to chart' + ClientHeight = 31 + ClientWidth = 198 + TabOrder = 2 + object lblMargin: TLabel + AnchorSideLeft.Control = gbMargin + Left = 16 + Height = 15 + Top = 5 + Width = 38 + BorderSpacing.Left = 16 + Caption = 'Margin' + end + object seMargin: TSpinEdit + AnchorSideLeft.Control = lblMargin + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = gbMargin + AnchorSideRight.Control = gbMargin + AnchorSideRight.Side = asrBottom + Left = 70 + Height = 23 + Top = 0 + Width = 72 + Alignment = taRightJustify + BorderSpacing.Left = 16 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 + MaxValue = 1000 + OnChange = seMarginChange + TabOrder = 0 + end + end end object MemoPanel: TPanel AnchorSideTop.Side = asrBottom Left = 0 - Height = 196 + Height = 158 Top = 25 - Width = 423 + Width = 429 Align = alClient BevelOuter = bvNone - ClientHeight = 196 - ClientWidth = 423 + ClientHeight = 158 + ClientWidth = 429 Constraints.MinHeight = 80 TabOrder = 1 object lblText: TLabel @@ -150,14 +219,15 @@ object ChartTitleFootFrame: TChartTitleFootFrame AnchorSideBottom.Control = MemoPanel AnchorSideBottom.Side = asrBottom Left = 0 - Height = 177 + Height = 139 Top = 19 - Width = 423 + Width = 429 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Top = 4 OnChange = mmoTextChange ScrollBars = ssAutoBoth TabOrder = 0 + WordWrap = False end end end diff --git a/components/tachart/demo/charteditor/cetitlefootframe.pas b/components/tachart/demo/charteditor/cetitlefootframe.pas index a97ba7d124..cea60d0733 100644 --- a/components/tachart/demo/charteditor/cetitlefootframe.pas +++ b/components/tachart/demo/charteditor/cetitlefootframe.pas @@ -1,12 +1,11 @@ unit ceTitleFootFrame; {$mode ObjFPC}{$H+} -{.$DEFINE WYSIWYG_TITLE} interface uses - Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls, + Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls, Spin, TATextElements, TAGraph, ceFontFrame, ceShapeBrushPenMarginsFrame; @@ -15,20 +14,27 @@ type { TChartTitleFootFrame } TChartTitleFootFrame = class(TFrame) + Bevel1: TBevel; cbShow: TCheckBox; cbWordwrap: TCheckBox; + cbHTML: TCheckBox; gbFont: TGroupBox; gbShapeBrushPenMargins: TGroupBox; + gbMargin: TGroupBox; + lblMargin: TLabel; lblText: TLabel; MemoPanel: TPanel; mmoText: TMemo; PanelTop: TPanel; ParamsPanel: TPanel; rgAlignment: TRadioGroup; + seMargin: TSpinEdit; + procedure cbHTMLChange(Sender: TObject); procedure cbShowChange(Sender: TObject); procedure cbWordwrapClick(Sender: TObject); procedure mmoTextChange(Sender: TObject); procedure rgAlignmentClick(Sender: TObject); + procedure seMarginChange(Sender: TObject); private FTitle: TChartTitle; FFontFrame: TChartFontFrame; @@ -51,6 +57,7 @@ implementation {$R *.lfm} uses + Math, TAChartUtils, ceUtils; constructor TChartTitleFootFrame.Create(AOwner: TComponent); @@ -58,24 +65,27 @@ begin inherited; FFontFrame := TChartFontFrame.Create(self); - FFontFrame.Parent := gbFont; + FFontFrame.Name := ''; FFontFrame.Align := alClient; FFontFrame.BorderSpacing.Left := 8; FFontFrame.BorderSpacing.Right := 8; FFontFrame.OnChange := @ChangedHandler; + FFontFrame.Parent := gbFont; gbFont.AutoSize := true; + gbFont.Caption := 'Font'; FShapeBrushPenMarginsFrame := TChartShapeBrushPenMarginsFrame.Create(self); - FShapeBrushPenMarginsFrame.Parent := gbShapeBrushPenMargins; + FShapeBrushPenMarginsFrame.Name := ''; 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; + FShapeBrushPenMarginsFrame.Parent := gbShapeBrushPenMargins; gbShapeBrushPenMargins.AutoSize := true; + // Caption of this groupbox depends on title/footer. Will be set by Prepare. BoldHeaders(Self); @@ -90,11 +100,10 @@ begin MemoPanel.Constraints.MinHeight + ParamsPanel.Height + ParamsPanel.BorderSpacing.Top + ParamsPanel.BorderSpacing.Bottom; - PreferredWidth := gbFont.Width + + PreferredWidth := Max(gbFont.Width, rgAlignment.Width) + gbShapeBrushPenMargins.Width + gbShapeBrushPenMargins.BorderSpacing.Left; end; - procedure TChartTitleFootFrame.cbShowChange(Sender: TObject); begin FTitle.Visible := cbShow.Checked; @@ -104,6 +113,13 @@ begin gbShapeBrushPenMargins.Visible := cbShow.Checked; gbFont.Visible := cbShow.Checked; cbWordwrap.Visible := cbShow.Checked; + cbHTML.Visible := cbShow.Checked; + gbMargin.Visible := cbShow.Checked; +end; + +procedure TChartTitleFootFrame.cbHTMLChange(Sender: TObject); +begin + FTitle.TextFormat := TEXT_FORMAT[cbHTML.Checked]; end; procedure TChartTitleFootFrame.cbWordwrapClick(Sender: TObject); @@ -114,10 +130,6 @@ end; procedure TChartTitleFootFrame.ChangedHandler(Sender: TObject); begin GetChart.Invalidate; - {$IFDEF WYSIWYG_TITLE} - mmoText.Font.Assign(FTitle.Font); - mmoText.Color := FTitle.Brush.Color; - {$ENDIF} end; function TChartTitleFootFrame.GetAlignment: TAlignment; @@ -137,27 +149,34 @@ 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; cbWordwrap.Checked := ATitle.Wordwrap; + cbHTML.Checked := (ATitle.TextFormat = tfHTML); + seMargin.Value := ATitle.Margin; mmoText.Lines.Assign(ATitle.Text); - {$IFDEF WYSIWYG_TITLE} - mmoText.Font.Assign(ATitle.Font); - mmoText.Font.Orientation := 0; - {$ENDIF} SetAlignment(ATitle.Alignment); FFontFrame.Prepare(ATitle.Font, false); FShapeBrushPenMarginsFrame.Prepare(ATitle.Shape, ATitle.Brush, ATitle.Frame, ATitle.Margins); + if ATitle = GetChart.Title then + gbShapeBrushPenMargins.Caption := 'Title background' + else + gbShapeBrushPenMargins.Caption := 'Footer background'; +end; + +procedure TChartTitleFootFrame.rgAlignmentClick(Sender: TObject); +begin + FTitle.Alignment := GetAlignment; +end; + +procedure TChartTitleFootFrame.seMarginChange(Sender: TObject); +begin + FTitle.Margin := seMargin.Value; end; procedure TChartTitleFootFrame.SetAlignment(AValue: TAlignment); diff --git a/components/tachart/demo/charteditor/ceutils.pas b/components/tachart/demo/charteditor/ceutils.pas index ab64b36c06..61ffb023fd 100644 --- a/components/tachart/demo/charteditor/ceutils.pas +++ b/components/tachart/demo/charteditor/ceutils.pas @@ -5,10 +5,12 @@ unit ceUtils; interface uses - Graphics, Classes, SysUtils, Controls; + Graphics, Classes, SysUtils, Controls, + TAChartUtils; const DEFAULT_DROPDOWN_COUNT = 32; + TEXT_FORMAT: array[boolean] of TChartTextFormat = (tfNormal, tfHTML); procedure BoldHeaders(AControl: TControl); diff --git a/components/tachart/demo/charteditor/charteditordemo.lpi b/components/tachart/demo/charteditor/charteditordemo.lpi index f3897f390d..dfdc198a5b 100644 --- a/components/tachart/demo/charteditor/charteditordemo.lpi +++ b/components/tachart/demo/charteditor/charteditordemo.lpi @@ -170,6 +170,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/tachart/demo/charteditor/charteditordemo.lpr b/components/tachart/demo/charteditor/charteditordemo.lpr index a9e9f5de8c..4edfebab1a 100644 --- a/components/tachart/demo/charteditor/charteditordemo.lpr +++ b/components/tachart/demo/charteditor/charteditordemo.lpr @@ -8,7 +8,8 @@ uses {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset Forms, ceMain, ceSeriesDlg, cePointerFrame, ceTitleFootFrame, ceAxisFrame, - ceSeriesFrame, ceChartEditor, ceImages; + ceSeriesFrame, ceChartEditor, ceImages, ceSimplePenFrame, ceSimpleBrushFrame, + ceMarksForm, ceArrowFrame; {$R *.res} @@ -18,6 +19,7 @@ begin Application.Initialize; Application.CreateForm(TChartImagesDM, ChartImagesDM); Application.CreateForm(TMainForm, MainForm); + Application.CreateForm(TMarksForm, MarksForm); Application.Run; end. diff --git a/components/tachart/tatextelements.pas b/components/tachart/tatextelements.pas index 622cea013c..8c5ab8369a 100644 --- a/components/tachart/tatextelements.pas +++ b/components/tachart/tatextelements.pas @@ -374,7 +374,11 @@ begin DrawLink(ADrawer, ADataPoint, ALabelCenter); with GetLabelBrush do begin - clr := TColor(IfThen(Color = clDefault, FOwner.Color, Color)); + if Color = clDefault then + begin + if FOwner <> nil then clr := FOwner.Color else clr := clBtnFace; + end else + clr := Color; ADrawer.SetBrushParams(Style, ColorToRGB(clr)); end; if IsMarginRequired then begin