LCL: Implement function SetRectRgn for Windows and Gtk(2). Issue #23288, patch from Valdinilson Lourenço da Cunha

git-svn-id: trunk@39263 -
This commit is contained in:
juha 2012-11-07 22:56:59 +00:00
parent 32fa5fe6c5
commit 7b19e58f07
9 changed files with 87 additions and 0 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;