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 -
This commit is contained in:
paul 2011-06-30 10:09:56 +00:00
parent e8085ad171
commit cb7061fa17
4 changed files with 18 additions and 6 deletions

View File

@ -339,6 +339,7 @@ type
StackAddrs: TCallBacksArray; StackAddrs: TCallBacksArray;
{$endif} {$endif}
PenPos: TPoint; PenPos: TPoint;
BkMode: Integer;
CurrentTextColor: TGDIColor; CurrentTextColor: TGDIColor;
CurrentBackColor: TGDIColor; CurrentBackColor: TGDIColor;
DCTextMetric: TDevContextTextMetric; // only valid if dcfTextMetricsValid set DCTextMetric: TDevContextTextMetric; // only valid if dcfTextMetricsValid set

View File

@ -1060,7 +1060,7 @@ end;
constructor TGtkDeviceContext.Create; constructor TGtkDeviceContext.Create;
begin begin
// nothing BkMode := OPAQUE;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -3507,10 +3507,19 @@ end;
bottom borders of the rectangle. bottom borders of the rectangle.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TGtk2WidgetSet.FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; function TGtk2WidgetSet.FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean;
var
TempBr: HBrush;
begin begin
Result := IsValidDC(DC) and IsValidGDIObject(Brush); Result := IsValidDC(DC) and IsValidGDIObject(Brush);
if not Result or IsRectEmpty(Rect) then 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); 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])); //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;
@ -6231,7 +6240,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TGtk2WidgetSet.IsWindowVisible(handle: HWND): boolean; function TGtk2WidgetSet.IsWindowVisible(handle: HWND): boolean;
begin begin
Result:=(handle<>0) and GTK_WIDGET_VISIBLE(PGtkWidget(handle)); Result := (handle <> 0) and GTK_WIDGET_VISIBLE(PGtkWidget(handle));
end; end;
function TGtk2WidgetSet.IsZoomed(handle: HWND): boolean; function TGtk2WidgetSet.IsZoomed(handle: HWND): boolean;
@ -7707,12 +7716,13 @@ end;
Returns: Returns:
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TGtk2WidgetSet.SetBkMode(DC: HDC; bkMode : Integer) : Integer; function TGtk2WidgetSet.SetBkMode(DC: HDC; bkMode: Integer) : Integer;
var var
DevCtx: TGtkDeviceContext absolute DC; DevCtx: TGtkDeviceContext absolute DC;
begin begin
// Your code here // Your code here
Result:=0; Result := DevCtx.BkMode;
DevCtx.BkMode := bkMode;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -617,7 +617,8 @@ begin
gtk_window_set_default_size(GtkWindow, Max(1,AForm.Width), Max(1,AForm.Height)); gtk_window_set_default_size(GtkWindow, Max(1,AForm.Width), Max(1,AForm.Height));
gtk_widget_set_uposition(PGtkWidget(GtkWindow), AForm.Left, AForm.Top); gtk_widget_set_uposition(PGtkWidget(GtkWindow), AForm.Left, AForm.Top);
GtkWindowShowModal(AForm, GtkWindow); GtkWindowShowModal(AForm, GtkWindow);
end else end
else
Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible); Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible);
InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect); InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect);
end; end;