TAChart: Improved layout in Marks form.

This commit is contained in:
wp_xyz 2021-08-05 11:54:59 +02:00
parent 3f78502c54
commit add83f5ee3
4 changed files with 80 additions and 59 deletions

View File

@ -322,37 +322,37 @@ object ChartLegendFrame: TChartLegendFrame
AnchorSideRight.Control = gbFont
AnchorSideRight.Side = asrBottom
Left = 322
Height = 165
Height = 167
Top = 136
Width = 216
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 16
Caption = 'Items'
ClientHeight = 145
ClientHeight = 147
ClientWidth = 212
TabOrder = 5
object cbInverted: TCheckBox
AnchorSideLeft.Control = gbItems
AnchorSideTop.Control = gbItems
AnchorSideTop.Control = seSymbolWidth
AnchorSideTop.Side = asrBottom
Left = 8
Height = 19
Top = 6
Top = 120
Width = 63
BorderSpacing.Left = 8
BorderSpacing.Top = 6
BorderSpacing.Bottom = 8
Caption = 'Inverted'
OnChange = cbInvertedChange
TabOrder = 0
TabOrder = 4
end
object seColumns: TSpinEdit
AnchorSideTop.Control = cbInverted
AnchorSideTop.Side = asrBottom
AnchorSideTop.Control = gbItems
AnchorSideRight.Control = gbItems
AnchorSideRight.Side = asrBottom
Left = 108
Height = 23
Top = 33
Top = 8
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
@ -361,19 +361,20 @@ object ChartLegendFrame: TChartLegendFrame
MaxValue = 1000
MinValue = 1
OnChange = seColumnsChange
TabOrder = 1
TabOrder = 0
Value = 1
end
object lblColumns: TLabel
AnchorSideLeft.Control = cbInverted
AnchorSideLeft.Control = gbItems
AnchorSideTop.Control = seColumns
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seColumns
Left = 8
Height = 15
Top = 37
Top = 12
Width = 92
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Columns'
FocusControl = seColumns
@ -385,7 +386,7 @@ object ChartLegendFrame: TChartLegendFrame
AnchorSideRight.Control = cbItemFillOrder
Left = 8
Height = 15
Top = 64
Top = 39
Width = 92
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
@ -398,7 +399,7 @@ object ChartLegendFrame: TChartLegendFrame
AnchorSideRight.Side = asrBottom
Left = 108
Height = 23
Top = 60
Top = 35
Width = 96
Anchors = [akTop, akRight]
BorderSpacing.Top = 4
@ -410,7 +411,7 @@ object ChartLegendFrame: TChartLegendFrame
'by rows'
)
OnChange = cbItemFillOrderChange
TabOrder = 2
TabOrder = 1
Text = 'by columns'
end
object seSpacing: TSpinEdit
@ -420,7 +421,7 @@ object ChartLegendFrame: TChartLegendFrame
AnchorSideRight.Side = asrBottom
Left = 108
Height = 23
Top = 87
Top = 62
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
@ -428,7 +429,7 @@ object ChartLegendFrame: TChartLegendFrame
BorderSpacing.Right = 8
MaxValue = 1000
OnChange = seSpacingChange
TabOrder = 3
TabOrder = 2
Value = 20
end
object lblSpacing: TLabel
@ -438,7 +439,7 @@ object ChartLegendFrame: TChartLegendFrame
AnchorSideRight.Control = seSpacing
Left = 8
Height = 15
Top = 91
Top = 66
Width = 92
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8
@ -452,7 +453,7 @@ object ChartLegendFrame: TChartLegendFrame
AnchorSideRight.Side = asrBottom
Left = 108
Height = 23
Top = 114
Top = 89
Width = 96
Alignment = taRightJustify
Anchors = [akTop, akRight]
@ -461,7 +462,7 @@ object ChartLegendFrame: TChartLegendFrame
BorderSpacing.Bottom = 8
MaxValue = 1000
OnChange = seSymbolWidthChange
TabOrder = 4
TabOrder = 3
Value = 20
end
object lblSymbolWidth: TLabel
@ -471,7 +472,7 @@ object ChartLegendFrame: TChartLegendFrame
AnchorSideRight.Control = seSymbolWidth
Left = 8
Height = 15
Top = 118
Top = 93
Width = 92
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 8

