From cb7061fa17dc1f951f5a84c881ea9e5a1092f241 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 30 Jun 2011 10:09:56 +0000 Subject: [PATCH] gtk2: when FillRect is called with a hatched/bitmap brush first fill the rect with a BkColor if BkMode = OPAQUE git-svn-id: trunk@31472 - --- lcl/interfaces/gtk2/gtk2def.pp | 1 + lcl/interfaces/gtk2/gtk2devicecontext.inc | 2 +- lcl/interfaces/gtk2/gtk2winapi.inc | 18 ++++++++++++++---- lcl/interfaces/gtk2/gtk2wsforms.pp | 3 ++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2def.pp b/lcl/interfaces/gtk2/gtk2def.pp index e4402323f4..6942f32d8e 100644 --- a/lcl/interfaces/gtk2/gtk2def.pp +++ b/lcl/interfaces/gtk2/gtk2def.pp @@ -339,6 +339,7 @@ type StackAddrs: TCallBacksArray; {$endif} PenPos: TPoint; + BkMode: Integer; CurrentTextColor: TGDIColor; CurrentBackColor: TGDIColor; DCTextMetric: TDevContextTextMetric; // only valid if dcfTextMetricsValid set diff --git a/lcl/interfaces/gtk2/gtk2devicecontext.inc b/lcl/interfaces/gtk2/gtk2devicecontext.inc index 515c5ef70f..faea4e6551 100644 --- a/lcl/interfaces/gtk2/gtk2devicecontext.inc +++ b/lcl/interfaces/gtk2/gtk2devicecontext.inc @@ -1060,7 +1060,7 @@ end; constructor TGtkDeviceContext.Create; begin - // nothing + BkMode := OPAQUE; end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index e23f73fae4..f5ce2f2c06 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -3507,10 +3507,19 @@ end; bottom borders of the rectangle. ------------------------------------------------------------------------------} function TGtk2WidgetSet.FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; +var + TempBr: HBrush; begin Result := IsValidDC(DC) and IsValidGDIObject(Brush); if not Result or IsRectEmpty(Rect) then - exit; + Exit; + if (PGdiObject(Brush)^.GDIBrushFill <> GDK_SOLID) and (TGtkDeviceContext(DC).BkMode = OPAQUE) then + begin + // fill a rectangle with a solid back color first + TempBr := CreateSolidBrush(TGtkDeviceContext(DC).CurrentBackColor.ColorRef); + TGtkDeviceContext(DC).FillRect(Rect, TempBr, True); + DeleteObject(TempBr); + end; Result := TGtkDeviceContext(DC).FillRect(Rect, Brush, True); //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; @@ -6231,7 +6240,7 @@ end; ------------------------------------------------------------------------------} function TGtk2WidgetSet.IsWindowVisible(handle: HWND): boolean; begin - Result:=(handle<>0) and GTK_WIDGET_VISIBLE(PGtkWidget(handle)); + Result := (handle <> 0) and GTK_WIDGET_VISIBLE(PGtkWidget(handle)); end; function TGtk2WidgetSet.IsZoomed(handle: HWND): boolean; @@ -7707,12 +7716,13 @@ end; Returns: ------------------------------------------------------------------------------} -function TGtk2WidgetSet.SetBkMode(DC: HDC; bkMode : Integer) : Integer; +function TGtk2WidgetSet.SetBkMode(DC: HDC; bkMode: Integer) : Integer; var DevCtx: TGtkDeviceContext absolute DC; begin // Your code here - Result:=0; + Result := DevCtx.BkMode; + DevCtx.BkMode := bkMode; end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/gtk2/gtk2wsforms.pp b/lcl/interfaces/gtk2/gtk2wsforms.pp index 2c12a61d1d..0e6af91967 100644 --- a/lcl/interfaces/gtk2/gtk2wsforms.pp +++ b/lcl/interfaces/gtk2/gtk2wsforms.pp @@ -617,7 +617,8 @@ begin gtk_window_set_default_size(GtkWindow, Max(1,AForm.Width), Max(1,AForm.Height)); gtk_widget_set_uposition(PGtkWidget(GtkWindow), AForm.Left, AForm.Top); GtkWindowShowModal(AForm, GtkWindow); - end else + end + else Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible); InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect); end;