mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 12:29:29 +02:00
LCL: Fix TSpeedButton AutoSize with alignment. Issue #27396, patch from Michl.
git-svn-id: trunk@52231 -
This commit is contained in:
parent
fa6c3b0d21
commit
3c1f7de3ea
@ -1009,26 +1009,25 @@ end;
|
||||
function TCustomSpeedButton.GetTextSize(Drawing: boolean; PaintRect: TRect): TSize;
|
||||
var
|
||||
TMP: String;
|
||||
TXTStyle: TTextStyle;
|
||||
Flags: Cardinal;
|
||||
DC: HDC; // ~bk see : TCustomLabel.CalculateSize
|
||||
OldFont: HGDIOBJ; // "
|
||||
begin
|
||||
if FShowCaption and (Caption <> '') then
|
||||
begin
|
||||
TMP := Caption;
|
||||
TXTStyle := Canvas.TextStyle;
|
||||
TXTStyle.Opaque := False;
|
||||
TXTStyle.Clipping := True;
|
||||
TXTStyle.ShowPrefix := ShowAccelChar;
|
||||
TXTStyle.Alignment := taLeftJustify;
|
||||
TXTStyle.Layout := tlTop;
|
||||
TXTStyle.RightToLeft := UseRightToLeftReading;
|
||||
TXTStyle.SystemFont := Canvas.Font.IsDefault;//Match System Default Style
|
||||
DeleteAmpersands(TMP);
|
||||
|
||||
Flags := DT_CalcRect;
|
||||
if not TXTStyle.SingleLine then Inc(Flags, DT_WordBreak);
|
||||
|
||||
DrawText(Canvas.Handle, PChar(TMP), Length(TMP), PaintRect, Flags);
|
||||
if not Canvas.TextStyle.SingleLine then
|
||||
Inc(Flags, DT_WordBreak);
|
||||
DC := GetDC(Parent.Handle);
|
||||
try
|
||||
OldFont := SelectObject(DC, HGDIOBJ(Font.Reference.Handle));
|
||||
DrawText(DC, PChar(TMP), Length(TMP), PaintRect, Flags);
|
||||
SelectObject(DC, OldFont);
|
||||
finally
|
||||
ReleaseDC(Parent.Handle, DC);
|
||||
end;
|
||||
Result.CY := PaintRect.Bottom - PaintRect.Top;
|
||||
Result.CX := PaintRect.Right - PaintRect.Left;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user