diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index 092f58b3b3..ea699df77a 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -1068,6 +1068,7 @@ type FBevelInner, FBevelOuter : TPanelBevel; FBevelWidth : TBevelWidth; FAlignment : TAlignment; + FVertAlignment: TVerticalAlignment; FFullRepaint: Boolean; FWordWrap: Boolean; procedure PaintBevel(var ARect: TRect; ABevel: TPanelBevel); @@ -1076,6 +1077,7 @@ type procedure SetBevelInner(const Value: TPanelBevel); procedure SetBevelOuter(const Value: TPanelBevel); procedure SetBevelWidth(const Value: TBevelWidth); + procedure SetVertAlignment(const Value: TVerticalAlignment); procedure SetWordwrap(const Value: Boolean); protected class procedure WSRegisterClass; override; @@ -1088,6 +1090,7 @@ type procedure Paint; override; procedure SetParentBackground(const AParentBackground: Boolean); override; procedure UpdateParentColorChange; + property VerticalAlignment: TVerticalAlignment read FVertAlignment write SetVertAlignment default taVerticalCenter; property WordWrap: Boolean read FWordwrap write SetWordwrap default false; public constructor Create(TheOwner: TComponent); override; @@ -1146,6 +1149,7 @@ type property TabOrder; property TabStop; property UseDockManager default True; + property VerticalAlignment; property Visible; property Wordwrap; property OnChangeBounds; diff --git a/lcl/include/custompanel.inc b/lcl/include/custompanel.inc index f39f88bf35..b5b005d63f 100644 --- a/lcl/include/custompanel.inc +++ b/lcl/include/custompanel.inc @@ -34,6 +34,7 @@ begin FBevelInner := bvNone; FBevelWidth := 1; FAlignment := taCenter; + FVertAlignment := taVerticalCenter; FFullRepaint := True; Color := {$ifdef UseCLDefault}clDefault{$else}clBtnFace{$endif}; with GetControlClassDefaultSize do @@ -83,6 +84,15 @@ begin inherited; end; +procedure TCustomPanel.SetVertAlignment(const Value: TVerticalAlignment); +begin + if FVertAlignment <> Value then + begin + FVertAlignment := Value; + Invalidate; + end; +end; + procedure TCustomPanel.SetWordwrap(const Value: Boolean); begin if FWordwrap <> Value then @@ -126,7 +136,9 @@ begin // Note: Frame3D inflates ARect end; -procedure TCustomPanel.Paint; +procedure TCustomPanel.Paint; +const + VerticalAlignmentToTextLayout: array[TVerticalAlignment] of TTextLayout = (tlTop, tlBottom, tlCenter); var ARect: TRect; TS : TTextStyle; @@ -143,7 +155,7 @@ begin TS.Alignment := BidiFlipAlignment(Self.Alignment, UseRightToLeftAlignment); if BiDiMode<>bdLeftToRight then TS.RightToLeft:= True; - TS.Layout:= tlCenter; + TS.Layout:= VerticalAlignmentToTextlayout[FVertAlignment]; TS.Opaque:= false; TS.Clipping:= false; TS.SystemFont:=Canvas.Font.IsDefault;