mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 22:19:29 +02:00
gtk3: make TCanvas.TextRect useable on coordinates <> 0,0. patch by Anton Kavalenka. issue #31933
git-svn-id: trunk@58592 -
This commit is contained in:
parent
dacdf78926
commit
11c3b18b53
@ -95,7 +95,7 @@ begin
|
|||||||
g_type_init;
|
g_type_init;
|
||||||
gtk_init(@argc, @argv);
|
gtk_init(@argc, @argv);
|
||||||
AGtkThread := g_thread_self();
|
AGtkThread := g_thread_self();
|
||||||
AId := 'lcl.' + dbgHex(PtrUInt(AGtkThread));
|
AId := 'org.lcl.thread_' + dbgHex(PtrUInt(AGtkThread));
|
||||||
FGtk3Application := TGtkApplication.new(PgChar(AId), G_APPLICATION_NON_UNIQUE);
|
FGtk3Application := TGtkApplication.new(PgChar(AId), G_APPLICATION_NON_UNIQUE);
|
||||||
// FGtk3Application^.set_application_id(PgChar(AId));
|
// FGtk3Application^.set_application_id(PgChar(AId));
|
||||||
FGtk3Application^.register(nil, nil);
|
FGtk3Application^.register(nil, nil);
|
||||||
|
@ -966,7 +966,7 @@ begin
|
|||||||
if FBkMode = TRANSPARENT then
|
if FBkMode = TRANSPARENT then
|
||||||
begin
|
begin
|
||||||
DebugLn('TGtk3DeviceContext.ApplyBrush setting transparent source');
|
DebugLn('TGtk3DeviceContext.ApplyBrush setting transparent source');
|
||||||
cairo_set_source_surface(Widget, CairoSurface, 0 , 0);
|
//cairo_set_source_surface(Widget, CairoSurface, 0 , 0);
|
||||||
end else
|
end else
|
||||||
SetSourceColor(FCurrentBrush.Color);
|
SetSourceColor(FCurrentBrush.Color);
|
||||||
end;
|
end;
|
||||||
@ -1552,13 +1552,14 @@ begin
|
|||||||
if ABrush <> 0 then
|
if ABrush <> 0 then
|
||||||
begin
|
begin
|
||||||
ATempBrush := FCurrentBrush;
|
ATempBrush := FCurrentBrush;
|
||||||
|
fBkMode:=OPAQUE;
|
||||||
SetCurrentBrush(TGtk3Brush(ABrush));
|
SetCurrentBrush(TGtk3Brush(ABrush));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
applyBrush;
|
applyBrush;
|
||||||
cairo_rectangle(Widget, x, y, w, h);
|
cairo_rectangle(Widget, x, y, w, h);
|
||||||
|
cairo_stroke_preserve(Widget);
|
||||||
cairo_fill(Widget);
|
cairo_fill(Widget);
|
||||||
cairo_stroke(Widget);
|
|
||||||
// cairo_clip(Widget);
|
// cairo_clip(Widget);
|
||||||
|
|
||||||
// cairo_fill_preserve(Widget);
|
// cairo_fill_preserve(Widget);
|
||||||
|
@ -1665,9 +1665,10 @@ function TGtk3Widget.GtkEventPaint(Sender: PGtkWidget; AContext: Pcairo_t
|
|||||||
): Boolean; cdecl;
|
): Boolean; cdecl;
|
||||||
var
|
var
|
||||||
Msg: TLMPaint;
|
Msg: TLMPaint;
|
||||||
AStruct: PPaintStruct;
|
AStruct: TPaintStruct;
|
||||||
P: TPoint;
|
P: TPoint;
|
||||||
AClipRect: TGdkRectangle;
|
AClipRect: TGdkRectangle;
|
||||||
|
localClip:TRect;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
@ -1677,9 +1678,9 @@ begin
|
|||||||
FillChar(Msg, SizeOf(Msg), #0);
|
FillChar(Msg, SizeOf(Msg), #0);
|
||||||
|
|
||||||
Msg.Msg := LM_PAINT;
|
Msg.Msg := LM_PAINT;
|
||||||
New(AStruct);
|
//New(AStruct);
|
||||||
FillChar(AStruct^, SizeOf(TPaintStruct), 0);
|
FillChar(AStruct, SizeOf(TPaintStruct), 0);
|
||||||
Msg.PaintStruct := AStruct;
|
Msg.PaintStruct := @AStruct;
|
||||||
|
|
||||||
with PaintData do
|
with PaintData do
|
||||||
begin
|
begin
|
||||||
@ -1690,14 +1691,15 @@ begin
|
|||||||
ClipRegion := nil;
|
ClipRegion := nil;
|
||||||
// gdk_cairo_region(AContext, ClipRegion);
|
// gdk_cairo_region(AContext, ClipRegion);
|
||||||
// Event^.expose.region;
|
// Event^.expose.region;
|
||||||
if ClipRect = nil then
|
//if ClipRect = nil then
|
||||||
New(ClipRect);
|
// New(ClipRect);
|
||||||
gdk_cairo_get_clip_rectangle(AContext, @AClipRect);
|
gdk_cairo_get_clip_rectangle(AContext, @AClipRect);
|
||||||
ClipRect^ := RectFromGdkRect(AClipRect);
|
localClip:=RectFromGdkRect(AClipRect);
|
||||||
|
ClipRect := @localClip;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FCairoContext := AContext;
|
FCairoContext := AContext;
|
||||||
Msg.DC := BeginPaint(THandle(Self), AStruct^);
|
Msg.DC := BeginPaint(THandle(Self), AStruct);
|
||||||
FContext := Msg.DC;
|
FContext := Msg.DC;
|
||||||
|
|
||||||
Msg.PaintStruct^.rcPaint := PaintData.ClipRect^;
|
Msg.PaintStruct^.rcPaint := PaintData.ClipRect^;
|
||||||
@ -1743,11 +1745,11 @@ begin
|
|||||||
LCLObject.WindowProc(TLMessage(Msg));
|
LCLObject.WindowProc(TLMessage(Msg));
|
||||||
finally
|
finally
|
||||||
FCairoContext := nil;
|
FCairoContext := nil;
|
||||||
Dispose(PaintData.ClipRect);
|
//Dispose(PaintData.ClipRect);
|
||||||
Fillchar(FPaintData, SizeOf(FPaintData), 0);
|
Fillchar(FPaintData, SizeOf(FPaintData), 0);
|
||||||
FContext := 0;
|
FContext := 0;
|
||||||
EndPaint(THandle(Self), AStruct^);
|
EndPaint(THandle(Self), AStruct);
|
||||||
Dispose(AStruct);
|
//Dispose(AStruct);
|
||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
Application.HandleException(nil);
|
Application.HandleException(nil);
|
||||||
|
@ -210,7 +210,7 @@ begin
|
|||||||
cairo_region_get_extents(RSrc1, @ACairoRect);
|
cairo_region_get_extents(RSrc1, @ACairoRect);
|
||||||
TGtk3Region(Dest).Handle := cairo_region_create_rectangle(@ACairoRect);
|
TGtk3Region(Dest).Handle := cairo_region_create_rectangle(@ACairoRect);
|
||||||
RDest := TGtk3Region(Dest).Handle;
|
RDest := TGtk3Region(Dest).Handle;
|
||||||
cairo_region_translate(RDest, -ACairoRect.x, -ACairoRect.y);
|
//cairo_region_translate(RDest, -ACairoRect.x, -ACairoRect.y);
|
||||||
end else
|
end else
|
||||||
AStatus := cairo_region_intersect(RDest, RSrc1);
|
AStatus := cairo_region_intersect(RDest, RSrc1);
|
||||||
end;
|
end;
|
||||||
@ -1361,6 +1361,29 @@ begin
|
|||||||
Result := cairo_region_equal(TGtk3Region(Rgn1).Handle,TGtk3Region(Rgn2).Handle);
|
Result := cairo_region_equal(TGtk3Region(Rgn1).Handle,TGtk3Region(Rgn2).Handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TGtk3WidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right,Bottom: Integer): Integer;
|
||||||
|
var
|
||||||
|
ncorg,dcOrigin:TPoint;
|
||||||
|
rgn,clip:HRGN;
|
||||||
|
begin
|
||||||
|
{$IFDEF GTK3DEBUGNOTIMPLEMENTED}
|
||||||
|
DebugLn('WARNING: TGtk3WidgetSet.ExcludeClipRect not implemented ...');
|
||||||
|
{$ENDIF}
|
||||||
|
rgn:=Self.CreateRectRgn(Left,Top,Right,Bottom);
|
||||||
|
//Self.SelectClipRGN(dc,rgn);
|
||||||
|
clip:=Self.CreateEmptyRegion;
|
||||||
|
Self.GetClipRGN(dc,clip);
|
||||||
|
Self.CombineRgn(clip,rgn,clip,RGN_AND);
|
||||||
|
Self.SelectClipRGN(dc,clip);
|
||||||
|
DeleteObject(clip);
|
||||||
|
DeleteObject(rgn);
|
||||||
|
// fail Self.ExtSelectClipRGN(dc,rgn,RGN_AND);
|
||||||
|
{ ncorg:=Tgtk3DeviceContext(dc).fncOrigin;
|
||||||
|
GetWindowOrgEx(DC, @DCOrigin);
|
||||||
|
Result:=inherited IntersectClipRect(dc, Left, Top, Right, Bottom);}
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TGtk3WidgetSet.ExcludeClipRect(dc: hdc; Left, Top, Right,
|
function TGtk3WidgetSet.ExcludeClipRect(dc: hdc; Left, Top, Right,
|
||||||
Bottom: Integer): Integer;
|
Bottom: Integer): Integer;
|
||||||
begin
|
begin
|
||||||
|
@ -87,6 +87,7 @@ function EnumFontFamilies(DC: HDC; Family: Pchar; EnumFontFamProc: FontEnumProc;
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
function EnumFontFamiliesEx({%H-}DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; {%H-}Flags: dword): longint; override;
|
function EnumFontFamiliesEx({%H-}DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; {%H-}Flags: dword): longint; override;
|
||||||
function EqualRgn(Rgn1: HRGN; Rgn2: HRGN): Boolean; override;
|
function EqualRgn(Rgn1: HRGN; Rgn2: HRGN): Boolean; override;
|
||||||
|
function IntersectClipRect(dc: hdc; Left, Top, Right,Bottom: Integer): Integer; override;
|
||||||
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
|
||||||
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
|
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
|
||||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
||||||
|
Loading…
Reference in New Issue
Block a user