View Issue Details

IDProjectCategoryView StatusLast Update
0015684LazarusLCLpublic2014-05-22 19:29
ReporterSENAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.29 (SVN)Product Build 
Target VersionFixed in Version0.9.29 (SVN) 
Summary0015684: Not right cropping in TStringGrid
Descriptionin TStringGrid (TDrawGrid)
When I put bitmap on cell Image not crop, if image was set in last row (columns I havnt test I use only col[0]).
Additional InformationWhen I add in Horizont ScrollBar one or more points for position, cropping is right.

for files (screen and test project) see Bug 0015622
TagsNo tags attached.
Fixed in Revision23729, 23730, 23778
LazTarget-
Widgetset
Attached Files
  • Screen.png (23,730 bytes)
    Screen.png (23,730 bytes)
  • gridsdrawingcellfix.diff (1,226 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 23732)
    +++ lcl/grids.pas	(working copy)
    @@ -3306,6 +3306,7 @@
       Rs: Boolean;
       R: TRect;
       ClipArea: Trect;
    +  ClipRgn: HRGN;
     
       procedure DoDrawCell;
       var
    @@ -3324,7 +3325,7 @@
         Rgn := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
         SelectClipRgn(Canvas.Handle, Rgn);
         DrawCell(aCol, aRow, R, gds);
    -    SelectClipRgn(Canvas.Handle, 0);
    +    SelectClipRgn(Canvas.Handle, ClipRgn);
         DeleteObject(Rgn);
       end;
     
    @@ -3335,6 +3336,7 @@
     
       // is this row within the ClipRect?
       ClipArea := Canvas.ClipRect;
    +
       if not VerticalIntersect( R, ClipArea) then begin
         {$IFDEF DbgVisualChange}
         DebugLn('Drawrow: Skipped row: ', IntToStr(aRow));
    @@ -3342,6 +3344,9 @@
         exit;
       end;
     
    +  ClipRgn := CreateRectRgn(ClipArea.Left, ClipArea.Top, ClipArea.Right,
    +    ClipArea.Bottom);
    +
       // Draw columns in this row
       with FGCache.VisibleGrid do begin
         for aCol:=left to Right do begin
    @@ -3389,6 +3394,7 @@
         if HorizontalIntersect( R, ClipArea) then
           DoDrawCell;
       end;
    +  DeleteObject(ClipRgn);
     end;
     
     procedure TCustomGrid.EditButtonClicked(Sender: TObject);
    
    gridsdrawingcellfix.diff (1,226 bytes)
  • gridsdrawingcellfix-2.diff (684 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 23740)
    +++ lcl/grids.pas	(working copy)
    @@ -3321,11 +3321,15 @@
            end;
         end;
     
    -    Rgn := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
    -    SelectClipRgn(Canvas.Handle, Rgn);
    -    DrawCell(aCol, aRow, R, gds);
    -    SelectClipRgn(Canvas.Handle, 0);
    -    DeleteObject(Rgn);
    +    Canvas.SaveHandleState;
    +    try
    +      Rgn := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
    +      SelectClipRgn(Canvas.Handle, Rgn);
    +      DrawCell(aCol, aRow, R, gds);
    +      DeleteObject(Rgn);
    +    finally
    +      Canvas.RestoreHandleState;
    +    end;
       end;
     
     begin
    

Relationships

related to 0015622 closedZeljan Rikalo transparence in StringGrid with Qt, and crop bug. 
related to 0016011 closedsamuel herzog Can't draw on StringGrid with OnDrawCell 
related to 0026169 assignedJesus Reyes GetFormImage fails to get DBGrid image 

Activities

SEN

2010-02-18 08:41

reporter   ~0034574

Last edited: 2010-02-18 08:42

Qt4.6.1, after fix, now cropping image not visible, there are gray row... when click on it, image is show...
in gtk2 all ok...

thanx for you...

SEN

2010-02-19 10:54

reporter   ~0034593

Im sorry, but now in QT image strached... but i need crop, such as gtk2..
And now first row draw normal, but all next show grayed... also in IDE...

in gtk2 work well.

2010-02-19 11:01

 

Screen.png (23,730 bytes)
Screen.png (23,730 bytes)

2010-02-19 12:52

 

gridsdrawingcellfix.diff (1,226 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 23732)
+++ lcl/grids.pas	(working copy)
@@ -3306,6 +3306,7 @@
   Rs: Boolean;
   R: TRect;
   ClipArea: Trect;
+  ClipRgn: HRGN;
 
   procedure DoDrawCell;
   var
@@ -3324,7 +3325,7 @@
     Rgn := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
     SelectClipRgn(Canvas.Handle, Rgn);
     DrawCell(aCol, aRow, R, gds);
-    SelectClipRgn(Canvas.Handle, 0);
+    SelectClipRgn(Canvas.Handle, ClipRgn);
     DeleteObject(Rgn);
   end;
 
