From 518fc97931773b1ed65224f040b652bbcb5eb73f Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 22 Mar 2010 08:23:33 +0000 Subject: [PATCH] qt: fix SelectClipRgn which is uses device coordinates and Qt uses logical git-svn-id: trunk@24166 - --- lcl/interfaces/qt/qtobjects.pas | 6 ++++++ lcl/interfaces/qt/qtwinapi.inc | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/lcl/interfaces/qt/qtobjects.pas b/lcl/interfaces/qt/qtobjects.pas index 119c794a76..6171dd447e 100644 --- a/lcl/interfaces/qt/qtobjects.pas +++ b/lcl/interfaces/qt/qtobjects.pas @@ -290,6 +290,7 @@ type function GetRegionType: integer; function getBoundingRect: TRect; function numRects: Integer; + procedure translate(dx, dy: Integer); property IsPolyRegion: Boolean read GetIsPolyRegion; end; @@ -1798,6 +1799,11 @@ begin Result := QRegion_numRects(Widget); end; +procedure TQtRegion.translate(dx, dy: Integer); +begin + QRegion_translate(Widget, dx, dy); +end; + { TQtDeviceContext } {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 59f0a885b5..9481dafd90 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -4312,6 +4312,7 @@ function TQtWidgetSet.SelectClipRGN(DC: hDC; RGN: HRGN): Longint; var QtDC: TQtDeviceContext; EmptyRegion: QRegionH; + P: TPoint; begin Result := ERROR; if IsValidDC(DC) then @@ -4320,6 +4321,10 @@ begin if IsValidGDIObject(RGN) then begin Result := TQtRegion(Rgn).GetRegionType; + // RGN is in Device coordinates. Qt expects logical coordinates + // so we need to convert RGN coords + GetWindowOrgEx(DC, @P); + TQtRegion(Rgn).translate(P.X, P.Y); QtDC.setClipRegion(TQtRegion(Rgn).Widget); end else begin