mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 02:39:23 +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;
|
function TCustomSpeedButton.GetTextSize(Drawing: boolean; PaintRect: TRect): TSize;
|
||||||
var
|
var
|
||||||
TMP: String;
|
TMP: String;
|
||||||
TXTStyle: TTextStyle;
|
|
||||||
Flags: Cardinal;
|
Flags: Cardinal;
|
||||||
|
DC: HDC; // ~bk see : TCustomLabel.CalculateSize
|
||||||
|
OldFont: HGDIOBJ; // "
|
||||||
begin
|
begin
|
||||||
if FShowCaption and (Caption <> '') then
|
if FShowCaption and (Caption <> '') then
|
||||||
begin
|
begin
|
||||||
TMP := Caption;
|
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);
|
DeleteAmpersands(TMP);
|
||||||
|
|
||||||
Flags := DT_CalcRect;
|
Flags := DT_CalcRect;
|
||||||
if not TXTStyle.SingleLine then Inc(Flags, DT_WordBreak);
|
if not Canvas.TextStyle.SingleLine then
|
||||||
|
Inc(Flags, DT_WordBreak);
|
||||||
DrawText(Canvas.Handle, PChar(TMP), Length(TMP), PaintRect, Flags);
|
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.CY := PaintRect.Bottom - PaintRect.Top;
|
||||||
Result.CX := PaintRect.Right - PaintRect.Left;
|
Result.CX := PaintRect.Right - PaintRect.Left;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user