View Issue Details

IDProjectCategoryView StatusLast Update
0035662PatchesLCLpublic2019-06-14 01:08
ReporterAlexey Tor.Assigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version2.1 (SVN) 
Summary0035662: Grid: pretty lines for GridLineStyle=psDot on Win32
DescriptionWin10.
By default, Grid's Pen.Cosmetic=true, so grid lines with style=psDot (or dash-dot) paint ugly, not like pixels, but like short fragments. Patch makes Pen.Cosmetic=false, so lines paint nicely (like pixels).
TagsNo tags attached.
Fixed in Revision61383
LazTarget2.0.4
Widgetset
Attached Files
  • gr_cosm.diff (414 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 61308)
    +++ lcl/grids.pas	(working copy)
    @@ -4530,6 +4530,7 @@
         end else begin
           Dv := goVertLine in Options;
           Dh := goHorzLine in Options;
    +      Pen.Cosmetic := false;
           Pen.Style := fGridLineStyle;
           Pen.Color := fGridLineColor;
           Pen.Width := fGridLineWidth;
    
    gr_cosm.diff (414 bytes)
  • gr_cosm2.diff (871 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 61308)
    +++ lcl/grids.pas	(working copy)
    @@ -4474,7 +4474,9 @@
     procedure TCustomGrid.DrawCellGrid(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState);
     var
       dv,dh: Boolean;
    +  OldCosmeticUsed, OldCosmetic: Boolean;
     begin
    +  OldCosmeticUsed := false;
     
       with Canvas do begin
     
    @@ -4530,6 +4532,9 @@
         end else begin
           Dv := goVertLine in Options;
           Dh := goHorzLine in Options;
    +      OldCosmeticUsed := true;
    +      OldCosmetic := Pen.Cosmetic;
    +      Pen.Cosmetic := false;
           Pen.Style := fGridLineStyle;
           Pen.Color := fGridLineColor;
           Pen.Width := fGridLineWidth;
    @@ -4552,6 +4557,8 @@
           end;
         end;
     
    +    if OldCosmeticUsed then
    +      Pen.Cosmetic := OldCosmetic;
       end; // with canvas,rect
     end;
     
    
    gr_cosm2.diff (871 bytes)

Relationships

related to 0035647 assignedJesus Reyes Patches Grids: publish GridLineColor, GridLineStyle 
related to 0033866 closedJesus Reyes Lazarus gtk2: Pen pattern depends on line length 

Activities

Alexey Tor.

2019-06-01 12:40

reporter  

gr_cosm.diff (414 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 61308)
+++ lcl/grids.pas	(working copy)
@@ -4530,6 +4530,7 @@
     end else begin
       Dv := goVertLine in Options;
       Dh := goHorzLine in Options;
+      Pen.Cosmetic := false;
       Pen.Style := fGridLineStyle;
       Pen.Color := fGridLineColor;
       Pen.Width := fGridLineWidth;
gr_cosm.diff (414 bytes)

wp

2019-06-01 13:16

developer   ~0116516

I wonder why GridLineColor and GridLineStyle are not published...

Anyway, Pen.Cosmetic is a rarely changed property. Therefore, you should reset it to its former value after painting the grid. Otherwise, custom painting code may be affected.

Alexey Tor.

2019-06-01 13:37

reporter   ~0116518

fixed patch.

gr_cosm2.diff (871 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 61308)
+++ lcl/grids.pas	(working copy)
@@ -4474,7 +4474,9 @@
 procedure TCustomGrid.DrawCellGrid(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState);
 var
   dv,dh: Boolean;
+  OldCosmeticUsed, OldCosmetic: Boolean;
 begin
+  OldCosmeticUsed := false;
 
   with Canvas do begin
 
@@ -4530,6 +4532,9 @@
     end else begin
       Dv := goVertLine in Options;
       Dh := goHorzLine in Options;
+      OldCosmeticUsed := true;
+      OldCosmetic := Pen.Cosmetic;
+      Pen.Cosmetic := false;
       Pen.Style := fGridLineStyle;
       Pen.Color := fGridLineColor;
       Pen.Width := fGridLineWidth;
@@ -4552,6 +4557,8 @@
       end;
     end;
 
+    if OldCosmeticUsed then
+      Pen.Cosmetic := OldCosmetic;
   end; // with canvas,rect
 end;
 
gr_cosm2.diff (871 bytes)

Alexey Tor.

2019-06-01 13:38

reporter   ~0116519

Pls also apply https://bugs.freepascal.org/view.php?id=35647

wp

2019-06-01 16:24

developer   ~0116521

Hmmm... And when a user wants the "normal" dotted line with the elongated dots? And do all widgetsets have the same behavior to draw fine dots for non-cosmetic pen?

Maybe it's better to publish a complete pen for the grid lines (GridLinePen), then the user has full control.

Alexey Tor.

2019-06-01 17:04

reporter   ~0116522

>And when a user wants the "normal" dotted line
For grids it's not handy, it looks much worse.
E.g. gtk2 paints "nice dots" always.

>to publish a complete pen
Not ok, since Delphi publishes GridLineWidth
http://docwiki.embarcadero.com/Libraries/Rio/en/Vcl.Grids.TCustomGrid.GridLineWidth

wp

2019-06-02 11:51

developer   ~0116530

I pass the report over to Jesus.

Anton Kavalenka

2019-06-02 14:09

reporter   ~0116531

"Nice dots" in GTK2 0033866

Jesus Reyes

2019-06-12 08:53

developer   ~0116683

Last edited: 2019-06-12 08:54

View 2 revisions

Check the notes in the related bug report (0033866)

Jesus Reyes

2019-06-14 01:08

developer   ~0116718

Applied, thanks.

Issue History

Date Modified Username Field Change
2019-06-01 12:40 Alexey Tor. New Issue
2019-06-01 12:40 Alexey Tor. File Added: gr_cosm.diff
2019-06-01 13:16 wp Note Added: 0116516
2019-06-01 13:37 Alexey Tor. File Added: gr_cosm2.diff
2019-06-01 13:37 Alexey Tor. Note Added: 0116518
2019-06-01 13:38 Alexey Tor. Note Added: 0116519
2019-06-01 13:49 wp Assigned To => wp
2019-06-01 13:49 wp Status new => assigned
2019-06-01 16:24 wp Note Added: 0116521
2019-06-01 17:04 Alexey Tor. Note Added: 0116522
2019-06-02 11:51 wp Relationship added related to 0035647
2019-06-02 11:51 wp Assigned To wp => Jesus Reyes
2019-06-02 11:51 wp Note Added: 0116530
2019-06-02 14:09 Anton Kavalenka Note Added: 0116531
2019-06-12 08:53 Jesus Reyes Note Added: 0116683
2019-06-12 08:53 Jesus Reyes Relationship added related to 0033866
2019-06-12 08:54 Jesus Reyes Note Edited: 0116683 View Revisions
2019-06-14 01:08 Jesus Reyes Status assigned => resolved
2019-06-14 01:08 Jesus Reyes Resolution open => fixed
2019-06-14 01:08 Jesus Reyes Fixed in Version => 2.1 (SVN)
2019-06-14 01:08 Jesus Reyes Fixed in Revision => 61383
2019-06-14 01:08 Jesus Reyes LazTarget => 2.0.4
2019-06-14 01:08 Jesus Reyes Note Added: 0116718