mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-10 22:19:19 +02:00
- use CreateBrushIndirect for gtk and qt to implement CreatePatternBrush
- use changes of Luiz Americo from 0008814 to pattern brush git-svn-id: trunk@12874 -
This commit is contained in:
parent
35cdd59256
commit
c6a5a6d431
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user