mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 10:29:28 +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;
|
||||
gtk_init(@argc, @argv);
|
||||
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^.set_application_id(PgChar(AId));
|
||||
FGtk3Application^.register(nil, nil);
|
||||
|
@ -966,7 +966,7 @@ begin
|
||||
if FBkMode = TRANSPARENT then
|
||||
begin
|
||||
DebugLn('TGtk3DeviceContext.ApplyBrush setting transparent source');
|
||||
cairo_set_source_surface(Widget, CairoSurface, 0 , 0);
|
||||
//cairo_set_source_surface(Widget, CairoSurface, 0 , 0);
|
||||
end else
|
||||
SetSourceColor(FCurrentBrush.Color);
|
||||
end;
|
||||
@ -1552,13 +1552,14 @@ begin
|
||||
if ABrush <> 0 then
|
||||
begin
|
||||
ATempBrush := FCurrentBrush;
|
||||
fBkMode:=OPAQUE;
|
||||
SetCurrentBrush(TGtk3Brush(ABrush));
|
||||
end;
|
||||
|
||||
applyBrush;
|
||||
cairo_rectangle(Widget, x, y, w, h);
|
||||
cairo_stroke_preserve(Widget);
|
||||
cairo_fill(Widget);
|
||||
cairo_stroke(Widget);
|
||||
// cairo_clip(Widget);
|
||||
|
||||
// cairo_fill_preserve(Widget);
|
||||
|
@ -1665,9 +1665,10 @@ function TGtk3Widget.GtkEventPaint(Sender: PGtkWidget; AContext: Pcairo_t
|
||||
): Boolean; cdecl;
|
||||
var
|
||||
Msg: TLMPaint;
|
||||
AStruct: PPaintStruct;
|
||||
AStruct: TPaintStruct;
|
||||
P: TPoint;
|
||||
AClipRect: TGdkRectangle;
|
||||
localClip:TRect;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
@ -1677,9 +1678,9 @@ begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
|
||||
Msg.Msg := LM_PAINT;
|
||||
New(AStruct);
|
||||
FillChar(AStruct^, SizeOf(TPaintStruct), 0);
|
||||
Msg.PaintStruct := AStruct;
|
||||
//New(AStruct);
|
||||
FillChar(AStruct, SizeOf(TPaintStruct), 0);
|
||||
Msg.PaintStruct := @AStruct;
|
||||
|
||||
with PaintData do
|
||||
begin
|
||||
@ -1690,14 +1691,15 @@ begin
|
||||
ClipRegion := nil;
|
||||
// gdk_cairo_region(AContext, ClipRegion);
|
||||
// Event^.expose.region;
|
||||
if ClipRect = nil then
|
||||
New(ClipRect);
|
||||
//if ClipRect = nil then
|
||||
// New(ClipRect);
|
||||
gdk_cairo_get_clip_rectangle(AContext, @AClipRect);
|
||||
ClipRect^ := RectFromGdkRect(AClipRect);
|
||||
localClip:=RectFromGdkRect(AClipRect);
|
||||
ClipRect := @localClip;
|
||||
end;
|
||||
|
||||
FCairoContext := AContext;
|
||||
Msg.DC := BeginPaint(THandle(Self), AStruct^);
|
||||
Msg.DC := BeginPaint(THandle(Self), AStruct);
|
||||
FContext := Msg.DC;
|
||||
|
||||
Msg.PaintStruct^.rcPaint := PaintData.ClipRect^;
|
||||
@ -1743,11 +1745,11 @@ begin
|
||||
LCLObject.WindowProc(TLMessage(Msg));
|
||||
finally
|
||||
FCairoContext := nil;
|
||||
Dispose(PaintData.ClipRect);
|
||||
//Dispose(PaintData.ClipRect);
|
||||
Fillchar(FPaintData, SizeOf(FPaintData), 0);
|
||||
FContext := 0;
|
||||
EndPaint(THandle(Self), AStruct^);
|
||||
Dispose(AStruct);
|
||||
EndPaint(THandle(Self), AStruct);
|
||||
//Dispose(AStruct);
|
||||
end;
|
||||
except
|
||||
Application.HandleException(nil);
|
||||
|
@ -210,7 +210,7 @@ begin
|
||||
cairo_region_get_extents(RSrc1, @ACairoRect);
|
||||
TGtk3Region(Dest).Handle := cairo_region_create_rectangle(@ACairoRect);
|
||||
RDest := TGtk3Region(Dest).Handle;
|
||||
cairo_region_translate(RDest, -ACairoRect.x, -ACairoRect.y);
|
||||
//cairo_region_translate(RDest, -ACairoRect.x, -ACairoRect.y);
|
||||
end else
|
||||
AStatus := cairo_region_intersect(RDest, RSrc1);
|
||||
end;
|
||||
@ -1361,6 +1361,29 @@ begin
|
||||
Result := cairo_region_equal(TGtk3Region(Rgn1).Handle,TGtk3Region(Rgn2).Handle);
|
||||
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,
|
||||
Bottom: Integer): Integer;
|
||||
begin
|
||||
|
@ -87,6 +87,7 @@ function EnumFontFamilies(DC: HDC; Family: Pchar; EnumFontFamProc: FontEnumProc;
|
||||
{$ENDIF}
|
||||
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 IntersectClipRect(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 ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
|
||||
|
Loading…
Reference in New Issue
Block a user