CairoCanvas: fix GdkCairoCanvas ignored Controls coordinates, always paints on parent (0, 0) position, from Petr-K, issue #25485

git-svn-id: trunk@44432 -
This commit is contained in:
jesus 2014-03-15 08:33:39 +00:00
parent 9f64f946ed
commit b6ea3d2753
2 changed files with 16 additions and 2 deletions

View File

@ -61,6 +61,7 @@ type
procedure DebugSys; procedure DebugSys;
protected protected
ScaleX, ScaleY, FontScale: Double; ScaleX, ScaleY, FontScale: Double;
procedure SetLazClipRect(r: TRect);
procedure DoLineTo(X1,Y1: Integer); override; procedure DoLineTo(X1,Y1: Integer); override;
function CreateCairoHandle: HDC; virtual; abstract; function CreateCairoHandle: HDC; virtual; abstract;
procedure DestroyCairoHandle; virtual; procedure DestroyCairoHandle; virtual;
@ -411,6 +412,7 @@ end;
procedure TCairoPrinterCanvas.SetClipRect(const ARect: TRect); procedure TCairoPrinterCanvas.SetClipRect(const ARect: TRect);
begin begin
RequiredState([csHandleValid]);
if FUserClipRect=nil then if FUserClipRect=nil then
New(FUserClipRect); New(FUserClipRect);
@ -442,6 +444,7 @@ end;
procedure TCairoPrinterCanvas.SetClipping(const AValue: boolean); procedure TCairoPrinterCanvas.SetClipping(const AValue: boolean);
begin begin
RequiredState([csHandleValid]);
cairo_reset_clip(cr); cairo_reset_clip(cr);
if not AValue then begin if not AValue then begin
@ -500,6 +503,11 @@ begin
DebugLn('CurMatrix: xx=%f yx=%f xy=%f yy=%f x0=%f y0=%f',[xx,yx,xy,yy,x0,y0]); DebugLn('CurMatrix: xx=%f yx=%f xy=%f yy=%f x0=%f y0=%f',[xx,yx,xy,yy,x0,y0]);
end; end;
procedure TCairoPrinterCanvas.SetLazClipRect(r: TRect);
begin
FLazClipRect := r;
end;
constructor TCairoPrinterCanvas.Create(APrinter: TPrinter); constructor TCairoPrinterCanvas.Create(APrinter: TPrinter);
begin begin
inherited Create(APrinter); inherited Create(APrinter);

View File

@ -18,6 +18,10 @@ type
implementation implementation
uses
Classes;
{ TGdkCairoCanvas } { TGdkCairoCanvas }
function TGdkCairoCanvas.CreateCairoHandle: HDC; function TGdkCairoCanvas.CreateCairoHandle: HDC;
@ -27,8 +31,10 @@ end;
procedure TGdkCairoCanvas.SetHandle(NewHandle: HDC); procedure TGdkCairoCanvas.SetHandle(NewHandle: HDC);
begin begin
if NewHandle <> 0 then if NewHandle <> 0 then begin
NewHandle := {%H-}HDC(gdk_cairo_create(TGtk2DeviceContext(NewHandle).Drawable)); NewHandle := {%H-}HDC(gdk_cairo_create(TGtkDeviceContext(NewHandle).Drawable));
SetLazClipRect(Rect(Control.Left, Control.Top, Control.Left + Control.Width, Control.Top + Control.Height));
end;
inherited SetHandle(NewHandle); inherited SetHandle(NewHandle);
end; end;