Gtk3: added helper functions to convert cairo rect to TRect and vice versa.

This commit is contained in:
zeljan1 2025-01-15 22:24:01 +01:00
parent 2592b7e842
commit f0e7cbe936

View File

@ -25,7 +25,7 @@ uses
BaseUnix, Unix,
{$ENDIF}
Classes, SysUtils, Controls, StdCtrls, Graphics,
LazGtk3, LazGdk3, LazGLib2, LazGObject2, LazGdkPixbuf2, LazPango1,
LazGtk3, LazGdk3, LazGLib2, LazGObject2, LazGdkPixbuf2, LazPango1, Lazcairo1,
LCLType, InterfaceBase;
type
@ -304,6 +304,9 @@ function RectFromPangoRect(APangoRect: TPangoRectangle): TRect;
function GdkRectFromRect(R: TRect): TGdkRectangle;
function GtkAllocationFromRect(R: TRect): TGtkAllocation;
function CairoRectFromRect(const R: TRect): Tcairo_rectangle_int_t;
function RectFromCairoRect(const ACairoRect: Tcairo_rectangle_int_t): TRect;
function GdkKeyToLCLKey(AValue: Word): Word;
function GdkModifierStateToLCL(AState: TGdkModifierType; const AIsKeyEvent: Boolean): PtrInt;
function GdkModifierStateToShiftState(AState: TGdkModifierType): TShiftState;
@ -420,6 +423,28 @@ begin
end;
end;
function CairoRectFromRect(const R:TRect):Tcairo_rectangle_int_t;
begin
with Result do
begin
x := R.Left;
y := R.Top;
width := R.Right-R.Left;
height := R.Bottom-R.Top;
end;
end;
function RectFromCairoRect(const ACairoRect:Tcairo_rectangle_int_t):TRect;
begin
with Result do
begin
Left := ACairoRect.x;
Top := ACairoRect.y;
Right := Left + ACairoRect.Width;
Bottom := Top + ACairoRect.Height;
end;
end;
function GtkAllocationFromRect(R: TRect): TGtkAllocation;
begin
with Result do
@ -1322,4 +1347,5 @@ begin
g_list_free(TopList);
end;
end.