Gtk2,Qt: make ETO_OPAQUE work from TCanvas.TextOut(). issue #22719

git-svn-id: trunk@38373 -
This commit is contained in:
zeljko 2012-08-25 15:29:23 +00:00
parent 1ffcfe06cd
commit dbe9056692
2 changed files with 26 additions and 14 deletions

View File

@ -3823,6 +3823,7 @@ var
Foreground, BackgroundColor: PGDKColor; Foreground, BackgroundColor: PGDKColor;
CurDx: PInteger; CurDx: PInteger;
CurStr: PChar; CurStr: PChar;
R: TRect;
procedure DoTextOut(X,Y : Integer; Str: Pchar; CurCount: Integer); procedure DoTextOut(X,Y : Integer; Str: Pchar; CurCount: Integer);
var var
@ -3854,12 +3855,14 @@ begin
if DevCtx.GC <> nil then; // create GC if DevCtx.GC <> nil then; // create GC
if ((Options and (ETO_OPAQUE+ETO_CLIPPED)) <> 0) if ((Options and (ETO_OPAQUE+ETO_CLIPPED)) <> 0) and
and (Rect=nil) (Rect=nil) then
then begin begin
DebugLn('WARNING: [TGtk2WidgetSet.ExtTextOut] Rect=nil'); R := RectFromGdkRect(DevCtx.ClipRect);
Result := False; OffsetRect(R, -R.Left, -R.Top);
exit; OffsetRect(R, X, Y);
DrawText(DC, Str, Count, R, DT_SINGLELINE or DT_CALCRECT);
Rect := @R;
end; end;
BackgroundColor := nil; BackgroundColor := nil;
@ -3868,8 +3871,8 @@ begin
DCOrigin := DevCtx.Offset; DCOrigin := DevCtx.Offset;
if (Options and ETO_CLIPPED) <> 0 if (Options and ETO_CLIPPED) <> 0 then
then begin begin
X := Rect^.Left; X := Rect^.Left;
Y := Rect^.Top; Y := Rect^.Top;
IntersectClipRect(DC, Rect^.Left, Rect^.Top, IntersectClipRect(DC, Rect^.Left, Rect^.Top,

View File

@ -2181,6 +2181,7 @@ var
WideStr: WideString; WideStr: WideString;
QtDC: TQtDeviceContext absolute DC; QtDC: TQtDeviceContext absolute DC;
B: Boolean; B: Boolean;
R, R1: TRect;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI ExtTextOut]'); WriteLn('[WinAPI ExtTextOut]');
@ -2188,12 +2189,20 @@ begin
Result := False; Result := False;
if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then
exit;
if not IsValidDC(DC) then Exit; if not IsValidDC(DC) then Exit;
if ((Options and ETO_OPAQUE) <> 0) then if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then
begin
if Count >= 0 then
WideStr := GetUtf8String(Copy(Str, 1, Count))
else
WideStr := GetUtf8String(Str);
R := QtDC.getClipRegion.getBoundingRect;
QtDC.font.Metrics.boundingRect(@R1, @R, 0, @WideStr);
Rect := @R1;
end else
if ((Options and ETO_OPAQUE) <> 0) and (Rect <> nil) then
QtDC.fillRect(Rect^.Left, Rect^.Top, Rect^.Right - Rect^.Left, Rect^.Bottom - Rect^.Top); QtDC.fillRect(Rect^.Left, Rect^.Top, Rect^.Right - Rect^.Left, Rect^.Bottom - Rect^.Top);
if Str <> nil then if Str <> nil then