View Issue Details

IDProjectCategoryView StatusLast Update
0025485LazarusPrinterpublic2014-11-06 12:16
ReporterPetr-KAssigned ToJesus Reyes 
PriorityhighSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3 (SVN)Product Buildtrunk #43585 
Target Version1.4Fixed in Version1.3 (SVN) 
Summary0025485: CairoCanvas - repair Clipping
DescriptionAdded missing RequiredState([csHandleValid]);

GdkCairoCanvas ignored Controls coordinates, always paints on parent (0, 0) position.
TagsNo tags attached.
Fixed in Revision44432
LazTarget1.4
WidgetsetGTK 2
Attached Files
  • cairocanvas.patch (1,925 bytes)
    Index: unix/gdkcairocanvas.pas
    ===================================================================
    --- unix/gdkcairocanvas.pas	(revision 43585)
    +++ unix/gdkcairocanvas.pas	(working copy)
    @@ -18,6 +18,10 @@
     
     implementation
     
    +uses
    +  Classes;
    +
    +
     { TGdkCairoCanvas }
     
     function TGdkCairoCanvas.CreateCairoHandle: HDC;
    @@ -27,8 +31,10 @@
     
     procedure TGdkCairoCanvas.SetHandle(NewHandle: HDC);
     begin
    -  if NewHandle <> 0 then
    -    NewHandle := {%H-}HDC(gdk_cairo_create(TGtk2DeviceContext(NewHandle).Drawable));
    +  if NewHandle <> 0 then begin
    +    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);
     end;
     
    Index: cairocanvas.pas
    ===================================================================
    --- cairocanvas.pas	(revision 43585)
    +++ cairocanvas.pas	(working copy)
    @@ -61,6 +61,7 @@
         procedure DebugSys;
       protected
         ScaleX, ScaleY, FontScale: Double;
    +    procedure SetLazClipRect(r: TRect);
         procedure DoLineTo(X1,Y1: Integer); override;
         function CreateCairoHandle: HDC; virtual; abstract;
         procedure DestroyCairoHandle; virtual;
    @@ -411,6 +412,7 @@
     
     procedure TCairoPrinterCanvas.SetClipRect(const ARect: TRect);
     begin
    +  RequiredState([csHandleValid]);
       if FUserClipRect=nil then
         New(FUserClipRect);
     
    @@ -442,6 +444,7 @@
     
     procedure TCairoPrinterCanvas.SetClipping(const AValue: boolean);
     begin
    +  RequiredState([csHandleValid]);
       cairo_reset_clip(cr);
     
       if not AValue then begin
    @@ -500,6 +503,11 @@
         DebugLn('CurMatrix: xx=%f yx=%f xy=%f yy=%f x0=%f y0=%f',[xx,yx,xy,yy,x0,y0]);
     end;
     
    +procedure TCairoPrinterCanvas.SetLazClipRect(r: TRect);
    +begin
    +  FLazClipRect := r;
    +end;
    +
     constructor TCairoPrinterCanvas.Create(APrinter: TPrinter);
     begin
       inherited Create(APrinter);
    
    cairocanvas.patch (1,925 bytes)

Activities

Petr-K

2014-01-02 15:07

reporter  

cairocanvas.patch (1,925 bytes)
Index: unix/gdkcairocanvas.pas
===================================================================
--- unix/gdkcairocanvas.pas	(revision 43585)
+++ unix/gdkcairocanvas.pas	(working copy)
@@ -18,6 +18,10 @@
 
 implementation
 
+uses
+  Classes;
+
+
 { TGdkCairoCanvas }
 
 function TGdkCairoCanvas.CreateCairoHandle: HDC;
@@ -27,8 +31,10 @@
 
 procedure TGdkCairoCanvas.SetHandle(NewHandle: HDC);
 begin
-  if NewHandle <> 0 then
-    NewHandle := {%H-}HDC(gdk_cairo_create(TGtk2DeviceContext(NewHandle).Drawable));
+  if NewHandle <> 0 then begin
+    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);
 end;
 
Index: cairocanvas.pas
===================================================================
--- cairocanvas.pas	(revision 43585)
+++ cairocanvas.pas	(working copy)
@@ -61,6 +61,7 @@
     procedure DebugSys;
   protected
     ScaleX, ScaleY, FontScale: Double;
+    procedure SetLazClipRect(r: TRect);
     procedure DoLineTo(X1,Y1: Integer); override;
     function CreateCairoHandle: HDC; virtual; abstract;
     procedure DestroyCairoHandle; virtual;
@@ -411,6 +412,7 @@
 
 procedure TCairoPrinterCanvas.SetClipRect(const ARect: TRect);
 begin
+  RequiredState([csHandleValid]);
   if FUserClipRect=nil then
     New(FUserClipRect);
 
@@ -442,6 +444,7 @@
 
 procedure TCairoPrinterCanvas.SetClipping(const AValue: boolean);
 begin
+  RequiredState([csHandleValid]);
   cairo_reset_clip(cr);
 
   if not AValue then begin
@@ -500,6 +503,11 @@
     DebugLn('CurMatrix: xx=%f yx=%f xy=%f yy=%f x0=%f y0=%f',[xx,yx,xy,yy,x0,y0]);
 end;
 
+procedure TCairoPrinterCanvas.SetLazClipRect(r: TRect);
+begin
+  FLazClipRect := r;
+end;
+
 constructor TCairoPrinterCanvas.Create(APrinter: TPrinter);
 begin
   inherited Create(APrinter);
cairocanvas.patch (1,925 bytes)

Jesus Reyes

2014-03-15 09:34

developer   ~0073711

Applied, thanks.

Issue History

Date Modified Username Field Change
2014-01-02 15:07 Petr-K New Issue
2014-01-02 15:07 Petr-K File Added: cairocanvas.patch
2014-01-25 06:11 Jesus Reyes Assigned To => Jesus Reyes
2014-01-25 06:11 Jesus Reyes Status new => assigned
2014-03-14 07:47 Jesus Reyes LazTarget => -
2014-03-14 07:47 Jesus Reyes Priority normal => high
2014-03-15 09:34 Jesus Reyes Fixed in Revision => 44432
2014-03-15 09:34 Jesus Reyes LazTarget - => 1.4
2014-03-15 09:34 Jesus Reyes Note Added: 0073711
2014-03-15 09:34 Jesus Reyes Status assigned => resolved
2014-03-15 09:34 Jesus Reyes Fixed in Version => 1.3 (SVN)
2014-03-15 09:34 Jesus Reyes Resolution open => fixed
2014-03-15 09:34 Jesus Reyes Target Version => 1.4
2014-11-06 12:16 Petr-K Status resolved => closed