View Issue Details

IDProjectCategoryView StatusLast Update
0025154LazarusLCLpublic2014-10-04 13:14
ReporterBabak MahmoudabadiAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSWindowsOS Versionall
Product VersionProduct Build 
Target Version1.4Fixed in Version1.3 (SVN) 
Summary0025154: TCustomGrid Right to left Bugs
DescriptionHello guys

The DBGrid appearance in Right to left mode is incorrect.
I provided a patch for fix this issue and attached it.
Please update TCustomDBGrid and TCustomGrid Class.

Thanks.
Bob
Additional InformationFPC 2.6.2
Tagsdbgrid, patch
Fixed in Revision46377
LazTarget1.4
Widgetset
Attached Files
  • Patch.zip (10,421 bytes)
  • GridsTestHarness(BiDi-RightToLeft).zip (4,006 bytes)
  • DBGrid_Indicator_For_BiDi_RightToLeft.patch (2,367 bytes)
    Index: lcl/dbgrids.pas
    ===================================================================
    --- lcl/dbgrids.pas	(revision 46342)
    +++ lcl/dbgrids.pas	(working copy)
    @@ -3056,19 +3056,31 @@
       case Opt of
         dsBrowse:
           begin //
    -        ACanvas.Brush.Color:=clBlack;
    -        ACanvas.Pen.Color:=clBlack;
    -        CenterY;
    -        x:= R.Left+3;
    -        if MultiSel then begin
    +      ACanvas.Brush.Color:=clBlack;
    +      ACanvas.Pen.Color:=clBlack;
    +      CenterY;
    +      x:= R.Left+3;
    +      if MultiSel then begin
    +        if BiDiMode = bdRightToLeft then begin
    +          ACanvas.Polyline([point(x+dx,y-dy),  point(x,y),point(x+dx,y+dy), point(x+dx,y+dy-1)]);
    +          ACanvas.Polyline([point(x+dx,y-dy+1),  point(x+1,y),point(x+dx,y+dy-1), point(x+dx,y+dy-2)]);
    +          CenterX;
    +          Dec(X,3);
    +          ACanvas.Ellipse(Rect(X+dx-2,Y-2,X+dx+2,Y+2));
    +        end else begin
               ACanvas.Polyline([point(x,y-dy),  point(x+dx,y),point(x,y+dy), point(x,y+dy-1)]);
               ACanvas.Polyline([point(x,y-dy+1),point(x+dx-1,y),point(x, y+dy-1), point(x,y+dy-2)]);
               CenterX;
               Dec(X,3);
               ACanvas.Ellipse(Rect(X-2,Y-2,X+2,Y+2));
    -        end else
    -          ACanvas.Polygon([point(x,y-dy),point(x+dx,y),point(x, y+dy),point(x,y-dy)]);
    -       end;
    +        end;
    +      end else begin
    +          if BiDiMode = bdRightToLeft then
    +            ACanvas.Polygon([point(x,y),point(x+dx,y-dy),point(x+dx, y+dy),point(x,y)])
    +          else
    +            ACanvas.Polygon([point(x,y-dy),point(x+dx,y),point(x, y+dy),point(x,y-dy)]);
    +        end;
    +      end;
         dsEdit:
           DrawEdit(clBlack);
         dsInsert:
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 46342)
    +++ lcl/grids.pas	(working copy)
    @@ -7201,8 +7201,17 @@
     }
     begin
       if goRowSelect in Options then begin
    -    aRect.Left := FGCache.FixedWidth + 1;
    -    aRect.Right := FGCache.MaxClientXY.x;
    +    if UseRightToLeftAlignment then
    +    begin
    +      aRect.Left := GCache.ClientWidth - GCache.MaxClientXY.x;
    +      aRect.Right := GCache.ClientWidth - GCache.FixedWidth;
    +    end
    +    else
    +    begin
    +      aRect.Left := GCache.FixedWidth + 1;
    +      aRect.Right := GCache.MaxClientXY.x;
    +    end;
    +
         FlipRect(aRect);
       end;
       if goHorzLine in Options then dec(aRect.Bottom, 1);
    

Activities

Babak Mahmoudabadi

2013-10-06 19:35

reporter  

Patch.zip (10,421 bytes)

Mike Thompson

2014-09-28 22:18

developer   ~0077786

Last edited: 2014-09-28 22:21

View 3 revisions

There isn't a patch attached. Please see http://wiki.lazarus.freepascal.org/Creating_A_Patch for details on how to do so. There's also no test project attached.

In the meantime, I can confirm the issue still exists (Indicator in DB Grid pointing the wrong direction) and I will work through the supplied code and see if I can't produce a patch from it. Shouldn't be that hard.

Mike Thompson

2014-09-28 22:32

developer  

GridsTestHarness(BiDi-RightToLeft).zip (4,006 bytes)

Mike Thompson

2014-09-28 22:35

developer  

DBGrid_Indicator_For_BiDi_RightToLeft.patch (2,367 bytes)
Index: lcl/dbgrids.pas
===================================================================
--- lcl/dbgrids.pas	(revision 46342)
+++ lcl/dbgrids.pas	(working copy)
@@ -3056,19 +3056,31 @@
   case Opt of
     dsBrowse:
       begin //