View File

@ -9,6 +9,7 @@ object MarksForm: TMarksForm
ClientHeight = 511
ClientWidth = 535
OnCreate = FormCreate
OnShow = FormShow
LCLVersion = '2.3.0.0'
object ButtonPanel: TButtonPanel
Left = 6
@ -42,13 +43,11 @@ object MarksForm: TMarksForm
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
@ -88,6 +87,7 @@ object MarksForm: TMarksForm
object gbLabelFont: TGroupBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 162
Top = 0
@ -103,7 +103,7 @@ object MarksForm: TMarksForm
AnchorSideRight.Control = gbArrow
AnchorSideRight.Side = asrBottom
Left = 296
Height = 113
Height = 117
Top = 275
Width = 207
Anchors = [akTop, akLeft, akRight]
@ -111,18 +111,18 @@ object MarksForm: TMarksForm
BorderSpacing.Left = 24
BorderSpacing.Top = 16
Caption = 'Position'
ClientHeight = 93
ClientHeight = 97
ClientWidth = 203
TabOrder = 4
object lblDistance: TLabel
AnchorSideLeft.Control = gbPosition
AnchorSideTop.Control = seDistance
AnchorSideTop.Side = asrCenter
Left = 16
Left = 8
Height = 15
Top = 8
Top = 12
Width = 45
BorderSpacing.Left = 16
BorderSpacing.Left = 8
Caption = 'Distance'
end
object seDistance: TSpinEdit
@ -131,14 +131,14 @@ object MarksForm: TMarksForm
AnchorSideTop.Control = gbPosition
AnchorSideRight.Control = gbPosition
AnchorSideRight.Side = asrBottom
Left = 85
Left = 77
Height = 23
Top = 4
Width = 110
Top = 8
Width = 118
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 24
BorderSpacing.Top = 4
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
MaxValue = 1000
@ -149,9 +149,9 @@ object MarksForm: TMarksForm
AnchorSideLeft.Control = lblDistance
AnchorSideTop.Control = cmbMarkPositions
AnchorSideTop.Side = asrCenter
Left = 16
Left = 8
Height = 15
Top = 39
Top = 43
Width = 43
Caption = 'Position'
end
@ -161,10 +161,10 @@ object MarksForm: TMarksForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = seDistance
AnchorSideRight.Side = asrBottom
Left = 85
Left = 77
Height = 23
Top = 35
Width = 110
Top = 39
Width = 118
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Bottom = 8
@ -183,9 +183,9 @@ object MarksForm: TMarksForm
AnchorSideLeft.Control = lblPosition
AnchorSideTop.Control = cmbMarkPositions
AnchorSideTop.Side = asrBottom
Left = 16
Left = 8
Height = 19
Top = 66
Top = 70
Width = 112
BorderSpacing.Top = 6
BorderSpacing.Bottom = 8

View File

