From d369df934cb73ce831e2b29d69898833041d072a Mon Sep 17 00:00:00 2001 From: rich2014 Date: Thu, 27 Jul 2023 22:12:47 +0800 Subject: [PATCH] Cocoa: Fix #40395: TCocoaWidgetSet.PtInRegion() implemented --- lcl/interfaces/cocoa/cocoawinapi.inc | 28 +++++++++++++++++++++++++++ lcl/interfaces/cocoa/cocoawinapih.inc | 1 + 2 files changed, 29 insertions(+) diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index ed48f2a20d..f0c3b7b621 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -2092,6 +2092,34 @@ begin end; end; +{------------------------------------------------------------------------------ +Method: PtInRegion +Params: RNG - Handle to region + X, Y - Point +Returns: If the specified point lies in the region +------------------------------------------------------------------------------} +function TCocoaWidgetSet.PtInRegion(RGN: HRGN; X, Y: Integer): Boolean; +begin + Result := False; + + {$IFDEF VerboseWinAPI} + DebugLn('TCocoaWidgetSet.PtInRegion RGN: ' + DbgS(RGN), ' X: ', DbgS(X), + ' Y: ', DbgS(Y)); + {$ENDIF} + + if not (TObject(RGN) is TCocoaRegion) then + begin + DebugLn('TCocoaWidgetSet.PtInRegion Error - invalid region ', DbgS(RGN), '!'); + Exit; + end; + + Result := TCocoaRegion(RGN).ContainsPoint(Classes.Point(X, Y)); + + {$IFDEF VerboseWinAPI} + DebugLn('TCocoaRegion.PtInRegion Result: ' + DbgS(Result)); + {$ENDIF} +end; + function TCocoaWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; var ctx: TCocoaContext; diff --git a/lcl/interfaces/cocoa/cocoawinapih.inc b/lcl/interfaces/cocoa/cocoawinapih.inc index f16cac1ba9..2523228761 100644 --- a/lcl/interfaces/cocoa/cocoawinapih.inc +++ b/lcl/interfaces/cocoa/cocoawinapih.inc @@ -148,6 +148,7 @@ function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer; Filled, Continuous function Polygon(DC: HDC; Points: PPoint; NumPts: Integer; Winding: boolean): boolean; override; function Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean; override; function PostMessage(Handle: HWND; Msg: Cardinal; wParam: WParam; lParam: LParam): Boolean; override; +function PtInRegion(RGN: HRGN; X, Y: Integer): Boolean; override; function Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; override; function RectVisible(dc : hdc; const ARect: TRect) : Boolean; override;