-        ACanvas.Brush.Color:=clBlack;
-        ACanvas.Pen.Color:=clBlack;
-        CenterY;
-        x:= R.Left+3;
-        if MultiSel then begin
+      ACanvas.Brush.Color:=clBlack;
+      ACanvas.Pen.Color:=clBlack;
+      CenterY;
+      x:= R.Left+3;
+      if MultiSel then begin
+        if BiDiMode = bdRightToLeft then begin
+          ACanvas.Polyline([point(x+dx,y-dy),  point(x,y),point(x+dx,y+dy), point(x+dx,y+dy-1)]);
+          ACanvas.Polyline([point(x+dx,y-dy+1),  point(x+1,y),point(x+dx,y+dy-1), point(x+dx,y+dy-2)]);
+          CenterX;
+          Dec(X,3);
+          ACanvas.Ellipse(Rect(X+dx-2,Y-2,X+dx+2,Y+2));
+        end else begin
           ACanvas.Polyline([point(x,y-dy),  point(x+dx,y),point(x,y+dy), point(x,y+dy-1)]);
           ACanvas.Polyline([point(x,y-dy+1),point(x+dx-1,y),point(x, y+dy-1), point(x,y+dy-2)]);
           CenterX;
           Dec(X,3);
           ACanvas.Ellipse(Rect(X-2,Y-2,X+2,Y+2));
-        end else
-          ACanvas.Polygon([point(x,y-dy),point(x+dx,y),point(x, y+dy),point(x,y-dy)]);
-       end;
+        end;
+      end else begin
+          if BiDiMode = bdRightToLeft then
+            ACanvas.Polygon([point(x,y),point(x+dx,y-dy),point(x+dx, y+dy),point(x,y)])
+          else
+            ACanvas.Polygon([point(x,y-dy),point(x+dx,y),point(x, y+dy),point(x,y-dy)]);
+        end;
+      end;
     dsEdit:
       DrawEdit(clBlack);
     dsInsert:
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 46342)
+++ lcl/grids.pas	(working copy)
@@ -7201,8 +7201,17 @@
 }
 begin
   if goRowSelect in Options then begin
-    aRect.Left := FGCache.FixedWidth + 1;
-    aRect.Right := FGCache.MaxClientXY.x;
+    if UseRightToLeftAlignment then
+    begin
+      aRect.Left := GCache.ClientWidth - GCache.MaxClientXY.x;
+      aRect.Right := GCache.ClientWidth - GCache.FixedWidth;
+    end
+    else
+    begin
+      aRect.Left := GCache.FixedWidth + 1;
+      aRect.Right := GCache.MaxClientXY.x;
+    end;
+
     FlipRect(aRect);
   end;
   if goHorzLine in Options then dec(aRect.Bottom, 1);

Mike Thompson

2014-09-28 22:40

developer   ~0077787

Last edited: 2014-09-29 10:54

View 2 revisions

Easier than I thought - all the changes were in blocks.

The issue reported by @Babak is that the indicator is drawn in the wrong direction

Less said about attached patch "grids.pas.patch" the better. I selected the wrong file first time. Sorry. Please ignore this file.
Edit: Reinier Olislagers: deleted file

Attached patch "DBGrid_Indicator_For_BiDi_RightToLeft.patch" is completely derived from @Babak Mahmoudabadi's code, and I can confirm it works.

Attached project shows TStringGrid and TDBGrid in RightToLeft. Issue only affects TDBGrid though. I included the other two grids as there is a minor change in grids.pas, and I wanted to see if anything obvious was broken in the other two. Couldn't see anything.

Jesus Reyes

2014-09-30 20:50

developer   ~0077825

Applied, thanks.

Issue History

Date Modified Username Field Change
2013-10-06 19:35 Babak Mahmoudabadi New Issue
2013-10-06 19:35 Babak Mahmoudabadi File Added: Patch.zip
2013-10-06 19:57 Jonas Maebe Project FPC => Lazarus
2013-10-07 07:53 Jesus Reyes Assigned To => Jesus Reyes
2013-10-07 07:53 Jesus Reyes Status new => assigned
2014-09-24 19:42 Babak Mahmoudabadi Tag Attached: dbgrid
2014-09-24 19:42 Babak Mahmoudabadi Tag Attached: patch
2014-09-24 21:02 Jesus Reyes LazTarget => 1.4
2014-09-24 21:02 Jesus Reyes Product Version 2.6.2 =>
2014-09-24 21:02 Jesus Reyes Target Version => 1.4
2014-09-24 21:04 Jesus Reyes Additional Information Updated View Revisions
2014-09-28 22:18 Mike Thompson Note Added: 0077786
2014-09-28 22:19 Mike Thompson Note Edited: 0077786 View Revisions
2014-09-28 22:21 Mike Thompson Note Edited: 0077786 View Revisions
2014-09-28 22:32 Mike Thompson File Added: GridsTestHarness(BiDi-RightToLeft).zip
2014-09-28 22:34 Mike Thompson File Added: grids.pas.patch
2014-09-28 22:35 Mike Thompson File Added: DBGrid_Indicator_For_BiDi_RightToLeft.patch
2014-09-28 22:40 Mike Thompson Note Added: 0077787
2014-09-29 10:53 Reinier Olislagers File Deleted: grids.pas.patch
2014-09-29 10:54 Reinier Olislagers Note Edited: 0077787 View Revisions
2014-09-30 20:50 Jesus Reyes Fixed in Revision => 46377
2014-09-30 20:50 Jesus Reyes Note Added: 0077825
2014-09-30 20:50 Jesus Reyes Status assigned => resolved
2014-09-30 20:50 Jesus Reyes Fixed in Version => 1.3 (SVN)
2014-09-30 20:50 Jesus Reyes Resolution open => fixed