From d2bc4123dc64143e48a0a478696c2682a12cb448 Mon Sep 17 00:00:00 2001 From: jujibo Date: Sun, 9 May 2021 08:26:02 +0000 Subject: [PATCH] Reimplement the removed procedure in Lazarus trunk git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8011 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/jujiboutils/src/jlabel.pas | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/components/jujiboutils/src/jlabel.pas b/components/jujiboutils/src/jlabel.pas index 59c4dfdd6..b940a39c4 100644 --- a/components/jujiboutils/src/jlabel.pas +++ b/components/jujiboutils/src/jlabel.pas @@ -40,6 +40,8 @@ type procedure SetShadowColor2(AValue: TColor); protected procedure SetShadowColor(Value: TColor); + procedure DoCalculateTextPosition(var TextTop: integer; + var TextLeft: integer); virtual; property ShadowColor: TColor read FShadowColor write SetShadowColor; property ShadowColor2: TColor read FShadowColor2 write SetShadowColor2; property LabelStyle: TLabelStyle read FLabelStyle write SetLabelStyle; @@ -206,6 +208,26 @@ begin end; end; +procedure TJCustomLabel.DoCalculateTextPosition(var TextTop: integer; + var TextLeft: integer); +var + lTextHeight: integer; + lTextWidth: integer; +begin + TextLeft := 0; + if Layout = tlTop then + begin + TextTop := 0; + end else + begin + CalculateSize(Width, lTextWidth, lTextHeight); + case Layout of + tlCenter: TextTop := (Height - lTextHeight) div 2; + tlBottom: TextTop := Height - lTextHeight; + end; + end; +end; + procedure TJCustomLabel.Paint; var TR: TTextStyle; @@ -244,7 +266,7 @@ begin RightToLeft := UseRightToLeftReading; ExpandTabs := True; end; - DoMeasureTextPosition(TextTop, TextLeft); + DoCalculateTextPosition(TextTop, TextLeft); //debugln('TCustomLabel.Paint ',dbgs(Alignment=tacenter),' ',dbgs(Layout=tlCenter),' ',dbgs(TextLeft),' TextTop=',dbgs(TextTop),' ',dbgs(R)); LabelText := GetLabelText; OldFontColor := Font.Color;