View Issue Details

IDProjectCategoryView StatusLast Update
0031689LazarusLCLpublic2020-03-10 09:13
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionno change required 
Product Version1.9 (SVN) 
Summary0031689: Make Grid grayed if disabled
DescriptionThis form is disabled.
Picture. all controls are greyed. but Grid.
Wish: grey Grid's font too.
TagsNo tags attached.
Fixed in Revision
LazTarget-
Widgetset
Attached Files

Relationships

related to 0032565 closedBart Broersma Patches TApplication.DimDisabledControls 

Activities

CudaText man

2017-04-20 18:41

reporter  

grid-disabled-colr.png (72,063 bytes)   
grid-disabled-colr.png (72,063 bytes)   

wp

2017-04-20 19:10

developer   ~0099714

Why don't you do this at application level? You just have to set the Font's color to some disabled color in OnPrepareCanvas, it's almost a one-liner...

procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;
  aState: TGridDrawState);
var
  grid: TCustomGrid;
begin
  grid := Sender as TCustomGrid;
  if not grid.Enabled then grid.Canvas.Font.Color := clSilver;
end;

Zeljan Rikalo

2017-04-20 19:16

developer   ~0099715

IMO, Grid should have disabled look when it's disabled. This is LCL bug.

CudaText man

2017-04-20 19:17

reporter   ~0099716

Last edited: 2017-04-20 19:18

View 2 revisions

I dunno about OnPrepareCanvas, many laz users too..

CudaText man

2017-04-26 08:11

reporter  

gr.diff (1,440 bytes)   
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 54734)
+++ lcl/grids.pas	(working copy)
@@ -1187,7 +1187,7 @@
     property RowHeights[aRow: Integer]: Integer read GetRowHeights write SetRowHeights;
     property SaveOptions: TSaveOptions read FsaveOptions write FSaveOptions;
     property SelectActive: Boolean read FSelectActive write SetSelectActive;
-    property SelectedColor: TColor read GetSelectedColor write SetSelectedColor;
+    property SelectedColor: TColor read GetSelectedColor write SetSelectedColor default clHighlight;
     property SelectedColumn: TGridColumn read GetSelectedColumn;
     property Selection: TGridRect read GetSelection write SetSelection;
     property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssAutoBoth;
@@ -1514,6 +1514,7 @@
     property PopupMenu;
     property RangeSelectMode;
     property RowCount;
+    property SelectedColor;
     property ScrollBars;
     property ShowHint;
     property TabAdvance;
@@ -1738,6 +1739,7 @@
     property PopupMenu;
     property RangeSelectMode;
     property RowCount;
+    property SelectedColor;
     property ScrollBars;
     property ShowHint;
     property TabAdvance;
@@ -3771,6 +3773,9 @@
     Canvas.Font.Color := clWindowText;
   end;
 
+  if not Enabled then
+    Canvas.Font.Color := clGrayText;
+
   DoPrepareCanvas(aCol, aRow, aState);
 end;
 
gr.diff (1,440 bytes)   

CudaText man

2017-04-26 08:13

reporter   ~0099938

gr.diff
Grids
a- set default for prp SelectedColor
b- publish SelectedColor in DrawGrid/StringGrid
c- use clGrayText for disabled-state

CudaText man

2017-04-26 08:23

reporter  

after-fix-gray.png (9,114 bytes)   
after-fix-gray.png (9,114 bytes)   

Zeljan Rikalo

2017-04-26 10:39

developer   ~0099941

If you publish SelectedColor then you must set also SelectionFontColor or I'm missing something ?

wp

2017-04-26 11:25

developer   ~0099944

An automatic painting of colors in a disabled stringgrid is very complicated because there are so many options for colors: Did you think about columns, each column can have its own color and its own font? Did you think about the AlternateColor for row coloring? If a disabled grid is drawn with clGrayText then this color must not conflict with the others. To avoid this there will be new other properties to be introduced into the grid, just for the ease of having gray text in case of a disabled grid? Is that worth it? If you really need such a feature use the OnPrepareCanvas event shown above. If you don't know it ... now you do.

Bart Broersma

2017-04-26 17:07

developer   ~0099948

You could calculate (mask?) a grey value for alternate color.
In disabled state simply ignore all font colors.
If OnPrepareCanvas is assigned then it's up to the programmer to check for Enabled and adjust his code for disabled state.

If somebody has textcolor clGrayText in any control in Enabled state, he won't see a difference between enabled/disabled, so this should not realy matter.

Ondrej Pokorny

2017-04-26 21:15

developer   ~0099951

We can call the "disabled grid is not grayed" appearance a Delphi compatibility feature :)

Bart Broersma

2017-04-26 23:33

developer   ~0099959

