From 0d3a0d3d895b653e9bb9d93393da19e598964146 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 17 Jul 2007 01:36:43 +0000 Subject: [PATCH] QT: correction in DrawText with DT_CALCRECT git-svn-id: trunk@11532 - --- lcl/interfaces/qt/qtthemes.pas | 14 -------------- lcl/interfaces/qt/qtwinapi.inc | 9 +++++---- lcl/interfaces/qt/qtwinapih.inc | 2 +- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/lcl/interfaces/qt/qtthemes.pas b/lcl/interfaces/qt/qtthemes.pas index e279078895..f2490fc418 100644 --- a/lcl/interfaces/qt/qtthemes.pas +++ b/lcl/interfaces/qt/qtthemes.pas @@ -52,7 +52,6 @@ type procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override; procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal; AContentRect: PRect); override; procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); override; - procedure DrawText(ACanvas: TPersistent; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags, Flags2: Cardinal); override; function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override; function HasTransparentParts(Details: TThemedElementDetails): Boolean; override; @@ -163,19 +162,6 @@ begin end; -procedure TQtThemeServices.DrawText(ACanvas: TPersistent; - Details: TThemedElementDetails; const S: WideString; R: TRect; Flags, - Flags2: Cardinal); -begin - with TCanvas(ACanvas) do - begin - WidgetSet.SetBkMode(Handle, TRANSPARENT); - WidgetSet.DrawText(Handle, PChar(String(S)), Length(S), R, Flags); - if Brush.Style = bsSolid then; - WidgetSet.SetBkMode(Handle, OPAQUE); - end; -end; - function TQtThemeServices.HasTransparentParts(Details: TThemedElementDetails): Boolean; begin Result := True; diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 5c2792fc99..b2c5e95162 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -739,7 +739,7 @@ end; * The result will the height of the text. ------------------------------------------------------------------------------} function TQtWidgetSet.DrawText(DC: HDC; Str: PChar; Count: Integer; - var Rect: TRect; Flags: Cardinal): Integer; + var ARect: TRect; Flags: Cardinal): Integer; var WideStr: WideString; QtFontMetrics: TQtFontMetrics; @@ -792,7 +792,7 @@ begin if Flags and DT_NOPREFIX = 0 then F := F or $800;{QTTextShowMnemonic;} - QFontMetrics_BoundingRect(QtFontMetrics.Widget, @R, @Rect, F, @WideStr); + QFontMetrics_BoundingRect(QtFontMetrics.Widget, @R, @ARect, F, @WideStr); //TODO: result should be different when DT_VCENTER or DT_BOTTOM is set @@ -807,11 +807,12 @@ begin {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI DrawText] Rect=', dbgs(Rect)); {$endif} - Rect := R; + ARect.Right := ARect.Left + R.Right - R.Left; + ARect.Bottom := ARect.Top + R.Bottom - R.Top; Exit; end; - with Rect do + with ARect do QtDC.DrawText(left, Top, Right-Left, Bottom-Top, F, @WideStr); end; diff --git a/lcl/interfaces/qt/qtwinapih.inc b/lcl/interfaces/qt/qtwinapih.inc index 05f91088b1..4e349274ac 100644 --- a/lcl/interfaces/qt/qtwinapih.inc +++ b/lcl/interfaces/qt/qtwinapih.inc @@ -49,7 +49,7 @@ procedure DeleteCriticalSection(var CritSection: TCriticalSection); override; function DeleteObject(GDIObject: HGDIOBJ): Boolean; override; function DestroyCaret(Handle : HWND): Boolean; override; function DestroyCursor(Handle: hCursor): Boolean; override; -function DrawText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; Flags: Cardinal): Integer; override; +function DrawText(DC: HDC; Str: PChar; Count: Integer; var ARect: TRect; Flags: Cardinal): Integer; override; function Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean; override; function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;