mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 23:19:50 +02:00
Qt: fixed TQtWidgetSet.DrawText() when ARect param is out of bounds of clipRect, also added QT_DRAWTEXT_MAP_TO_CLIPRECT define if someone want's that drawText respects DT_WORDBREAK flag if included. fixes #17678
git-svn-id: trunk@27779 -
This commit is contained in:
parent
ab775d508d
commit
cd8a98a15d
@ -1200,6 +1200,9 @@ var
|
|||||||
QtDC: TQtDeviceContext;
|
QtDC: TQtDeviceContext;
|
||||||
F: Integer;
|
F: Integer;
|
||||||
Pt: TPoint;
|
Pt: TPoint;
|
||||||
|
ClipRect: TRect;
|
||||||
|
B: Boolean;
|
||||||
|
|
||||||
|
|
||||||
procedure CalculateOffsetWithAngle(const AFontAngle: Integer;
|
procedure CalculateOffsetWithAngle(const AFontAngle: Integer;
|
||||||
var TextLeft,TextTop: Integer);
|
var TextLeft,TextTop: Integer);
|
||||||
@ -1245,7 +1248,7 @@ var
|
|||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
WriteLn('[WinAPI DrawText] DC: ', dbghex(DC), ' Str: ', string(Str),
|
WriteLn('[WinAPI DrawText] DC: ', dbghex(DC), ' Str: ', string(Str),
|
||||||
' CalcRect: ', dbgs((Flags and DT_CALCRECT) = DT_CALCRECT));
|
' CalcRect: ', dbgs((Flags and DT_CALCRECT) = DT_CALCRECT),' ARect ',dbgs(ARect));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
Result := 0;
|
Result := 0;
|
||||||
@ -1260,6 +1263,31 @@ begin
|
|||||||
else
|
else
|
||||||
WideStr := GetUtf8String(Str);
|
WideStr := GetUtf8String(Str);
|
||||||
|
|
||||||
|
|
||||||
|
B := QtDC.getClipping;
|
||||||
|
if B and
|
||||||
|
(Flags and DT_NOCLIP = DT_NOCLIP) and
|
||||||
|
(Flags and DT_WORDBREAK = DT_WORDBREAK) then
|
||||||
|
begin
|
||||||
|
ClipRect := QtDC.getClipRegion.getBoundingRect;
|
||||||
|
//this is just to get same behaviour as gtk2 and win32
|
||||||
|
//IMO, we should change ARect.Left and/or ARect.Top if smaller than
|
||||||
|
//clip rect (map to clipRect). Then multiline text is drawn ok.
|
||||||
|
//look at issue http://bugs.freepascal.org/view.php?id=17678 . zeljko.
|
||||||
|
if (ARect.Left < ClipRect.Left) or (ARect.Top < ClipRect.Top) then
|
||||||
|
begin
|
||||||
|
{$note remove ifdef if I'm wrong about DT_WORDBREAK OBSERVATION}
|
||||||
|
{$IFDEF QT_DRAWTEXT_MAP_TO_CLIPRECT}
|
||||||
|
if ARect.Left < ClipRect.Left then
|
||||||
|
ARect.Left := ClipRect.Left;
|
||||||
|
if ARect.Top < ClipRect.Top then
|
||||||
|
ARect.Top := ClipRect.Top;
|
||||||
|
{$ELSE}
|
||||||
|
Flags := Flags and not DT_WORDBREAK;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
F := DTFlagsToQtFlags(Flags);
|
F := DTFlagsToQtFlags(Flags);
|
||||||
|
|
||||||
QtDC.Metrics.BoundingRect(@R, @ARect, F, @WideStr);
|
QtDC.Metrics.BoundingRect(@R, @ARect, F, @WideStr);
|
||||||
@ -1296,7 +1324,7 @@ begin
|
|||||||
|
|
||||||
// we cannot fit into rectangle, so use DT_SINGLELINE.See #17329.
|
// we cannot fit into rectangle, so use DT_SINGLELINE.See #17329.
|
||||||
// http://msdn.microsoft.com/en-us/library/dd162498%28v=VS.85%29.aspx
|
// http://msdn.microsoft.com/en-us/library/dd162498%28v=VS.85%29.aspx
|
||||||
if QtDC.getClipping and
|
if B and
|
||||||
(Flags and DT_NOCLIP = DT_NOCLIP) and
|
(Flags and DT_NOCLIP = DT_NOCLIP) and
|
||||||
(Flags and DT_WORDBREAK = DT_WORDBREAK) and
|
(Flags and DT_WORDBREAK = DT_WORDBREAK) and
|
||||||
(Flags and DT_SINGLELINE = DT_SINGLELINE) and
|
(Flags and DT_SINGLELINE = DT_SINGLELINE) and
|
||||||
|
Loading…
Reference in New Issue
Block a user