From fe08ba3b2f7b3f566eb7188f0e0e94956ffe0375 Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Tue, 21 Jan 2025 09:51:11 +0100 Subject: [PATCH] Gtk3: fixed fillRect() overload without brush. issue #41342 --- lcl/interfaces/gtk3/gtk3objects.pas | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lcl/interfaces/gtk3/gtk3objects.pas b/lcl/interfaces/gtk3/gtk3objects.pas index b3fb661acf..16ff8d2f3f 100644 --- a/lcl/interfaces/gtk3/gtk3objects.pas +++ b/lcl/interfaces/gtk3/gtk3objects.pas @@ -295,6 +295,8 @@ type procedure TranslateCairoToDevice; procedure Translate(APoint: TPoint); procedure set_antialiasing(aamode:boolean); + procedure Save; + procedure Restore; property BkMode: integer read FBkMode write FBkMode; property BkColor: TColorRef read GetBkColor write SetBkColor; property BgBrush: TGtk3Brush read FBgBrush; {bgBrush is created when SetBk is called, otherwise is nil} @@ -2349,12 +2351,14 @@ begin begin ATempBrush := FCurrentBrush; CurrentBrush:= TGtk3Brush(ABrush); - applyBrush; - end; + end else + ATempBrush := FCurrentBrush; + + applyBrush; cairo_rectangle(pcr, x + PixelOffset, y + PixelOffset, w - 1, h - 1); - if (ABrush <> 0) and (CurrentBrush.Style <> BS_NULL) then + if (CurrentBrush.Style <> BS_NULL) then begin cairo_fill_preserve(pcr); // must paint border, filling is not enough @@ -2363,8 +2367,7 @@ begin cairo_stroke(pcr); end; - if ABrush <> 0 then - CurrentBrush:= ATempBrush; + CurrentBrush:= ATempBrush; cairo_new_path(pcr); finally cairo_restore(pcr); @@ -2743,6 +2746,16 @@ begin cairo_set_antialias(pcr, caa[aamode]); end; +procedure TGtk3DeviceContext.Save; +begin + cairo_save(pcr); +end; + +procedure TGtk3DeviceContext.Restore; +begin + cairo_restore(pcr); +end; + procedure TGtk3DeviceContext.SetCanvasScaleFactor(const AValue: double); var matrix: Tcairo_matrix_t;