mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 21:19:24 +02:00
LCL: Implementation of function FillRgn to GTK/GTK2. Issue #23241
git-svn-id: trunk@39224 -
This commit is contained in:
parent
b36cc487aa
commit
b466b6ee60
@ -4109,6 +4109,49 @@ begin
|
|||||||
//DebugLn(Format('trace:< [TGtkWidgetSet.FillRect] DC:0x%x; Rect: ((%d,%d)(%d,%d)); brush: %x', [Integer(DC), Rect.left, rect.top, rect.right, rect.bottom, brush]));
|
//DebugLn(Format('trace:< [TGtkWidgetSet.FillRect] DC:0x%x; Rect: ((%d,%d)(%d,%d)); brush: %x', [Integer(DC), Rect.left, rect.top, rect.right, rect.bottom, brush]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: FillRgn
|
||||||
|
Params: DC: HDC; RegionHnd: HRGN; hbr: HBRUSH
|
||||||
|
Returns: True if the function succeeds
|
||||||
|
|
||||||
|
Fills a region by using the specified brush
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TGtkWidgetSet.FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool;
|
||||||
|
var
|
||||||
|
GtkDC: Integer;
|
||||||
|
OldRgn: PGdkRegion;
|
||||||
|
DevCtx: TGtkDeviceContext absolute DC;
|
||||||
|
ARect: TRect;
|
||||||
|
CRect : TGDKRectangle;
|
||||||
|
hasClipping: Boolean;
|
||||||
|
begin
|
||||||
|
//todo: sanity checks for valid handle etc.
|
||||||
|
Result := IsValidDC(DC) and IsValidGDIObject(hbr) and IsValidGDIObject(RegionHnd);
|
||||||
|
if not Result then Exit;
|
||||||
|
|
||||||
|
GtkDC := SaveDC(DC);
|
||||||
|
DevCtx.ClipRegion := PGdiObject(CreateRegionCopy(RegionHnd));
|
||||||
|
OldRgn:= DevCtx.ClipRegion^.GDIRegionObject;
|
||||||
|
|
||||||
|
hasClipping := Assigned(OldRgn); //todo: Check a better way
|
||||||
|
try
|
||||||
|
if hasClipping then
|
||||||
|
if SelectClipRGN(DC, RegionHnd) <> ERROR then
|
||||||
|
begin
|
||||||
|
gdk_region_get_clipbox(PGDIObject(RegionHnd)^.GDIRegionObject, @CRect);
|
||||||
|
ARect := RectFromGdkRect(CRect);
|
||||||
|
DevCtx.FillRect(ARect, hbr, True);
|
||||||
|
if hasClipping then
|
||||||
|
SelectClipRGN(DC, HRGN(OldRgn));
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
if hasClipping then
|
||||||
|
gdk_region_destroy(OldRgn);
|
||||||
|
RestoreDC(DC, GtkDC);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: Frame3d
|
Function: Frame3d
|
||||||
Params: -
|
Params: -
|
||||||
|
@ -85,6 +85,7 @@ function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str:
|
|||||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
||||||
|
|
||||||
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
||||||
|
function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;
|
||||||
function Frame3d(DC: HDC; var ARect: TRect; const FrameWidth : integer; const Style : TBevelCut): Boolean; override;
|
function Frame3d(DC: HDC; var ARect: TRect; const FrameWidth : integer; const Style : TBevelCut): Boolean; override;
|
||||||
function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override;
|
function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override;
|
||||||
|
|
||||||
|
@ -3967,6 +3967,49 @@ begin
|
|||||||
//DebugLn(Format('trace:< [TGtk2WidgetSet.FillRect] DC:0x%x; Rect: ((%d,%d)(%d,%d)); brush: %x', [Integer(DC), Rect.left, rect.top, rect.right, rect.bottom, brush]));
|
//DebugLn(Format('trace:< [TGtk2WidgetSet.FillRect] DC:0x%x; Rect: ((%d,%d)(%d,%d)); brush: %x', [Integer(DC), Rect.left, rect.top, rect.right, rect.bottom, brush]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: FillRgn
|
||||||
|
Params: DC: HDC; RegionHnd: HRGN; hbr: HBRUSH
|
||||||
|
Returns: True if the function succeeds
|
||||||
|
|
||||||
|
Fills a region by using the specified brush
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TGtk2WidgetSet.FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool;
|
||||||
|
var
|
||||||
|
GtkDC: Integer;
|
||||||
|
OldRgn: PGdkRegion;
|
||||||
|
DevCtx: TGtkDeviceContext absolute DC;
|
||||||
|
ARect: TRect;
|
||||||
|
CRect : TGDKRectangle;
|
||||||
|
hasClipping: Boolean;
|
||||||
|
begin
|
||||||
|
//todo: sanity checks for valid handle etc.
|
||||||
|
Result := IsValidDC(DC) and IsValidGDIObject(hbr) and IsValidGDIObject(RegionHnd);
|
||||||
|
if not Result then Exit;
|
||||||
|
|
||||||
|
GtkDC := SaveDC(DC);
|
||||||
|
DevCtx.ClipRegion := PGdiObject(CreateRegionCopy(RegionHnd));
|
||||||
|
OldRgn:= DevCtx.ClipRegion^.GDIRegionObject;
|
||||||
|
|
||||||
|
hasClipping := Assigned(OldRgn); //todo: Check a better way
|
||||||
|
try
|
||||||
|
if hasClipping then
|
||||||
|
if SelectClipRGN(DC, RegionHnd) <> ERROR then
|
||||||
|
begin
|
||||||
|
gdk_region_get_clipbox(PGDIObject(RegionHnd)^.GDIRegionObject, @CRect);
|
||||||
|
ARect := RectFromGdkRect(CRect);
|
||||||
|
DevCtx.FillRect(ARect, hbr, True);
|
||||||
|
if hasClipping then
|
||||||
|
SelectClipRGN(DC, HRGN(OldRgn));
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
if hasClipping then
|
||||||
|
gdk_region_destroy(OldRgn);
|
||||||
|
RestoreDC(DC, GtkDC);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: Frame3d
|
Function: Frame3d
|
||||||
Params: -
|
Params: -
|
||||||
|
@ -99,6 +99,7 @@ function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; overr
|
|||||||
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||||
|
|
||||||
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
||||||
|
function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;
|
||||||
function Frame3d(DC: HDC; var ARect: TRect; const FrameWidth : integer; const Style : TBevelCut): Boolean; override;
|
function Frame3d(DC: HDC; var ARect: TRect; const FrameWidth : integer; const Style : TBevelCut): Boolean; override;
|
||||||
function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override;
|
function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user