No need to replicate the bugs of the ancient greek IMHO.

Ondrej Pokorny

2017-04-27 08:43

developer   ~0099962

Last edited: 2017-04-27 08:49

View 2 revisions

In this case I hope you will fix this consequently in all LCL controls: TSynEdit, TTreeView, TListView and counting :P

(Just to make sure: I agree with wp here: there are so many variants how to color the disabled grid - the best is to let the programmer to take care for it himself if he needs it.)

CudaText man

2017-04-27 11:26

reporter   ~0099964

For Listview-- already greyed
For Treeview--
a- must add param AEnabled to
procedure TThemeServices.DrawText(ACanvas: TPersistent;
  Details: TThemedElementDetails; const S: String; R: TRect; Flags,
  Flags2: Cardinal);

for themed draw mode.
add and set Canvas.Font.Color:=clGrayText (if not en)

b- treeview.inc:
  set Canvas.Font.Color before

    if (tvoThemedDraw in Options) then
      ThemeServices.DrawText(Canvas, Details, AText, NodeRect, DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOPREFIX, 0)
    else
      DrawText(Canvas.Handle, PChar(AText), -1, NodeRect, DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOPREFIX);

wp

2017-04-27 12:26

developer   ~0099965

Last edited: 2017-04-27 12:29

View 3 revisions

> For Listview-- already greyed

No. TListview is particularly bad because it introduces the gray background (already in Delphi) - maybe a Windows issue? This means you'll also have to take care of widgetsets...

CudaText man

2017-04-27 15:20

reporter   ~0099969

On Ubuntu i see Listview grayed backgnd, and grayed font text.

wp

2017-04-27 15:28

developer   ~0099970

Last edited: 2017-04-28 18:08

View 2 revisions

AFAIK, TListview is the only control which draws a gray background if disabled (*). And on Windows the text stays black.

(*) Well, TEdit does the same...

CudaText man

2017-04-28 20:56

reporter   ~0099987

clGrayText used in several LCL controls if disabled; why not on Grid. Treeview ltr.

Michl

2017-04-28 23:37

developer   ~0099990

If this is a question of taste, I'll vote for a grayed grid too ;)

Zeljan Rikalo

2017-10-22 18:16

developer   ~0103685

@wp TListView is grayed because it is painted by widgetset not by LCL as it is case with TTreeView, TCustomGrid etc....

Juha Manninen

2020-03-10 09:13

developer   ~0121522

I am resolving this one. Will not be implemented.

Issue History

Date Modified Username Field Change
2017-04-20 18:41 CudaText man New Issue
2017-04-20 18:41 CudaText man File Added: grid-disabled-colr.png
2017-04-20 19:10 wp Note Added: 0099714
2017-04-20 19:16 Zeljan Rikalo Note Added: 0099715
2017-04-20 19:17 CudaText man Note Added: 0099716
2017-04-20 19:18 CudaText man Note Edited: 0099716 View Revisions
2017-04-26 08:11 CudaText man File Added: gr.diff
2017-04-26 08:13 CudaText man Note Added: 0099938
2017-04-26 08:23 CudaText man File Added: after-fix-gray.png
2017-04-26 10:39 Zeljan Rikalo Note Added: 0099941
2017-04-26 11:25 wp Note Added: 0099944
2017-04-26 17:07 Bart Broersma Note Added: 0099948
2017-04-26 21:15 Ondrej Pokorny Note Added: 0099951
2017-04-26 23:33 Bart Broersma Note Added: 0099959
2017-04-27 08:43 Ondrej Pokorny Note Added: 0099962
2017-04-27 08:49 Ondrej Pokorny Note Edited: 0099962 View Revisions
2017-04-27 11:26 CudaText man Note Added: 0099964
2017-04-27 12:26 wp Note Added: 0099965
2017-04-27 12:27 wp Note Edited: 0099965 View Revisions
2017-04-27 12:29 wp Note Edited: 0099965 View Revisions
2017-04-27 15:20 CudaText man Note Added: 0099969
2017-04-27 15:28 wp Note Added: 0099970
2017-04-28 18:08 wp Note Edited: 0099970 View Revisions
2017-04-28 20:56 CudaText man Note Added: 0099987
2017-04-28 23:37 Michl Note Added: 0099990
2017-10-22 15:15 Juha Manninen Relationship added related to 0032565
2017-10-22 18:16 Zeljan Rikalo Note Added: 0103685
2020-03-10 09:13 Juha Manninen Assigned To => Juha Manninen
2020-03-10 09:13 Juha Manninen Status new => resolved
2020-03-10 09:13 Juha Manninen Resolution open => no change required
2020-03-10 09:13 Juha Manninen LazTarget => -
2020-03-10 09:13 Juha Manninen Note Added: 0121522