mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 17:16:01 +02:00
TAChart: New property FullWidth of TChartTitle to draw the title/footer background across the entire chart.
This commit is contained in:
parent
3f4356f2bc
commit
8b2c86f689
@ -75,7 +75,7 @@ type
|
|||||||
procedure DrawLink(
|
procedure DrawLink(
|
||||||
ADrawer: IChartDrawer; ADataPoint, ALabelCenter: TPoint); virtual;
|
ADrawer: IChartDrawer; ADataPoint, ALabelCenter: TPoint); virtual;
|
||||||
function GetBoundingBox(
|
function GetBoundingBox(
|
||||||
ADrawer: IChartDrawer; const ATextSize: TPoint): TRect;
|
ADrawer: IChartDrawer; const ATextSize: TPoint): TRect; virtual;
|
||||||
function GetTextShiftNeeded: Boolean;
|
function GetTextShiftNeeded: Boolean;
|
||||||
function IsMarginRequired: Boolean;
|
function IsMarginRequired: Boolean;
|
||||||
strict protected
|
strict protected
|
||||||
@ -140,6 +140,7 @@ type
|
|||||||
FBrush: TBrush;
|
FBrush: TBrush;
|
||||||
FCenter: TPoint;
|
FCenter: TPoint;
|
||||||
FFont: TFont;
|
FFont: TFont;
|
||||||
|
FFullWidth: Boolean;
|
||||||
FFrame: TChartTitleFramePen;
|
FFrame: TChartTitleFramePen;
|
||||||
FMargin: TChartDistance;
|
FMargin: TChartDistance;
|
||||||
FPolygon: TPointArray;
|
FPolygon: TPointArray;
|
||||||
@ -152,11 +153,14 @@ type
|
|||||||
procedure SetBrush(AValue: TBrush);
|
procedure SetBrush(AValue: TBrush);
|
||||||
procedure SetFont(AValue: TFont);
|
procedure SetFont(AValue: TFont);
|
||||||
procedure SetFrame(AValue: TChartTitleFramePen);
|
procedure SetFrame(AValue: TChartTitleFramePen);
|
||||||
|
procedure SetFullWidth(AValue: Boolean);
|
||||||
procedure SetMargin(AValue: TChartDistance);
|
procedure SetMargin(AValue: TChartDistance);
|
||||||
procedure SetText(AValue: TStrings);
|
procedure SetText(AValue: TStrings);
|
||||||
procedure SetWordwrap(AValue: Boolean);
|
procedure SetWordwrap(AValue: Boolean);
|
||||||
procedure WordWrapCaption(ADrawer: IChartDrawer; AMaxWidth: Integer);
|
procedure WordWrapCaption(ADrawer: IChartDrawer; AMaxWidth: Integer);
|
||||||
strict protected
|
strict protected
|
||||||
|
function GetBoundingBox(ADrawer: IChartDrawer;
|
||||||
|
const ATextSize: TPoint): TRect; override;
|
||||||
function GetFrame: TChartPen; override;
|
function GetFrame: TChartPen; override;
|
||||||
function GetLabelBrush: TBrush; override;
|
function GetLabelBrush: TBrush; override;
|
||||||
function GetLabelFont: TFont; override;
|
function GetLabelFont: TFont; override;
|
||||||
@ -175,6 +179,7 @@ type
|
|||||||
property Brush: TBrush read FBrush write SetBrush;
|
property Brush: TBrush read FBrush write SetBrush;
|
||||||
property Font: TFont read FFont write SetFont;
|
property Font: TFont read FFont write SetFont;
|
||||||
property Frame: TChartTitleFramePen read FFrame write SetFrame;
|
property Frame: TChartTitleFramePen read FFrame write SetFrame;
|
||||||
|
property FullWidth: Boolean read FFullWidth write SetFullWidth default false;
|
||||||
property Margin: TChartDistance
|
property Margin: TChartDistance
|
||||||
read FMargin write SetMargin default DEF_MARGIN;
|
read FMargin write SetMargin default DEF_MARGIN;
|
||||||
property OnGetShape;
|
property OnGetShape;
|
||||||
@ -667,6 +672,34 @@ begin
|
|||||||
DrawLabel(ADrawer, FCenter, FCenter, GetRealCaption, FPolygon);
|
DrawLabel(ADrawer, FCenter, FCenter, GetRealCaption, FPolygon);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TChartTitle.GetBoundingBox(
|
||||||
|
ADrawer: IChartDrawer; const ATextSize: TPoint): TRect;
|
||||||
|
begin
|
||||||
|
Result := inherited;
|
||||||
|
if FullWidth then
|
||||||
|
begin
|
||||||
|
case Alignment of
|
||||||
|
taLeftJustify:
|
||||||
|
begin
|
||||||
|
Result.Left := -ATextSize.X div 2 - Margins.Left;
|
||||||
|
Result.Right := Result.Left + FOwner.Width;
|
||||||
|
FCenter.X := ATextSize.X div 2 + Margins.Left;
|
||||||
|
end;
|
||||||
|
taRightJustify:
|
||||||
|
begin
|
||||||
|
Result.Right := ATextSize.X div 2 + Margins.Right;
|
||||||
|
Result.Left := Result.Right - FOwner.Width;
|
||||||
|
FCenter.X := FOwner.Width - ATextSize.X div 2 - Margins.Right;
|
||||||
|
end;
|
||||||
|
taCenter:
|
||||||
|
begin
|
||||||
|
Result.Left := -FOwner.Width div 2;
|
||||||
|
Result.Right := +FOwner.Width div 2;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TChartTitle.GetFrame: TChartPen;
|
function TChartTitle.GetFrame: TChartPen;
|
||||||
begin
|
begin
|
||||||
Result := Frame;
|
Result := Frame;
|
||||||
@ -738,6 +771,13 @@ begin
|
|||||||
StyleChanged(Self);
|
StyleChanged(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartTitle.SetFullWidth(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FFullWidth = AValue then exit;
|
||||||
|
FFullWidth := AValue;
|
||||||
|
StyleChanged(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChartTitle.SetMargin(AValue: TChartDistance);
|
procedure TChartTitle.SetMargin(AValue: TChartDistance);
|
||||||
begin
|
begin
|
||||||
if FMargin = AValue then exit;
|
if FMargin = AValue then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user