diff --git a/lcl/include/intfbasewinapi.inc b/lcl/include/intfbasewinapi.inc index 9287b7d90c..e403325cd5 100644 --- a/lcl/include/intfbasewinapi.inc +++ b/lcl/include/intfbasewinapi.inc @@ -2019,6 +2019,11 @@ begin Result := True; end; +function TWidgetSet.SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; +begin + Result := False; +end; + function TWidgetSet.SetROP2(DC: HDC; Mode: Integer): Integer; begin Result := 0; diff --git a/lcl/include/winapi.inc b/lcl/include/winapi.inc index 44fb533e6f..cc5874d9bb 100644 --- a/lcl/include/winapi.inc +++ b/lcl/include/winapi.inc @@ -886,6 +886,11 @@ begin Result := WidgetSet.SetProp(Handle,Str,Data); end; +function SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; +begin + Result := WidgetSet.SetRectRgn(aRGN, X1, Y1, X2, Y2); +end; + function SetROP2(DC: HDC; Mode: Integer): Integer; begin Result := WidgetSet.SetRop2(Dc, Mode); diff --git a/lcl/include/winapih.inc b/lcl/include/winapih.inc index 880ed51586..fd44b1aad8 100644 --- a/lcl/include/winapih.inc +++ b/lcl/include/winapih.inc @@ -250,6 +250,7 @@ function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; {$IFDEF IF_B function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} //function SetRect --> independent +function SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} //function SetRectEmpty --> independent function SetROP2(DC: HDC; Mode: Integer): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function SetScrollInfo(Handle: HWND; SBStyle: Integer; ScrollInfo: TScrollInfo; Redraw : Boolean): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index d858cc95a1..3e39192588 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -9064,6 +9064,36 @@ begin Result:=true; end; +{------------------------------------------------------------------------------ + Method: SetRectRgn + Params: aRGN: HRGN; X1, Y1, X2, Y2 : Integer + Returns: True if the function succeeds + + Converts a region into a rectangular region with the specified coordinates. + ------------------------------------------------------------------------------} +function TGtkWidgetSet.SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; + + procedure Swap(var A, B: Integer); + var + Tmp: Integer; + begin + Tmp := A; + A := B; + B := Tmp; + end; + +var + AGdiObject: PGdiObject absolute aRGN; +begin + Result := IsValidGDIObject(aRGN); + if Result then begin + if (X1 > X2) then swap(X1, X2); + if (Y1 > Y2) then swap(Y1, Y2); + AGdiObject^.GDIRegionObject := CreateRectGDKRegion(Rect(X1,Y1,X2,Y2)); + Result := True; + end; +end; + {------------------------------------------------------------------------------ function TGtkWidgetSet.SetROPMode(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; diff --git a/lcl/interfaces/gtk/gtkwinapih.inc b/lcl/interfaces/gtk/gtkwinapih.inc index 4bbf530839..0a869c6fb9 100644 --- a/lcl/interfaces/gtk/gtkwinapih.inc +++ b/lcl/interfaces/gtk/gtkwinapih.inc @@ -201,6 +201,7 @@ function SetForegroundWindow(hWnd: HWND): boolean; override; function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; override; function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; override; function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override; +function SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; override; function SetROP2(DC: HDC; Mode: Integer): Integer; override; function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override; function SetSysColors(cElements: Integer; const lpaElements; const lpaRgbValues): Boolean; override; diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index 9c43e3d9bd..f48f15d107 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -8467,6 +8467,36 @@ begin Result:=true; end; +{------------------------------------------------------------------------------ + Method: SetRectRgn + Params: aRGN: HRGN; X1, Y1, X2, Y2 : Integer + Returns: True if the function succeeds + + Converts a region into a rectangular region with the specified coordinates. + ------------------------------------------------------------------------------} +function TGtk2WidgetSet.SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; + + procedure Swap(var A, B: Integer); + var + Tmp: Integer; + begin + Tmp := A; + A := B; + B := Tmp; + end; + +var + AGdiObject: PGdiObject absolute aRGN; +begin + Result := IsValidGDIObject(aRGN); + if Result then begin + if (X1 > X2) then swap(X1, X2); + if (Y1 > Y2) then swap(Y1, Y2); + AGdiObject^.GDIRegionObject := CreateRectGDKRegion(Rect(X1,Y1,X2,Y2)); + Result := True; + end; +end; + {------------------------------------------------------------------------------ function TGtk2WidgetSet.SetROPMode(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; diff --git a/lcl/interfaces/gtk2/gtk2winapih.inc b/lcl/interfaces/gtk2/gtk2winapih.inc index 6d29f44a23..dd1d2f9957 100644 --- a/lcl/interfaces/gtk2/gtk2winapih.inc +++ b/lcl/interfaces/gtk2/gtk2winapih.inc @@ -214,6 +214,7 @@ function SetForegroundWindow(hWnd: HWND): boolean; override; function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; override; function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; override; function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override; +function SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; override; function SetROP2(DC: HDC; Mode: Integer): Integer; override; function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override; function SetSysColors(cElements: Integer; const lpaElements; const lpaRgbValues): Boolean; override; diff --git a/lcl/interfaces/win32/win32winapi.inc b/lcl/interfaces/win32/win32winapi.inc index f189bf26d4..5b7a4c2358 100644 --- a/lcl/interfaces/win32/win32winapi.inc +++ b/lcl/interfaces/win32/win32winapi.inc @@ -3192,6 +3192,19 @@ begin Result := Boolean(Windows.SetProp(Handle, Str, Windows.HANDLE(Data))); end; +{------------------------------------------------------------------------------ + Method: SetRectRgn + Params: aRGN: HRGN; X1, Y1, X2, Y2 : Integer + Returns: True if the function succeeds + + Converts a region into a rectangular region with the specified coordinates. + + ------------------------------------------------------------------------------} +function TWin32WidgetSet.SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; +begin + Result := Boolean(Windows.SetRectRgn(aRGN, X1, Y1, X2, Y2)); +end; + {------------------------------------------------------------------------------ Method: SetROP2 Params: DC - Device Context diff --git a/lcl/interfaces/win32/win32winapih.inc b/lcl/interfaces/win32/win32winapih.inc index 0f956506d2..dc3fd96ce1 100644 --- a/lcl/interfaces/win32/win32winapih.inc +++ b/lcl/interfaces/win32/win32winapih.inc @@ -213,6 +213,7 @@ function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; override; function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; override; function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; override; function SetProp(Handle: hwnd; Str: PChar; Data: Pointer): Boolean; override; +function SetRectRgn(aRGN: HRGN; X1, Y1, X2, Y2 : Integer): Boolean; override; function SetROP2(DC: HDC; Mode: Integer): Integer; override; function SetScrollInfo(Handle: HWND; SBStyle: Integer; ScrollInfo: TScrollInfo; BRedraw: Boolean): Integer; override; function SetStretchBltMode(DC: HDC; StretchMode: Integer): Integer; override;