diff --git a/lcl/include/winapi.inc b/lcl/include/winapi.inc index d37c8659f5..fab063ba6c 100644 --- a/lcl/include/winapi.inc +++ b/lcl/include/winapi.inc @@ -137,8 +137,13 @@ begin end; function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; +var + LogBrush: TLogBrush; begin - Result := WidgetSet.CreatePatternBrush(ABitmap); + LogBrush.lbStyle := BS_PATTERN; + LogBrush.lbColor := 0; + LogBrush.lbHatch := ABitmap; + Result := WidgetSet.CreateBrushIndirect(LogBrush); end; function CreatePenIndirect(const LogPen: TLogPen): HPEN; diff --git a/lcl/interfaces/gtk/gtk1object.inc b/lcl/interfaces/gtk/gtk1object.inc index 7311027890..abbf1afc01 100644 --- a/lcl/interfaces/gtk/gtk1object.inc +++ b/lcl/interfaces/gtk/gtk1object.inc @@ -5716,10 +5716,14 @@ begin EnsureGCColor(DC, dccGDIBrushColor, GetBrush^.GDIBrushFill = GDK_Solid, False);//Brush Color if GetBrush^.GDIBrushFill <> GDK_Solid then - if GetBrush^.GDIBrushPixmap <> nil then begin + if GetBrush^.GDIBrushPixmap <> nil then + begin gdk_gc_set_fill(GC, GetBrush^.GDIBrushFill); - gdk_gc_set_Stipple(GC, GetBrush^.GDIBrushPixmap); - gdk_gc_get_values(GC,@GCValues); + if GetBrush^.GDIBrushFill = GDK_STIPPLED then + gdk_gc_set_stipple(GC, GetBrush^.GDIBrushPixmap) + else + gdk_gc_set_tile(GC, GetBrush^.GDIBrushPixmap); + gdk_gc_get_values(GC, @GCValues); end end; DevCon.SelectedColors := dcscBrush; diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index 0464c1c084..49bea430b9 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -1046,15 +1046,27 @@ begin BS_PATTERN, // Pattern brush defined by a memory bitmap. BS_PATTERN8X8: // Same as BS_PATTERN. begin - GObject^.GDIBrushFill := GDK_TILED; - if IsValidGDIObject(lbHatch) - and (PGdiObject(lbHatch)^.GDIType = gdiBitmap) - then - GObject^.GDIBrushPixmap := PGdiObject(lbHatch)^.GDIBitmapObject + GObject^.GDIBrushPixmap := nil; + if IsValidGDIObject(lbHatch) and (PGdiObject(lbHatch)^.GDIType = gdiBitmap) then + begin + case PGdiObject(lbHatch)^.GDIBitmapType of + gbBitmap: + begin + GObject^.GDIBrushPixmap := PGdiObject(lbHatch)^.GDIBitmapObject; + GObject^.GDIBrushFill := GDK_STIPPLED; + end; + gbPixmap: + begin + GObject^.GDIBrushPixmap := PGdiObject(lbHatch)^.GDIPixmapObject.Image; + GObject^.GDIBrushFill := GDK_TILED; + end; + end + end else RaiseGDBException('unsupported bitmap'); + if GObject^.GDIBrushPixmap <> nil then + gdk_pixmap_ref(GObject^.GDIBrushPixmap); end; - else RaiseGDBException(Format('unsupported Style %d',[lbStyle])); end; @@ -1953,41 +1965,6 @@ begin Result := HPALETTE(PtrUInt(GObject)); end; -function TGTKWidgetSet.CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; -var - GObject: PGdiObject; -begin - {$IFDEF DebugGDKTraps} - BeginGDKErrorTrap; - {$ENDIF} - - GObject := NewGDIObject(gdiBrush); - try - {$IFDEF DebugGDIBrush} - DebugLn('[TGtkWidgetSet.CreatePatternBrush] ',DbgS(GObject)); - {$ENDIF} - GObject^.IsNullBrush := False; - GObject^.GDIBrushFill := GDK_STIPPLED; - GObject^.GDIBrushPixmap := nil; - if PGdiObject(ABitmap)^.GDIType = gdiBitmap then - case PGdiObject(ABitmap)^.GDIBitmapType of - gbBitmap: GObject^.GDIBrushPixmap := PGdiObject(ABitmap)^.GDIBitmapObject; - gbPixmap: GObject^.GDIBrushPixmap := PGdiObject(ABitmap)^.GDIPixmapObject.Image; - end; - if GObject^.GDIBrushPixmap <> nil then - gdk_pixmap_ref(GObject^.GDIBrushPixmap); - //GObject^.GDIBrushFill := GDK_TILED; - {$IFDEF DebugGDKTraps} - EndGDKErrorTrap; - {$ENDIF} - Result := HBRUSH(PtrUInt(GObject)); - except - Result:=0; - DisposeGDIObject(GObject); - DebugLn('TGtkWidgetSet.CreateBrushIndirect failed'); - end; -end; - {------------------------------------------------------------------------------ Function: CreatePenIndirect Params: none @@ -2519,8 +2496,8 @@ begin debugln('TGtkWidgetSet.DeleteObject gdiBrush: ',DbgS(GdiObject)); //if Cardinal(GdiObject)=$404826F4 then RaiseGDBException(''); {$ENDIF} - if (GDIBrushPixmap <> nil) - then gdk_bitmap_unref(GDIBrushPixmap); + if (GDIBrushPixmap <> nil) then + gdk_pixmap_unref(GDIBrushPixmap); {$IFDEF DebugGDKTraps} EndGDKErrorTrap; {$ENDIF} diff --git a/lcl/interfaces/gtk/gtkwinapih.inc b/lcl/interfaces/gtk/gtkwinapih.inc index 88387d61c3..1a6c4032da 100644 --- a/lcl/interfaces/gtk/gtkwinapih.inc +++ b/lcl/interfaces/gtk/gtkwinapih.inc @@ -59,7 +59,6 @@ function CreateCursor(ACursorInfo: PIconInfo): hCursor; override; function CreateFontIndirect(const LogFont: TLogFont): HFONT; override; function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; override; function CreatePalette(const LogPalette: TLogPalette): HPALETTE; override; -function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; override; function CreatePenIndirect(const LogPen: TLogPen): HPEN; override; function CreatePixmapIndirect(const Data: Pointer; const TransColor: Longint): HBITMAP; override; Function CreatePolygonRgn(Points: PPoint; NumPts: Integer; FillMode: integer): HRGN; Override; diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 52a39d4e52..875d433f00 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -435,30 +435,30 @@ begin BS_PATTERN, // Pattern brush defined by a memory bitmap. BS_PATTERN8X8: // Same as BS_PATTERN. begin + QtBrush.setTextureImage(TQtImage(LogBrush.lbHatch).Handle); end; else WriteLn(Format('Unsupported Style %d',[LogBrush.lbStyle])); end; - { Other non-utilized Qt brushes: - - QtDense1Pattern, - QtDense2Pattern, - QtDense3Pattern, - QtDense4Pattern, - QtDense5Pattern, - QtDense6Pattern, - QtDense7Pattern, - QtLinearGradientPattern, - QtRadialGradientPattern, - QtConicalGradientPattern, - QtTexturePattern = 24 );} + { + Other non-utilized Qt brushes: + QtDense1Pattern, + QtDense2Pattern, + QtDense3Pattern, + QtDense4Pattern, + QtDense5Pattern, + QtDense6Pattern, + QtDense7Pattern, + QtLinearGradientPattern, + QtRadialGradientPattern, + QtConicalGradientPattern + } // set brush color Color := QBrush_Color(QtBrush.Widget)^; ColorRefToTQColor(ColorToRGB(logBrush.lbColor), Color); QBrush_setColor(QtBrush.Widget, @Color); - except {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI CreateBrushIndirect] Failed'); @@ -601,16 +601,6 @@ begin end; end; -function TQtWidgetSet.CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; -var - QtBrush: TQtBrush; -begin - Result := 0; - QtBrush := TQtBrush.Create(True); - QtBrush.setTextureImage(TQtImage(ABitmap).Handle); - Result := HBRUSH(QtBrush); -end; - {------------------------------------------------------------------------------ Function: CreatePenIndirect Params: none diff --git a/lcl/interfaces/qt/qtwinapih.inc b/lcl/interfaces/qt/qtwinapih.inc index fa26b7ce57..1d076131bc 100644 --- a/lcl/interfaces/qt/qtwinapih.inc +++ b/lcl/interfaces/qt/qtwinapih.inc @@ -59,7 +59,6 @@ function CreateCursor(ACursorInfo: PIconInfo): hCursor; override; function CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN; override; function CreateFontIndirect(const LogFont: TLogFont): HFONT; override; function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; override; -function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; override; function CreatePenIndirect(const LogPen: TLogPen): HBRUSH; override; function CreatePixmapIndirect(const Data: Pointer; const TransColor: Longint): HBITMAP; override; function CreatePolygonRgn(Points: PPoint; NumPts: Integer; FillMode: integer): HRGN; override;