@ -30,6 +30,7 @@ type
procedure cbMarksCenteredChange(Sender: TObject);
procedure cmbMarkPositionsChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure seDistanceChange(Sender: TObject);
private
FSeries: TChartSeries;
@ -39,10 +40,8 @@ type
FArrowFrame: TChartArrowFrame;
function GetChart: TChart;
procedure ShapeChangedHandler(AShape: TChartLabelShape);
public
procedure Prepare(ASeries: TChartSeries);
end;
var
@ -53,7 +52,7 @@ implementation
{$R *.lfm}
uses
TASeries,
Math, TASeries,
ceUtils;
@ -82,9 +81,7 @@ begin
FFontFrame := TChartFontFrame.Create(self);
FFontFrame.Name := '';
FFontFrame.Align := alClient;
FFontFrame.BorderSpacing.Left := 16;
FFontFrame.BorderSpacing.Right := 8;
FFontFrame.BorderSpacing.Bottom := 8;
FFontFrame.BorderSpacing.Around := 8;
FFontFrame.AutoSize := true;
FFontFrame.Parent := gbLabelFont;
gbLabelFont.AutoSize := true;
@ -93,10 +90,7 @@ begin
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.BorderSpacing.Around := 8;
FShapeBrushPenMarginsFrame.OnShapeChange := @ShapeChangedHandler;
FShapeBrushPenMarginsFrame.AutoSize := true;
FShapeBrushPenMarginsFrame.Parent := gbShapeBrushPenMargins;
@ -106,9 +100,7 @@ begin
FLinkPenFrame := TSimpleChartPenFrame.Create(self);
FLinkPenFrame.Name := '';
FLinkPenFrame.Align := alClient;
FLinkPenFrame.BorderSpacing.Left := 16;
FLinkPenFrame.BorderSpacing.Right := 8;
FLinkPenFrame.BorderSpacing.Bottom := 8;
FLinkPenFrame.BorderSpacing.Around := 8;
FLinkPenFrame.AutoSize := true;
FLinkPenFrame.Parent := gbLinkPen;
gbLinkPen.AutoSize := true;
@ -117,9 +109,7 @@ begin
FArrowFrame := TChartArrowFrame.Create(self);
FArrowFrame.Name := '';
FArrowFrame.Align := alClient;
FArrowFrame.BorderSpacing.Left := 16;
FArrowFrame.BorderSpacing.Right := 8;
FArrowFrame.BorderSpacing.Bottom := 8;
FArrowFrame.BorderSpacing.Around := 8;
FArrowFrame.AutoSize := true;
FArrowFrame.Parent := gbArrow;
gbArrow.AutoSize := true;
@ -130,6 +120,37 @@ begin
BoldHeaders(self);
end;
procedure TMarksForm.FormShow(Sender: TObject);
var
wf: Integer = 0;
hf: Integer = 0;
ws: Integer = 0;
hs: Integer = 0;
begin
FFontFrame.GetPreferredsize(wf, hf);
inc(wf, 2 * FLinkPenFrame.BorderSpacing.Around);
inc(hf, 2 * FLinkPenFrame.BorderSpacing.Around);
// inc(wf, FLinkPenFrame.BorderSpacing.Left + FLinkPenFrame.BorderSpacing.Right);
// inc(hf, FLinkPenFrame.BorderSpacing.Top + FLinkPenFrame.BorderSpacing.Bottom);
FShapeBrushPenMarginsFrame.GetPreferredSize(ws, hs);
inc(ws, 2 * FShapeBrushPenMarginsFrame.BorderSpacing.Around);
inc(hs, 2 * FShapeBrushPenMarginsFrame.BorderSpacing.Around);
// inc(ws, FShapeBrushPenMarginsFrame.BorderSpacing.Left + FShapeBrushPenMarginsFrame.BorderSpacing.Right);
// inc(hs, FShapeBrushPenMarginsFrame.BorderSpacing.Top + FShapeBrushPenMarginsFrame.BorderSpacing.Bottom);
if wf > ws then begin
gbShapeBrushPenMargins.AnchorSideRight.Control := gbLabelFont;
gbShapeBrushPenMargins.AnchorSideRight.Side := asrRight;
gbShapeBrushPenMargins.Anchors := gbShapeBrushPenMargins.Anchors + [akRight];
end else
begin
gbLabelFont.AnchorSideRight.Control := gbShapeBrushPenMargins;
gbLabelFont.AnchorSideRight.Side := asrRight;
gbLabelFont.Anchors := gbLabelFont.Anchors + [akRight];
end;
end;
function TMarksForm.GetChart: TChart;
begin
Result := FSeries.ParentChart;

View File

@ -2,9 +2,9 @@ object SimpleChartPenFrame: TSimpleChartPenFrame
Left = 0
Height = 62
Top = 0
Width = 124
Width = 120
ClientHeight = 62
ClientWidth = 124
ClientWidth = 120
OnResize = FrameResize
TabOrder = 0
DesignLeft = 620
@ -26,7 +26,6 @@ object SimpleChartPenFrame: TSimpleChartPenFrame
AnchorSideLeft.Control = cbVisible
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 62
Height = 25
@ -51,7 +50,7 @@ object SimpleChartPenFrame: TSimpleChartPenFrame
Left = 40
Height = 22
Top = 33
Width = 84
Width = 80
Mode = ccmPenWidth
Options = [ccoPatternBrush, ccoPatternPen]
PenPattern = '1|1'