@@ -3335,6 +3336,7 @@
 
   // is this row within the ClipRect?
   ClipArea := Canvas.ClipRect;
+
   if not VerticalIntersect( R, ClipArea) then begin
     {$IFDEF DbgVisualChange}
     DebugLn('Drawrow: Skipped row: ', IntToStr(aRow));
@@ -3342,6 +3344,9 @@
     exit;
   end;
 
+  ClipRgn := CreateRectRgn(ClipArea.Left, ClipArea.Top, ClipArea.Right,
+    ClipArea.Bottom);
+
   // Draw columns in this row
   with FGCache.VisibleGrid do begin
     for aCol:=left to Right do begin
@@ -3389,6 +3394,7 @@
     if HorizontalIntersect( R, ClipArea) then
       DoDrawCell;
   end;
+  DeleteObject(ClipRgn);
 end;
 
 procedure TCustomGrid.EditButtonClicked(Sender: TObject);
gridsdrawingcellfix.diff (1,226 bytes)

Zeljan Rikalo

2010-02-19 12:53

developer   ~0034596

I've attached patch which fixes problem.It just selects Canvas.ClipRect region instead of 0 after cell drawing.
Now it looks ok under qt too.

2010-02-19 16:24

 

gridsdrawingcellfix-2.diff (684 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 23740)
+++ lcl/grids.pas	(working copy)
@@ -3321,11 +3321,15 @@
        end;
     end;
 
-    Rgn := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
-    SelectClipRgn(Canvas.Handle, Rgn);
-    DrawCell(aCol, aRow, R, gds);
-    SelectClipRgn(Canvas.Handle, 0);
-    DeleteObject(Rgn);
+    Canvas.SaveHandleState;
+    try
+      Rgn := CreateRectRgn(R.Left, R.Top, R.Right, R.Bottom);
+      SelectClipRgn(Canvas.Handle, Rgn);
+      DrawCell(aCol, aRow, R, gds);
+      DeleteObject(Rgn);
+    finally
+      Canvas.RestoreHandleState;
+    end;
   end;
 
 begin

Zeljan Rikalo

2010-02-19 16:24

developer   ~0034599

Attached probably cheaper patch for same problem, it uses SaveHandleState & RestoreHandleState only.

Jesus Reyes

2010-02-24 20:19

developer   ~0034733

Applied.

Thanks.

Issue History

Date Modified Username Field Change
2010-02-05 12:41 SEN New Issue
2010-02-05 18:50 Jesus Reyes Status new => assigned
2010-02-05 18:50 Jesus Reyes Assigned To => Jesus Reyes
2010-02-09 14:44 Jesus Reyes Relationship added related to 0015622
2010-02-18 06:37 Jesus Reyes Fixed in Revision => 23729
2010-02-18 06:37 Jesus Reyes LazTarget => -
2010-02-18 06:37 Jesus Reyes Status assigned => resolved
2010-02-18 06:37 Jesus Reyes Fixed in Version => 0.9.29 (SVN)
2010-02-18 06:37 Jesus Reyes Resolution open => fixed
2010-02-18 08:41 SEN Status resolved => assigned
2010-02-18 08:41 SEN Resolution fixed => reopened
2010-02-18 08:41 SEN Note Added: 0034574
2010-02-18 08:42 SEN Note Edited: 0034574
2010-02-18 09:56 Zeljan Rikalo Fixed in Revision 23729 => 23729, 23730
2010-02-18 09:56 Zeljan Rikalo Status assigned => resolved
2010-02-18 09:56 Zeljan Rikalo Resolution reopened => fixed
2010-02-19 10:54 SEN Status resolved => assigned
2010-02-19 10:54 SEN Resolution fixed => reopened
2010-02-19 10:54 SEN Note Added: 0034593
2010-02-19 11:01 SEN File Added: Screen.png
2010-02-19 12:52 Zeljan Rikalo File Added: gridsdrawingcellfix.diff
2010-02-19 12:53 Zeljan Rikalo Note Added: 0034596
2010-02-19 16:24 Zeljan Rikalo File Added: gridsdrawingcellfix-2.diff
2010-02-19 16:24 Zeljan Rikalo Note Added: 0034599
2010-02-24 20:19 Jesus Reyes Fixed in Revision 23729, 23730 => 23729, 23730, 23778
2010-02-24 20:19 Jesus Reyes Status assigned => resolved
2010-02-24 20:19 Jesus Reyes Resolution reopened => fixed
2010-02-24 20:19 Jesus Reyes Note Added: 0034733
2010-03-16 18:52 Vincent Snijders Relationship added related to 0016011
2011-12-01 11:23 Marc Weustink Status resolved => closed
2014-05-22 19:29 Jesus Reyes Relationship added related to 0026169